Architecture
Status of this document: §1–§3 and §5 describe Phases 0–3; §4 and §6 were rewritten for Phase 4 (studio, media pipeline) and the buildable part of Phase 5, as built on 2026-11-22. Anything not built is marked not implemented.
1. Phase 0 — verified findings (2026-11-22)
Recorded as given by the project lead, who performed the reconnaissance; not re-investigated here.
| Subject | Finding |
|---|---|
| IMM1003 / IMM1033 platform | Two apps, uqo-imm1003 and uqo-imm1033 (« Notes de cours interactives »). Each is a prebuilt static dist/ served by a tiny node server.mjs <port> <dist> under PM2, with /api/health. No video player, no administration, no authentication, no storage layer. Nothing reusable for a video MOOC beyond the deployment pattern. Their source repository was not inspected further. |
atlas.spboucher.ai |
Resolves to the owner's public gateway (51.161.112.61, Caddy, automatic TLS). No route exists yet (connections fail). There is no existing deployment and no data to preserve. |
| House stack | Next.js 16 (App Router), React 19, strict TypeScript, Tailwind CSS 4, zod, @simplewebauthn (passkeys), vitest, Playwright + axe, pnpm, Node ≥ 24; one Next server process under PM2 behind the Caddy gateway; SQLite/filesystem state in a data/ directory outside git; /api/health. Proven on a dozen of the owner's production sites. Reference read for conventions: orix-spboucher-ai. |
| Curriculum repository | atlas-ai-mooc (read-only for this project). 24 sessions in 6 parts; its plan supersedes the placeholder list of the platform specification §4. At the time of the last import (2026-11-22), sessions S01–S08 declared implemented, S09 draft, the others planned; other people were writing sessions in that repository while this platform was built. No video is recorded. No licence is chosen. No session has been reviewed by the instructor. |
| Production port | 8840 (default PORT). |
2. Stack chosen, and why not the specification's « default candidate »
The specification (§14) proposes PostgreSQL, S3-compatible object storage, containers and FFmpeg workers as a default, and adds: prefer the existing proven stack when warranted; avoid complexity for its own sake. The house stack is used because:
- The public site is read-only. Phases 1–3 have no write path at all: no database is needed to serve a manifest of 24 sessions. A committed, schema-validated JSON snapshot is simpler, diffable, and cannot be corrupted at runtime.
- One operator, one node. The owner runs every site as a single Next process under PM2 behind one Caddy gateway, with state in
data/. A second runtime (Postgres, MinIO, a container engine) would be the only one of its kind to operate, back up and patch. - Nothing is lost for Phase 4. Authoring metadata fits SQLite (as in the reference project); media bytes go through a storage interface (
src/modules/storage) for which an S3 implementation can be added without touching routes. - Scale. The corpus is 24 sessions, a few hundred transcript segments per capsule, a few hundred glossary terms: a local search index is the right size (specification §10 prefers it).
Single package rather than a monorepo: the four domain modules live in src/modules/* and depend on nothing in src/app or src/components (enforced by convention and by the unit tests, which import them without Next). Splitting them into workspace packages later is mechanical.
3. Layers
content/course.manifest.json ─┐
content/import/** ├─► src/lib/content.ts ──► buildView(manifest, mode) ──► CourseView ──► pages, search index,
content/preview/overlay.json ─┘ (server only) (publication.ts) sitemap, JSON-LD,
ATLAS_DATA_DIR/media/** ──────────► MediaStorage (FsStorage) ◄── /media/[...path] (mediaAllowed) media routessrc/modules/content-schema—schema.ts(zod: manifest, sections, quiz, glossary…),publication.ts(the only place that decides visibility),urls.ts,adapter.ts(pure conversions from the course repository's formats).src/modules/learning-engine—quiz.ts(grading),state.ts(local state, export/import, completion rule),vtt.ts(captions, transcript),text.ts.src/modules/search— tokenisation, typo-tolerant matching, ranking, facets, highlighting.src/modules/diagram-library—logic.ts(the model behind each diagram, unit-tested),registry.ts(catalogue).src/modules/storage—MediaStorageinterface,FsStorage, range parsing, MIME allow-list.src/lib— server glue:content.ts(loader),search-index.ts,seo.ts,serve.ts,env.ts;client/store.ts(localStorage holder).src/app— routes.src/components— UI.
The publication rule (one function)
buildView(manifest, mode) returns the CourseView. Pages never see the manifest.
| Session state | production | preview |
|---|---|---|
planned, draft |
« À venir » — public plan only | « À venir » — public plan only |
preview |
« À venir » — public plan only | open, bannered, never counted as published |
published |
open | open |
archived |
withdrawn notice, not indexed | same |
Within an open session, each section and capsule has its own visibility (private / preview / public). Downloads additionally require download: true and a recorded licence (canDownload). Counts shown to visitors (counts.published, counts.capsules) exclude preview-only sessions and synthetic capsules.
Modes
ATLAS_PREVIEW=1 selects the preview mode. It is read at build time (pages are static) and at run time (media and content routes). The preview build goes to .next-preview/, so it cannot be started by mistake as the production build; it sends X-Robots-Tag: noindex, serves Disallow: / in robots.txt, an empty sitemap, no-store media, and shows a non-dismissible banner on every page.
4. Rendering and caching (changed in Phase 4)
- Public pages are rendered on demand (
export const dynamic = "force-dynamic"on the(public)layout) from the publications in force. Publishing, scheduling, rolling back and withdrawing take effect at the next request, with no rebuild, and there is no cached copy of a withdrawn page that could be served by mistake. The cost is a server render per request (SQLite is in-process; the public manifest is cached per content revision). Static generation and ISR were rejected for this reason: a stale page after a rollback is a leak. - No
loading.tsxin the public tree any more: under a Suspense boundary anotFound()or a redirect would answer 200. Unknown addresses are real 404s and former addresses real 308s ((public)/[...rest], session pages). - The search corpus (
/recherche/index.json) and the sitemap are dynamic too; the corpus is kept in memory per content revision, one minute at most. /media,/contenu,/telecharger,/api/health*, everything under/adminare dynamic.- The development preview (
ATLAS_PREVIEW=1, separate.next-preview) still exists for the committed snapshot; it never reads the database and closes the studio.
5. What is deliberately not here
No service worker (no offline promise is made; the site only tells the visitor when the connection drops). No analytics. No cookie. No server-side learner state. No third-party origin (CSP: default-src 'self', no remote host listed). No AI API.
6. Phase 4 as built
┌──────────── /admin (pages) ── requireEditorPage ─┐
browser (passkey) ───▶│ /admin/api/[...path] ── dispatch(): session, role, origin, CSRF, rate limit ──▶ src/server/*
└──────────── /admin/apercu/** (private preview: working copy) ┘ │
▼
course repository ──importer (data only)──▶ sync.ts (3-way diff) ──▶ working copy ──publish.ts──▶ publications (immutable)
(content.ts) │ publicManifest(now)
uploads (chunks) ──▶ masters/ ──jobs──▶ worker (ffmpeg) ──▶ media/<session>/<capsule>/<encode>/ ▼
buildView(manifest, "production") ──▶ public sitesrc/server/— plain Node modules shared by the Next server, the worker and the CLI:db.ts(node:sqlite, WAL, forward-only migrations),auth.ts,audit.ts(+ content-addressedblobs),content.ts(working copy),publish.ts(publications, public manifest),sync.ts(bootstrap, diff, apply),importer.ts(moved fromscripts/lib),uploads.ts,magic.ts,archive.ts,captions.ts,jobs.ts,transcode.ts,worker.ts,storage.ts,ops.ts,backup.ts,log.ts,http.ts.src/lib/studio/— the Next-side gate (guard.ts: cookies, page and API guards) and the API table (api.ts).src/app/admin/— sign-in and enrolment pages, studio pages, the API route, the private preview (pages + media, figures, downloads for editors).src/components/studio/— the interface.- One gate, unchanged in spirit.
loadPublicManifest()insrc/lib/content.tsreturns eitherpublicManifest()(live publications) or the committed snapshot (no database yet);buildViewfilters it as before.getPreviewCourse()builds the editors' view from the working copy inpreviewmode and is only called under/adminafter the session check. Section bodies are read by hash through references present in a view. - Database
ATLAS_DATA_DIR/atlas.db:editors,credentials,auth_sessions,enroll_tokens,challenges,audit,blobs,course,course_sessions,sections,capsules,resources,resource_versions,publications,imports,uploads,upload_chunks,masters,jobs,meta,schema_migrations. - Files:
media/(servable when published),masters/(originals by SHA-256),resources/,uploads/(staging),work/(scratch),backups/.
Why SQLite through node:sqlite rather than better-sqlite3: nothing to compile on macOS arm64 across Node 24–26, and the synchronous API fits a single-node tool. Verified here on Node 26.13 only; node:sqlite exists unflagged from Node 22.13/24 (it may print an experimental warning on 24).
7. Known limits of the current design
- Public pages cost a server render each; no page cache exists in the application (a gateway micro-cache would be safe only for anonymous GETs outside
/admin, and would delay rollbacks by its lifetime). - Limits kept in memory (rate limits, search corpus, public manifest cache) assume one web process.
- The JavaScript of the player, the quiz engine and the diagram library is part of every build, including production, where the diagram routes are 404. That is platform code, not course content; the leak check covers content.
- CSP uses
'unsafe-inline'for scripts and styles, because statically generated Next pages cannot carry a per-request nonce. No remote origin is allowed, which bounds the risk; seeSECURITY.md. - Importing a session trusts its
metadata.yamlstatus. A session markedimplementedwhile still being edited would be snapshotted as it is; it staysdraft(invisible) until someone decides otherwise.