Développement local — Development Setup

Prérequis

Outil Version Utilisation
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

Démarrage rapide

git clone [email protected]:SerhiiInUa/citadel-v2.git
cd citadel-v2
cp .env.example .env
# Редагуй .env — додай токени ботів

# One-time: активувати pre-push doc-coverage hook (Phase 49.1)
bash scripts/setup-hooks.sh

Pourquoi ce hook : il bloque git push quand tu modifies du code sans mettre à jour la doc. Contournement : git push --no-verify. Détails dans la section "Documentation Law" de CLAUDE.md.

Frontend

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

Vite proxyfie automatiquement :

Commandes de build

Backend

Master Bot (CRM API)

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

C'est le serveur API principal avec 68+ endpoints. Nécessite MASTER_BOT_TOKEN dans .env.

Child Bot (AI Proxy)

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 CRM API (68+ endpoints)
19211 Child Bot Health check
18888 Nginx (VPS) Production uniquement
18889 Nginx (Docker) Frontend Docker

Variables d'environnement (.env)

Obligatoires

MASTER_BOT_TOKEN=...           # Telegram @BotFather
CRM_ALLOWED_ORIGINS=http://localhost:5173

Pour les fonctionnalités complètes

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' pour le dev (affiche dans le terminal)
[email protected]

Docker (optionnel)

# Stack complète
docker compose -f docker/docker-compose.yml up -d --build

# Frontend uniquement
docker compose -f docker/docker-compose.yml up -d frontend

Structure du projet

citadel-v2/
├── master-bot/          # Telegram оркестратор + CRM API (:19210)
├── child-bot/           # Per-project AI proxy (:19211)
├── mcp-server/          # State bridge (:19200)
├── shared/              # Спільний код (db, auth, routes, migrations)
├── frontend/            # React CRM + Phaser (Vite)
├── clients/             # ARC CLI
├── services/            # NotebookLM Bridge (Python)
├── 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. Lance le frontend : cd frontend && npm run dev
  2. Lance le Master Bot : cd master-bot && bun run bot.ts
  3. Ouvre http://localhost:5173
  4. Inscris-toi via email (email_provider=console → code affiché dans le terminal)
  5. Crée un projet via l'UI
  6. Travaille avec les workers via le Workspace

Vérification rapide des types

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 already in use lsof -i :19210kill <PID>
Erreur CORS Vérifie CRM_ALLOWED_ORIGINS dans .env
Le frontend ne voit pas l'API Vérifie que le Master Bot tourne sur :19210
Bun ne trouve pas les modules bun install dans le répertoire concerné
Erreurs i18n cd frontend && npm run i18n:compile