Just-in-Time, Verifiable Policy Guidance for High-Stakes Case Management
This project demonstrates a compliance-safe, proactive intelligence layer that delivers exact policy clauses with real page citations based on structured case context — no chat, no search bar, no hallucinations.
Built for seamless integration with Appian (or any case management system).
Agents handling insurance claims, regulatory compliance, or government benefits must consult fragmented, frequently updated policy documents. Current process:
- Alt-Tab to multiple systems
- Manual keyword search
- Risk of missing updates or wrong clauses
- High average handling time (AHT) + compliance errors
Our system eliminates this by automatically providing the exact relevant clause with page citation when a case is opened.
- Proactive Guidance: Receives structured case context (claim_type, jurisdiction, etc.) via POST request
- Exact Retrieval: Uses hierarchical PageIndex reasoning on pre-loaded policies
- Real PDF Page Citations: Shows actual page numbers from the original document
- Compliance-Safe: LLM only summarizes retrieved text — no external knowledge
- Versioning & Updates: Hash-based change detection; new versions created only when content changes
- Manual + Auto Ingestion:
- Local trusted PDFs (
sample_pdfs/) - Optional auto-fetch from authorized sources (
config/sources.json)
- Local trusted PDFs (
- Audit-Ready: Full provenance (policy name, version, section, page)
Appian / Frontend
↓ (POST /retrieve)
FastAPI Backend
↓
In-Memory + Supabase Storage
↓
PageIndex Tree Traversal → Relevant Clauses → Gemini Summary → Citations -
On Startup:
- Loads PDFs from
sample_pdfs/ - Optionally fetches latest versions from
sources.json - Parses with Docling → builds tree with real page numbers
- Stores versioned trees in Supabase (persists across restarts)
- Loads PDFs from
-
On Case Open:
- Appian sends structured context:
{ "claim_type": "flood damage", "jurisdiction": "Florida" } - Backend filters latest policy versions
- Traverses PageIndex tree to find matching sections
- Summarizes clauses (Gemini 2.5 Flash, restricted prompt)
- Returns guidance with real PDF page citations
- Appian sends structured context:
-
On Case Open:
- Admin clicks Settings → /admin
- Uploads new/internal PDFs
- Indexed immediately and available for retrieval
Tech Stack
- Backend: FastAPI (Python)
- PDF Parsing: Docling (real page numbers + structure)
- Storage: Supabase (PostgreSQL + JSONB for trees)
- Summarization: Gemini 2.5 Flash (restricted prompt)
- Frontend: React + TypeScript + ShadCN UI
- Routing: React Router
- Backend
cd backend
pip install -r requirements.txt
# Create .env
cp .env.example .env
# Add your SUPABASE_URL, SUPABASE_KEY, GEMINI_API_KEY
uvicorn main:app --reload- Frontend
cd frontend
npm install
npm start- Supabase Setup
- Create free project at
https://supabase.com - Run this SQL in SQL Editor:
CREATE TABLE policy_versions ( id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, policy_id TEXT NOT NULL, policy_name TEXT, jurisdiction TEXT, policy_type TEXT, version_num INTEGER NOT NULL, hash TEXT NOT NULL, effective_date DATE, index_tree JSONB NOT NULL, created_at TIMESTAMP DEFAULT NOW(), UNIQUE(policy_id, version_num) ); CREATE INDEX idx_latest_version ON policy_versions (policy_id, version_num DESC);
- Create free project at
- Start backend → watches PDFs load
- Open frontend → dashboard
- Edit case context (e.g., "flood damage", "India")
- Click "Analyze Case" → guidance appears with real page citations
- Click Settings icon → /admin → upload new policy PDF
- Query again → new policy available
- No hallucinations (LLM only sees retrieved text)
- Verifiable citations (real PDF pages)
- Full audit trail (versioning + hashes)
- No data stored beyond policy documents
- Canva PPT: Click here to view
No Alt-Tab. No Search. Just the Right Clause - Instantly.