How ashba2801/chatlaw works
ChatLaw is a multilingual legal-information and workflow platform. A browser user asks a grounded legal question, optionally using voice or case context; the web application proxies requests to the FastAPI RAG engine, which retrieves legal material and generates cited answers. Separate workflows support guided document drafting and private case workspaces, while deterministic case intelligence helps users identify forums and nearby advocates. The repository also includes a PDF-to-legal-corpus ingestion path. The README documents the cross-service architecture; source excerpts establish selected route, persistence, retrieval, and ingestion links, but not every runtime connection.
Main entry points: layout.tsx Web application · chat.py Chat endpoint · route.ts RAG proxy · CaseDetail.tsx Case workspace
Components 26
Web experience
- Web application
web/app/(product)/layout.tsx - Legal chat
web/components/chat/ChatInterface.tsx - Voice chat
web/lib/speech/useVoiceChat.ts - Research workspace
web/components/research/ResearchWorkspace.tsx - Case workspace
web/components/cases/CaseDetail.tsx - Document editor
web/components/documents/DocumentEditor.tsx
API and workflows
- RAG proxy
web/app/api/rag/[...path]/route.ts - Case API
web/app/api/cases/[id]/route.ts - Case intelligence
web/app/api/case-intelligence/route.ts - Document API
web/app/api/documents/route.ts - FastAPI routes
rag-engine/api/main.py - Chat endpoint
rag-engine/api/routes/chat.py - Search endpoint
rag-engine/api/routes/search.py - Conversation service
rag-engine/api/conversation_service.py - Court and advocate directory
web/lib/case-intelligence/providers.ts
Legal RAG
- Case query analysis
rag-engine/cases/query_understanding.py - Vector retrieval
rag-engine/retrieval/vector_search.py - Answer generation
rag-engine/generation/answer.py - Document drafting
rag-engine/conversation/document_drafting.py - Legal templates
rag-engine/documents/templates.py - Case-law retrieval
rag-engine/cases/retrieval.py
Legal corpus
- PDF legal parser
rag-engine/ingestion/parsers/pdf_parser.py - Ingestion models
rag-engine/ingestion/models.py - Embedding ingestion
rag-engine/embeddings/ingestion.py - Postgres and pgvector
database/lib/vector-search.ts
Other components
- Browser user
Connections 26
- Browser user → Web application: uses
- Web application → Legal chat: presents
- Web application → Research workspace: presents
- Web application → Case workspace: presents
- Web application → Document editor: presents
- Legal chat → RAG proxy: requests answers
- Voice chat → RAG proxy: sends chat
- Research workspace → RAG proxy: requests research
- RAG proxy → FastAPI routes: proxies requests
- Case workspace → Case API: manages cases
- Case workspace → Case intelligence: requests classification
- Document editor → Document API: manages drafts
- Case intelligence → Court and advocate directory: uses providers
- FastAPI routes → Chat endpoint: registers
rag-engine/api/main.py - FastAPI routes → Search endpoint: registers
rag-engine/api/main.py - Chat endpoint → Vector retrieval: retrieves context
- Chat endpoint → Answer generation: generates answer
- Chat endpoint → Document drafting: handles draft turns
rag-engine/api/routes/chat.py - Chat endpoint → Conversation service: reads history
rag-engine/api/routes/chat.py - Search endpoint → Vector retrieval: searches
- Vector retrieval → Postgres and pgvector: queries vectors
- Document drafting → Legal templates: uses templates
- Case query analysis → Case-law retrieval: informs retrieval
rag-engine/cases/retrieval.py - PDF legal parser → Ingestion models: builds structured data
rag-engine/ingestion/parsers/pdf_parser.py - PDF legal parser → Embedding ingestion: supplies corpus chunks
- Embedding ingestion → Postgres and pgvector: stores embeddings