# api-200/api200 architecture

> Architecture diagram of the GitHub repository api-200/api200, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/api-200/api200
- Repository: https://github.com/api-200/api200

## Overview

API 200 is a third-party API gateway with a management dashboard, generated JavaScript client, and MCP support. The principal runtime flow validates a caller’s key, checks usage, resolves a configured endpoint, applies authentication and request settings, then proxies, transforms, and logs the result. The README also documents caching, retries, mocks, fallbacks, schema watching, incidents, monitoring, Swagger, and endpoint imports; those dashboard capabilities are represented, but their internal wiring is not inferred from unsampled code.

Main entry points: [`packages/backend/src/api-handler.ts`](https://github.com/api-200/api200/blob/main/packages/backend/src/api-handler.ts) (API router), [`packages/backend/src/modules/processRequest.ts`](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/processRequest.ts) (Proxy processing), [`packages/backend/src/modules/base/retrieveServiceRouteData.ts`](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/base/retrieveServiceRouteData.ts) (Route lookup), [`packages/backend/src/modules/handleRequest.ts`](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/handleRequest.ts) (Request handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["API gateway"]
  node_handler["API router<br/>[api-handler.ts]"]
  node_key["Key validation"]
  node_usage["Usage check<br/>[checkUsage.ts]"]
  node_route["Route lookup"]
  node_url["URL mapping<br/>[mapUrlParams.ts]"]
  node_auth["Third-party auth"]
  node_mock["Mock responses<br/>[provideMockData.ts]"]
  node_request["Request handler<br/>[handleRequest.ts]"]
  node_process["Proxy processing<br/>[processRequest.ts]"]
  node_transform["User transformation"]
  node_fallback["Fallback handling"]
  node_schema["Schema watching"]
end

subgraph group_data["Gateway services"]
  node_cache["Response caching<br/>[caching.ts]"]
  node_retry["Retry policy<br/>[retry.ts]"]
  node_logging["Request logging<br/>[logging.ts]"]
  node_redis[("Redis cache<br/>[cache.ts]")]
  node_supabase[("Supabase data<br/>[supabase.ts]")]
end

subgraph group_dashboard["Management dashboard"]
  node_dashboard["Dashboard UI<br/>[page.tsx]"]
  node_endpoint_admin["Endpoint management<br/>[page.tsx]"]
  node_imports["Endpoint imports<br/>[page.tsx]"]
  node_monitoring["Monitoring charts"]
  node_incidents["Incident detection<br/>[page.tsx]"]
  node_swagger["Swagger viewer<br/>[page.tsx]"]
end

subgraph group_integrations["Client integrations"]
  node_sdk["JavaScript SDK"]
  node_sdk_service["Service generation"]
  node_mcp["MCP server<br/>[index.ts]"]
end

node_caller(("API caller"))

node_caller -->|"sends request"| node_handler
node_handler -->|"validates key"| node_key
node_handler -->|"checks usage"| node_usage
node_handler -->|"loads route"| node_route
node_handler -->|"maps URL"| node_url
node_handler -->|"applies auth"| node_auth
node_handler -->|"checks mock"| node_mock
node_handler -->|"handles request"| node_request
node_handler -->|"extracts fallback"| node_fallback
node_handler -->|"records result"| node_logging
node_request -->|"processes request"| node_process
node_request -->|"transforms response"| node_transform
node_process -->|"logs processing"| node_logging
node_process -->|"uses caching"| node_cache
node_process -->|"uses retries"| node_retry
node_process -->|"checks schema"| node_schema
node_route -->|"reads and writes"| node_redis
node_route -->|"queries routes"| node_supabase
node_logging -->|"writes logs"| node_supabase
node_endpoint_admin -->|"manages endpoints"| node_supabase
node_sdk -->|"generates services"| node_sdk_service
node_sdk -.->|"calls gateway"| node_handler
node_mcp -.->|"uses gateway"| node_handler

click node_handler "https://github.com/api-200/api200/blob/main/packages/backend/src/api-handler.ts"
click node_key "https://github.com/api-200/api200/blob/main/packages/backend/src/modules/base/apiKeyValidation.ts"
click node_usage "https://github.com/api-200/api200/blob/main/packages/backend/src/modules/base/checkUsage.ts"
click node_route "https://github.com/api-200/api200/blob/main/packages/backend/src/modules/base/retrieveServiceRouteData.ts"
click node_url "https://github.com/api-200/api200/blob/main/packages/backend/src/modules/base/mapUrlParams.ts"
click node_auth "https://github.com/api-200/api200/blob/main/packages/backend/src/modules/applyThirdPartyAuth.ts"
click node_mock "https://github.com/api-200/api200/blob/main/packages/backend/src/modules/provideMockData.ts"
click node_request "https://github.com/api-200/api200/blob/main/packages/backend/src/modules/handleRequest.ts"
click node_process "https://github.com/api-200/api200/blob/main/packages/backend/src/modules/processRequest.ts"
click node_transform "https://github.com/api-200/api200/blob/main/packages/backend/src/modules/executeUserFunction.ts"
click node_fallback "https://github.com/api-200/api200/blob/main/packages/backend/src/modules/provideFallbackData.ts"
click node_schema "https://github.com/api-200/api200/blob/main/packages/backend/src/modules/checkResponseSchema.ts"
click node_cache "https://github.com/api-200/api200/blob/main/packages/backend/src/modules/caching.ts"
click node_retry "https://github.com/api-200/api200/blob/main/packages/backend/src/modules/retry.ts"
click node_logging "https://github.com/api-200/api200/blob/main/packages/backend/src/modules/logging.ts"
click node_redis "https://github.com/api-200/api200/blob/main/packages/backend/src/utils/cache.ts"
click node_supabase "https://github.com/api-200/api200/blob/main/packages/backend/src/utils/supabase.ts"
click node_dashboard "https://github.com/api-200/api200/blob/main/packages/dashboard/src/app/(layout)/services/page.tsx"
click node_endpoint_admin "https://github.com/api-200/api200/blob/main/packages/dashboard/src/app/(layout)/endpoints/new/page.tsx"
click node_imports "https://github.com/api-200/api200/blob/main/packages/dashboard/src/app/(layout)/services/import/page.tsx"
click node_monitoring "https://github.com/api-200/api200/blob/main/packages/dashboard/src/components/widgets/getServiceMonitoringData.ts"
click node_incidents "https://github.com/api-200/api200/blob/main/packages/dashboard/src/app/(layout)/incidents/page.tsx"
click node_swagger "https://github.com/api-200/api200/blob/main/packages/dashboard/src/app/(layout)/specification/page.tsx"
click node_sdk "https://github.com/api-200/api200/blob/main/packages/js-sdk/src/generators/client-generator.ts"
click node_sdk_service "https://github.com/api-200/api200/blob/main/packages/js-sdk/src/generators/service-generator.ts"
click node_mcp "https://github.com/api-200/api200/blob/main/packages/mcp/src/index.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_handler,node_key,node_usage,node_route,node_url,node_auth,node_mock,node_request,node_process,node_transform,node_fallback,node_schema toneBlue
class node_cache,node_retry,node_logging,node_redis,node_supabase toneAmber
class node_dashboard,node_endpoint_admin,node_imports,node_monitoring,node_incidents,node_swagger,node_caller toneMint
class node_sdk,node_sdk_service,node_mcp toneRose
```

## Components

### API gateway

- [API router](https://github.com/api-200/api200/blob/main/packages/backend/src/api-handler.ts): `packages/backend/src/api-handler.ts`
- [Key validation](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/base/apiKeyValidation.ts): `packages/backend/src/modules/base/apiKeyValidation.ts`
- [Usage check](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/base/checkUsage.ts): `packages/backend/src/modules/base/checkUsage.ts`
- [Route lookup](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/base/retrieveServiceRouteData.ts): `packages/backend/src/modules/base/retrieveServiceRouteData.ts`
- [URL mapping](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/base/mapUrlParams.ts): `packages/backend/src/modules/base/mapUrlParams.ts`
- [Third-party auth](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/applyThirdPartyAuth.ts): `packages/backend/src/modules/applyThirdPartyAuth.ts`
- [Mock responses](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/provideMockData.ts): `packages/backend/src/modules/provideMockData.ts`
- [Request handler](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/handleRequest.ts): `packages/backend/src/modules/handleRequest.ts`
- [Proxy processing](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/processRequest.ts): `packages/backend/src/modules/processRequest.ts`
- [User transformation](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/executeUserFunction.ts): `packages/backend/src/modules/executeUserFunction.ts`
- [Fallback handling](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/provideFallbackData.ts): `packages/backend/src/modules/provideFallbackData.ts`
- [Schema watching](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/checkResponseSchema.ts): `packages/backend/src/modules/checkResponseSchema.ts`

### Gateway services

- [Response caching](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/caching.ts): `packages/backend/src/modules/caching.ts`
- [Retry policy](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/retry.ts): `packages/backend/src/modules/retry.ts`
- [Request logging](https://github.com/api-200/api200/blob/main/packages/backend/src/modules/logging.ts): `packages/backend/src/modules/logging.ts`
- [Redis cache](https://github.com/api-200/api200/blob/main/packages/backend/src/utils/cache.ts): `packages/backend/src/utils/cache.ts`
- [Supabase data](https://github.com/api-200/api200/blob/main/packages/backend/src/utils/supabase.ts): `packages/backend/src/utils/supabase.ts`

### Management dashboard

- [Dashboard UI](https://github.com/api-200/api200/blob/main/packages/dashboard/src/app/(layout)/services/page.tsx): `packages/dashboard/src/app/(layout)/services/page.tsx`
- [Endpoint management](https://github.com/api-200/api200/blob/main/packages/dashboard/src/app/(layout)/endpoints/new/page.tsx): `packages/dashboard/src/app/(layout)/endpoints/new/page.tsx`
- [Endpoint imports](https://github.com/api-200/api200/blob/main/packages/dashboard/src/app/(layout)/services/import/page.tsx): `packages/dashboard/src/app/(layout)/services/import/page.tsx`
- [Monitoring charts](https://github.com/api-200/api200/blob/main/packages/dashboard/src/components/widgets/getServiceMonitoringData.ts): `packages/dashboard/src/components/widgets/getServiceMonitoringData.ts`
- [Incident detection](https://github.com/api-200/api200/blob/main/packages/dashboard/src/app/(layout)/incidents/page.tsx): `packages/dashboard/src/app/(layout)/incidents/page.tsx`
- [Swagger viewer](https://github.com/api-200/api200/blob/main/packages/dashboard/src/app/(layout)/specification/page.tsx): `packages/dashboard/src/app/(layout)/specification/page.tsx`

### Client integrations

- [JavaScript SDK](https://github.com/api-200/api200/blob/main/packages/js-sdk/src/generators/client-generator.ts): `packages/js-sdk/src/generators/client-generator.ts`
- [Service generation](https://github.com/api-200/api200/blob/main/packages/js-sdk/src/generators/service-generator.ts): `packages/js-sdk/src/generators/service-generator.ts`
- [MCP server](https://github.com/api-200/api200/blob/main/packages/mcp/src/index.ts): `packages/mcp/src/index.ts`

### Other components

- **API caller**

## Connections

- API caller → API router: sends request (evidence: `packages/backend/src/api-handler.ts`)
- API router → Key validation: validates key (evidence: `packages/backend/src/api-handler.ts`)
- API router → Usage check: checks usage (evidence: `packages/backend/src/api-handler.ts`)
- API router → Route lookup: loads route (evidence: `packages/backend/src/api-handler.ts`)
- API router → URL mapping: maps URL (evidence: `packages/backend/src/api-handler.ts`)
- API router → Third-party auth: applies auth (evidence: `packages/backend/src/api-handler.ts`)
- API router → Mock responses: checks mock (evidence: `packages/backend/src/api-handler.ts`)
- API router → Request handler: handles request (evidence: `packages/backend/src/api-handler.ts`)
- API router → Fallback handling: extracts fallback (evidence: `packages/backend/src/api-handler.ts`)
- API router → Request logging: records result (evidence: `packages/backend/src/api-handler.ts`)
- Request handler → Proxy processing: processes request (evidence: `packages/backend/src/modules/handleRequest.ts`)
- Request handler → User transformation: transforms response (evidence: `packages/backend/src/modules/handleRequest.ts`)
- Proxy processing → Request logging: logs processing (evidence: `packages/backend/src/modules/processRequest.ts`)
- Proxy processing → Response caching: uses caching (evidence: `packages/backend/src/modules/processRequest.ts`)
- Proxy processing → Retry policy: uses retries (evidence: `packages/backend/src/modules/processRequest.ts`)
- Proxy processing → Schema watching: checks schema (evidence: `packages/backend/src/modules/processRequest.ts`)
- Route lookup → Redis cache: reads and writes (evidence: `packages/backend/src/modules/base/retrieveServiceRouteData.ts`)
- Route lookup → Supabase data: queries routes (evidence: `packages/backend/src/modules/base/retrieveServiceRouteData.ts`)
- Request logging → Supabase data: writes logs (evidence: `packages/backend/src/modules/logging.ts`)
- Endpoint management → Supabase data: manages endpoints
- JavaScript SDK → Service generation: generates services (evidence: `packages/js-sdk/src/generators/client-generator.ts`)
- JavaScript SDK → API router: calls gateway
- MCP server → API router: uses gateway
