Skip to content

Architecture

How the portal is built today. The high-level design was the starting point; the architecture decision records chose leaner parts for much of it (one server with systemd instead of Kubernetes, Redis Streams instead of Kafka, PostgreSQL instead of a graph database). Where this page and an ADR differ, the ADR decides; where the code and both differ, the code is what runs.

Repository What it is
i3-academy-portal (this one) The learning platform and its API, the background services, the database’s core schema public and its migrations; for customers only, it consumes what the console configures
i3-academy-admin The admin console of the platform’s team: everything the operator does, with its own schemas admin and platform (ADR 0264, ADR 0449); installed first and alone
Academy The marketing website

They share only the database (ADR 0261). Each owns its schemas and migrates them: the portal public, the console admin and platform (the console’s database setup runs first on a new server). What the console may read and write there is listed in database consumers, and what it asks the portal to do goes through platform jobs.

apps/api Fastify 5, TypeScript: the API, a modular monolith (apps/api/src/modules, one folder per area)
apps/web Next.js 16 with React 19 and Tailwind: the portal people use
apps/docs Starlight: the docs site with the handbooks (ADR 0274)
apps/connector-host Runs the knowledge-source connectors the portal hosts itself
packages/contracts Shared schemas (zod), the event registry and the real-time protocol
packages/connector-* The connector protocol and the kit to build connectors
connectors/ The connectors (SharePoint, S3, Google Drive, Confluence, file share, CSV, LDAP)
integrations/ The n8n node
deploy/ install.sh's and update.sh's parts: systemd units, nginx sites, Docker, example settings
  • One process, many modules. Each area (courses, live, labs, billing, …) registers its routes in apps/api/src/app.ts.
  • Contracts in zod. Request bodies are parsed with the schemas of packages/contracts; the web app uses the same types. The automation API’s routes are described as OpenAPI from these schemas (GET /v1/openapi.json, reference), and every route has an MCP tool (list).
  • Tenancy in the database. Every organisation’s rows carry its tenant_id. withTenant (apps/api/src/db/client.ts) runs a request’s queries in a transaction as the unprivileged role academy_app, with the organisation (and for private spaces the person) set, so PostgreSQL’s row-level security policies decide what a query sees (ADR 0001). A forgotten where can’t leak another organisation’s data.
  • Events. A change writes its domain event into an outbox in the same transaction (apps/api/src/events/outbox.ts); it is published to Redis Streams only if the change commits. Consumers (webhooks, analytics, notifications, records) read the streams in consumer groups.
  • Encryption. Sensitive fields are encrypted per organisation with data keys wrapped by KMS_MASTER_KEY or the organisation’s own key service (ADR 0007).
  • AI goes through one gateway (apps/api/src/ai/gateway.ts) to the organisation’s own provider account (OpenAI-compatible, Anthropic, Gemini, Azure speech, …), with per-organisation daily budgets, per-person rate limits and a usage record.
  • Regional cells. An installation can run several cells, each with its own database; a directory sends a person to the cell of their organisation (ADR 0007).

The portal, its database server (a provision: PostgreSQL 17 with pgvector, and Redis) and the lab nodes are machines of their own. install.sh sets the portal and the lab nodes up from the checkout, builds there and delivers only the runtime (ADR 0444); deploy/update.sh updates them the same way (install, deploy, self-hosting):

Part What it does
nginx with certbot HTTPS for the portal, the API and the module hosts (content., docs., git., rtc., *.preview.)
i3-academy-api / academy-portal the API and the web app (Node 26, systemd)
PostgreSQL 17 with pgvector the data, and the vectors for searching knowledge sources
Redis 7 event streams, queues, rate limits, live presence
academy-connectors the connector host
LiveKit the media server for live sessions
Docling reads documents for knowledge sources
lab nodes (their own repository, i3-academy-lab-node) run learners’ code in containers under gVisor (ADR 0102, ADR 0497); they pair through the portal’s door, or join over a WireGuard tunnel
academy-git-gate the Git area’s repositories, in a container without network (ADR 0188)

Files (uploads, videos, generated media) are on the server’s disk (STORAGE_DIR); backups says what to keep. The Docker installation runs the same parts as containers behind Caddy.