Lokale Entwicklung — Development Setup
Voraussetzungen
| Tool | Version | Zweck |
|---|---|---|
| Bun | 1.x+ | Backend-Runtime (Master Bot, Child Bot, MCP) |
| Node.js | 22+ | Frontend-Build (npm) |
| Docker | Latest | Optional — für Containerisierung |
| Git | Latest | Repository |
Schnellstart
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
Warum der Hook: Blockiert
git push, wenn du Code änderst, ohne die Docs zu aktualisieren. Bypass:git push --no-verify. Details —CLAUDE.md, Abschnitt „Documentation Law".
Frontend
cd frontend
npm install
npm run dev # → http://localhost:5173
Vite proxied automatisch:
/api/crm/*→http://localhost:19210(Master Bot)/api/*→http://localhost:19200(MCP Server)/ws/*→ WebSocket überhttp://localhost:19200
Build-Befehle
npm run dev— Dev-Server mit Hot Reloadnpm run build— Production-Build →dist/npm run i18n:extract— Neue Übersetzungsstrings extrahierennpm run i18n:compile— Übersetzungen kompilieren (vor dem Build erforderlich)
Backend
Master Bot (CRM API)
cd master-bot
bun install
bun run bot.ts # → http://localhost:19210
Das ist der Haupt-API-Server mit 68+ Endpunkten. Benötigt MASTER_BOT_TOKEN in .env.
Child Bot (AI Proxy)
cd child-bot
bun install
bun run bot.ts # → http://localhost:19211
Pro-Projekt Telegram ↔ Claude CLI-Proxy. Benötigt CITADEL_BOT_TOKEN in .env.
MCP State Bridge
cd mcp-server
bun install
bun run server.ts # → http://localhost:19200
State-Manager, SSE, WebSocket.
Ports
| Port | Service | Beschreibung |
|---|---|---|
| 5173 | Vite Dev Server | Frontend + API-Proxy |
| 19200 | MCP State Bridge | State, SSE, WebSocket |
| 19210 | Master Bot | CRM API (68+ Endpunkte) |
| 19211 | Child Bot | Health Check |
| 18888 | Nginx (VPS) | Nur Production |
| 18889 | Nginx (Docker) | Docker-Frontend |
Umgebungsvariablen (.env)
Erforderlich
MASTER_BOT_TOKEN=... # Telegram @BotFather
CRM_ALLOWED_ORIGINS=http://localhost:5173
Für vollständigen Funktionsumfang
CITADEL_BOT_TOKEN=... # Child-Bot-Token
GITHUB_CLIENT_ID=... # GitHub OAuth
GITHUB_CLIENT_SECRET=...
GOOGLE_CLIENT_ID=... # Google OAuth
GOOGLE_CLIENT_SECRET=...
Optional
HEALTH_PORT=19210
CITADEL_DIR=/path/to/citadel-v2
EMAIL_PROVIDER=console # 'console' für Dev (gibt Code im Terminal aus)
[email protected]
Docker (optional)
# Vollständiger Stack
docker compose -f docker/docker-compose.yml up -d --build
# Nur Frontend
docker compose -f docker/docker-compose.yml up -d frontend
Projektstruktur
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)
Typischer Entwicklungs-Workflow
- Frontend starten:
cd frontend && npm run dev - Master Bot starten:
cd master-bot && bun run bot.ts http://localhost:5173öffnen- Per E-Mail registrieren (
email_provider=console→ Code im Terminal) - Projekt über die UI Erstellen
- Mit Workern im Workspace arbeiten
Schnelle Typprüfung
cd master-bot && bun build --no-bundle bot.ts # Type-check backend
cd frontend && npx vite build # Type-check + build frontend
Troubleshooting
| Problem | Lösung |
|---|---|
| Port already in use | lsof -i :19210 → kill <PID> |
| CORS-Fehler | CRM_ALLOWED_ORIGINS in .env prüfen |
| Frontend findet API nicht | Prüfen, ob Master Bot auf :19210 läuft |
| Bun findet Module nicht | bun install im entsprechenden Verzeichnis ausführen |
| i18n-Fehler | cd frontend && npm run i18n:compile |