364939466f
Architektur auf Separation of Concerns umgestellt – ohne Build-Schritt,
ohne neues Framework, ohne DB (KISS bleibt). Endpoint-URLs unveraendert,
daher 1:1-kompatibel zum bisherigen Stand.
Backend (Top-Level-Helfer + ein Router je Bereich):
- app.py auf duennen Einstieg reduziert (FastAPI + include_router + static)
- config/auth/jobengine/llamaswap als getrennte Helfer-Module
- Endpoints in routers/{models,jobs,maintenance}.py
Frontend (native ES-Module statt Single-File):
- index.html = Huelle: Sidebar-Nav, Topbar, Alert-Banner, Hash-Routing
- css/{base,components}.css – Tokens + Komponenten
- js/core/{api,ui,nav}.js + js/panels/{overview,models,maintenance,jobs}.js + main.js
- Panel-Vertrag: { id, mount?(), onStatus?(s), onJobs?(jobs) }
- Optik an docs/mission-control-overview.png angelehnt (Hero, KPI-Kacheln,
Listen, Aktivitaets-Stream, getoente Karten)
Doku: CLAUDE.md + README auf die neue Struktur aktualisiert.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
"""
|
|
Mission Control - eine schlanke Steuerzentrale fuer einen lokalen llama-swap Stack.
|
|
|
|
Dieser Einstieg haelt nur noch das Geruest zusammen: er baut die FastAPI-App,
|
|
haengt die Router ein und liefert das statische UI aus. Die eigentliche Logik
|
|
liegt nach Concern getrennt in:
|
|
- config.py Env-Vars / Konstanten
|
|
- auth.py optionale Token-Auth
|
|
- jobengine.py Hintergrund-Jobs mit Live-Log
|
|
- llamaswap.py Reden mit llama-swap + config.yaml lesen/schreiben
|
|
- routers/* ein Router je Bereich (models, jobs, maintenance, ...)
|
|
|
|
Bewusst KISS: kein Build-Schritt, kein Framework ueber FastAPI hinaus, keine DB.
|
|
Neue Bereiche kommen als routers/<bereich>.py + static/js/panels/<bereich>.js dazu.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from fastapi import FastAPI, HTTPException
|
|
from fastapi.responses import FileResponse, JSONResponse
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from routers import jobs, maintenance, models
|
|
|
|
app = FastAPI(title="Mission Control")
|
|
|
|
app.include_router(models.router)
|
|
app.include_router(jobs.router)
|
|
app.include_router(maintenance.router)
|
|
|
|
_STATIC = Path(__file__).parent / "static"
|
|
|
|
|
|
@app.get("/")
|
|
def index():
|
|
return FileResponse(_STATIC / "index.html")
|
|
|
|
|
|
app.mount("/static", StaticFiles(directory=_STATIC), name="static")
|
|
|
|
|
|
@app.exception_handler(HTTPException)
|
|
def _http_exc(_req, exc: HTTPException):
|
|
return JSONResponse(status_code=exc.status_code, content={"error": exc.detail})
|