System overview
What the website, Education Hub, and API each do, and how a request moves between them.
Read this once when you join the platform. It is the map. Product detail stays in the Website, Education Hub, and API sections. Those pages link back here instead of retelling the map.
Status. Source-verified against the default branches on 11 November 2026. No environment was called. Hostnames below are strings committed in Railway config or application source, not a live DNS check. Revisions are on the audit record.
What each part is for
Three git repositories, plus a clinic API that lives inside the API repository.
| Part | Repository | Who it is for | What it owns |
|---|---|---|---|
| Public website | Naalya-Website | Visitors reading about the schools | Marketing pages, Sanity content, a public chat widget, enquiry posts |
| Education Hub | Education-Hub | Staff, students, guardians, guests, platform operators | The signed-in product UI |
| Schools API | Naalya-API (apps/server, apps/worker, apps/audit) | The Hub, the website, and jobs | School data, auth, permissions, background work |
| Clinic API | Naalya-API (apps/ehr) | The clinic web app and external clinic callers | A separate HTTP API and a separate Postgres database |
The Hub does not store school records of its own. It calls the schools API. The website does not store applications of its own. Editorial pages come from Sanity. Enquiries and the public chat go to the schools API over HTTP.
The figure below is the system context: people, what they open, the apps in the API repository, and the outside services those apps call.
Visitors use the website. Signed-in people use the Hub. Both browsers call the schools API. Sanity holds website content. The schools API and the clinic API use different Postgres databases.
Containers inside the API repository
nest-cli.json declares four applications and one library. The HTTP schools API is apps/server. It listens on PORT (the process default in bootstrap() is 8000 when config has no port) and sets the global prefix api/v1. Paths under /queues are excluded so Bull Board can sit at /queues.
apps/worker does not call listen. It consumes RabbitMQ queues QUEUES.WORKER and QUEUES.AGENT. apps/audit consumes QUEUES.AUDIT. apps/ehr is a second HTTP server, prefix api/v1, port from EHR_PORT (default 8100).
libs/shared is imported as @app/shared. It holds config, the Hub database module, permissions, and other code the apps share. The clinic app has its own env schema, ehrEnvSchema in apps/ehr/src/config/ehr-env.config.ts. A comment there says it does not load the Hub DATABASE_URL.
How data moves
Sign-in. The Hub collects credentials or follows Microsoft OAuth, then stores accessToken and refreshToken in localStorage under auth-token. Axios sends Authorization: Bearer. See Authentication across the platforms.
School records. Hub screens call /api/v1/... on VITE_API_URL. The server’s JwtAuthGuard sets a school id on the request from the JWT. Repositories that use the tenant scope add that schoolId on read and write. UserType.PLATFORM_ADMIN sets a bypass instead of a school id. This is application-level tenancy in one Hub database, not a database per school.
Website content. React Router loaders read Sanity with GROQ. That path does not go through the schools API.
Website enquiries and chat. The contact and admission forms post to {VITE_API_URL}/api/v1/enquiry with an x-api-key header (submitEnquiry in app/lib/naalya-chat/site.ts). The chat widget calls /api/v1/public-ai/chat and /api/v1/public-ai/config the same way. A second write stores a Sanity formSubmission through the website’s own POST /api/form-submission, which uses the server-side SANITY_WRITE_TOKEN. The committed openapi.json in the website repo does not list these enquiry or public-ai paths. Treat that file as stale. Details are on The API client.
Realtime. The Hub opens a Centrifugo websocket at {VITE_CENTRIFUGO_URL}/connection/websocket and subscribes to personal:user#{userId} after RealtimeQuery.getToken(). Query invalidation is a separate message path. Collaborative documents use a different socket: the Hub rewrites VITE_API_URL to ws and appends /collab. The server attaches that socket from CollabService.attach in apps/server/src/main.ts. How that socket, Pip, and the rate limits behave when more than one API process is running is on Several copies.
Background work. HTTP handlers enqueue work. The worker and audit processes consume it. BullMQ uses Redis (REDIS_URL). The Nest microservice transport uses RabbitMQ (RABBIT_MQ_URL). They are not the same queue.
Clinic. The schools API can receive POST /api/v1/tenants/naalya/ehr/webhook (NaalyaEhrWebhookController). The clinic API is not a module inside apps/server. It is apps/ehr.
Trust boundaries
The browser holds Hub tokens in localStorage. Anyone who can run script in that origin can read them. The API still has to enforce permissions. Hub route guards (requirePermission, requireFeature) only decide what the UI loads. They are not the authorisation boundary.
Public website routes do not sign a person in. The publishable or secret key in VITE_NAALYA_API_KEY is shipped to the browser because it is a VITE_ variable. ApiKeyGuard accepts a publishable key only with an Origin on the key’s allow list. The header name is x-api-key.
CORS on the schools API allows FRONTEND_URL and EDUCATION_HUB_URL with credentials. publicAiCors reflects any Origin for /api/v1/public-ai/ and for POST /api/v1/enquiry, allows x-api-key, and does not set credentials.
Docs UI (/docs, /docs/swagger, /docs/swagger/json) and Bull Board (/queues) use HTTP Basic authentication when NODE_ENV is not development. The clinic API mounts an additional unauthenticated filtered spec at /api/v1/external/openapi.json.
No helmet dependency is declared in the API package.json. Do not describe the API as having Helmet.
What this page does not claim
- That the Railway hostnames answer on the public internet today. They are values in
.railway/environments.ts(API) and.railway/railway.ts(Hub). - A retention schedule for school data, beyond the refresh-token default named on Security and example data.
- That staging and
maincontain the same commit. On 11 November 2026 they did not. See the audit record.
Where to go next
Environments
Local, staging, and production as the repositories configure them.
Authentication
How tokens are issued, stored, and checked.
HTTP surface
Prefix, errors, pagination, and the controller map.
Run the API locally
Toolchain, env file, and the Taskfile.
Run the Hub locally
Bun, Vite, and the type watcher.
Run the website locally
pnpm, Sanity, and the public site.
Sources
Naalya-APInest-cli.json,apps/server/src/main.tsbootstrap,apps/worker/src/main.ts,apps/audit/src/main.ts,apps/ehr/src/main.ts,apps/ehr/src/config/ehr-env.config.tsehrEnvSchemaNaalya-APIlibs/shared/src/config/env.config.tsenvSchema, tenant middleware andJwtAuthGuard.enterTenantContext,ApiKeyGuardEducation-Hubsrc/services/api/api.instance.ts,src/components/providers/realtime.provider.tsxRealtimeProvider,src/lib/collab/collab.tscollabWsUrlNaalya-Websiteapp/lib/naalya-chat/site.tssubmitEnquiry,app/lib/naalya-chat/client.tscreateNaalyaChat,app/routes/api/form-submission.ts,app/routes.ts