194 lines
5.6 KiB
Markdown
194 lines
5.6 KiB
Markdown
# BSN Live-System — Initialer Projektplan
|
|
|
|
> **Ziel:** Neuer Server, neues Projekt, alles von Tag 1 an richtig.
|
|
> **Erstellt:** 21. Juni 2026 — basierend auf 3 Review-Runden + sys-1/2-Tests
|
|
|
|
---
|
|
|
|
## Phase 0 — Server einrichten (1h)
|
|
|
|
```bash
|
|
# User anlegen
|
|
sudo useradd -m -s /bin/bash cody
|
|
sudo useradd -m -s /bin/bash basti
|
|
sudo useradd -m -s /bin/bash alicia
|
|
|
|
# Sudo für alle
|
|
echo "cody ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/cody
|
|
echo "basti ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/basti
|
|
echo "alicia ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/alicia
|
|
|
|
# SSH-Keys verteilen
|
|
# (Public Keys von Cody, Basti, Alicia in authorized_keys)
|
|
|
|
# Basis-Tools
|
|
sudo apt-get update && sudo apt-get install -y redis-server git python3-pip curl
|
|
sudo systemctl enable --now redis-server
|
|
|
|
# Python-Toolchain
|
|
pip install ruff mypy pre-commit pytest pytest-cov redis
|
|
```
|
|
|
|
---
|
|
|
|
## Phase 1 — Projekt-Repo aufsetzen (30min)
|
|
|
|
In Gitea (`git.datenhimmel.work`):
|
|
- Neues Repo `BSN-Community` anlegen
|
|
- Gitea Actions Runner registrieren
|
|
|
|
Im Projekt-Root:
|
|
|
|
```bash
|
|
git clone git@git.datenhimmel.work:danielkrause/BSN-Community.git
|
|
cd BSN-Community
|
|
```
|
|
|
|
**Dateien aus dem Prototypen kopieren:**
|
|
|
|
| Von (BSN-Chatsystem) | Nach (BSN-Community) | Grund |
|
|
|---|---|---|
|
|
| `.gitea/workflows/quality.yml` | `.gitea/workflows/quality.yml` | CI-Gate |
|
|
| `CODING_STANDARDS.md` | `CODING_STANDARDS.md` | Regelwerk |
|
|
| `queue_handler.py` | `src/queue_handler.py` | Queue-System |
|
|
| `webhook_queue.py` | `src/webhook_queue.py` | Signatur-Prüfung |
|
|
| `queue_worker.py` | `src/queue_worker.py` | Async Worker |
|
|
| `pyproject.toml` (aus HTML §13) | `pyproject.toml` | Ruff + mypy + pytest Config |
|
|
| `.pre-commit-config.yaml` (aus HTML §13) | `.pre-commit-config.yaml` | Pre-Commit Hooks |
|
|
| `docs/bsn-coding-standards.html` | `docs/bsn-coding-standards.html` | IT-Bibel |
|
|
|
|
**Git initial:**
|
|
```bash
|
|
git add -A
|
|
git commit -m "chore: Projekt-Setup mit CI-Gate, Queue, Coding-Standards"
|
|
git push origin main
|
|
# Gitea Actions prüft automatisch!
|
|
```
|
|
|
|
---
|
|
|
|
## Phase 2 — Hermes-Agenten einrichten (30min)
|
|
|
|
```bash
|
|
# Cody-Profil (Entwickler)
|
|
hermes profile create cody --clone-from default
|
|
hermes config set agent.environment_hint "Du bist Cody, BSN-Entwickler. Befolge skill_view('bsn-coding-standards'). CI: .gitea/workflows/quality.yml" --profile cody
|
|
|
|
# Alicia-Profil (Content)
|
|
hermes profile create alicia --clone-from default
|
|
hermes config set agent.environment_hint "Du bist Alicia, BSN-Content-Managerin. System-Übersicht: read_file('ALICIA.md'). Befolge skill_view('bsn-coding-standards')." --profile alicia
|
|
|
|
# Basti-Profil (Redakteur)
|
|
hermes profile create basti --clone-from default
|
|
hermes config set agent.environment_hint "Du bist Basti, BSN-Redakteur. Befolge skill_view('bsn-coding-standards') bei Code-Arbeit." --profile basti
|
|
```
|
|
|
|
**Skills installieren (pro Profil):**
|
|
```
|
|
skill_view('bsn-coding-standards') # Coding-Regeln
|
|
skill_view('web-research') # Recherche
|
|
skill_view('article-management') # Article Server (Alicia/Basti)
|
|
```
|
|
|
|
---
|
|
|
|
## Phase 3 — Flask-App-Struktur (1h)
|
|
|
|
Statt `app.py` (5599 Zeilen Monolith) → saubere Struktur:
|
|
|
|
```
|
|
src/
|
|
├── app.py # Flask-App-Factory + Config (< 100 Zeilen)
|
|
├── routes/
|
|
│ ├── __init__.py
|
|
│ ├── whatsapp.py # WhatsApp Webhook (→ Queue)
|
|
│ ├── telegram.py # Telegram Webhook (→ Queue)
|
|
│ ├── admin.py # Admin-Dashboard
|
|
│ └── api.py # Öffentliche API
|
|
├── services/
|
|
│ ├── __init__.py
|
|
│ ├── intake.py # Message-Verarbeitung
|
|
│ └── game_service.py # Spiele-Logik
|
|
├── models/
|
|
│ ├── __init__.py
|
|
│ └── submission.py # DB-Modell
|
|
├── queue/
|
|
│ ├── __init__.py
|
|
│ ├── handler.py # QueueHandler (von queue_handler.py)
|
|
│ ├── webhook.py # Signatur + Intake (von webhook_queue.py)
|
|
│ └── worker.py # Queue-Worker (von queue_worker.py)
|
|
├── utils/
|
|
│ ├── __init__.py
|
|
│ └── validators.py
|
|
tests/
|
|
├── test_routes/
|
|
├── test_services/
|
|
├── test_queue/
|
|
└── conftest.py
|
|
```
|
|
|
|
---
|
|
|
|
## Phase 4 — Services starten (15min)
|
|
|
|
```bash
|
|
# Flask-App (systemd)
|
|
sudo tee /etc/systemd/system/bsn-chatbot.service << EOF
|
|
[Unit]
|
|
Description=BSN Chatbot
|
|
After=network.target redis-server.service
|
|
|
|
[Service]
|
|
User=cody
|
|
WorkingDirectory=/home/cody/workspace/BSN-Community
|
|
ExecStart=/home/cody/venv/bin/python src/app.py
|
|
Restart=always
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
# Queue-Worker (systemd)
|
|
sudo tee /etc/systemd/system/bsn-worker.service << EOF
|
|
[Unit]
|
|
Description=BSN Queue Worker
|
|
After=redis-server.service
|
|
|
|
[Service]
|
|
User=cody
|
|
WorkingDirectory=/home/cody/workspace/BSN-Community
|
|
ExecStart=/home/cody/venv/bin/python src/queue/worker.py --poll 2 --batch 5
|
|
Restart=always
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable --now bsn-chatbot bsn-worker
|
|
```
|
|
|
|
---
|
|
|
|
## Phase 5 — Monitoring (später)
|
|
|
|
- `structlog` für strukturiertes Logging
|
|
- `GlitchTip` für Error-Tracking
|
|
- `/admin/queue` Endpoint für Queue-Status
|
|
|
|
---
|
|
|
|
## ✅ Checkliste: Ist alles drin?
|
|
|
|
- [ ] CI-Gate (Gitea Actions) prüft jeden Push
|
|
- [ ] Pre-commit blockiert lokal
|
|
- [ ] Coding-Standards-Skill in allen Profilen
|
|
- [ ] Queue puffert Submissions (Tunnel down = nix verloren)
|
|
- [ ] Signatur-Prüfung vor Enqueue
|
|
- [ ] Dedup über message_id
|
|
- [ ] Worker verarbeitet asynchron
|
|
- [ ] Flask-Struktur sauber getrennt (Routes ≠ Services ≠ Models)
|
|
- [ ] Alle Agenten (Cody, Basti, Alicia) haben environment_hint
|
|
- [ ] Redis läuft als systemd-Service
|
|
- [ ] Worker läuft als systemd-Service
|