How furkan-sailpeak/jfk-files-rag works
JFK Files Research System is a web-based research assistant for grounded questions about declassified JFK records. The principal workflow routes a query, retrieves and reranks archive evidence, generates a streamed answer, then checks grounding and citations. Document-ID lookups and metadata, conversational, and out-of-scope queries have distinct branches; the UI also exposes text analysis and archive statistics. The repository includes a separate evaluation and prompt-optimization toolkit. Backend internals and some UI wiring were not excerpted, so those links rely on README documentation or are omitted where evidence is insufficient.
Main entry points: app.py Flask API · App.jsx Research UI · run.py Evaluation runner · score.py Evaluation scoring
Components 26
Research interface
- Research UI
rag/frontend/src/App.jsx - Sign-in
rag/frontend/src/Auth.jsx
Query pipeline
- Flask API
rag/app.py - ID shortcut
rag/app.py - Query router
rag/app.py - Chat and refusal
rag/app.py - Archive queries
rag/app.py - Hybrid retrieval
rag/app.py - Evidence reranker
rag/app.py - Answer generation
rag/app.py - Grounding check
rag/app.py - Citation verifier
rag/app.py - Archive statistics
rag/app.py - Text analysis
rag/app.py
Data and models
- PostgreSQL archive
- Groq LLM
- OpenAI embeddings
- Supabase auth
- National Archives PDFs
Evaluation toolkit
- Evaluation runner
eval/run.py - Evaluation scoring
eval/score.py - Prompt optimizer
eval/optimize.py - GEPA optimizer
eval/optimize_gepa.py - Blind A/B collection
eval/collect_ab.py
Other components
- Researcher
- Evaluator
Connections 35
- Researcher → Research UI: submits query
README.md - Research UI → Flask API: streams chat request
rag/frontend/src/App.jsx - Research UI → Sign-in: opens sign-in
rag/frontend/src/App.jsx - Sign-in → Supabase auth: requests sign-in link
rag/frontend/src/Auth.jsx - Flask API → ID shortcut: checks document ID
README.md - ID shortcut → PostgreSQL archive: fetches pages
README.md - Flask API → Query router: routes query
README.md - Query router → Chat and refusal: dispatches chat or refusal
README.md - Query router → Archive queries: dispatches metadata query
README.md - Query router → Hybrid retrieval: dispatches simple or research
README.md - Hybrid retrieval → PostgreSQL archive: searches archive
README.md - Hybrid retrieval → OpenAI embeddings: embeds query
README.md - Hybrid retrieval → Evidence reranker: provides candidates
README.md - Evidence reranker → Groq LLM: judges evidence
README.md - Evidence reranker → Answer generation: provides selected sources
README.md - Answer generation → Groq LLM: generates answer
README.md - Answer generation → Grounding check: checks answer
README.md - Grounding check → Answer generation: retries with expansion
README.md - Grounding check → Citation verifier: passes grounded answer
README.md - Citation verifier → Research UI: streams verified answer
README.md - Archive queries → PostgreSQL archive: counts and samples records
README.md - Flask API → Archive statistics: serves stats endpoint
README.md - Flask API → Text analysis: serves analyze endpoint
README.md - Research UI → Archive statistics: fetches archive stats
rag/frontend/src/App.jsx - Research UI → Text analysis: submits analysis
rag/frontend/src/App.jsx - Citation verifier → National Archives PDFs: links cited pages
README.md - Evaluator → Evaluation runner: runs questions
eval/run.py - Evaluation runner → Flask API: posts chat requests
eval/run.py - Evaluation runner → Evaluation scoring: scores captured results
eval/score.py - Prompt optimizer → Evaluation runner: evaluates prompts
eval/optimize.py - Prompt optimizer → Evaluation scoring: uses scoring
eval/optimize.py - GEPA optimizer → Evaluation scoring: scores candidates
eval/optimize_gepa.py - GEPA optimizer → Flask API: evaluates candidate prompts
eval/optimize_gepa.py - Blind A/B collection → Evaluation runner: collects paired answers
eval/collect_ab.py - Evaluator → Blind A/B collection: rates blinded pairs
README.md