How soma39/legal-ai-lexa works
LegalAI is a full-stack Indian legal assistance platform. Users authenticate, ask legal questions, and receive answers grounded in indexed statutory material; the product also supports document drafting and export, statutory graph exploration, privacy controls, and administration of the corpus and feedback. The graph follows documented frontend routing and backend module references. Some subsystem behavior is described only in the README, so those relationships are cited there rather than inferred from unsampled source.
Main entry points: main.py FastAPI application · App.tsx Web application · database.py Application database · api.ts REST client
Components 27
Client experience
- Web application
frontend/src/App.tsx - Authentication state
frontend/src/context/AuthContext.tsx - Legal consultation UI
frontend/src/pages/ChatPage.tsx - Drafting wizard
frontend/src/pages/DocumentDraftingPage.tsx - Knowledge graph UI
frontend/src/pages/KnowledgeGraphPage.tsx - Admin console
frontend/src/pages/AdminPage.tsx - Privacy controls
frontend/src/pages/PrivacyPage.tsx - REST client
frontend/src/services/api.ts
API and governance
- FastAPI application
backend/app/main.py - Auth and safeguards
backend/app/api/deps.py - Authentication API
backend/app/api/v1/auth.py - Conversation API
backend/app/api/v1/chat.py - Document API
backend/app/api/v1/documents.py - Knowledge graph API
backend/app/api/v1/knowledge_graph.py - Privacy API
backend/app/api/v1/privacy.py - Administration API
backend/app/api/v1/admin.py - Feedback API
backend/app/api/v1/feedback.py
Legal assistance
- Direct legal search
backend/app/api/v1/rag.py - RAG orchestration
backend/app/services/rag/rag_service.py - Legal vector index
backend/app/services/rag/vector_store.py - Answer generation
backend/app/services/rag/llm_provider.py
Drafting and graph
- Draft templates
backend/app/services/document_generation/templates.py - Word generation
backend/app/services/document_generation/docx_generator.py - PDF generation
backend/app/services/document_generation/pdf_generator.py
Persistence
- Application database
backend/app/core/database.py - Domain records
backend/app/models/__init__.py
Other components
- Citizen or researcher
Connections 43
- Citizen or researcher → Web application: uses
- Web application → Legal consultation UI: routes to
frontend/src/App.tsx - Web application → Drafting wizard: routes to
frontend/src/App.tsx - Web application → Knowledge graph UI: routes to
frontend/src/App.tsx - Web application → Admin console: routes to
frontend/src/App.tsx - Web application → Privacy controls: routes to
frontend/src/App.tsx - Web application → Authentication state: provides state
frontend/src/App.tsx - Authentication state → REST client: calls
frontend/src/context/AuthContext.tsx - Legal consultation UI → REST client: calls
frontend/src/pages/ChatPage.tsx - Drafting wizard → REST client: calls
frontend/src/pages/DocumentDraftingPage.tsx - Knowledge graph UI → REST client: calls
- Admin console → REST client: calls
frontend/src/pages/AdminPage.tsx - Privacy controls → REST client: calls
- REST client → FastAPI application: REST requests
- FastAPI application → Authentication API: registers
backend/app/main.py - FastAPI application → Conversation API: registers
backend/app/main.py - FastAPI application → Document API: registers
backend/app/main.py - FastAPI application → Knowledge graph API: registers
backend/app/main.py - FastAPI application → Privacy API: registers
backend/app/main.py - FastAPI application → Administration API: registers
backend/app/main.py - FastAPI application → Feedback API: registers
backend/app/main.py - FastAPI application → Direct legal search: registers
backend/app/main.py - Conversation API → RAG orchestration: invokes
backend/app/api/v1/chat.py - Direct legal search → RAG orchestration: invokes
backend/app/api/v1/rag.py - Direct legal search → Legal vector index: searches
backend/app/api/v1/rag.py - RAG orchestration → Legal vector index: retrieves
backend/app/services/rag/rag_service.py - RAG orchestration → Answer generation: generates answer
backend/app/services/rag/rag_service.py - Document API → Draft templates: uses
backend/app/api/v1/documents.py - Document API → Word generation: generates
backend/app/api/v1/documents.py - Document API → PDF generation: generates
backend/app/api/v1/documents.py - Administration API → Legal vector index: manages index
backend/app/api/v1/admin.py - Authentication API → Application database: accesses
backend/app/api/v1/auth.py - Conversation API → Application database: accesses
backend/app/api/v1/chat.py - Document API → Application database: accesses
backend/app/api/v1/documents.py - Knowledge graph API → Application database: accesses
backend/app/api/v1/knowledge_graph.py - Privacy API → Application database: accesses
backend/app/api/v1/privacy.py - Administration API → Application database: accesses
backend/app/api/v1/admin.py - Feedback API → Application database: accesses
backend/app/api/v1/feedback.py - Application database → Domain records: maps records
backend/app/models/__init__.py - Citizen or researcher → Knowledge graph UI: explores statutes
- Citizen or researcher → Privacy controls: manages privacy
- Admin console → Administration API: manages corpus
- Citizen or researcher → Drafting wizard: creates drafts