How dhyani2206/sec-regulatory-rag works
SEC Regulatory RAG is an evidence-first research assistant: users select a filing scope, ask a regulatory question, and receive a structured, cited answer or a grounded refusal. The Streamlit app is a thin client; FastAPI delegates query work to the RAG engine, which routes questions, retrieves filing and CFR evidence, ranks it, and applies an evidence guard before answering. Separate ingestion and indexing modules prepare the two corpora. The README documents comparison and compliance-summary capabilities; their runtime wiring is not established by the sampled code, so those branches are shown without invented connections.
Main entry points: answer_engine.py Answer engine · api_client.py API client · query_service.py Query service · app.py Streamlit app
Components 25
User interface and API
- Streamlit app
frontend/app.py - API client
frontend/frontend/api_client.py - FastAPI app
app/main.py - Query endpoint
app/api/v1/endpoints/query.py - Scope options
app/api/v1/endpoints/options.py
Grounded query workflow
- Query service
app/services/query_service.py - Answer engine
src/rag/answer_engine.py - Filing query router
src/rag/query_router.py - Rules router
src/rag/rules_router.py - Filing retrieval
src/rag/retrieve_filings.py - Section retrieval
src/rag/retrieve_filing_sections.py - Rule retrieval
src/rag/retrieve_rules.py - Evidence ranking
src/rag/evidence_ranker.py - Evidence guard
src/rag/evidence_pack.py
Regulatory corpora
- Filing extraction
src/extraction/batch_extractor.py - Filing index builder
src/rag/embeddings.py - CFR ingestion
src/rules/ingest_ecfr_rules.py - Rules index builder
src/rules/build_rules_index.py - Filing vector index
- Rules vector index
Research extensions
- Filing comparison
src/rag/diff_engine.py - Compliance summary
src/rag/compliance_summary.py
Other components
- Researcher
- eCFR
- Language model
Connections 24
- Researcher → Streamlit app: asks question
- Streamlit app → API client: requests options and answers
- API client → Scope options: GET options
- API client → Query endpoint: POST query
- Query endpoint → Query service: calls
- Query service → Answer engine: processes query
- Answer engine → Filing query router: routes filing query
- Answer engine → Rules router: routes rule query
- Answer engine → Filing retrieval: retrieves filings
- Answer engine → Section retrieval: retrieves sections
- Answer engine → Rule retrieval: retrieves rules
- Answer engine → Evidence ranking: ranks evidence
- Answer engine → Evidence guard: checks evidence
- Query service → Streamlit app: returns structured response
- Scope options → Filing extraction: reads filing metadata
- Filing extraction → Filing index builder: provides extracted sections
- Filing index builder → Filing vector index: builds index
- CFR ingestion → eCFR: fetches regulations
- CFR ingestion → Rules index builder: provides rule text
- Rules index builder → Rules vector index: builds index
- Filing retrieval → Filing vector index: searches
- Section retrieval → Filing vector index: searches
- Rule retrieval → Rules vector index: searches
- Answer engine → Language model: generates grounded answer