# WarezHou$e BBS Late-80s style BBS in the browser. Node 22 + TypeScript (strict, CommonJS), Postgres 16, xterm.js front end. Callers connect over a WebSocket; all BBS logic runs server-side and writes ANSI to a dumb terminal. ## Commands - `npm run build`: tsc, then `scripts/copy-assets.mjs` copies `src/**/*.sql` into `dist/` - `npm test`: build, then `node --test` on `dist/**/*.test.js` (pure engine code only, no DB) - `docker compose up -d --build`: full stack at http://localhost:8080; `docker compose logs app` ## Architecture (core) | Path | Role | |---|---| | `src/server.ts` | HTTP/WS server, node slots, runs migrations then each door's `init()` | | `src/session/Session.ts` | One caller: throttled output, `readKey/readChoice/readLine/yesNo/pause`, notices | | `src/session/ansi.ts` | Pipe colour codes (`|00`-`|15` fg, `|16`-`|23` bg, `|CL`), `padRight`, `center`, `esc` | | `src/ui/` | Shared widgets: `makeBox`, `menuItem`, `readNumber`, `pickFromList`, `commas`, `padLeft` | | `src/nodes.ts` | Live sessions; `notifyUser(userId, text)`, `broadcast(text)` | | `src/db.ts` | `pool`, `withTx(fn)`, `migrate()`; BIGINT comes back as JS number | | `src/screens/` | Core BBS screens (logon, new user, main menu) | | `src/doors/` | Door framework + one folder per door (see `src/doors/CLAUDE.md`) | | `db/migrations/` | Core SQL migrations, applied in filename order on start | ## Conventions - **Screens fit 80x25.** Keep lines within 79 visible chars; use `vlen()` for padding text with pipe codes. - All output goes through `Session` (`print`/`println` take pipe codes). Escape user text with `esc()` before embedding it. - Hotkey prompts that should show live messages use `s.promptChoice(prompt, keys)` (single-line prompt). - Multi-row state changes go in `withTx`, with `SELECT ... FOR UPDATE` on the rows you read then write. - `Disconnected` is thrown from any I/O when the caller drops; let it propagate. ## Modularity rule Core code never imports from a door except via `src/doors/registry.ts`. A door imports only from `src/session/*`, `src/ui/*`, `src/db.ts`, `src/nodes.ts` and `src/users/userRepo.ts` (types, `isSysop`). Doors never import from each other or from `src/screens/`. Each area keeps its own `CLAUDE.md`; when working inside a door, its folder plus this API is all the context needed.