Expand description
Self-hosted org gateway — the Gateway pillar deployment mode.
Bundles the LLM proxy (crate::proxy), the per-request usage store
(Postgres usage_events), and the admin console into one deployable
server process.
§Cross-pillar coupling
serve.rs calls proxy::start_proxy to start the LLM proxy and wires
proxy::usage_sink for async Postgres persistence. The proxy in turn
mounts gateway_server::user_api and gateway_server::mcp::proxy routes
(feature-gated). This bidirectional dependency is intentional: the
gateway is a single process, not two services.
§Invariants
- Local-Free: compiled in or out via
--features gateway-server, never gated by account/license/plan (Local-Free Invariant). - Fail-open: a slow or down Postgres degrades metering, never live LLM traffic.
Modules§
- admin_
api - Admin usage API (enterprise#20) — the self-hosted gateway’s spend/savings
breakdown, straight from
usage_events(Doc 08 §3.3). - admin_
status GET /api/admin/status(enterprise#46) — the gateway’s live health/config card for the admin dashboard.- admin_
timeseries GET /api/admin/timeseries(enterprise#46) — per-day usage/savings series for the admin dashboard’s trend charts.- admin_
ui - Embedded admin dashboard (enterprise#45) — the org monitoring console served from the gateway’s admin port.
- doctor
lean-ctx gateway doctor(enterprise#49) — go-live preflight.- evidence
- Signed usage-evidence export (enterprise#36, EU-AI-Act evidence trail).
- init
lean-ctx gateway init(enterprise#47) — plug-and-play gateway setup.- keys_
cli lean-ctx gateway keys(enterprise#48) — per-person key management forgateway-keys.toml, replacing the manualopenssl rand | shasumdance.- mcp
- MCP context governance — observe stage (Epic GL#91, Doc 15 §7).
- report
lean-ctx gateway report(enterprise#50) — the printable CTO/value report.- security
- Admin-port security hardening (#54): response headers + auth throttling.
- serve
lean-ctx gateway serve(enterprise#10) — the self-hosted org gateway.- store
usage_eventsPostgres store (enterprise#17, baseline fields enterprise#18).- user_
api - Personal usage view (
/me, enterprise#64) — served on the proxy port, authenticated by the caller’s own gateway key.