Minimal desktop demo: Electron wraps a Vite dev server UI and spawns a local FastAPI (uvicorn) process. The React UI talks to the backend over HTTP.
| Piece | Role |
|---|---|
| Electron (main process) | Desktop shell; starts uvicorn from backend/; waits for GET /health; opens a window loading the React dev URL; stops uvicorn on quit. |
| React (renderer) | UI in the Electron window; fetch to http://127.0.0.1:8000 (health + echo). |
| FastAPI | Local HTTP API on 127.0.0.1:8000; mock JSON only. CORS allows all origins for local dev. |
The backend now includes a deterministic RAG data layer with endpoints:
POST /store: body is Document withoutdoc_id(case_id,raw_text,source, optionaltimestamp); generatesdoc_id, parses, ingests.POST /parse: body is full Document (includesdoc_id, ISOtimestamp); returns StructuredDocument (nestedsummary,jurisdiction,source_spanon facts).POST /ingest: body is{ "document": Document, "structured": StructuredDocument }; returns{ "num_chunks", "doc_id" }.POST /query: body is QueryInput (case_id,query,top_k, optionalfilters.type); returns QueryResult (query,chunkswithchunk_id+metadata,structured_hitswithdoc_id,sources).
Run Ollama and pull a chat model used for extraction, for example:
ollama pull llama3.1:8bSentence-transformers embeddings are loaded automatically by Python from Hugging Face.
- Node.js and npm
- Python 3 with
pip
-
Python dependencies (virtualenv recommended):
cd backend python -m venv .venvActivate the environment, then install:
-
macOS / Linux (folder name can be
.venvorvenv):source .venv/bin/activate pip install -r requirements.txt -
Windows (cmd):
.venv\Scripts\activate pip install -r requirements.txt
On Windows, if
pythonis not on PATH, usepy -3instead, or setPYTHONwhen running Electron (see below). -
-
Node dependencies:
npm install npm install --prefix frontend
From the repo root:
npm run devThis runs:
- Vite dev server for the React app (
http://127.0.0.1:5173). - Electron after the dev server is reachable; Electron spawns uvicorn and polls
http://127.0.0.1:8000/healthbefore opening the window.
Use Ping Backend and Echo in the UI to hit the API.
PYTHON: Optional. Path or command for the Python executable used to run uvicorn (overridespy -3on Windows andpythonelsewhere).CASES_ROOT: Optional base directory for case files (default:backend/cases).GROQ_API_KEY: Required for legal-structure parsing on RAG ingest. Without it, Discovery uploads still save to the context library, butcases/{case_id}/structured/{doc_id}.jsonis not written and the UI may show an indexing error on the card.CHROMA_PERSIST_DIR: Optional Chroma persistence directory (default:backend/chroma).OLLAMA_MODEL: Ollama extraction model (default:llama3.1:8b).EMBED_MODEL: sentence-transformers embedding model (default:all-MiniLM-L6-v2).
With the venv activated (see Setup):
cd backend
source .venv/bin/activate # macOS/Linux — Windows: .venv\Scripts\activate
uvicorn main:app --host 127.0.0.1 --port 8000curl -X POST http://127.0.0.1:8000/store \
-H "Content-Type: application/json" \
-d '{
"case_id":"case-123",
"raw_text":"John Doe sued Acme Corp after a collision on Jan 2, 2024.",
"source":"upload"
}'curl -X POST http://127.0.0.1:8000/query \
-H "Content-Type: application/json" \
-d '{"case_id":"case-123","query":"What happened and who are the parties?","top_k":5,"filters":{"type":null}}'filters.type can be null, or "raw", "summary", "event", or "claim" to restrict vector hits.
With the venv activated (see Setup):
cd backend
source .venv/bin/activate # macOS/Linux — or: source venv/bin/activate
pip install -r requirements.txt # once, if not already installed
python -m pytest tests/ -vTests use a temporary Chroma directory and cases root (CHROMA_PERSIST_DIR, CASES_ROOT) and mock embed_texts so they run without downloading embedding models. /store is tested with parse_legal_structure mocked so Ollama is not required.
- Integration (RAG path, no Ollama):
python -m pytest tests/ -m integration -q - Live Ollama (optional, needs Ollama on
127.0.0.1:11434):python -m pytest tests/ -m ollama -q
Coverage (app modules under backend/, excludes tests/; config in backend/pyproject.toml):
cd backend
source .venv/bin/activate
python -m pytest tests/ -q --cov=. --cov-report=term-missingLocal coverage data files (backend/.coverage, etc.) are gitignored.
electron/main.js # Electron entry
frontend/ # Vite + React
backend/main.py # FastAPI app
backend/tests/ # pytest — conftest.py + rag/, upload/, parser/, …