The backend API behind OpenLearn, built with NestJS and PostgreSQL.
  • TypeScript 92.3%
  • Python 7.4%
  • JavaScript 0.2%
  • Dockerfile 0.1%
Find a file
Sandro Alves 811ffd5b22 docs(api): document the script checks
Add a Script checks section to testing.md covering test_scripts.py,
unit_test.py and diagnostics.py, trim the index intro and align the setup
install wording with install.py.
2026-10-03 09:18:54 +01:00
.husky feat(api): rate limiting, atomic gameplay, refresh tokens and hardening 2026-08-13 23:31:34 +01:00
.yarn/releases chore(api): drop railway scripts and untrack install-state 2026-08-22 03:02:10 +01:00
docs docs(api): document the script checks 2026-10-03 09:18:54 +01:00
prisma fix(api): remove the legacy tiers re-created after the rename 2026-09-30 01:11:38 +01:00
scripts chore(api): generate secrets on install and unify backups 2026-10-03 04:14:29 +01:00
src feat(api): refuse insecure environment defaults at boot 2026-10-02 07:08:50 +01:00
test feat(api): re-encode avatars server-side with sharp 2026-09-27 23:08:46 +01:00
.dockerignore chore(api): prune dead schemas, unused deps and docker context bloat 2026-09-09 23:34:39 +01:00
.env.example feat(api): refuse insecure environment defaults at boot 2026-10-02 07:08:50 +01:00
.gitignore refactor(scripts): consolidate python tooling 2026-08-19 17:46:45 +01:00
.node-version feat(auth): rotate admin password on every startup 2026-08-12 16:58:32 +01:00
.oxlintrc.json feat(auth): rotate admin password on every startup 2026-08-12 16:58:32 +01:00
.prettierrc feat(auth): rotate admin password on every startup 2026-08-12 16:58:32 +01:00
.yarnrc.yml style: format yaml config files 2026-08-18 00:18:39 +01:00
AGENTS.md docs(api): restructure the documentation set 2026-10-02 06:14:40 +01:00
commitlint.config.ts feat(auth): rotate admin password on every startup 2026-08-12 16:58:32 +01:00
docker-compose.yml feat(api): refuse insecure environment defaults at boot 2026-10-02 07:08:50 +01:00
Dockerfile chore(api): streamline runtime deps, DI wiring and container build 2026-09-09 23:34:39 +01:00
eslint.config.mjs feat(auth): rotate admin password on every startup 2026-08-12 16:58:32 +01:00
LICENSE feat(auth): rotate admin password on every startup 2026-08-12 16:58:32 +01:00
nest-cli.json refactor(api): Go-like layout with cmd/ entrypoints and flat internal domains 2026-08-14 00:45:53 +01:00
openapi.json feat(api): expose the degree role and the learning activity on public profiles 2026-09-30 09:43:54 +01:00
package.json feat(api): re-encode avatars server-side with sharp 2026-09-27 23:08:46 +01:00
prisma.config.ts feat(auth): rotate admin password on every startup 2026-08-12 16:58:32 +01:00
README.md feat(api): refuse insecure environment defaults at boot 2026-10-02 07:08:50 +01:00
tsconfig.build.json fix(api): harden security, types and contracts 2026-09-09 02:37:19 +01:00
tsconfig.json fix(api): harden security, types and contracts 2026-09-09 02:37:19 +01:00
yarn.lock feat(api): re-encode avatars server-side with sharp 2026-09-27 23:08:46 +01:00

OpenLearn API

NestJS REST API for the OpenLearn learning platform. It serves PostgreSQL data through Zod-validated endpoints, protects them with JWT authentication and rate limiting, runs the lesson content, progress, XP and AI features, and documents every route in Swagger.

Stack

Layer Technology
Runtime Node.js 24, NestJS 11
Language TypeScript
Database PostgreSQL via Prisma
Validation Zod, nestjs-zod
Auth JWT access tokens, rotating refresh tokens
Cache and queue Redis (optional), BullMQ
Docs Swagger at /api/docs
Linting oxlint, then ESLint
License AGPL-3.0-or-later

Prerequisites

  • Node.js 24.14.0 (see .node-version) and Yarn 4
  • Docker and Docker Compose v2, for PostgreSQL and Redis

Quick start

yarn install
docker compose up -d postgres redis
cp .env.example .env
yarn prisma:generate
yarn prisma:migrate
yarn prisma:seed
yarn start:dev

The API listens on http://localhost:4000; Swagger is at http://localhost:4000/api/docs. A fresh admin password is generated and printed on each boot unless ADMIN_PASSWORD is set; production requires the variable and never prints it (see Operations).

Redis is optional for the API to boot but required for the AI verdict cache and the AI job queue. Set AI_API_KEY to grade answers with a model. See Setup for the full clone-to-running walkthrough.

Commands

Command Purpose
yarn start:dev Dev server with watch
yarn build Compile to dist/
yarn start:prod Run dist/cmd/server/main
yarn test Jest unit suite
yarn test:e2e E2E suite
yarn check Lint, unit tests, build and OpenAPI drift check
yarn prisma:migrate Run pending migrations (dev)
yarn prisma:migrate:deploy Apply migrations in deployed environments
yarn prisma:seed Upsert canonical content, roles, ladder and users
yarn openapi:check Regenerate openapi.json and fail on drift

The full environment variable reference is in .env.example and Setup.

Documentation

Document Contents
docs/README.md Index of the documentation set
docs/setup.md Prerequisites, environment variables, local and Docker setup
docs/architecture.md Modules, request flow, auth, AI, courses, XP, runtime configuration
docs/authoring.md Server-side lesson XML validation contract
docs/operations.md Deploy, rate limits, AI configuration, Redis, security, backups
docs/testing.md Jest, E2E and the OpenAPI drift check
scripts/README.md Python helper scripts and OpenAPI tooling
AGENTS.md Machine-facing invariants and the verification gate

License

AGPL-3.0-or-later. See LICENSE.