Skip to content

zettelkasten.dashboard.backend.main

zettelkasten.dashboard.backend.main

FastAPI backend for the Zettelkasten Dashboard.

Serves the REST API and proxies agent chat requests. Run with: uvicorn zettelkasten.dashboard.backend.main:app --reload --port 8742

health async

health() -> dict

Liveness + identity + build probe the launcher uses to manage this backend.

The service is workspace-scoped (zettelkasten-dashboard@<instance>) so a health-confirmed port skip distinguishes this workspace's backend not just from unrelated processes but also from a sibling angelo checkout's dashboard holding the same port. build (and version) let a launcher detect a backend running stale code (old build after an upgrade or source edit) and recycle it instead of skipping it.

Declared async so it runs on the event loop and needs no worker-thread token: it answers instantly even while the single-token warm-up holds the pool. warming (and the fuller warmup object) report that background progress — the backend is live and serving, embeddings are still loading.

Source code in zettelkasten/dashboard/backend/main.py
@app.get("/api/health")
async def health() -> dict:
    """Liveness + identity + build probe the launcher uses to manage this backend.

    The ``service`` is workspace-scoped (``zettelkasten-dashboard@<instance>``)
    so a health-confirmed port skip distinguishes *this* workspace's backend not
    just from unrelated processes but also from a sibling angelo checkout's
    dashboard holding the same port. ``build`` (and ``version``) let a launcher
    detect a backend running *stale* code (old build after an upgrade or source
    edit) and recycle it instead of skipping it.

    Declared ``async`` so it runs on the event loop and needs no worker-thread
    token: it answers instantly even while the single-token warm-up holds the
    pool. ``warming`` (and the fuller ``warmup`` object) report that background
    progress — the backend is live and serving, embeddings are still loading.
    """
    from memory.dashboard.launcher_core import (
        build_id,
        current_instance_id,
        package_version,
    )

    instance = current_instance_id()
    warmup = warmup_state()
    return {
        "status": "ok",
        "service": f"zettelkasten-dashboard@{instance}",
        "instance": instance,
        "version": package_version(),
        "build": build_id(),
        "pid": os.getpid(),
        "started_at": _STARTED_AT,
        "warming": not warmup["ready"],
        "warmup": warmup,
    }