API
The backend that powers the Naalya schools platform, a NestJS monorepo over PostgreSQL.
Welcome to the backend. The Naalya API is the server behind the schools platform: every login, student record, grade, and email goes through it. This section is how it's built and how to add to it without surprises.
It's a NestJS monorepo. NestJS organizes TypeScript code into modules. The monorepo packs the schools HTTP API, a worker, an audit consumer, a separate clinic API (apps/ehr), and a shared library. School records for the Hub live in one PostgreSQL database. The clinic API uses a second database (EHR_DATABASE_URL). Redis, RabbitMQ, and Centrifugo are also part of the running system. The map is on System overview.
Two things shape almost everything you touch:
- Multi-tenant: each school is a tenant; data is auto-scoped so one school never sees another's.
- CASL permissions: a rules engine that decides, per user, which actions they may take on which resources.
You don't have to master either on day one, just know they're always running in the background.
System shape
Three deployable apps, each with one job, plus libs/shared (imported everywhere as @app/shared) for common code.
apps/
server/ : the HTTP API (Express 5): what the Hub and website talk to
worker/ : background job processor (no HTTP listen)
audit/ : audit-log microservice (no HTTP listen)
ehr/ : clinic HTTP API, separate database and port
libs/
shared/ : code shared across the apps (@app/shared)You'll live mostly in server: it runs guards, validation, and database access. worker and audit do not call listen. They drain queued jobs (emails, audit records) so the API stays responsive. ehr is a second HTTP process. Full tour in Architecture. The route map is HTTP surface.
Using this section
The sidebar runs in the order a new engineer needs it: Start here, Core concepts, Access and security, How-to guides, Reference, Rover and AI, then the School features folder. Find your way explains each group and points you to a starting page for common jobs.
The code is the source of truth
Docs drift. When a page and the code disagree, the code wins: a quick PR to fix the doc is always welcome.
Where to go next
The first four cards are the first-day path. The last four are the systems you will meet once you add product behaviour.
Getting started
Install, copy .env.example, start Redis, Centrifugo, and Gotenberg, and boot the apps.
Architecture
The monorepo: server, worker, audit, the clinic API, and the shared library.
HTTP surface
Prefix, errors, pagination, webhooks, and controller paths.
Module anatomy
How one resource module is built: Entity, Repository, Service, Controller, DTO.
Auth and permissions
Guards, the JWT, CASL actions and resources, and how a request gets authorized.
AI system
Rover and the subagents: the RPC seam, tools vs skills.
How realtime works
Centrifugo channels, the two tokens, and Hub query invalidation.
How Chowbea works
OpenAPI client plus the type bus for types Swagger cannot carry.