repowiseportkey-ai/gateway

Architecture of portkey-ai/gateway

portkey-ai/gateway is 661 source files holding 2,373 symbols across 5 modules, written mainly in TypeScript, JavaScript, Dockerfile. The largest module is src, with 427 files, and 21 files are entry points into the dependency graph.

How gateway fits together

Requests from an application enter through the server that src/start-server.ts starts, and src/index.ts is the top-level entry point. src/globals.ts is where gateway-wide behavior is set up once and made available to the rest of the codebase. Guardrails are implemented in the plugins directory, where plugins/default holds constraint logic that can be applied to request content and metadata regardless of which provider receives the request. plugins/bedrock/type.ts defines the action model used to guard chat completions, with ContentPolicy extending BedrockAction. plugins/pillar contains scan logic for detecting risky content in prompts and responses, and the output is the streamed model response returned to the application.

Largest modules

  • src: 427 files and 42,897 lines of code
  • plugins: 112 files and 18,811 lines of code
  • cookbook: 33 files and 877 lines of code
  • tests: 10 files and 3,514 lines of code
  • root: 6 files and 168 lines of code

Languages

By file count: TypeScript 581 files, JavaScript 6 files, Dockerfile 1 file.

Documentation

Repowise documents gateway in 753 pages generated from the source, 46 of them written explanations of the repository and its modules. Module guides include:

  • src/handlers: API Request Handlers
  • src/providers/bedrock: AWS Bedrock Provider
  • src/middlewares/adminAuth: Admin Authentication Middleware
  • src/providers/anthropic: Anthropic Provider

More on gateway: summary and FAQ, codebase overview, code health.

Related guide: Best dependency graph tools for monorepos