<<<<<<< HEAD
A starter cloud-native API gateway platform with four independently deployable services, Docker Compose support, Kubernetes manifests, Prometheus metrics, Grafana provisioning, and a k6 smoke test.
gateway/ HTTP gateway and routing rules
services/ auth, user, notification, and analytics services
infrastructure/docker/ local development stack
infrastructure/kubernetes/ Kubernetes manifests
infrastructure/prometheus/ Prometheus configuration
infrastructure/grafana/ Grafana provisioning
load-testing/ k6 scenarios
scripts/ local helper scripts
docs/ architecture, API, learning notes, and diagrams
A production-style API Gateway built with Spring Cloud Gateway β JWT auth & RBAC, Redis-backed rate limiting and caching, Kubernetes-native service discovery, Resilience4j circuit breaking, event-driven messaging with Kafka, and full observability with Prometheus, Grafana, and OpenTelemetry/Jaeger. Containerized with Docker and deployed on Kubernetes.
This gateway sits in front of a set of backend microservices (Auth, User, Notification, Analytics) and acts as the single entry point for all client traffic. It handles authentication, authorization, rate limiting, and routing in one place instead of duplicating that logic across every service, discovers services dynamically instead of hardcoding addresses, and fails gracefully when a downstream service is unhealthy.
flowchart LR
Client["π Client"]
Gateway["πͺ API Gateway<br/>:8080"]
Config["βοΈ Config Server<br/>:8888"]
Auth["π Auth Service<br/>:4001"]
User["π€ User Service<br/>:4002"]
Notification["π¨ Notification Service<br/>:4003"]
Analytics["π Analytics Service<br/>:4004"]
Redis["β‘ Redis"]
Postgres["π PostgreSQL"]
Kafka["π¬ Kafka"]
Client --> Gateway
Gateway --> Auth
Gateway --> User
Gateway --> Notification
Gateway --> Analytics
Config -.->|configure| Gateway
Auth --> Postgres
User --> Postgres
Gateway --> Redis
Notification --> Kafka
Analytics --> Kafka
What happens inside the gateway on every request:
flowchart TB
Request["π₯ Incoming Request"] --> Logging["π Logging Filter"]
Logging --> RateLimit["β±οΈ Rate Limiter<br/>(Redis)"]
RateLimit -->|exceeded| RateLimitReject["β 429 Too Many Requests"]
RateLimit -->|within limit| JWTFilter["π JWT Auth Filter"]
JWTFilter -->|invalid or missing| AuthReject["β 401 Unauthorized"]
JWTFilter -->|valid| RBACFilter["π RBAC Filter"]
RBACFilter -->|not permitted| RBACReject["β 403 Forbidden"]
RBACFilter -->|permitted| Discovery["π§ Route Resolution<br/>via K8s Service DNS"]
Discovery --> CircuitBreaker["β‘ Circuit Breaker"]
CircuitBreaker -->|closed| Proxy["β‘οΈ Proxy to Service"]
CircuitBreaker -->|open| Fallback["β©οΈ Fallback Response"]
Proxy --> ResponseFilter["π€ Response / Trace Filter"]
Fallback --> ResponseFilter
ResponseFilter --> Response["β
Response to Client"]
Auth flow:
flowchart TB
Client["π Client"] -->|login credentials| Auth["π Auth Service"]
Auth -->|issues JWT| Client
Client -->|request + JWT| Gateway["πͺ API Gateway"]
Gateway --> JWTCheck{"JWT valid?"}
JWTCheck -->|no| Reject["β 401 Unauthorized"]
JWTCheck -->|yes| RBAC{"Role permitted<br/>for this route?"}
RBAC -->|no| Forbidden["β 403 Forbidden"]
RBAC -->|yes| Backend["β
Backend Services"]
π This is a slice of it. Request flow, configuration, resilience (circuit breaking), Kubernetes cluster layout & service discovery, and full observability are all diagrammed in
docs/ARCHITECTURE.md.
- Phase 0 β Requirements, HLD, LLD
- Phase 1 β Gateway, Routing, JWT, RBAC
- Phase 2 β Redis, Rate Limiting, Caching
- Phase 3 β Service Discovery, Config Server, Microservices
- Phase 4 β Observability
- Phase 5 β Docker & Kubernetes
- Phase 6 β CI/CD, Load Testing, Documentation
- JWT-based authentication and role-based access control (RBAC)
- Dynamic request routing via Spring Cloud Gateway
- Redis-backed rate limiting and response caching
- Kubernetes-native service discovery and centralized configuration via Spring Cloud Config
- Circuit breaking and fallback handling via Resilience4j
- Event-driven notifications and analytics via Kafka
- Metrics (Prometheus/Grafana) and distributed tracing (OpenTelemetry/Jaeger)
- Containerized with Docker, deployed to Kubernetes with HPA
- CI/CD via GitHub Actions with Testcontainers-backed integration tests
| Layer | Technologies |
|---|---|
| Language & Framework | Java 21, Spring Boot |
| Gateway | Spring Cloud Gateway |
| Security | Spring Security, JWT |
| Data & Caching | PostgreSQL, Redis |
| Service Discovery & Config | Kubernetes-native (Services/DNS), Spring Cloud Config |
| Resilience | Resilience4j |
| Messaging | Kafka |
| Observability | Prometheus, Grafana, OpenTelemetry, Jaeger |
| Containers & Orchestration | Docker, Kubernetes |
| CI/CD | GitHub Actions, Testcontainers |
- Java 21+
- Docker & Docker Compose
- Maven or Gradle
git clone https://github.com/<your-username>/<your-repo>.git
cd <your-repo>
docker-compose upThe gateway will be available at http://localhost:8080.
.
βββ api-gateway/ # Spring Cloud Gateway
βββ auth-service/
βββ user-service/
βββ notification-service/
βββ analytics-service/
βββ docs/
β βββ ARCHITECTURE.md
β βββ HLD.md
β βββ LLD.md
β βββ decisions/ # one file per major engineering decision
βββ k8s/ # Kubernetes manifests / Helm chart
βββ docker-compose.yml
βββ .github/workflows/ # CI/CD pipelines
docs/ARCHITECTURE.mdβ full system architecture β low-level design β high-level design
MIT β see LICENSE.
Requirements: Node.js 20+, Docker Desktop, and optionally k6.
docker compose -f infrastructure/docker/docker-compose.yml up --buildThe gateway is then available at http://localhost:8080.
Useful endpoints:
GET /healthzβ gateway healthGET /readyzβ gateway readinessGET /metricsβ Prometheus metricsGET /api/auth/healthzGET /api/users/healthzGET /api/notifications/healthzGET /api/analytics/healthz
For local development without Docker, start each service with npm start from its directory and then start the gateway.
kubectl apply -f infrastructure/kubernetes/namespace.yaml
kubectl apply -f infrastructure/kubernetes/The manifests use the cloud-gateway namespace and expose the gateway through a LoadBalancer service.
The gateway is intentionally dependency-free and uses the Node.js fetch API for routing. Each service owns its own port and health endpoint. See docs/architecture/README.md for the request flow and docs/api/README.md for the route contract.
A scalable cloud-native API Gateway platform featuring microservices, Kubernetes orchestration, observability, event-driven architecture, and AI-powered traffic insights.
3dcceb19b109563d7cc3b454df085158b4b986ae