How stphnlwnga/llm-gateway works
llm-gateway is currently a Go walking skeleton: the live user workflow serves health, readiness, and a stub OpenAI model-list endpoint, while a separate admin command runs Postgres migrations. Configuration and structured logging support both binaries; Postgres readiness is wired into the HTTP API. The README describes provider routing, tenant keys, rate limits, budgets, usage metering, and tracing as product goals, but this milestone does not implement those request capabilities. Relationships shown here follow the excerpts and README; unsampled behavior is not inferred.
Main entry points: gateway/main.go Gateway composition · server.go HTTP routes and readiness · gatewayctl/main.go Migration command · serve.go Drain and shutdown
Components 12
Gateway runtime
- Gateway composition
cmd/gateway/main.go - Drain and shutdown
cmd/gateway/serve.go - HTTP routes and readiness
internal/httpapi/server.go - OpenAI error responses
internal/httpapi/errors.go
Database administration
- Migration command
cmd/gatewayctl/main.go - Migration runner
internal/store/postgres/migrate.go
Shared support
- Typed settings
internal/config/config.go - Structured logger
internal/telemetry/logger.go - Postgres pool and ping
internal/store/postgres/postgres.go
Other components
- API client
- Operator
- Postgres
Connections 16
- API client → HTTP routes and readiness: calls API
README.md - Gateway composition → Typed settings: loads settings
cmd/gateway/main.go - Gateway composition → Structured logger: creates logger
cmd/gateway/main.go - Gateway composition → Postgres pool and ping: opens pool
cmd/gateway/main.go - Gateway composition → HTTP routes and readiness: builds handler
cmd/gateway/main.go - Gateway composition → Drain and shutdown: starts serving
cmd/gateway/main.go - Gateway composition → Drain and shutdown: sets drain callback
cmd/gateway/main.go - HTTP routes and readiness → Postgres pool and ping: checks readiness
- HTTP routes and readiness → OpenAI error responses: formats errors
internal/httpapi/server.go - Operator → Migration command: runs migration
README.md - Migration command → Typed settings: loads settings
cmd/gatewayctl/main.go - Migration command → Structured logger: creates logger
cmd/gatewayctl/main.go - Migration command → Migration runner: runs command
cmd/gatewayctl/main.go - Migration runner → Postgres: applies migrations
internal/store/postgres/migrate.go - Postgres pool and ping → Postgres: pings
internal/store/postgres/postgres.go - Drain and shutdown → HTTP routes and readiness: starts draining
cmd/gateway/serve.go