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 push quand tu changes du code sans mettre à jour la doc. Contournement : git push --no-verify. Détails, section « Documentation Law » de CLAUDE.md.

Frontend

cd frontend
npm install
npm run dev          # → http://localhost:5173

Vite proxifie automatiquement :

Commandes de build

Backend

Master Bot (API CRM)

cd master-bot
bun install
bun run bot.ts       # → http://localhost

C'est le serveur API principal avec plus de 68 endpoints. Nécessite a platform secret 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 a platform secret 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

a platform secret=...           # Telegram @BotFather
CRM_ALLOWED_ORIGINS=http://localhost:5173

Pour toutes les fonctionnalités

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=...

Optionnelles

HEALTH_PORT=19210
CITADEL_DIR=/path/to/citadel-v2
EMAIL_PROVIDER=console          # 'console' for dev (prints to terminal)
the admin [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/
├── 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)

Workflow de développement typique

  1. Démarre le frontend : cd frontend && npm run dev
  2. Démarre le Master Bot : cd master-bot && bun run bot.ts
  3. Ouvre http://localhost:5173
  4. Inscris-toi par email (email_provider=console → le code apparaît dans le terminal)
  5. Crée un projet via l'UI
  6. 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 → 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
Bun ne trouve pas les modules bun install dans le répertoire correspondant
Erreurs i18n cd frontend && npm run i18n:compile