How tnau94/traffic-law-graphrag works
Traffic Law GraphRAG is a Vietnamese traffic-law assistant with two main workflows: ingest legal documents into a Neo4j knowledge graph and hybrid search index, then answer user queries through direct legal lookup or grounded GraphRAG retrieval. The graph also preserves documented amendment/versioning and graph-browsing capabilities. Some subsystem links rely on README descriptions or SOURCE INDEX references; unsampled details are not assumed.
Main entry points: pipeline.py GraphRAG pipeline · indexer.py Search indexer · connection.py Neo4j client · sync.py Corpus sync
Components 25
API and experience
- FastAPI application
src/api/main.py - Query endpoint
src/api/routes/query.py - Query service
src/api/services/query_service.py - Graph browsing
src/api/services/graph_service.py - Ingest endpoint
src/api/routes/ingest.py - Ingest service
src/api/services/ingest_service.py
Legal data ingestion
- Corpus sync
src/sync.py - Legal parsing
src/parser - Amendment recording
src/parser/amendment_recorder.py - Graph importer
src/graph/neo4j/importer.py - Search indexer
src/rag/indexer.py
Query and grounding
- GraphRAG pipeline
src/pipeline/pipeline.py - Query router
src/pipeline/router.py - Query rewriter
src/pipeline/rewriter.py - Hybrid retriever
src/rag/retriever.py - Graph validation
src/pipeline/graph_validator.py - Evidence builder
src/pipeline/evidence_builder.py - Answer generator
src/pipeline/generator.py - Provider key manager
src/extraction/key_manager.py
Knowledge and retrieval
- Embedding manager
src/rag/embedding.py - Neo4j client
src/graph/neo4j/connection.py - Neo4j graph and indexes
- Legal versioning
src/versioning/version_builder.py
Other components
- User
- Grounded answer
Connections 30
- User → Query endpoint: asks
README.md - FastAPI application → Query endpoint: routes
src/api/main.py - Query endpoint → Query service: calls
src/api/routes/query.py - Query service → GraphRAG pipeline: runs
src/api/services/query_service.py - GraphRAG pipeline → Query router: routes query
src/pipeline/pipeline.py - GraphRAG pipeline → Query rewriter: rewrites query
src/pipeline/pipeline.py - GraphRAG pipeline → Hybrid retriever: retrieves candidates
src/pipeline/pipeline.py - GraphRAG pipeline → Graph validation: validates provisions
src/pipeline/pipeline.py - GraphRAG pipeline → Evidence builder: builds evidence
src/pipeline/pipeline.py - GraphRAG pipeline → Answer generator: generates answer
src/pipeline/pipeline.py - Query router → Provider key manager: gets provider keys
src/pipeline/router.py - Query rewriter → Provider key manager: uses provider keys
src/pipeline/rewriter.py - Query service → Grounded answer: returns result
src/api/services/query_service.py - User → Ingest endpoint: submits documents
README.md - Ingest endpoint → Ingest service: starts task
src/api/routes/ingest.py - Ingest service → Legal parsing: parses file
- Corpus sync → Legal parsing: parses corpus
README.md - Legal parsing → Amendment recording: records amendments
src/parser/amendment_recorder.py - Corpus sync → Graph importer: imports graph
README.md - Corpus sync → Search indexer: builds indexes
README.md - Ingest service → Search indexer: indexes units
src/api/services/ingest_service.py - Search indexer → Embedding manager: embeds text
src/rag/indexer.py - Search indexer → Neo4j client: writes through
src/rag/indexer.py - Graph importer → Neo4j client: imports through
src/graph/neo4j/importer.py - Hybrid retriever → Embedding manager: embeds query
src/rag/retriever.py - Hybrid retriever → Neo4j client: searches through
src/rag/retriever.py - Neo4j client → Neo4j graph and indexes: connects
src/graph/neo4j/connection.py - Graph browsing → Neo4j graph and indexes: browses graph
- Graph importer → Legal versioning: builds versions
src/graph/neo4j/importer.py - Legal versioning → Neo4j graph and indexes: stores legal history