Architecture overview
High-level shape of the deployed platform.
Request path
Host Nginx (docs/nginx/eacmlab.conf) terminates HTTPS and proxies by path:
| Location | Upstream |
|---|---|
/ | Client |
/api/, /socket.io/, /health | Server |
CORS is handled by Express only (not Nginx).
Environments and host ports
| Env | Compose file | Client host port | Server host port | Images |
|---|---|---|---|---|
| Dev | docker-compose.dev.yml | 39000 → 3000 | 39001 → 4000 | Local build (target: deps) |
| Test | docker-compose.test.yml | 44000 → 3000 | 44001 → 4000 | ghcr.io/avier99/eacmlab-*-test-latest |
| Prod | docker-compose.prod.yml | 45000 → 3000 | 45001 → 4000 | ghcr.io/avier99/eacmlab-*-prod-latest |
Public hostnames: eacmlab.org (prod), test.eacmlab.org (test). Docs will use docs.eacmlab.org on port 46000 (separate compose/image — see Deployment overview).
Process roles
| Process | Responsibility |
|---|---|
| Client | UI for participants and admins; App Router pages; Socket.IO client |
| Server | REST under /api, Socket.IO game/room/survey/admin events, Prisma writes |
| Postgres | All durable experiment and admin data (DATABASE_URL) |
Server container entrypoint always runs migrations before listen:
npx prisma migrate deploy
exec node index.js
Realtime vs HTTP
- HTTP: auth, experiment metadata, surveys, admin CRUD, export jobs, health
- Socket.IO: rooms, foraging rounds, arithmetic, live admin monitor, simulations, session restore
See Realtime sockets and Game engine.
Auth (summary)
Admin HTTP routes use JWT middleware (requireAdminAuth). Participant flow uses session tokens restored over Socket.IO. The client lists next-auth in package.json but does not import or use it — ignore it for architecture docs.