How adhiraj808/lexdraft-ai works
LegalDraftAI takes a lawyer’s case facts through a React dashboard into authenticated case APIs, stores case records, then preprocesses and extracts entities, classifies the case, retrieves precedents, and generates a draft. Users can review drafts, regenerate sections, and export PDF. The graph includes the documented chat/RAG and Google sign-in capabilities; some route and UI wiring is represented at subsystem level because those files were not excerpted. NLP stage calls and persistence are supported by the pipeline and service excerpts.
Main entry points: pipeline.py NLP orchestrator · case_service.py Case processing service · App.jsx React app and pages · main.py FastAPI application
Components 26
Web application
- React app and pages
frontend/src/App.jsx - Case entry and review
frontend/src/pages/NewCasePage.jsx - Legal chat workspace
frontend/src/pages/NewChatPage.jsx - Authentication state
frontend/src/hooks/useAuth.jsx - HTTP API client
frontend/src/services/api.js
API and services
- FastAPI application
backend/main.py - Auth endpoints
backend/app/api/routes/auth.py - Case endpoints
backend/app/api/routes/cases.py - RAG endpoints
backend/app/api/routes/rag.py - Authentication logic
backend/app/services/auth_service.py - Case processing service
backend/app/services/case_service.py - PDF export
backend/app/utils/pdf_generator.py
Legal intelligence
- NLP orchestrator
backend/app/nlp/pipeline.py - Legal text preprocessing
backend/app/nlp/preprocessor.py - Entity extraction
backend/app/nlp/ner.py - Case classification
backend/app/nlp/classifier.py - Precedent retrieval
backend/app/nlp/retriever.py - Draft generation
backend/app/nlp/generator.py
Persistence and identity
- PostgreSQL records
backend/app/db/postgres.py - Redis cache and progress
backend/app/db/redis_client.py - User records
backend/app/models/user.py - Case and draft records
backend/app/models/case.py
Other components
- Lawyer
- Google identity
- Legal knowledge store
- Groq service
Connections 29
- Lawyer → React app and pages: uses
frontend/src/App.jsx - React app and pages → Case entry and review: routes to
frontend/src/App.jsx - React app and pages → Legal chat workspace: routes to
frontend/src/App.jsx - React app and pages → Authentication state: provides auth
frontend/src/App.jsx - Case entry and review → HTTP API client: submits cases
frontend/src/pages/NewCasePage.jsx - Legal chat workspace → HTTP API client: sends requests
frontend/src/pages/NewChatPage.jsx - Authentication state → HTTP API client: calls auth
frontend/src/hooks/useAuth.jsx - HTTP API client → FastAPI application: HTTP requests
- FastAPI application → Auth endpoints: registers routes
backend/main.py - FastAPI application → Case endpoints: registers routes
backend/main.py - FastAPI application → RAG endpoints: registers routes
backend/main.py - Auth endpoints → Authentication logic: delegates auth
backend/app/api/routes/auth.py - Authentication logic → PostgreSQL records: queries and commits
- Authentication logic → User records: creates users
backend/app/services/auth_service.py - Authentication logic → Google identity: verifies credentials
backend/app/services/auth_service.py - Case endpoints → Case processing service: delegates cases
backend/app/api/routes/cases.py - Case processing service → NLP orchestrator: processes case
backend/app/services/case_service.py - Case processing service → PostgreSQL records: persists results
- Case processing service → Case and draft records: stores case and draft
backend/app/services/case_service.py - Case processing service → Redis cache and progress: caches and publishes
backend/app/services/case_service.py - NLP orchestrator → Legal text preprocessing: cleans text
backend/app/nlp/pipeline.py - NLP orchestrator → Entity extraction: extracts entities
backend/app/nlp/pipeline.py - NLP orchestrator → Case classification: classifies facts
backend/app/nlp/pipeline.py - NLP orchestrator → Precedent retrieval: retrieves precedents
backend/app/nlp/pipeline.py - NLP orchestrator → Draft generation: generates sections
backend/app/nlp/pipeline.py - Precedent retrieval → Legal knowledge store: queries knowledge
- Draft generation → Groq service: may use
- Case endpoints → PDF export: exports PDF
backend/app/api/routes/cases.py - Case entry and review → Lawyer: presents drafts