DOCS / ARCHITECTURE / OVERVIEW

Architecture Overview

Lattice is a two-app monorepo: the gateway is the thing applications and providers actually talk to, and the dashboard is an admin surface built entirely on top of the gateway's own management API.

Company applications Lattice Gateway (Nitro + h3) Providers Bearer lattice_sk_… Bearer lattice_sk_… Bearer lattice_sk_… Bearer management key Postgresapplications · keys · usage · logs Dashboard (Nuxt) Postgresdashboard sessions App A App B App C /v1OpenAI-compatible API /management/v1Admin API Auth · quota · rate limit Routerregistry + strategy + circuit breaker OpenAI Anthropic Google Ollama(self-hosted) vLLM(self-hosted)

Two trust boundaries, two APIs

/v1/**/management/v1/**
Who calls itCompany applicationsThe dashboard (or any admin script)
AuthPer-application lattice_sk_… keyA separate management API key
ScopeChat completions, model listing — scoped to the calling application's policyProvisioning and observability across every application
Middleware02.auth.ts → 03.rate-limit.ts04.management-auth.ts

Provider credentials (OPENAI_API_KEY, etc.) live only in the gateway's environment. Neither an application nor the dashboard can ever see them — the dashboard reaches the gateway the same way an application would, over the network, with a bearer key, just against /management/v1 instead of /v1.

Runtime stack

  • Gateway: Nitro v3 + h3, running on Bun's bun preset. Postgres via Drizzle ORM (drizzle-orm/bun-sql).
  • Dashboard: Nuxt 4 + Nuxt UI, session auth via better-auth, data fetching/caching via Pinia Colada.
  • Shared: Valibot for every schema (requests, responses, environment variables) in both apps and in packages/api-contract.

Why two separate databases

The gateway's Postgres database owns applications, API keys, usage counters, rate-limit counters, request logs, and provider health state — the operational data of the gateway itself. The dashboard's Postgres database owns exactly one thing: better-auth's session/user/account tables for the humans who sign into the dashboard. They can be the same physical Postgres server (different logical databases) or entirely separate servers; nothing in either app assumes otherwise. This keeps "who can sign into the admin UI" architecturally separate from "what the gateway is doing," so rotating or restoring one never touches the other.

Where to go next

LATTICE — INTERNAL AI INFRASTRUCTURE
GITHUB © 2026