Architecture
The API package is organized around clear responsibilities. Controllers handle HTTP boundaries, models handle database behavior, services handle cross-cutting domain logic, and routers bind paths to controllers.
API structure
Section titled “API structure”contextcreates shared runtime state such as config, database, logger, settings, and services.controllersparse requests, call models or services, and write responses.modelsown database queries and transactions.servicesown behavior that crosses endpoint boundaries, such as sessions, email, OPAQUE, JWKS, settings, branding, and audit logging.http/routersroute incoming requests to controllers.utilscontains shared helpers for security, CSRF, PKCE, pagination, crypto, and HTTP behavior.
Keep business rules out of routers. Keep database details out of UI services. Make the ownership easy to follow.
Frontend packages
Section titled “Frontend packages”user-uihosts login, registration, consent, OTP, password reset, dashboard, organization switching, and account settings.admin-uihosts operational management pages.darkauth-clientprovides application integration helpers.demo-appdemonstrates app integration.docsis the Astro documentation site.
Data flow
Section titled “Data flow”Most changes follow this path: schema, controller, model or service, router, UI service, UI page, tests, docs. Simple changes may skip pieces, but every touched boundary should stay consistent.