Template

API Gateway Architecture Template

A complete API gateway pattern with auth middleware, rate limiting, request routing, response caching, and backend service fan-out.

Template preview

Copy this Mermaid code into Cybewave Studio or any Mermaid-compatible editor.

api-gateway.mmd
graph TD
    WebApp[Web App] --> GW[API Gateway]
    MobileApp[Mobile App] --> GW
    ThirdParty[3rd-Party Client] --> GW

    GW --> RateLimit[Rate Limiter]
    GW --> AuthMiddleware[Auth Middleware]
    AuthMiddleware --> JWT[JWT Validation]
    AuthMiddleware --> APIKey[API Key Check]

    GW --> Router[Request Router]

    Router --> UserAPI[User Service API]
    Router --> OrderAPI[Order Service API]
    Router --> ProductAPI[Product Service API]
    Router --> SearchAPI[Search Service API]

    GW --> Transform[Response Transformer]
    GW --> Logger[Logging & Metrics]
    Logger --> Monitoring[Monitoring Dashboard]

    GW --> Cache[(Response Cache)]

    subgraph Backend Services
        UserAPI --> UserDB[(Users DB)]
        OrderAPI --> OrderDB[(Orders DB)]
        ProductAPI --> ProductDB[(Products DB)]
        SearchAPI --> Elastic[(Elasticsearch)]
    end

Why use this template?

A proven gateway pattern for any microservice backend.

Single Entry Point

All client traffic flows through one gateway — simplifying auth, logging, and monitoring.

Rate Limiting & Auth

Built-in rate limiter and auth middleware with JWT validation and API key support.

Response Caching

Cache layer at the gateway reduces backend load and improves response times for frequent queries.

Request Routing

Intelligent router fans out requests to the correct backend service based on path and method.

Frequently asked questions

What is the API gateway pattern?

The API gateway pattern provides a single entry point for all client requests. It handles cross-cutting concerns like authentication, rate limiting, logging, and request routing before forwarding to backend microservices.

When should I use an API gateway?

Use an API gateway when you have multiple backend services and need centralized auth, rate limiting, response transformation, or protocol translation. It is essential in microservice architectures.

Can I add GraphQL federation to this template?

Yes. Open the template in Cybewave Studio and ask the AI to replace REST routing with a GraphQL federation layer. The AI will update the diagram with a schema registry and subgraph services.

Design your API gateway

Free to start. 50 AI credits/month. No credit card required.

Get started for free →

Or explore pricing plans for teams.