# jashankish/local-legal-ai architecture

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

- Interactive diagram: https://gitdiagram.com/jashankish/local-legal-ai
- Repository: https://github.com/jashankish/local-legal-ai

## Overview

Local Legal AI is a self-hosted legal-document assistant. Lawyers and staff use the Streamlit UI to authenticate, upload legal files, and ask questions; the FastAPI service processes uploads for indexing and handles queries that retrieve document context for an answer. The README also describes document management, analytics, audit/access controls, and n8n automation. The query pipeline and vector-store interactions are shown where documented or sampled; exact wiring between some backend modules and automation flows is not established by the excerpts.

Main entry points: [`backend/app.py`](https://github.com/jashankish/local-legal-ai/blob/main/backend/app.py) (FastAPI service), [`rag/rag_pipeline.py`](https://github.com/jashankish/local-legal-ai/blob/main/rag/rag_pipeline.py) (RAG pipeline), [`rag/simple_embedder.py`](https://github.com/jashankish/local-legal-ai/blob/main/rag/simple_embedder.py) (Document embedder), [`vector_store/chromadb_setup.py`](https://github.com/jashankish/local-legal-ai/blob/main/vector_store/chromadb_setup.py) (Vector store manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_streamlit["Streamlit UI<br/>[streamlit_app.py]"]
end

subgraph group_api_security["API and access"]
  node_api["FastAPI service<br/>[app.py]"]
  node_auth["JWT access control<br/>[auth.py]"]
  node_users[("User records<br/>[users.json]")]
  node_analytics["Usage analytics<br/>[analytics.py]"]
end

subgraph group_documents_search["Document and search"]
  node_processor["Legal file processor"]
  node_embedder["Document embedder<br/>[simple_embedder.py]"]
  node_query_embedder["Query embedder<br/>[embedder.py]"]
  node_rag["RAG pipeline<br/>[rag_pipeline.py]"]
  node_vectors["Vector store manager<br/>[chromadb_setup.py]"]
  node_chroma[("ChromaDB collection")]
end

subgraph group_inference["Inference"]
  node_model["vLLM inference<br/>[vllm_launcher.sh]"]
  node_gpu["Private GPU host"]
end

subgraph group_operations["Audit and automation"]
  node_audit["Audit logging<br/>[audit_log.py]"]
  node_n8n["Workflow automation<br/>[workflows.json]"]
end

node_user(("Lawyer or staff"))
node_file_drop(("File drop"))
node_slack["Slack alerts"]

node_user -->|"asks or uploads"| node_streamlit
node_streamlit -->|"sends requests"| node_api
node_api -->|"checks identity"| node_auth
node_auth -->|"reads and writes"| node_users
node_api -->|"processes uploads"| node_processor
node_processor -->|"provides text"| node_embedder
node_api -->|"requests chunks"| node_embedder
node_embedder -->|"stores chunks"| node_vectors
node_api -->|"handles questions"| node_rag
node_rag -->|"searches documents"| node_vectors
node_vectors -->|"reads and writes"| node_chroma
node_rag -->|"requests completion"| node_model
node_model -->|"runs inference"| node_gpu
node_api -->|"serves reports"| node_analytics
node_api -.->|"records activity"| node_audit
node_file_drop -.->|"triggers flow"| node_n8n
node_n8n -.->|"sends alerts"| node_slack

click node_streamlit "https://github.com/jashankish/local-legal-ai/blob/main/frontend/streamlit_app.py"
click node_api "https://github.com/jashankish/local-legal-ai/blob/main/backend/app.py"
click node_auth "https://github.com/jashankish/local-legal-ai/blob/main/backend/auth.py"
click node_users "https://github.com/jashankish/local-legal-ai/blob/main/data/users.json"
click node_analytics "https://github.com/jashankish/local-legal-ai/blob/main/backend/analytics.py"
click node_processor "https://github.com/jashankish/local-legal-ai/blob/main/rag/enhanced_document_processor.py"
click node_embedder "https://github.com/jashankish/local-legal-ai/blob/main/rag/simple_embedder.py"
click node_query_embedder "https://github.com/jashankish/local-legal-ai/blob/main/backend/embedder.py"
click node_rag "https://github.com/jashankish/local-legal-ai/blob/main/rag/rag_pipeline.py"
click node_vectors "https://github.com/jashankish/local-legal-ai/blob/main/vector_store/chromadb_setup.py"
click node_chroma "https://github.com/jashankish/local-legal-ai/tree/main/data/chroma_db"
click node_model "https://github.com/jashankish/local-legal-ai/blob/main/model/vllm_launcher.sh"
click node_audit "https://github.com/jashankish/local-legal-ai/blob/main/security/audit_log.py"
click node_n8n "https://github.com/jashankish/local-legal-ai/blob/main/workflows/n8n/workflows.json"

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_streamlit toneBlue
class node_api,node_auth,node_users,node_analytics toneAmber
class node_processor,node_embedder,node_query_embedder,node_rag,node_vectors,node_chroma toneMint
class node_model,node_gpu toneRose
class node_audit,node_n8n,node_user,node_file_drop,node_slack toneIndigo
```

## Components

### User experience

- [Streamlit UI](https://github.com/jashankish/local-legal-ai/blob/main/frontend/streamlit_app.py): `frontend/streamlit_app.py`

### API and access

- [FastAPI service](https://github.com/jashankish/local-legal-ai/blob/main/backend/app.py): `backend/app.py`
- [JWT access control](https://github.com/jashankish/local-legal-ai/blob/main/backend/auth.py): `backend/auth.py`
- [User records](https://github.com/jashankish/local-legal-ai/blob/main/data/users.json): `data/users.json`
- [Usage analytics](https://github.com/jashankish/local-legal-ai/blob/main/backend/analytics.py): `backend/analytics.py`

### Document and search

- [Legal file processor](https://github.com/jashankish/local-legal-ai/blob/main/rag/enhanced_document_processor.py): `rag/enhanced_document_processor.py`
- [Document embedder](https://github.com/jashankish/local-legal-ai/blob/main/rag/simple_embedder.py): `rag/simple_embedder.py`
- [Query embedder](https://github.com/jashankish/local-legal-ai/blob/main/backend/embedder.py): `backend/embedder.py`
- [RAG pipeline](https://github.com/jashankish/local-legal-ai/blob/main/rag/rag_pipeline.py): `rag/rag_pipeline.py`
- [Vector store manager](https://github.com/jashankish/local-legal-ai/blob/main/vector_store/chromadb_setup.py): `vector_store/chromadb_setup.py`
- [ChromaDB collection](https://github.com/jashankish/local-legal-ai/tree/main/data/chroma_db): `data/chroma_db`

### Inference

- [vLLM inference](https://github.com/jashankish/local-legal-ai/blob/main/model/vllm_launcher.sh): `model/vllm_launcher.sh`
- **Private GPU host**

### Audit and automation

- [Audit logging](https://github.com/jashankish/local-legal-ai/blob/main/security/audit_log.py): `security/audit_log.py`
- [Workflow automation](https://github.com/jashankish/local-legal-ai/blob/main/workflows/n8n/workflows.json): `workflows/n8n/workflows.json`

### Other components

- **Lawyer or staff**
- **File drop**
- **Slack alerts**

## Connections

- Lawyer or staff → Streamlit UI: asks or uploads
- Streamlit UI → FastAPI service: sends requests
- FastAPI service → JWT access control: checks identity
- JWT access control → User records: reads and writes
- FastAPI service → Legal file processor: processes uploads
- Legal file processor → Document embedder: provides text
- FastAPI service → Document embedder: requests chunks
- Document embedder → Vector store manager: stores chunks
- FastAPI service → RAG pipeline: handles questions
- RAG pipeline → Vector store manager: searches documents
- Vector store manager → ChromaDB collection: reads and writes
- RAG pipeline → vLLM inference: requests completion
- vLLM inference → Private GPU host: runs inference
- FastAPI service → Usage analytics: serves reports
- FastAPI service → Audit logging: records activity
- File drop → Workflow automation: triggers flow
- Workflow automation → Slack alerts: sends alerts
