Frontend (/viz)¶
/viz is AutoRAG’s only browser surface. It’s a Vite + React 18 +
TypeScript + @react-three/fiber app, served as a built static
bundle by FastAPI.
Layout¶
Path |
What |
|---|---|
|
Source — TypeScript, not shipped to PyPI. |
|
Vite entry. |
|
|
|
|
|
Root component. |
|
Hand-typed mirror of |
|
Zustand store for cross-component scene state. |
|
|
|
r3f components — |
|
DOM components — |
|
Committed build output. |
The TypeScript source lives outside src/autorag/ so uv /
ruff / mypy don’t scan it. The build output lives inside
the Python package so wheel packaging picks it up via the existing
static/ glob — no MANIFEST.in changes needed.
App.tsx wraps <Scene> in ui/SceneBoundary — an error
boundary. r3f’s <Canvas> throws synchronously when a WebGL context
can’t be created (software/headless GL, blocklisted GPU); the boundary
keeps the rail and overlays alive and shows a “3D view unavailable”
notice instead of unmounting the whole app to a blank page.
Build flow¶
cd frontend && npm install && npm run build
tsc -b && vite build runs the TypeScript project-references build
for typecheck, then emits index.html + hashed
assets/index-<hash>.{js,css} into src/autorag/static/viz/
(Vite’s emptyOutDir: true clears stale hashes). Commit the rebuilt
bundle alongside any frontend/src/ changes in the same commit so
HTML, source, and assets never drift.
For interactive iteration:
cd frontend && npm run dev # Vite on http://localhost:5173
The dev server proxies /viz/data and /viz/search to a
separately running autorag serve on port 8000 (see server.proxy
in vite.config.ts).
FastAPI wiring¶
autorag.vizresolves_VIZ_DIR = static/viz/, serves_VIZ_DIR / "index.html"atGET /viz, and exportsviz_assets_dirfor the static mount.autorag.apimounts the assets dir at/viz-assetsinside the existing[rag]try/else, so[server]-only installs (without[rag]) silently skip both the viz endpoints and the assets mount.base: '/viz-assets/'invite.config.tsis load-bearing — it makes built asset URLs (<script src="/viz-assets/assets/index-<hash>.js">) match the mount.
Built bundle is committed¶
CI does not run a node build. Rationale:
Python-only CI keeps passing with zero new infra.
PyPI / git-installed wheels need the built assets anyway — they ship via the existing
static/glob.The viz changes infrequently relative to the Python backend.
If a CI build is wanted later: add one GitHub Actions job with
setup-node@v4 running npm ci && npm run build in
frontend/. Additive.
Three.js and @types/three are pinned exactly (no ^) —
drei 9.x must move in lockstep with any Three bump. Current:
three@0.165.0.