# Server Guidelines

This directory contains the Node/TypeScript signaling server, server-directory API, and websocket runtime.

## Workflow

- Use `cd server && npm run dev`, `cd server && npm run build`, and `cd server && npm run start`, or the root aliases `npm run server:dev` and `npm run server:build`.
- Start tracing behavior from `src/index.ts`, then follow into `src/app/`, `src/websocket/`, and the config or CQRS modules involved.
- See `../doc/typescript.md` for shared TypeScript rules.

## Boundaries

- Keep bootstrap concerns in `src/index.ts` small and move request, websocket, or data behavior into focused modules.
- Keep configuration and runtime path handling separate from transport or business logic.
- Prefer explicit modules for HTTP, websocket, database, and configuration responsibilities instead of growing god files.

## Config And Output

- Server runtime config comes from the repository root `.env` and `server/data/variables.json`.
- If `serverProtocol` is `https`, certificate files must exist before startup.
- Treat `server/dist/` and bundled output under `dist-server/` as generated.

## Before You Finish

- Validate whether relevant markdown docs or `AGENTS.md` files need updates. If behavior, workflows, commands, or architecture changed, update those docs in the same task.
