# dhanushshetty18/legal-techai architecture

> Architecture diagram of the GitHub repository dhanushshetty18/legal-techai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dhanushshetty18/legal-techai
- Repository: https://github.com/dhanushshetty18/legal-techai

## Overview

Legal-TechAI combines an Android client, a Next.js web interface, a FastAPI legal-document engine, and a separate e-filing drafting app. Its main documented workflow captures or uploads documents, extracts and processes text, then supports inconsistency review and legal Q&A; case search and document drafting are additional user-facing branches. The README also describes OCR-driven form hydration and statutory checklists. Backend route registration and selected upload, RAG, and client API code were sampled; links to unsampled feature internals are omitted.

Main entry points: [`backend/main.py`](https://github.com/dhanushshetty18/legal-techai/blob/main/backend/main.py) (FastAPI Application), [`android/app/src/main/java/com/legaltechai/app/data/AppRepository.kt`](https://github.com/dhanushshetty18/legal-techai/blob/main/android/app/src/main/java/com/legaltechai/app/data/AppRepository.kt) (Android Repository), [`e-filing-updated/backend/routers/drafting.py`](https://github.com/dhanushshetty18/legal-techai/blob/main/e-filing-updated/backend/routers/drafting.py) (Drafting API), [`android/app/src/main/java/com/legaltechai/app/network/ApiService.kt`](https://github.com/dhanushshetty18/legal-techai/blob/main/android/app/src/main/java/com/legaltechai/app/network/ApiService.kt) (Android API Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Client Applications"]
  node_android_ui["Android Screens"]
  node_android_repo["Android Repository<br/>[AppRepository.kt]"]
  node_android_api["Android API Service<br/>[ApiService.kt]"]
  node_web_features["Web Workflows"]
end

subgraph group_api["API Routing"]
  node_api_app["FastAPI Application<br/>[main.py]"]
  node_ingest_route["Upload Route<br/>[ingest.py]"]
  node_rag_route["RAG Route<br/>[rag.py]"]
  node_inconsistency_route["Inconsistency Route<br/>[inconsistency.py]"]
  node_ocr_route["OCR Routes<br/>[ocr_extract.py]"]
  node_case_store[("Case Database<br/>[database.py]")]
end

subgraph group_processing["Document Processing"]
  node_chunking["Text Chunking<br/>[chunker.py]"]
  node_ocr_extract["OCR Extraction<br/>[ocr_extractor.py]"]
end

subgraph group_legal_ai["Legal Analysis"]
  node_inconsistency["Inconsistency Analysis<br/>[core.py]"]
  node_rag_service["Legal Q&amp;A Service<br/>[service.py]"]
end

subgraph group_filing["E-Filing Drafting"]
  node_filing_web["Filing Interface<br/>[page.tsx]"]
  node_drafting_api["Drafting API<br/>[drafting.py]"]
  node_draft_mode_a["Word Draft Generator<br/>[engine_mode_a.py]"]
  node_draft_mode_b["PDF Draft Generator<br/>[engine_mode_b.py]"]
end

node_user(("Legal User"))
node_court_services["Gemini AI Service"]

node_user -->|"uses"| node_android_ui
node_android_repo -->|"calls"| node_android_api
node_android_api -->|"HTTP requests"| node_api_app
node_android_repo -->|"caches cases"| node_case_store
node_user -->|"uses"| node_web_features
node_user -->|"uses"| node_filing_web
node_api_app -->|"registers"| node_ingest_route
node_api_app -->|"registers"| node_rag_route
node_api_app -->|"registers"| node_inconsistency_route
node_api_app -->|"registers"| node_ocr_route
node_ingest_route -->|"cleans and chunks"| node_chunking
node_rag_route -->|"invokes"| node_rag_service
node_rag_service -.->|"embeds and generates"| node_court_services
node_api_app -->|"initializes tables"| node_case_store
node_drafting_api -->|"generates Word"| node_draft_mode_a
node_drafting_api -->|"generates PDF"| node_draft_mode_b

click node_android_ui "https://github.com/dhanushshetty18/legal-techai/tree/main/android/app/src/main/java/com/legaltechai/app/ui/screens"
click node_android_repo "https://github.com/dhanushshetty18/legal-techai/blob/main/android/app/src/main/java/com/legaltechai/app/data/AppRepository.kt"
click node_android_api "https://github.com/dhanushshetty18/legal-techai/blob/main/android/app/src/main/java/com/legaltechai/app/network/ApiService.kt"
click node_web_features "https://github.com/dhanushshetty18/legal-techai/tree/main/frontend/src/app"
click node_filing_web "https://github.com/dhanushshetty18/legal-techai/blob/main/e-filing-updated/frontend/src/app/file-case/page.tsx"
click node_api_app "https://github.com/dhanushshetty18/legal-techai/blob/main/backend/main.py"
click node_ingest_route "https://github.com/dhanushshetty18/legal-techai/blob/main/backend/routers/ingest.py"
click node_rag_route "https://github.com/dhanushshetty18/legal-techai/blob/main/backend/routers/rag.py"
click node_inconsistency_route "https://github.com/dhanushshetty18/legal-techai/blob/main/backend/routers/inconsistency.py"
click node_ocr_route "https://github.com/dhanushshetty18/legal-techai/blob/main/backend/routers/ocr_extract.py"
click node_chunking "https://github.com/dhanushshetty18/legal-techai/blob/main/backend/modules/chunker.py"
click node_ocr_extract "https://github.com/dhanushshetty18/legal-techai/blob/main/backend/modules/ocr_extractor.py"
click node_inconsistency "https://github.com/dhanushshetty18/legal-techai/blob/main/backend/modules/inconsistency/core.py"
click node_rag_service "https://github.com/dhanushshetty18/legal-techai/blob/main/backend/modules/rag/service.py"
click node_case_store "https://github.com/dhanushshetty18/legal-techai/blob/main/backend/database.py"
click node_drafting_api "https://github.com/dhanushshetty18/legal-techai/blob/main/e-filing-updated/backend/routers/drafting.py"
click node_draft_mode_a "https://github.com/dhanushshetty18/legal-techai/blob/main/e-filing-updated/backend/modules/engine_mode_a.py"
click node_draft_mode_b "https://github.com/dhanushshetty18/legal-techai/blob/main/e-filing-updated/backend/modules/engine_mode_b.py"

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_android_ui,node_android_repo,node_android_api,node_web_features,node_user toneBlue
class node_api_app,node_ingest_route,node_rag_route,node_inconsistency_route,node_ocr_route,node_case_store toneAmber
class node_chunking,node_ocr_extract toneMint
class node_inconsistency,node_rag_service toneRose
class node_filing_web,node_drafting_api,node_draft_mode_a,node_draft_mode_b,node_court_services toneIndigo
```

## Components

### Client Applications

- [Android Screens](https://github.com/dhanushshetty18/legal-techai/tree/main/android/app/src/main/java/com/legaltechai/app/ui/screens): `android/app/src/main/java/com/legaltechai/app/ui/screens`
- [Android Repository](https://github.com/dhanushshetty18/legal-techai/blob/main/android/app/src/main/java/com/legaltechai/app/data/AppRepository.kt): `android/app/src/main/java/com/legaltechai/app/data/AppRepository.kt`
- [Android API Service](https://github.com/dhanushshetty18/legal-techai/blob/main/android/app/src/main/java/com/legaltechai/app/network/ApiService.kt): `android/app/src/main/java/com/legaltechai/app/network/ApiService.kt`
- [Web Workflows](https://github.com/dhanushshetty18/legal-techai/tree/main/frontend/src/app): `frontend/src/app`

### API Routing

- [FastAPI Application](https://github.com/dhanushshetty18/legal-techai/blob/main/backend/main.py): `backend/main.py`
- [Upload Route](https://github.com/dhanushshetty18/legal-techai/blob/main/backend/routers/ingest.py): `backend/routers/ingest.py`
- [RAG Route](https://github.com/dhanushshetty18/legal-techai/blob/main/backend/routers/rag.py): `backend/routers/rag.py`
- [Inconsistency Route](https://github.com/dhanushshetty18/legal-techai/blob/main/backend/routers/inconsistency.py): `backend/routers/inconsistency.py`
- [OCR Routes](https://github.com/dhanushshetty18/legal-techai/blob/main/backend/routers/ocr_extract.py): `backend/routers/ocr_extract.py`
- [Case Database](https://github.com/dhanushshetty18/legal-techai/blob/main/backend/database.py): `backend/database.py`

### Document Processing

- [Text Chunking](https://github.com/dhanushshetty18/legal-techai/blob/main/backend/modules/chunker.py): `backend/modules/chunker.py`
- [OCR Extraction](https://github.com/dhanushshetty18/legal-techai/blob/main/backend/modules/ocr_extractor.py): `backend/modules/ocr_extractor.py`

### Legal Analysis

- [Inconsistency Analysis](https://github.com/dhanushshetty18/legal-techai/blob/main/backend/modules/inconsistency/core.py): `backend/modules/inconsistency/core.py`
- [Legal Q&A Service](https://github.com/dhanushshetty18/legal-techai/blob/main/backend/modules/rag/service.py): `backend/modules/rag/service.py`

### E-Filing Drafting

- [Filing Interface](https://github.com/dhanushshetty18/legal-techai/blob/main/e-filing-updated/frontend/src/app/file-case/page.tsx): `e-filing-updated/frontend/src/app/file-case/page.tsx`
- [Drafting API](https://github.com/dhanushshetty18/legal-techai/blob/main/e-filing-updated/backend/routers/drafting.py): `e-filing-updated/backend/routers/drafting.py`
- [Word Draft Generator](https://github.com/dhanushshetty18/legal-techai/blob/main/e-filing-updated/backend/modules/engine_mode_a.py): `e-filing-updated/backend/modules/engine_mode_a.py`
- [PDF Draft Generator](https://github.com/dhanushshetty18/legal-techai/blob/main/e-filing-updated/backend/modules/engine_mode_b.py): `e-filing-updated/backend/modules/engine_mode_b.py`

### Other components

- **Legal User**
- **Gemini AI Service**

## Connections

- Legal User → Android Screens: uses
- Android Repository → Android API Service: calls
- Android API Service → FastAPI Application: HTTP requests
- Android Repository → Case Database: caches cases
- Legal User → Web Workflows: uses
- Legal User → Filing Interface: uses
- FastAPI Application → Upload Route: registers
- FastAPI Application → RAG Route: registers
- FastAPI Application → Inconsistency Route: registers
- FastAPI Application → OCR Routes: registers
- Upload Route → Text Chunking: cleans and chunks
- RAG Route → Legal Q&A Service: invokes
- Legal Q&A Service → Gemini AI Service: embeds and generates
- FastAPI Application → Case Database: initializes tables
- Drafting API → Word Draft Generator: generates Word
- Drafting API → PDF Draft Generator: generates PDF
