Skip to content

Repository files navigation

🚀 API Gateway Platform

The next-generation API gateway — where Kong/Zuul meet AI. Enterprise-grade request routing, traffic shaping, and policy management powered by pluggable rate-limiting algorithms, Redis-backed distributed counters, Kafka event streaming, and LLM-driven natural-language configuration.

Stop writing YAML configs. Chat with your gateway instead. "Route all premium users to the new service cluster" — done. "Block requests over 10MB for non-VIP clients" — handled.

System Architecture

✨ Why This Stands Out

  • 🧠 AI-Native Configuration: Configure routing policies and rate limits in plain English via MCP + LLM. No more YAML hell
  • ⚡ Algorithm Flexibility: Token Bucket, Sliding Window, or custom algorithms — swap anytime, zero downtime
  • 🔄 Distributed by Default: Redis-powered counters work seamlessly across 100+ instances with perfect consistency
  • 📡 Event-Driven Architecture: Every API call streamed to Kafka for audit, analytics, compliance, and debugging
  • 🎯 Zero-Trust Ready: JWT auth, mTLS support, encrypted service-to-service communication out of the box
  • 📊 Production Observability: Real-time New Relic dashboards, health checks, and performance metrics
  • 🚀 Cloud-Native Stack: Spring Boot 3.5 + Spring Cloud, containerized, Kubernetes-ready, horizontally scalable

🏗️ Architecture Overview

See the full system architecture:

System Architecture

The gateway acts as the central entry point, orchestrating traffic through authentication, routing, rate-limiting, and auditing layers.

🔑 Core Components

Gateway Service

Central request router and rate-limiter implementation. Handles:

  • Request routing to upstream services
  • Rate limiting with pluggable algorithms
  • Authentication and authorization enforcement

Architecture Details: Rate Limiter Architecture

Rate Limiting Engine

Three algorithms out-of-the-box:

  • Token Bucket: Smooth traffic shaping with burst capacity
  • Sliding Window: Precise request counting over time
  • Custom: Extend with your own algorithm

All counters distributed across Redis for consistency across instances.

Config Service

Centralized configuration management with service discovery integration for dynamic routing rules.

MCP Service

Exposes the Model Context Protocol interface for AI assistants to:

  • Query current gateway configuration
  • Modify routing rules in natural language
  • Create rate limiting policies via conversation

Audit & Observability

Event Pipeline: Kafka Audit Pipeline

All API requests logged asynchronously to Kafka for:

  • Compliance auditing
  • Performance monitoring
  • Root cause analysis

Real-time Observability: Observability Pipeline

Integrated monitoring with New Relic for dashboards and alerts.

📋 Services

Service Purpose
gateway-service Core API gateway (routing, rate-limiting, auth)
config-service Centralized rule and policy management
discovery-service Service registry and load balancing
audit-service Processes Kafka events for compliance
mcp-service LLM integration for natural language config
ai-admin-service Admin interface for AI-powered gateway management
user-service Demo service (user auth backends)
order-service Demo service (protected resource)

🚀 Quick Start

Prerequisites

  • Java 21+
  • Docker & Docker Compose
  • Redis
  • Kafka
  • (Optional) OpenAI API key for MCP+LLM features

Run Everything

docker-compose up -d

This starts:

  • Gateway Service (port 8080)
  • Config Service (port 8081)
  • Discovery Service (port 8761)
  • User Service (port 8082)
  • Order Service (port 8083)
  • Redis, Kafka, PostgreSQL

Make a Request

curl -H "Authorization: Bearer <token>" \
  http://localhost:8080/api/orders

The gateway will:

  1. Authenticate the request
  2. Apply rate limiting (default: 100 req/min per user)
  3. Route to the order-service
  4. Log the event to Kafka
  5. Return the response

⚙️ Configuration

Rate Limiting Policy

# config-service application.yml
gateway:
  rateLimit:
    algorithm: TOKEN_BUCKET  # or SLIDING_WINDOW
    capacity: 100            # tokens/time window
    refillRate: 60           # tokens/minute
    enabled: true

Natural Language Rule Configuration

# Chat with the gateway via MCP
"Set rate limit to 1000 requests per minute for premium users"
"Route /api/v2/* to the new service-v2 cluster"
"Enable rate limiting for anonymous users"

📊 Monitoring

Access dashboards at:

🔐 Security

  • JWT Authentication on all routes
  • Rate limiting prevents DDoS attacks
  • Audit logging tracks all requests
  • Service-to-service mTLS-ready (see k8s/ for Istio config)

📚 Learn More

  • Kafka Audit Pipeline: See docs/images/architecture/kafka_audit_pipeline.png
  • Infrastructure & AI Integration: See docs/images/architecture/infrastructure_and_AI.png
  • API Gateway Design: See docs/images/architecture/api_gateway_hld.png
  • Request/Response Sequences: See docs/images/architecture/sequence_diagram.png

🛠️ Development

# Build all services
mvn clean package

# Run tests
mvn test

# Build Docker images
mvn dockerfile:build

# Deploy to Kubernetes
kubectl apply -f k8s/

📝 License

See LICENSE file


Questions? Check the architecture diagrams in docs/images/architecture/ or explore individual service READMEs.

About

API gateway (like Kong/Zuul) — pluggable rate-limiting algorithms (token bucket, sliding window), auth, routing, backed by Redis for distributed counters, Kafka for async logging, MCP+LLM for natural-language rule config ("limit premium users to 100/min").

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages