Getting started
Run the Naalya API on your machine. What it needs, which parts you choose yourself, the Taskfile path from a fresh clone, and how to sign in.
This page takes you from a fresh clone of Naalya-API to a running server, worker, and audit app that the Education Hub can talk to. It assumes you are comfortable with Node, Docker, and a terminal.
At the end, the API runs on http://localhost:8000, its interactive reference is at /docs, and you can sign in to a demo school.
What the API needs
The API is three Node apps (server, worker, and audit) plus five services they connect to. You run the apps yourself. The services can come from anywhere, as long as the apps can reach them with a URL.
| Service | What it is for | Where you can get one |
|---|---|---|
| Postgres | All school data | Any Postgres with the pgvector and pg_trgm extensions. A local Docker container, a Postgres you already run, or a hosted one such as Neon or Supabase. |
| RabbitMQ | Request and reply calls between the server and the worker and audit apps | Any broker that speaks AMQP 0-9-1. A local RabbitMQ container, a hosted one such as CloudAMQP, or a compatible broker such as LavinMQ. |
| Redis | Background job queues (BullMQ), rate limits, and the Centrifugo engine | task infra starts one for you. Any other Redis you can reach also works. |
| Centrifugo | Live updates in the Hub | task infra starts one, already configured. |
| Gotenberg | Turning HTML into PDFs, such as report cards and letters | task infra starts one. |
Use whatever is easiest for you
The .env.example and Taskfile comments mention Neon and CloudAMQP because that is what some of the team use. Nothing in the code depends on them. A local Postgres and RabbitMQ in Docker work just as well, and keep your experiments away from shared data.
Postgres is the only one with a hard requirement. The migrations run CREATE EXTENSION for vector and pg_trgm, so the database must have them available and your user must be allowed to create them. A third extension, pg_stat_statements, is optional. The migration skips it with a notice if you are not allowed to create it.
Before you start
Install these:
| Tool | Version | Notes |
|---|---|---|
| Node.js | 22 | The Dockerfile builds on node:22-alpine. The repo has no .nvmrc or engines field. |
| pnpm | The version in package.json (packageManager) | Run corepack enable once and Corepack picks the right version for you. |
| Docker with Compose v2 | Any current release | For task infra, and for Postgres and RabbitMQ if you run them locally. |
| Task | Any current release | The project's command runner. See Task commands. |
You also need a Postgres database and a RabbitMQ broker from the table above. If you have neither, the example below gives you both on your own machine.
Example: Postgres and RabbitMQ in Docker
This is one way to do it, not a requirement. The pgvector/pgvector image is plain Postgres with pgvector included, and pg_trgm ships with Postgres.
docker run -d --name naalya-postgres \
-e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=naalya \
-p 5432:5432 pgvector/pgvector:pg17
docker run -d --name naalya-rabbitmq \
-p 5672:5672 -p 15672:15672 rabbitmq:4-managementThe matching URLs for .env.local are:
DATABASE_URL=postgres://postgres:postgres@localhost:5432/naalya
RABBIT_MQ_URL=amqp://guest:guest@localhost:5672The RabbitMQ management screen is then on http://localhost:15672. For a hosted database, use the connection string it gives you, including any sslmode setting.
These commands are examples and were not run for this page. Any image versions that include pgvector work.
Step 1: Install Task
Task is a small command runner. The repo's Taskfile.yml wraps the pnpm scripts in short, memorable commands, so task dev instead of pnpm dev:all.
brew install go-task # macOS
winget install Task.Task # WindowsOther systems and package managers are listed in the installation guide on the Task website. Check it worked with task --version. In the repo, run task on its own to list every command.
You don't have to use Task. Every task is one or two pnpm scripts, and Task commands shows which.
Step 2: Run setup the first time
From the repo root:
task setupOn a fresh clone this installs dependencies, copies .env.example to .env.local, and then stops with a message asking for your credentials. That stop is expected. It happens because DATABASE_URL is still empty, and nothing else can run without a database.
Step 3: Fill in .env.local
Open .env.local. Keys that already have values are safe local defaults. Leave them.
Set these, or the apps cannot work at all:
| Key | Value |
|---|---|
DATABASE_URL | Your Postgres connection string |
RABBIT_MQ_URL | Your broker's AMQP URL |
JWT_SECRET_KEY | Any long random string, such as the output of openssl rand -hex 32 |
R2_PUBLIC_BASE_URL | Any URL, such as http://localhost:9999, if you are not testing file uploads. The boot check refuses a value that is not a URL |
SUPERADMIN_EMAILS | Your email address. This key is not in .env.example, so add the line yourself. It makes you a platform admin on the demo school. Separate several addresses with commas |
The other blank keys belong to outside services: OpenAI, Cloudflare R2, Resend email, Unipile for WhatsApp, and Microsoft 365. The boot check (envSchema in libs/shared/src/config/env.config.ts) only requires most of them to be present. An empty value passes, and the apps start. The feature that uses that service then fails when you use it. Fill in the ones you need for the work in front of you, and ask the team for development keys.
The full list, with what reads each key, is on Config and environment.
Never commit .env.local
.env.local is ignored by git. Keep real keys there and nowhere else. Never paste them into the handbook, an issue, or a pull request.
Step 4: Finish setup
Run setup again:
task setupThis time it starts Redis, Centrifugo, and Gotenberg in Docker (task infra) and applies every migration to your database (task migration:run). Every step is safe to repeat. It does not overwrite your .env.local.
If the migration fails on CREATE EXTENSION "vector", your Postgres does not have pgvector. Use an image or host that includes it.
Step 5: Start the apps
task devThis runs, side by side with coloured labels:
- the server on port 8000, in watch mode,
- the worker and audit apps, in watch mode,
- the React Email preview on port 3001,
- the type bus watcher, which keeps the Hub's shared types current,
- the PDF stylesheet and preview watchers.
On first boot in development, the server creates a demo school if it does not exist yet (SchoolSeedService). Staging and production skip this.
To run one app on its own, use task dev:server, task dev:worker, or task dev:audit.
Step 6: Check that it works
| Address | What you should see |
|---|---|
http://localhost:8000/docs | Scalar, the interactive API reference. Send any request from here |
http://localhost:8000/docs/swagger | Swagger UI |
http://localhost:8000/queues | Bull Board, the job queue dashboard |
http://localhost:3001 | The email preview |
Locally, /docs and /queues are open. Outside development they ask for the DOCS_USERNAME and DOCS_PASSWORD set in the environment.
Step 7: Sign in
Sign-in is by a six-digit code sent by email. The address in SUPERADMIN_EMAILS is a platform operator, so in the Hub it signs in at /auth/operator and lands on /platform/hub. You can also call the auth routes from Scalar.
If you have not set up Resend, the email cannot be delivered. The code is still in the email job. Open http://localhost:8000/queues, find the email queue, and open the latest job. The code is in its data as otp. A failed email job is kept for a day. This works because Bull Board is open in development. The server comment on that setting says job data holds sign-in codes, which is why it is locked outside development. This path was read in code, not tried for this page.
To make yourself an admin of one school rather than of the platform, see Auth and permissions.
Day to day
| When | Run |
|---|---|
After git pull | task sync: installs new dependencies and applies new migrations |
| Changing an entity | task migration:generate NAME=short_name, then read the generated file, then task migration:run. See The database |
| Before you push | task check: lint and tests |
| Infra looks stuck | task infra:status, task infra:logs, or task infra:down then task infra |
When the API contract changes, regenerate the Hub's client in the Education Hub repo with bun api:generate while this API is running. See How Chowbea works.
Running everything in Docker
task docker:dev builds and runs the server, worker, and audit apps in containers too, with your source mounted so watch mode still works. task docker:dev:down stops it. It still needs your own Postgres and RabbitMQ. It is slower to start and harder to debug, so use it to reproduce a container-only problem, not for daily work.
If something goes wrong
Find what you see in the first column. Each row gives the cause and the fix.
| Symptom | Cause | Fix |
|---|---|---|
task setup stops and asks for credentials | DATABASE_URL is empty | Fill in Step 3, then run task setup again |
| The apps stop at boot with a Zod error that names a key | That key is missing from .env.local | Add the key, with an empty value if you do not use that service |
REDIS_URL environment variable is not configured | REDIS_URL is missing | Set it. The local default is redis://localhost:6379 |
| The server cannot connect to RabbitMQ | The broker is not running, or the URL, user, or password is wrong | Start the broker, then check the URL, user, and password in its management screen |
A migration fails on CREATE EXTENSION | Your Postgres does not have pgvector, or your user cannot create extensions | Use a Postgres with pgvector, and a user that can create extensions |
| No sign-in email arrives | Resend is not set up | Read the code from /queues, as in Step 7 |
Commands on this page come from Taskfile.yml and package.json at API fbb63d5178bcfe171292daebb19b6cbdac025a44. The setup path, boot checks, seed, and Bull Board behaviour were read in code at the same commit. They were not run for this page.
Where to go next
Task commands
Every task, what it runs, and when to use it.
Run the platform locally
Bring the API and the Education Hub up together.
Architecture
Server, worker, audit, the clinic API, and the shared library.
Config and environment
Every variable, grouped, and where each is read.
Add a resource module
Build your first feature end to end.