This codebase uses the Next.js App Router. Keep route files thin and move implementation into domain modules.
app/ owns route entrypoints only:
app/**/page.tsxshould compose page-level UI.app/**/route.tsshould parse HTTP boundaries and delegate tolib/**.- Route handlers with shared behavior should call a helper in
lib/routes.
components/ is grouped by product domain:
components/accountaccount settings and provider setup UI.components/authsession, sign-in, and avatar UI.components/chatchat console, transcript rendering, and chat sidebar.components/layoutapp shell and global layout controls.components/mediaimage and speech playground UI.components/modelsmodel explorer, model detail, filters, snippets, and health UI.components/providersprovider identity UI.components/searchglobal model search.
Prefer direct domain imports such as @/components/models/model-explorer over broad barrel exports. This keeps bundle ownership clearer during upgrades.
lib/openprovider contains OpenProvider application services and provider-facing orchestration.
lib/db contains database client and schema.
lib/http contains HTTP response and cache helpers that are not tied to one route.
lib/routes contains shared route handlers used by multiple App Router endpoints.
src/ contains the reusable gateway/runtime package: provider adapters, model discovery, routing core, CLI/server utilities, and low-level types.
Use npm run verify before dependency upgrades, deployment changes, or broad refactors. It runs TypeScript validation, the security audit, and the production web and gateway builds.