Développement local — Configuration du développement
Prérequis
| Outil | Version | Objet |
|---|---|---|
| Bun | 1.x+ | Runtime backend (Master Bot, Child Bot, MCP) |
| Node.js | 22+ | Build frontend (npm) |
| Docker | Latest | Optionnel — pour la conteneurisation |
| Git | Latest | Dépôt |
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
Pourquoi le hook : bloque
git pushquand tu changes du code sans mettre à jour la doc. Contournement :git push --no-verify. Détails — section « Documentation Law » deCLAUDE.md.
Frontend
cd frontend
npm install
npm run dev # → http://localhost:5173
Vite proxifie automatiquement :
/api/crm/*→http://localhost:19210(Master Bot)/api/*→http://localhost:19200(MCP Server)/ws/*→ WebSocket viahttp://localhost:19200
Commandes de build
npm run dev— serveur de dev avec hot reloadnpm run build— build de production →dist/npm run i18n:extract— extraire les nouvelles chaînes de traductionnpm run i18n:compile— compiler les traductions (requis avant le build)
Backend
Master Bot (API CRM)
cd master-bot
bun install
bun run bot.ts # → http://localhost:19210
C'est le serveur API principal avec plus de 68 endpoints. Nécessite MASTER_BOT_TOKEN dans .env.
Child Bot (proxy IA)
cd child-bot
bun install
bun run bot.ts # → http://localhost:19211
Proxy Telegram ↔ Claude CLI par projet. Nécessite CITADEL_BOT_TOKEN dans .env.
MCP State Bridge
cd mcp-server
bun install
bun run server.ts # → http://localhost:19200
Gestionnaire d'état, SSE, WebSocket.
Ports
| Port | Service | Description |
|---|---|---|
| 5173 | Vite Dev Server | Frontend + proxy API |
| 19200 | MCP State Bridge | État, SSE, WebSocket |
| 19210 | Master Bot | API CRM (plus de 68 endpoints) |
| 19211 | Child Bot | Health check |
| 18888 | Nginx (VPS) | Production uniquement |
| 18889 | Nginx (Docker) | Frontend Docker |
Variables d'environnement (.env)
Requises
MASTER_BOT_TOKEN=... # Telegram @BotFather
CRM_ALLOWED_ORIGINS=http://localhost:5173
Pour toutes les fonctionnalités
CITADEL_BOT_TOKEN=... # Child bot token
GITHUB_CLIENT_ID=... # GitHub OAuth
GITHUB_CLIENT_SECRET=...
GOOGLE_CLIENT_ID=... # Google OAuth
GOOGLE_CLIENT_SECRET=...
Optionnelles
HEALTH_PORT=19210
CITADEL_DIR=/path/to/citadel-v2
EMAIL_PROVIDER=console # 'console' for dev (prints to terminal)
[email protected]
Docker (optionnel)
# Full stack
docker compose -f docker/docker-compose.yml up -d --build
# Frontend only
docker compose -f docker/docker-compose.yml up -d frontend
Structure du projet
citadel-v2/
├── master-bot/ # Telegram orchestrator + CRM API (:19210)
├── child-bot/ # Per-project AI proxy (:19211)
├── mcp-server/ # State bridge (:19200)
├── shared/ # Shared code (db, auth, routes, migrations)
├── frontend/ # React CRM + Phaser (Vite)
├── clients/ # ARC CLI
├── services/ # archived Phase 36 NotebookLM Bridge (decommissioned 2026-06-05; RAG moved into shared/rag.ts 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)
Workflow de développement typique
- Démarre le frontend :
cd frontend && npm run dev - Démarre le Master Bot :
cd master-bot && bun run bot.ts - Ouvre
http://localhost:5173 - Inscris-toi par email (email_provider=console → le code apparaît dans le terminal)
- Crée un projet via l'UI
- Travaille avec les workers via le Workspace
Type check rapide
cd master-bot && bun build --no-bundle bot.ts # Type-check backend
cd frontend && npx vite build # Type-check + build frontend
Dépannage
| Problème | Solution |
|---|---|
| Port déjà utilisé | lsof -i :19210 → kill <PID> |
| Erreur CORS | Vérifie CRM_ALLOWED_ORIGINS dans .env |
| Le frontend n'atteint pas l'API | Vérifie que le Master Bot tourne sur :19210 |
| Bun ne trouve pas les modules | bun install dans le répertoire correspondant |
| Erreurs i18n | cd frontend && npm run i18n:compile |