Local Development: Development Setup
Requirements
| Tool | Version | Purpose |
|---|---|---|
| Bun | 1.x+ | Backend runtime (Master Bot, Child Bot, MCP) |
| Node.js | 22+ | Frontend build (npm) |
| Docker | Latest | Optional, for containerization |
| Git | Latest | Repository |
Quick Start
git clone [email protected]:SerhiiInUa/citadel-v2.git
cd citadel-v2
cp .env.example .env
# Edit .env — add bot tokens
# One-time: activate the pre-push doc-coverage hook (Phase 49.1)
bash scripts/setup-hooks.sh
Why the hook: blocks
git pushwhen you change code without updating docs. Bypass:git push --no-verify. Details,CLAUDE.mdsection "Documentation Law".
Frontend
cd frontend
npm install
npm run dev # → http://localhost:5173
Vite automatically proxies:
/api/crm/*→http://localhost(Master Bot)/api/*→http://localhost:19200(MCP Server)/ws/*→ WebSocket viahttp://localhost:19200
Build Commands
npm run dev: dev server with hot reloadnpm run build: production build →dist/npm run i18n:extract: extract new translation stringsnpm run i18n:compile: compile translations (required before build)
Backend
Master Bot (CRM API)
cd master-bot
bun install
bun run bot.ts # → http://localhost
This is the main API server with 68+ endpoints. Requires a platform secret in .env.
Child Bot (AI Proxy)
cd child-bot
bun install
bun run bot.ts # → http://localhost:19211
Per-project Telegram ↔ Claude CLI proxy. Requires a platform secret in .env.
MCP State Bridge
cd mcp-server
bun install
bun run server.ts # → http://localhost:19200
State manager, SSE, WebSocket.
Ports
| Port | Service | Description |
|---|---|---|
| 5173 | Vite Dev Server | Frontend + API proxy |
| 19200 | MCP State Bridge | State, SSE, WebSocket |
| 19210 | Master Bot | CRM API (68+ endpoints) |
| 19211 | Child Bot | Health check |
| 18888 | Nginx (VPS) | Production only |
| 18889 | Nginx (Docker) | Docker frontend |
Environment Variables (.env)
Required
a platform secret=... # Telegram @BotFather
CRM_ALLOWED_ORIGINS=http://localhost:5173
For Full Functionality
a platform secret=... # Child bot token
the GitHub OAuth client id=... # GitHub OAuth
the GitHub OAuth secret=...
the Google OAuth client id=... # Google OAuth
the Google OAuth secret=...
Optional
HEALTH_PORT=19210
CITADEL_DIR=/path/to/citadel-v2
EMAIL_PROVIDER=console # 'console' for dev (prints to terminal)
the admin [email protected]
Docker (optional)
# Full stack
docker compose -f docker/docker-compose.yml up -d --build
# Frontend only
docker compose -f docker/docker-compose.yml up -d frontend
Project Structure
citadel-v2/
├── the server code # Telegram orchestrator + CRM API ()
├── the server code # Per-project AI proxy (:19211)
├── mcp-server/ # State bridge (:19200)
├── the server code # Shared code (db, auth, routes, migrations)
├── frontend/ # React CRM + Phaser (Vite)
├── the server code # ARC CLI
├── services/ # archived Phase 36 semantic search (decommissioned 2026-06-05; RAG moved into the server code in Phase 71)
├── config/ # Registry, vault, workers
├── skills/ # Skill definitions + evals
├── docker/ # Compose + Dockerfiles + Nginx
├── infra/nginx/ # VPS Nginx config
├── scripts/ # Deploy, build scripts
├── docs/ # Documentation
└── data/ # SQLite DB (auto-created)
Typical Development Workflow
- Start the frontend:
cd frontend && npm run dev - Start the Master Bot:
cd master-bot && bun run bot.ts - Open
http://localhost:5173 - Register via email (email_provider=console → code appears in the terminal)
- Create a project via the UI
- Work with workers via the Workspace
Quick Type Check
cd master-bot && bun build --no-bundle bot.ts # Type-check backend
cd frontend && npx vite build # Type-check + build frontend
Troubleshooting
| Problem | Solution |
|---|---|
| Port already in use | lsof -i → kill <PID> |
| CORS error | Check CRM_ALLOWED_ORIGINS in .env |
| Frontend can't reach API | Check that the Master Bot is running on |
| Bun can't find modules | bun install in the corresponding directory |
| i18n errors | cd frontend && npm run i18n:compile |