Architecture
How Infra is built and hosted, at a high level.
This page is a short map for people who build on or integrate with Infra. The source of truth is the code; the repository's own docs go deeper.
The app
Infra is one Next.js (App Router) web app with React and TypeScript. The same app serves:
- the internal app for BHG staff (departments, Delivery, the knowledge base),
- the client portal for invited client people,
- the HTTP API under
/api, - the MCP server at
/api/mcp.
Public URL: infra.bluehorizonsgroup.com.
Hosting
| Part | What runs it |
|---|---|
| Web app and API | Cloudflare Workers, built with OpenNext. |
| Database | PostgreSQL on Neon, reached through Cloudflare Hyperdrive, with Prisma as the data layer. |
| Scheduled jobs | Cloudflare cron triggers: the daily DLE ceiling check, hourly due-date notifications, the weekly project data check, and housekeeping sweeps. |
| Rate limits | Cloudflare rate-limit bindings for short windows; a shared Postgres counter for the 10-minute paid-AI run cap and the MCP hourly budget. |
| Errors and tracing | Sentry. |
Sign-in and access
- People sign in with Microsoft Entra ID (Azure AD) single sign-on through NextAuth. There are no Infra passwords.
- Every request carries the person's role and departments. Page access is checked before a page renders, and every API route checks access again on the server.
- API keys and MCP connectors resolve to the same session shape as a browser sign-in, so they pass the same checks. See Connecting agents.
See Settings and access for roles and page access.
AI
- Model calls go through a Cloudflare AI Gateway, which holds the provider keys, so the app never holds them.
- AskBHG, knowledge-base search and the AI model catalog are served by Forge, BHG's separate knowledge and AI service. Infra calls it on the user's behalf.
- Delivery's AI (Sync, the project agent, BRD drafts, plan follow-ups, filing suggestions) runs in Infra and goes through the gateway.
- Every paid AI run counts against a per-person cap. See AI usage limits.
- Document text is treated as data, never as instructions to the model.
How Delivery keeps its plan honest
Delivery is built around one write path. Every change to a project's approved state, from Sync, a person, the project agent or an API key, goes through a single gate that either applies it (a lead's own hand edit) or stages it for review. Every applied change is logged with who, how, its source and quote, and can be reverted. Health, progress and status are derived from the plan by the server, never set by hand. See Changes and review.