Architecture
Gatewyse is a multi-tenant Express server that sits between client applications and AI provider APIs. The architecture is built around a small set of concerns — request normalization, security guards, routing, provider adaptation, and observability — wired together as Express middleware.
Sections
- Overview — Monorepo layout, request lifecycle, data flow between services.
- Routing Strategies — The 10 routing algorithms (priority, round-robin, weighted, least-cost, least-latency, free-tier-first, task-optimized, cost-optimized, failover, random) and how they compose with the routing cache.
- Provider Adapters — How adapters translate between the unified API and 38 different provider APIs, plus the base adapter contract and security guarantees.
- Contributing — Development setup, test tiers, code structure, and the PR process.
Licensing
The Enterprise Edition is gated on an Ed25519-signed JWT issued by the 137 & Co. platform. The license verifier runs first at boot, before the Zod env validator and Winston logger, because both depend on environment that has not yet been validated. See Environment Variables — License (EE) for the required LICENSE_* variables and the packages/server/src/services/license.service.ts source for the boot sequence.
At a Glance
| Concern | Layer |
|---|---|
| Request shape translation | packages/server/src/utils/request-normalizer.ts |
| Security guards | packages/server/src/middleware/prompt-guard.middleware.ts + services/prompt-guard.service.ts |
| Routing selection | packages/server/src/services/routing.service.ts |
| Provider HTTP | packages/server/src/providers/*.adapter.ts |
| Response shape translation | packages/server/src/utils/response-formatter.ts |
| Audit + usage tracking | packages/server/src/middleware/{audit-logger,usage-tracker}.middleware.ts |
| License verification (EE) | packages/server/src/services/license.service.ts + packages/license/ |