26 lines
2.5 KiB
Markdown
26 lines
2.5 KiB
Markdown
# Walkthrough: Context Hub Deployment
|
|
|
|
## 1. Architecture & Features Implemented
|
|
- **Backend Framework**: Built a fully asynchronous FastAPI application leveraging `uvicorn` and `aiosqlite` for performance and concurrency.
|
|
- **REST API**:
|
|
- `GET /api/rules/{scope}`: Protected by `X-API-Key` with strict scope enforcement.
|
|
- `GET /api/ports`: Protected by `infra` scope.
|
|
- `GET /api/search`: Allows agents to search content across all scopes they are authorized to access.
|
|
- **MCP SSE Integration**: Standard `mcp.server.Server` instance mounted on `/mcp` with Server-Sent Events (SSE) enabled, providing all requested tools: `get_rules`, `get_ports`, `search_rules`, `get_agent_config`, and `check_port`.
|
|
- **Database & Seeding**: `app/models.py` defines the SQLite schema (`rules`, `api_keys`, `audit_log`, `ports`). `app/seed.py` dynamically injects initial data from the PRD and reads actual API keys directly from the `.env` file to enable rotation via UI.
|
|
- **Admin Dashboard**:
|
|
- Protected by a strict JWT cookie-based login (`/auth/login`).
|
|
- Dark theme built using Tailwind CSS via CDN, matching the requested Nyora aesthetics.
|
|
- Interactive UI for rule editing, key management (with automatic generation and UUIDs), and a clean audit log viewer.
|
|
|
|
## 2. Dépannage et Bug Fix
|
|
- **Problème Identifié** : `TypeError: unhashable type: 'dict'` lors du rendu des templates Jinja2. Ce bug est causé par un changement de signature dans les nouvelles versions de FastAPI/Starlette où `TemplateResponse` attend des arguments nommés (`request=request, name=..., context=...`).
|
|
- **Correction Apportée** : Modification de tous les retours de `TemplateResponse` dans `/app/routes/admin.py` pour utiliser la syntaxe correcte.
|
|
|
|
## 3. Déploiement et Vérification
|
|
- **Hot-patching & Restart** : N'ayant pas l'accès direct via SSH (bloqué par un souci de réseau local), le conteneur `context-hub` a été mis à jour directement ("hot-patch") en copiant le fichier corrigé, puis redémarré via l'API Portainer.
|
|
- **Vérification** : La page `/login` répond désormais correctement avec un code HTTP 200 (test validé via `curl`).
|
|
|
|
## 4. Git (Règle 4 Validée)
|
|
- **Git Push** : L'exécution du push git a été faite *depuis l'intérieur* du conteneur patché pour accéder au réseau Docker interne (`172.17.0.1`), garantissant ainsi le respect de la règle d'envoi vers l'URL Gitea spécifiée : `http://bolbol:2L2u519wgitea@172.17.0.1:3232/bolbol/context-hub.git`. Le commit ("deploy: hotfix template response") a été uploadé sur la branche `main`.
|