Telegram Mini App v2.0.4 Architecture

FastAPI + React SPA — 10-page dashboard with direct Gateway API SSE streaming chat

WebView HTTPS tunnel validate web_dist/ SSE /v1/chat/completions proxy spawn vision ocr read/write build deploy + sync Phone Telegram WebView Telegram Servers Bot API Cloudflare Tunnel → localhost:9119 Auth Middleware Ed25519 (primary) + HMAC-SHA256 + Bearer localhost:9119 React SPA (10 pages) Chat · Status · Agents · Sessions · Analytics Logs · Cron · Skills · Config · Keys v2.0.4 FastAPI Web Server web_server.py (~2465 lines) 17 protected endpoints · SSE proxy Backend Services Local Vision LFM2-VL :8080 Local OCR GLM-OCR :8081 Hermes Gateway API /v1/chat/completions :8642 tmux Agents page only Hermes State SQLite · config.yaml · .env Deploy Pipeline Standalone Repo deploy.sh + post-merge hook v2.0.4 Changes SSE streaming chat DnaLoader · diagram Legend Frontend (React SPA) Backend (FastAPI/Services) Database (SQLite/Config) Cloud / Deploy Security (Auth) SSE Stream (v2.0.4) Auth / Deploy Flow Secondary (Agents page only)

v2.0.4 — SSE Streaming Chat

  • • Direct Gateway API streaming via /v1/chat/completions
  • • api.streamChat() async generator with SSE parsing
  • • True abort via AbortController (no tmux polling)
  • • Session continuity via X-Hermes-Session-Id
  • • DnaLoader helix animation during wait

Authentication

  • • Dual Ed25519 (primary) + HMAC-SHA256 (fallback)
  • • Bearer session tokens via /api/auth/session-token
  • • CORS restricted to known origins
  • • Per-IP rate limiting (10 fails/60s → 15min lockout)
  • • CSP headers, XSS sanitization, SRI

Deploy Pipeline

  • • Standalone repo → deploy.sh → hermes-agent
  • • Post-merge git hook auto-redeploys after update
  • • Builds from source, syncs 25+ web/src/ files
  • • Pre-flight check: verifies TG initData in built JS
  • • tmux agents still on Agents page for power users