How omar9965/legal-assistant works
This is a bilingual Egyptian Civil Code legal assistant: users submit questions through Streamlit, which invokes a LangGraph workflow for heuristic routing, confidence-gated caching, legal retrieval (including reformulation retries), and answer synthesis with conversation history. A separate ingestion path parses and chunks legal PDFs into the searchable collection and invalidates cached answers. The map preserves documented bilingual, caching, retrieval, and ingestion capabilities; unsampled implementation details and unverified connections are omitted.
Main entry points: graph_nodes.py Workflow Nodes · graph.py Workflow Graph · researcher.py Research Agent · vector_store.py Vector Store
Components 25
Agent Workflow
- Workflow Graph
controllers/graph.py - Workflow Nodes
controllers/graph_nodes.py - Workflow Routing
controllers/graph_edges.py - Workflow State
controllers/graph_state.py - Query Router
controllers/router.py - Cache Agent
controllers/graph_nodes.py - Answer Synthesis
controllers/scribe.py
Legal Retrieval
- Research Agent
controllers/researcher.py - Query Reformulation
controllers/graph_nodes.py - Query Expansion
models/query_expansion.py - Relevance Scoring
models/metadata_filtering.py - Article Extraction
models/document_processor.py
Models and Storage
- Model Resources
models/resources.py - Vector Store
models/vector_store.py - Legal Collection
- Response Cache
models/cache.py - Semantic Cache
- Runtime Config
utils/config.py
Document Ingestion
- Ingestion Pipeline
process.py - PDF Processing
models/document_processor.py
Other components
- Legal User
- Legal PDFs
- LLM Endpoint
Connections 28
- Legal User → Chat UI: submits query
README.md - App Entry → Chat UI: routes to
README.md - Chat UI → Workflow Graph: runs query
views/streamlit_app.py - Workflow Graph → Workflow Nodes: registers nodes
controllers/graph.py - Workflow Graph → Workflow Routing: uses routing
controllers/graph.py - Workflow Graph → Workflow State: uses state
controllers/graph.py - Workflow Graph → Response Cache: invalidates cache
controllers/graph.py - Workflow Nodes → Query Router: classifies query
controllers/graph_nodes.py - Workflow Nodes → Cache Agent: checks cache
controllers/graph_nodes.py - Workflow Nodes → Research Agent: retrieves documents
controllers/graph_nodes.py - Workflow Nodes → Query Reformulation: retries search
controllers/graph_nodes.py - Workflow Nodes → Answer Synthesis: synthesizes answer
controllers/graph_nodes.py - Research Agent → Vector Store: searches collection
controllers/researcher.py - Research Agent → Query Expansion: expands query
controllers/researcher.py - Research Agent → Relevance Scoring: scores results
controllers/researcher.py - Research Agent → Article Extraction: extracts article
controllers/researcher.py - Query Reformulation → Query Expansion: uses synonyms
controllers/graph_nodes.py - Vector Store → Legal Collection: reads and writes
models/vector_store.py - Response Cache → Semantic Cache: reads and writes
models/cache.py - Answer Synthesis → Model Resources: gets LLM
controllers/scribe.py - Model Resources → LLM Endpoint: configures client
models/resources.py - Vector Store → Model Resources: gets embeddings
models/vector_store.py - Ingestion Pipeline → PDF Processing: processes PDFs
process.py - Ingestion Pipeline → Vector Store: indexes chunks
process.py - Ingestion Pipeline → Response Cache: invalidates cache
process.py - Legal PDFs → Ingestion Pipeline: provides source files
README.md - Runtime Config → Vector Store: configures storage
models/vector_store.py - Runtime Config → Model Resources: configures models
models/resources.py