# praveenms02/juris-ai architecture

> Architecture diagram of the GitHub repository praveenms02/juris-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/praveenms02/juris-ai
- Repository: https://github.com/praveenms02/juris-ai

## Overview

JurisAI turns uploaded legal documents into searchable, analyzed records, then supports document Q&A, risk review, and study workflows. The main path runs from authenticated upload through backend persistence and AI extraction/indexing; later requests analyze or query the stored document, with results saved and presented in the frontend. Separate learning and collaborative-room capabilities extend the product. The README documents the cross-service phases; sampled source and the SOURCE INDEX support several implementation links, while unsampled feature internals are represented at their known paths.

Main entry points: [`backend/server.js`](https://github.com/praveenms02/juris-ai/blob/main/backend/server.js) (Express API), [`frontend/src/App.jsx`](https://github.com/praveenms02/juris-ai/blob/main/frontend/src/App.jsx) (React application), [`ai-service/app.py`](https://github.com/praveenms02/juris-ai/blob/main/ai-service/app.py) (FastAPI endpoints), [`backend/models/Document.js`](https://github.com/praveenms02/juris-ai/blob/main/backend/models/Document.js) (MongoDB records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_web["React application<br/>[App.jsx]"]
  node_document_ui["Document workflows"]
  node_chat_ui["Chat interface<br/>[ChatPage.jsx]"]
  node_risk_ui["Risk dashboard"]
end

subgraph group_api["Backend API"]
  node_api_server["Express API<br/>[server.js]"]
  node_document_controller["Document handling"]
  node_chat_controller["Chat handling<br/>[chatController.js]"]
  node_risk_service["Risk persistence<br/>[riskService.js]"]
  node_ai_client["AI service client<br/>[aiService.js]"]
end

subgraph group_intelligence["AI service"]
  node_ai_app["FastAPI endpoints<br/>[app.py]"]
  node_ingestion["Text ingestion<br/>[extraction.py]"]
  node_analysis["Document analysis<br/>[analyzer.py]"]
  node_rag["RAG pipeline<br/>[rag_pipeline.py]"]
  node_risk_engine["Risk engine<br/>[risk_engine.py]"]
end

subgraph group_persistence["Persistence"]
  node_mongo[("MongoDB records<br/>[Document.js]")]
  node_chroma[("Vector index<br/>[vector_store.py]")]
end

subgraph group_collaboration["Learning and collaboration"]
  node_mode_engine["Learning modes<br/>[mode_engine.py]"]
  node_quiz_engine["Quiz generation<br/>[quiz_engine.py]"]
  node_learning_ui["Learning pages<br/>[LearningHub.jsx]"]
  node_room_ui["Discussion rooms<br/>[DiscussionRoom.jsx]"]
  node_room_controller["Room workflows<br/>[roomController.js]"]
  node_room_service["Room management<br/>[roomService.js]"]
  node_room_socket["Realtime messaging<br/>[roomSocket.js]"]
end

node_user(("User"))

node_user -->|"uses"| node_web
node_web -->|"routes to"| node_document_ui
node_web -->|"routes to"| node_chat_ui
node_web -->|"routes to"| node_risk_ui
node_web -->|"routes to"| node_learning_ui
node_web -->|"routes to"| node_room_ui
node_document_ui -->|"requests"| node_api_server
node_chat_ui -->|"requests"| node_api_server
node_risk_ui -->|"requests"| node_api_server
node_api_server -->|"routes"| node_document_controller
node_api_server -->|"routes"| node_chat_controller
node_api_server -->|"routes"| node_risk_service
node_api_server -->|"routes"| node_room_controller
node_document_controller -->|"reads and writes"| node_mongo
node_document_controller -->|"calls"| node_ai_client
node_ai_client -->|"calls endpoints"| node_ai_app
node_ai_app -->|"extracts and chunks"| node_ingestion
node_ingestion -->|"indexes chunks"| node_chroma
node_ai_app -->|"analyzes text"| node_analysis
node_document_controller -->|"persists analysis"| node_mongo
node_chat_controller -->|"loads history"| node_mongo
node_chat_controller -->|"calls"| node_ai_client
node_ai_app -->|"runs chat"| node_rag
node_rag -->|"retrieves chunks"| node_chroma
node_risk_service -->|"stores results"| node_mongo
node_risk_service -.->|"requests analysis"| node_ai_client
node_ai_app -->|"scores risks"| node_risk_engine
node_learning_ui -.->|"requests learning"| node_api_server
node_ai_app -->|"runs modes"| node_mode_engine
node_mode_engine -->|"generates quizzes"| node_quiz_engine
node_room_ui -.->|"requests rooms"| node_api_server
node_room_controller -->|"delegates room work"| node_room_service
node_room_controller -->|"emits updates"| node_room_socket
node_room_service -->|"reads documents"| node_mongo
node_room_ui -.->|"exchanges messages"| node_room_socket

click node_web "https://github.com/praveenms02/juris-ai/blob/main/frontend/src/App.jsx"
click node_document_ui "https://github.com/praveenms02/juris-ai/blob/main/frontend/src/pages/DocumentDetailPage.jsx"
click node_chat_ui "https://github.com/praveenms02/juris-ai/blob/main/frontend/src/pages/ChatPage.jsx"
click node_risk_ui "https://github.com/praveenms02/juris-ai/blob/main/frontend/src/pages/RiskAnalysisPage.jsx"
click node_api_server "https://github.com/praveenms02/juris-ai/blob/main/backend/server.js"
click node_document_controller "https://github.com/praveenms02/juris-ai/blob/main/backend/controllers/documentController.js"
click node_chat_controller "https://github.com/praveenms02/juris-ai/blob/main/backend/controllers/chatController.js"
click node_risk_service "https://github.com/praveenms02/juris-ai/blob/main/backend/services/riskService.js"
click node_ai_client "https://github.com/praveenms02/juris-ai/blob/main/backend/services/aiService.js"
click node_mongo "https://github.com/praveenms02/juris-ai/blob/main/backend/models/Document.js"
click node_chroma "https://github.com/praveenms02/juris-ai/blob/main/ai-service/services/vector_store.py"
click node_ai_app "https://github.com/praveenms02/juris-ai/blob/main/ai-service/app.py"
click node_ingestion "https://github.com/praveenms02/juris-ai/blob/main/ai-service/services/extraction.py"
click node_analysis "https://github.com/praveenms02/juris-ai/blob/main/ai-service/services/analyzer.py"
click node_rag "https://github.com/praveenms02/juris-ai/blob/main/ai-service/services/rag_pipeline.py"
click node_risk_engine "https://github.com/praveenms02/juris-ai/blob/main/ai-service/services/risk_engine.py"
click node_mode_engine "https://github.com/praveenms02/juris-ai/blob/main/ai-service/services/mode_engine.py"
click node_quiz_engine "https://github.com/praveenms02/juris-ai/blob/main/ai-service/services/quiz_engine.py"
click node_learning_ui "https://github.com/praveenms02/juris-ai/blob/main/frontend/src/pages/LearningHub.jsx"
click node_room_ui "https://github.com/praveenms02/juris-ai/blob/main/frontend/src/pages/DiscussionRoom.jsx"
click node_room_controller "https://github.com/praveenms02/juris-ai/blob/main/backend/controllers/roomController.js"
click node_room_service "https://github.com/praveenms02/juris-ai/blob/main/backend/services/roomService.js"
click node_room_socket "https://github.com/praveenms02/juris-ai/blob/main/backend/sockets/roomSocket.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web,node_document_ui,node_chat_ui,node_risk_ui,node_user toneBlue
class node_api_server,node_document_controller,node_chat_controller,node_risk_service,node_ai_client toneAmber
class node_ai_app,node_ingestion,node_analysis,node_rag,node_risk_engine toneMint
class node_mongo,node_chroma toneRose
class node_mode_engine,node_quiz_engine,node_learning_ui,node_room_ui,node_room_controller,node_room_service,node_room_socket toneIndigo
```

## Components

### Web application

- [React application](https://github.com/praveenms02/juris-ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Document workflows](https://github.com/praveenms02/juris-ai/blob/main/frontend/src/pages/DocumentDetailPage.jsx): `frontend/src/pages/DocumentDetailPage.jsx`
- [Chat interface](https://github.com/praveenms02/juris-ai/blob/main/frontend/src/pages/ChatPage.jsx): `frontend/src/pages/ChatPage.jsx`
- [Risk dashboard](https://github.com/praveenms02/juris-ai/blob/main/frontend/src/pages/RiskAnalysisPage.jsx): `frontend/src/pages/RiskAnalysisPage.jsx`

### Backend API

- [Express API](https://github.com/praveenms02/juris-ai/blob/main/backend/server.js): `backend/server.js`
- [Document handling](https://github.com/praveenms02/juris-ai/blob/main/backend/controllers/documentController.js): `backend/controllers/documentController.js`
- [Chat handling](https://github.com/praveenms02/juris-ai/blob/main/backend/controllers/chatController.js): `backend/controllers/chatController.js`
- [Risk persistence](https://github.com/praveenms02/juris-ai/blob/main/backend/services/riskService.js): `backend/services/riskService.js`
- [AI service client](https://github.com/praveenms02/juris-ai/blob/main/backend/services/aiService.js): `backend/services/aiService.js`

### AI service

- [FastAPI endpoints](https://github.com/praveenms02/juris-ai/blob/main/ai-service/app.py): `ai-service/app.py`
- [Text ingestion](https://github.com/praveenms02/juris-ai/blob/main/ai-service/services/extraction.py): `ai-service/services/extraction.py`
- [Document analysis](https://github.com/praveenms02/juris-ai/blob/main/ai-service/services/analyzer.py): `ai-service/services/analyzer.py`
- [RAG pipeline](https://github.com/praveenms02/juris-ai/blob/main/ai-service/services/rag_pipeline.py): `ai-service/services/rag_pipeline.py`
- [Risk engine](https://github.com/praveenms02/juris-ai/blob/main/ai-service/services/risk_engine.py): `ai-service/services/risk_engine.py`

### Persistence

- [MongoDB records](https://github.com/praveenms02/juris-ai/blob/main/backend/models/Document.js): `backend/models/Document.js`
- [Vector index](https://github.com/praveenms02/juris-ai/blob/main/ai-service/services/vector_store.py): `ai-service/services/vector_store.py`

### Learning and collaboration

- [Learning modes](https://github.com/praveenms02/juris-ai/blob/main/ai-service/services/mode_engine.py): `ai-service/services/mode_engine.py`
- [Quiz generation](https://github.com/praveenms02/juris-ai/blob/main/ai-service/services/quiz_engine.py): `ai-service/services/quiz_engine.py`
- [Learning pages](https://github.com/praveenms02/juris-ai/blob/main/frontend/src/pages/LearningHub.jsx): `frontend/src/pages/LearningHub.jsx`
- [Discussion rooms](https://github.com/praveenms02/juris-ai/blob/main/frontend/src/pages/DiscussionRoom.jsx): `frontend/src/pages/DiscussionRoom.jsx`
- [Room workflows](https://github.com/praveenms02/juris-ai/blob/main/backend/controllers/roomController.js): `backend/controllers/roomController.js`
- [Room management](https://github.com/praveenms02/juris-ai/blob/main/backend/services/roomService.js): `backend/services/roomService.js`
- [Realtime messaging](https://github.com/praveenms02/juris-ai/blob/main/backend/sockets/roomSocket.js): `backend/sockets/roomSocket.js`

### Other components

- **User**

## Connections

- User → React application: uses (evidence: `README.md`)
- React application → Document workflows: routes to (evidence: `frontend/src/App.jsx`)
- React application → Chat interface: routes to (evidence: `frontend/src/App.jsx`)
- React application → Risk dashboard: routes to (evidence: `frontend/src/App.jsx`)
- React application → Learning pages: routes to (evidence: `frontend/src/App.jsx`)
- React application → Discussion rooms: routes to (evidence: `frontend/src/App.jsx`)
- Document workflows → Express API: requests (evidence: `README.md`)
- Chat interface → Express API: requests (evidence: `README.md`)
- Risk dashboard → Express API: requests (evidence: `README.md`)
- Express API → Document handling: routes (evidence: `backend/server.js`)
- Express API → Chat handling: routes (evidence: `backend/server.js`)
- Express API → Risk persistence: routes (evidence: `backend/server.js`)
- Express API → Room workflows: routes (evidence: `backend/server.js`)
- Document handling → MongoDB records: reads and writes (evidence: `backend/controllers/documentController.js`)
- Document handling → AI service client: calls (evidence: `backend/controllers/documentController.js`)
- AI service client → FastAPI endpoints: calls endpoints (evidence: `backend/services/aiService.js`)
- FastAPI endpoints → Text ingestion: extracts and chunks (evidence: `README.md`)
- Text ingestion → Vector index: indexes chunks (evidence: `README.md`)
- FastAPI endpoints → Document analysis: analyzes text (evidence: `ai-service/app.py`)
- Document handling → MongoDB records: persists analysis (evidence: `README.md`)
- Chat handling → MongoDB records: loads history (evidence: `backend/controllers/chatController.js`)
- Chat handling → AI service client: calls (evidence: `backend/controllers/chatController.js`)
- FastAPI endpoints → RAG pipeline: runs chat (evidence: `ai-service/app.py`)
- RAG pipeline → Vector index: retrieves chunks (evidence: `README.md`)
- Risk persistence → MongoDB records: stores results (evidence: `backend/services/riskService.js`)
- Risk persistence → AI service client: requests analysis
- FastAPI endpoints → Risk engine: scores risks (evidence: `README.md`)
- Learning pages → Express API: requests learning
- FastAPI endpoints → Learning modes: runs modes (evidence: `ai-service/app.py`)
- Learning modes → Quiz generation: generates quizzes (evidence: `ai-service/services/mode_engine.py`)
- Discussion rooms → Express API: requests rooms
- Room workflows → Room management: delegates room work (evidence: `backend/controllers/roomController.js`)
- Room workflows → Realtime messaging: emits updates (evidence: `backend/controllers/roomController.js`)
- Room management → MongoDB records: reads documents (evidence: `backend/services/roomService.js`)
- Discussion rooms → Realtime messaging: exchanges messages
