2.5 KiB
2.5 KiB
Walkthrough: Context Hub Deployment
1. Architecture & Features Implemented
- Backend Framework: Built a fully asynchronous FastAPI application leveraging
uvicornandaiosqlitefor performance and concurrency. - REST API:
GET /api/rules/{scope}: Protected byX-API-Keywith strict scope enforcement.GET /api/ports: Protected byinfrascope.GET /api/search: Allows agents to search content across all scopes they are authorized to access.
- MCP SSE Integration: Standard
mcp.server.Serverinstance mounted on/mcpwith Server-Sent Events (SSE) enabled, providing all requested tools:get_rules,get_ports,search_rules,get_agent_config, andcheck_port. - Database & Seeding:
app/models.pydefines the SQLite schema (rules,api_keys,audit_log,ports).app/seed.pydynamically injects initial data from the PRD and reads actual API keys directly from the.envfile 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.
- Protected by a strict JWT cookie-based login (
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ùTemplateResponseattend des arguments nommés (request=request, name=..., context=...). - Correction Apportée : Modification de tous les retours de
TemplateResponsedans/app/routes/admin.pypour 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-huba été mis à jour directement ("hot-patch") en copiant le fichier corrigé, puis redémarré via l'API Portainer. - Vérification : La page
/loginrépond désormais correctement avec un code HTTP 200 (test validé viacurl).
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 branchemain.