How raiyashu2004/juris works
1. System shape
JurisAI is a two-tier application: a React/Vite single-page frontend and a FastAPI backend. The frontend owns the user experience and lightweight client state; the backend owns legal AI orchestration, retrieval, and security-sensitive API calls.
2. Frontend boundary
The frontend lives under frontend/src and is organized by screens such as Chat, Legal Research, Case Finder, Document Analyzer, Draft Generator, My Documents, Saved Research, and Settings. This suggests a single SPA that routes between legal workflows rather than multiple separate apps.
3. Client state and persistence
The README indicates chat history is kept in browser storage for persistent conversational sessions. That means the frontend is not just rendering results; it also preserves user interaction state locally to avoid server-side session dependency.
4. Backend API surface
backend/main.py is the FastAPI entrypoint, with route modules split by domain: auth, chat, documents, and cases. This is a clean API boundary where each legal workflow is exposed through its own router instead of a single monolithic endpoint set.
5. AI orchestration layer
The core AI work is isolated in backend/services/: llm.py for model access, embeddings.py for vectorization, rag.py for retrieval-augmented generation, and langchain_chat.py for conversational memory/chain behavior. This indicates the backend acts as an LLM orchestration proxy rather than embedding AI logic in route handlers.
6. Legal document pipeline
document_analyser.py is the dedicated service for uploaded document review, summarization, and risk flagging. The document flow likely enters through the documents router, is processed in this service layer, and returns structured AI feedback to the frontend.
7. Legal knowledge retrieval
The data/ scripts (ingest_constitution.py, ingest_judgments.py) show an offline ingestion pipeline for Indian legal sources. These scripts appear to prepare the corpus that feeds embeddings and RAG, so the app’s answers are grounded in constitutional text and case law rather than general-purpose chat.
8. Auth and security boundary
Authentication is separated into backend/routers/auth.py and backend/utils/auth.py, with a mirrored frontend auth context in frontend/src/context/AuthContext.jsx. This suggests a dedicated identity boundary around login/session handling, distinct from the AI and document features.
9. Persistence and shared utilities
backend/models/db_models.py, backend/utils/database.py, and backend/utils/config.py indicate shared backend infrastructure for config and any persisted records. The README notes the deployment is designed to work without requiring a provisioned PostgreSQL database, so persistence is intentionally lightweight and deployment-friendly.
10. External services and runtime
The key external dependency is Google Gemini, accessed from the backend using an API key. The frontend points to the backend via VITE_BACKEND_URL, and the repo is set up for Vercel-hosted frontend plus Render-hosted backend, with docker-compose.yml and render.yaml capturing deployment wiring.
11. Build and delivery
The frontend is built with Vite into frontend/dist, which is what gets served in production. The backend runs as a Python ASGI service under Uvicorn/FastAPI. This separation makes the UI deployable as static assets while keeping AI and retrieval logic server-side.
12. Useful diagram takeaway
A good architecture diagram should show: user → React SPA → FastAPI routers → AI/services layer → Gemini + legal corpus. Separately, show offline ingestion feeding the corpus, and local browser storage supporting persistent chat history on the client.
Main entry points: main.py FastAPI app · App.jsx React SPA · rag.py RAG engine · auth.py Auth API
Components 23
Frontend
React/Vite single-page app and local UI state
- React SPA · Single-page frontend that routes between legal workflows
frontend/src/App.jsx - Legal pages · Chat, research, case finder, analyzer, draft, documents, saved research, settings
frontend/src/pages - Auth state · Frontend authentication context and session handling
frontend/src/context/AuthContext.jsx - Browser storage · Client-side storage for chat history and lightweight session state
Backend
FastAPI API, orchestration, and persistence boundary
- FastAPI app · Backend entrypoint mounting the domain routers
backend/main.py - Auth API · Login, registration, and session-related endpoints
backend/routers/auth.py - Chat API · Conversational legal assistant endpoints
backend/routers/chat.py - Documents API · Upload and document workflow endpoints
backend/routers/documents.py - Cases API · Case search and finder endpoints
backend/routers/cases.py - LLM access · Direct access to Gemini or other hosted model APIs
backend/services/llm.py - RAG engine · Retrieval-augmented generation over legal sources
backend/services/rag.py - Embeddings · Text embedding generation for search and retrieval
backend/services/embeddings.py - Chat chains · Conversational memory and chain behavior
backend/services/langchain_chat.py - Doc analyzer · Document review, summarization, and risk flagging
backend/services/document_analyser.py - Auth utils · Backend authentication helpers and token/session logic
backend/utils/auth.py - Config · Shared backend configuration and environment access
backend/utils/config.py - Database · Backend database utilities and shared persistence layer
backend/utils/database.py - DB models · Data models for persisted records
backend/models/db_models.py
Data
Offline legal corpus ingestion scripts
- Legal corpus · Ingested constitutional text and judgments used for retrieval
- Ingestion scripts · Scripts that prepare constitutional and judgment sources
data
Delivery
Build and deployment wiring
- Frontend build · Vite production output served as static assets
frontend/dist - Deploy config · Docker and Render wiring for frontend/backend delivery
docker-compose.yml
Other components
- User · Lawyer or end user interacting with the app
Connections 25
- User → React SPA: uses · User interacts with the web app
- React SPA → Legal pages: navigates · SPA switches between legal workflows
- React SPA → Auth state: auth state · Frontend keeps login state in context
- React SPA → Browser storage: persists chat · Chat history is kept locally in the browser
- Legal pages → FastAPI app: calls · Screens invoke backend APIs
- FastAPI app → Auth API: mounts · Main app exposes auth routes
- FastAPI app → Chat API: mounts · Main app exposes chat routes
- FastAPI app → Documents API: mounts · Main app exposes document routes
- FastAPI app → Cases API: mounts · Main app exposes case routes
- Auth API → Auth utils: uses · Authentication helpers protect the API
- Auth API → Database: reads/writes · Auth state may be persisted
- Chat API → Chat chains: delegates · Chat endpoints use conversation services
- Chat API → RAG engine: retrieves · Chat answers are grounded with RAG when needed
- Documents API → Doc analyzer: delegates · Document upload flow is analyzed by service layer
- Cases API → RAG engine: searches · Case workflows rely on retrieval
- RAG engine → Embeddings: vectorizes · Retrieval depends on embedding generation
- RAG engine → LLM access: generates · Retrieved context is turned into answers by the model client
- Chat chains → LLM access: chains · Conversation logic calls the model client
- Doc analyzer → LLM access: analyzes · Document analysis uses hosted LLMs
- RAG engine → Legal corpus: queries · Retrieval searches the ingested legal corpus
- Ingestion scripts → Legal corpus: builds · Offline scripts prepare the corpus used at runtime
- FastAPI app → Config: configures · Runtime settings and API keys come from shared config
- FastAPI app → DB models: uses · API and services share persistence models
- Deploy config → FastAPI app: runs · Deployment launches the ASGI backend
- Frontend build → React SPA: serves · Production frontend is the built static bundle