How to run, change and test Modern LMS on your own machine. For the one-command way to run everything, see the README. For every environment variable, see env.md.
Contents
- Requirements
- Run the dependencies
- Run the backend
- Run the frontend
- Try it out
- Features worth knowing about while developing
- Checks to run before a pull request
- Troubleshooting
| Tool | Version | Used for |
|---|---|---|
| Docker with Compose v2 | recent | The dependency stack, and the backend tests |
| Rust | stable, 1.88 or newer | backend/ |
| Node.js | 22 or newer | web/ and docs-site/ |
| Python 3 | any recent | scripts/seed_demo.py (optional) |
curl and jq |
any | scripts/phase1_e2e.sh and the API examples below (optional) |
You can run the whole system in Docker without Rust or Node installed. You only need them to work on the code outside containers.
The backend needs Postgres, Valkey (Redis), NATS, S3-compatible storage (RustFS), a TURN server (coturn) and a mail catcher (Mailpit). Start only those, without the app itself:
cp infra/docker/.env.example infra/docker/.env # optional: change the defaults
docker compose up -d postgres pgbouncer valkey nats rustfs coturn mailpit| Service | Address |
|---|---|
| PostgreSQL | localhost:5432 (user and password mlms) |
| PgBouncer | localhost:6432 |
| Valkey (Redis) | localhost:6379 |
| NATS (JetStream) | localhost:4222, monitoring at http://localhost:8222 |
| RustFS (S3) | API at http://localhost:9000, console at http://localhost:9001 |
| coturn (TURN/STUN) | localhost:3478 |
| Mailpit | SMTP at localhost:1025, inbox at http://localhost:8025 |
cd backend
cargo run --bin migrator -- control # create or upgrade the control database
cargo run --bin platform-api # http://localhost:8081 — signup and the platform console
cargo run --bin provisioner # creates each organisation's database, role and bucket
cargo run --bin lms-api # http://localhost:8080 — the API each organisation uses
cargo run --bin media-sfu # http://localhost:8090 — live classes (media on UDP 50000)
cargo run --bin workers # background jobs: reminders, migration checks, video transcodingAfter a schema change, upgrade every organisation's database:
cargo run --bin migrator -- tenantsThis migrates a small canary batch first (the 5 oldest organisations;
--canary 0 skips it). If any of them fail, it stops before touching the
rest. After the canary it migrates everyone in batches of 50
(--batch-size). One failing organisation never stops the others.
One Dockerfile builds any backend binary:
docker build -f infra/docker/backend.Dockerfile --build-arg BIN=lms-api -t mlms/lms-api .Run it on the dependency stack's network, so it can reach the other
services by name (inside a container, localhost means the container
itself):
docker run --rm --network modern-lms_default -p 8080:8080 \
-e MLMS_CONTROL_DATABASE__URL=postgres://mlms:mlms@postgres:5432/mlms_control \
-e MLMS_TENANT_DATABASES__HOST=postgres \
-e MLMS_TENANT_DATABASES__ADMIN_URL=postgres://mlms:mlms@postgres:5432/postgres \
-e MLMS_OBJECT_STORAGE__ENDPOINT=http://rustfs:9000 \
-e MLMS_MAIL__SMTP_URL=smtp://mailpit:1025 \
-e MLMS_NATS__URL=nats://nats:4222 \
-e MLMS_REDIS__URL=redis://valkey:6379 \
mlms/lms-apiinfra/docker/compose.yaml uses the same settings for every service, so
for more than one or two binaries, Compose is less typing.
docker compose up -d --build builds and runs every backend service and
the frontend. migrator control runs automatically before the APIs start.
To upgrade organisation databases after a schema change:
docker compose run --rm migrator tenantsInside Compose, the backend reaches RustFS as http://rustfs:9000. If a
file download link then fails in your browser, point that name at your
machine:
echo "127.0.0.1 rustfs" | sudo tee -a /etc/hostsSettings are environment variables prefixed with MLMS_, with __ for
nesting (for example MLMS_HTTP__PORT). The defaults target the local
stack. Outside MLMS_ENVIRONMENT=local, the services refuse to start with
development secrets, so a real deployment must set its own. The full
list, with defaults, is in env.md.
Every HTTP service serves:
/health/liveand/health/ready/openapi.jsonand interactive API docs at/docsmedia-sfualso serves Prometheus metrics at/metrics. Keep that path private at your proxy.
cd web
cp .env.example .env.local
npm install
npm run dev # http://localhost:3000.env.example lists every NEXT_PUBLIC_* variable the app reads. None of
them are secrets. The one you will most likely change is
NEXT_PUBLIC_DEV_TENANT_HOST: lms-api picks the organisation from the
request's host name, so point it at the organisation you are testing, for
example hps.modernlms.localhost:8080.
If lms-api runs on your machine and the frontend runs on a different
origin, start lms-api with MLMS_HTTP__PERMISSIVE_CORS=true (allowed in
local only).
docker build -f infra/docker/frontend.Dockerfile -t mlms/web \
--build-arg NEXT_PUBLIC_DEV_TENANT_HOST=localhost:8080 \
--build-arg NEXT_PUBLIC_PLATFORM_API_HOST=localhost:8081 \
.
docker run --rm -p 3000:3000 mlms/webNEXT_PUBLIC_* values are built into the browser bundle, so they are build
arguments. Rebuild the image to change them.
- The browser calls each organisation's API at
{slug}.modernlms.localhost:8080.*.localhostalways points at your own machine. - The web server's own routes (sign-in, signup) call
lms-apiinside the Compose network and name the organisation in theX-Forwarded-Hostheader, whichlms-apitrusts there (MLMS_HTTP__TRUST_FORWARDED_HOST). - Signup confirmation links open the web app's
/verify-emailpage.
With the stack running:
python scripts/seed_demo.pyThis creates the organisation greenfield with staff, students, courses
and sample data. Every account it creates uses the password
Demo-pass-2026!. The owner signs in as [email protected].
Open http://localhost:3000/signup. Enter the organisation's details (the form checks that the address is free), the first administrator's account, and accept the Terms and DPA. The confirmation email arrives in Mailpit at http://localhost:8025. Its link confirms the address, waits while the provisioner sets up the workspace, then takes you to sign-in.
# Sign up. The organisation waits for email confirmation.
curl -s localhost:8081/v1/signup -H 'content-type: application/json' -d '{
"organization": {"name": "High Physics School", "slug": "hps", "kind": "school",
"country_code": "PK", "timezone": "Asia/Karachi", "default_locale": "en",
"size_band": "101-500", "contact_phone": "+92-42-1234567"},
"admin": {"display_name": "Sara Khan", "email": "[email protected]",
"password": "correct horse battery staple"},
"accept_terms": true, "accept_dpa": true
}'
# Confirm with the token from the email in Mailpit.
ID=$(curl -s 'localhost:8025/api/v1/search?query=to:[email protected]' | jq -r '.messages[0].ID')
TOKEN=$(curl -s localhost:8025/api/v1/message/$ID | jq -r .Text | grep -o 'token=[A-Za-z0-9_-]*' | cut -d= -f2)
curl -s localhost:8081/v1/signup/verify -H 'content-type: application/json' -d "{\"token\": \"$TOKEN\"}"
curl -s localhost:8081/v1/organizations/hps/status
# Sign in to the new organisation and fetch the current user.
ACCESS=$(curl -s http://hps.modernlms.localhost:8080/v1/auth/login \
-H 'content-type: application/json' \
-d '{"email": "[email protected]", "password": "correct horse battery staple"}' | jq -r .access_token)
curl -s http://hps.modernlms.localhost:8080/v1/me -H "authorization: Bearer $ACCESS"scripts/phase1_e2e.shWith platform-api, provisioner and lms-api running, this signs up a
fresh organisation, sets up its structure, and creates staff and student
accounts (including CSV imports and guardians). It runs 53 checks and
prints each result. If signup fails, every later check fails too, so read
the first failure first.
With media-sfu running, open http://localhost:8090/dev in two tabs and
join the same room, as host in one and viewer in the other.
To load-test the SFU:
cargo run --release --bin sfu-bot -- --subscribers 30 --seconds 20The SFU announces your machine's main IP address to browsers. Set
MLMS_LIVE__SFU__ANNOUNCE_IP (for example 127.0.0.1) to override it.
The design and measurements are in
docs/spikes/0001-live-sfu.md.
Nobody needs a real email address to try the system. Signup forms offer
"Use a fake email": the platform creates an address such as
[email protected] with a password, shows both once, and
keeps every message for that address in its own database. Read them at
http://localhost:3000/fake-email-signin.
Fake email is on by default in local only and refuses to run in
production. Settings are MLMS_FAKE_MAIL__* in env.md.
Platform staff run the platform itself, not a school. Their accounts are separate from every organisation's accounts. The local stack creates the first one automatically:
| Where | Sign-in |
|---|---|
| http://localhost:3000/platform-login | mlmsadmin / mlmspassword |
| http://localhost:8081/console (small built-in page) | same |
These come from PLATFORM_BOOTSTRAP_EMAIL and PLATFORM_BOOTSTRAP_PASSWORD
in infra/docker/.env. The account is created once and never overwritten.
Change both before running anywhere but your own machine.
Staff have the role admin (can invite staff, suspend organisations and
impersonate a user for support) or support (read-only). Every console
action is recorded in an audit log, and impersonation is also recorded in
the organisation's own audit log.
Every organisation has a public admission portal at
http://localhost:3000/apply?tenant={slug}. Staff configure it under
Organisation console → Admission portal: opening dates, form
questions, announcements and the automatic emails. Applicants create their
own account, apply, and follow their application's progress.
Every member of an organisation has a mailbox at
{name}@{slug}.mail.{platform_domain}, opened from Mail in each
console. Mail between LMS addresses is delivered internally; anything else
goes out over SMTP (Mailpit locally).
An organisation admin adds a domain with POST /v1/domains, creates the
returned TXT and CNAME records, then calls POST /v1/domains/{host}/verify.
The provisioner re-checks active domains and disables them after repeated
failures.
The live-class editor runs C, C++, Python and Java through
Piston, a sandboxed code runner,
never inside the backend itself. Under Compose, the piston-setup service
installs the languages automatically. To run it again:
docker compose run --rm piston-setupPiston needs privileged: true. See the comment on the piston service
in infra/docker/compose.yaml before running it anywhere but your own
machine.
The project has no hosted CI, so run these yourself. Reviewers run them too.
Backend (from backend/; the tests need Docker running):
cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspaceThe lms-api integration tests live in bins/lms-api/tests/it/ and build
as one binary. They share one Postgres, RustFS and NATS container per run,
and every test gets its own fresh database. To run one module:
cargo test -p lms-api --test it <module>If you run the tests from inside a container, use --network host.
Frontend (from web/):
npm run lint
npm run typecheck
npm test
npm run buildDocker Compose (from the repo root):
docker compose config --quietThe troubleshooting page on the documentation site goes further: ports in use, Docker memory, failed migrations, missing email and resetting all data.
| Problem | Fix |
|---|---|
migration … was previously applied but has been modified |
Your local database was migrated from files with different line endings. Re-create it with docker compose down -v (this deletes local data). .gitattributes keeps .sql files on LF so this doesn't recur. |
| Sign-in succeeds but you stay on the sign-in page | Make sure cookies are allowed for the address you opened. Session cookies are only marked Secure when the site is served over HTTPS. |
| A file download link fails under Compose | Add 127.0.0.1 rustfs to your hosts file (see section 3). |
| Backend tests time out starting containers | Give Docker more memory, or run fewer tests at once with RUST_TEST_THREADS=2. |
| Builds are very slow on Windows | Keep the repository on a Linux filesystem (for example inside WSL) rather than a mounted Windows drive. |
docker compose ps -a shows migrator or piston-setup as Exited (0) |
That is expected. Both are one-shot jobs. |