# qlong-polax/legal_chatbot_using_graphrag_architecture architecture

> Architecture diagram of the GitHub repository qlong-polax/legal_chatbot_using_graphrag_architecture, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/qlong-polax/legal_chatbot_using_graphrag_architecture
- Repository: https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture

## Overview

This is a Vietnamese legal-assistance GraphRAG product. The user signs in through the React client, submits a question, and receives a sourced answer after retrieval, graph expansion, and Gemini synthesis; chat state and retrieval traces are persisted. A separate Databricks ETL path prepares legal documents for vector and graph search. The graph follows documented architecture plus sampled calls; several internal stages are represented from README capabilities because their implementation was not excerpted.

Main entry points: [`orchestrator/app.py`](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/orchestrator/app.py) (HTTP API), [`databricks_platform/src/lakehouse_pipeline.py`](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/databricks_platform/src/lakehouse_pipeline.py) (Medallion pipeline), [`orchestrator/graph.py`](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/orchestrator/graph.py) (LangGraph workflow), [`frontend/src/services/api.js`](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/frontend/src/services/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User Interface"]
  node_appui["App routes<br/>[App.jsx]"]
  node_authpages["Login and register<br/>[Login.jsx]"]
  node_chatui["Chat interface<br/>[Chat.jsx]"]
  node_api["API client<br/>[api.js]"]
end

subgraph group_backend["Answer Orchestration"]
  node_server["HTTP API<br/>[app.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_workflow["LangGraph workflow<br/>[graph.py]"]
  node_intent["Intent routing<br/>[intent.py]"]
  node_retrieval["Hybrid retrieval<br/>[retrievers.py]"]
  node_gemini["Gemini synthesis"]
end

subgraph group_data["Legal Data Platform"]
  node_qdrant[("Vector index")]
  node_neo4j[("Legal graph")]
  node_etl["Medallion pipeline"]
  node_clean["Text extraction<br/>[html_to_text.py]"]
  node_chunking["Legal chunking<br/>[chunking.py]"]
  node_embedding["Gemini embeddings"]
  node_sinks["Index writers<br/>[sinks.py]"]
  node_etlentry["ETL entry point<br/>[run_pipeline.py]"]
end

subgraph group_state["Session and State"]
  node_session["Session storage<br/>[session.js]"]
  node_postgres[("Conversation database")]
  node_redis[("Cache and queue")]
end

node_user(("Legal user"))

node_user -->|"uses"| node_appui
node_appui -->|"routes to"| node_authpages
node_appui -->|"routes to"| node_chatui
node_authpages -->|"calls auth"| node_api
node_chatui -->|"sends questions"| node_api
node_chatui -->|"reads session"| node_session
node_api -->|"reads token"| node_session
node_api -->|"HTTP requests"| node_server
node_server -->|"validates identity"| node_auth
node_server -->|"runs workflow"| node_workflow
node_workflow -->|"routes intent"| node_intent
node_workflow -->|"retrieves context"| node_retrieval
node_retrieval -->|"vector search"| node_qdrant
node_retrieval -->|"keyword and graph search"| node_neo4j
node_workflow -->|"synthesizes answer"| node_gemini
node_server -->|"persists chat"| node_postgres
node_server -->|"checks cache"| node_redis
node_etlentry -->|"starts stages"| node_etl
node_etl -->|"extracts text"| node_clean
node_etl -->|"builds chunks"| node_chunking
node_etl -->|"embeds chunks"| node_embedding
node_etl -->|"writes indexes"| node_sinks
node_sinks -->|"writes vectors"| node_qdrant
node_sinks -->|"writes graph"| node_neo4j

click node_appui "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/frontend/src/App.jsx"
click node_authpages "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/frontend/src/pages/Login.jsx"
click node_chatui "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/frontend/src/pages/Chat.jsx"
click node_api "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/frontend/src/services/api.js"
click node_session "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/frontend/src/services/session.js"
click node_server "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/orchestrator/app.py"
click node_auth "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/orchestrator/auth.py"
click node_workflow "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/orchestrator/graph.py"
click node_intent "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/orchestrator/intent.py"
click node_retrieval "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/orchestrator/retrievers.py"
click node_etl "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/databricks_platform/src/lakehouse_pipeline.py"
click node_clean "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/databricks_platform/src/html_to_text.py"
click node_chunking "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/databricks_platform/src/chunking.py"
click node_embedding "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/databricks_platform/src/gemini_embedding.py"
click node_sinks "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/databricks_platform/src/sinks.py"
click node_etlentry "https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/databricks_platform/jobs/run_pipeline.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_appui,node_authpages,node_chatui,node_api,node_user toneBlue
class node_server,node_auth,node_workflow,node_intent,node_retrieval,node_gemini toneAmber
class node_qdrant,node_neo4j,node_etl,node_clean,node_chunking,node_embedding,node_sinks,node_etlentry toneMint
class node_session,node_postgres,node_redis toneRose
```

## Components

### User Interface

- [App routes](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login and register](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Chat interface](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/frontend/src/pages/Chat.jsx): `frontend/src/pages/Chat.jsx`
- [API client](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### Answer Orchestration

- [HTTP API](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/orchestrator/app.py): `orchestrator/app.py`
- [Authentication](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/orchestrator/auth.py): `orchestrator/auth.py`
- [LangGraph workflow](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/orchestrator/graph.py): `orchestrator/graph.py`
- [Intent routing](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/orchestrator/intent.py): `orchestrator/intent.py`
- [Hybrid retrieval](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/orchestrator/retrievers.py): `orchestrator/retrievers.py`
- **Gemini synthesis**

### Legal Data Platform

- **Vector index**
- **Legal graph**
- [Medallion pipeline](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/databricks_platform/src/lakehouse_pipeline.py): `databricks_platform/src/lakehouse_pipeline.py`
- [Text extraction](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/databricks_platform/src/html_to_text.py): `databricks_platform/src/html_to_text.py`
- [Legal chunking](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/databricks_platform/src/chunking.py): `databricks_platform/src/chunking.py`
- [Gemini embeddings](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/databricks_platform/src/gemini_embedding.py): `databricks_platform/src/gemini_embedding.py`
- [Index writers](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/databricks_platform/src/sinks.py): `databricks_platform/src/sinks.py`
- [ETL entry point](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/databricks_platform/jobs/run_pipeline.py): `databricks_platform/jobs/run_pipeline.py`

### Session and State

- [Session storage](https://github.com/qlong-polax/legal_chatbot_using_graphrag_architecture/blob/main/frontend/src/services/session.js): `frontend/src/services/session.js`
- **Conversation database**
- **Cache and queue**

### Other components

- **Legal user**

## Connections

- Legal user → App routes: uses (evidence: `README.md`)
- App routes → Login and register: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Chat interface: routes to (evidence: `frontend/src/App.jsx`)
- Login and register → API client: calls auth (evidence: `frontend/src/pages/Login.jsx`)
- Chat interface → API client: sends questions (evidence: `frontend/src/pages/Chat.jsx`)
- Chat interface → Session storage: reads session (evidence: `frontend/src/pages/Chat.jsx`)
- API client → Session storage: reads token (evidence: `frontend/src/services/api.js`)
- API client → HTTP API: HTTP requests (evidence: `frontend/src/services/api.js`)
- HTTP API → Authentication: validates identity (evidence: `orchestrator/app.py`)
- HTTP API → LangGraph workflow: runs workflow (evidence: `orchestrator/app.py`)
- LangGraph workflow → Intent routing: routes intent (evidence: `orchestrator/graph.py`)
- LangGraph workflow → Hybrid retrieval: retrieves context (evidence: `orchestrator/graph.py`)
- Hybrid retrieval → Vector index: vector search (evidence: `README.md`)
- Hybrid retrieval → Legal graph: keyword and graph search (evidence: `README.md`)
- LangGraph workflow → Gemini synthesis: synthesizes answer (evidence: `README.md`)
- HTTP API → Conversation database: persists chat (evidence: `orchestrator/app.py`)
- HTTP API → Cache and queue: checks cache (evidence: `orchestrator/app.py`)
- ETL entry point → Medallion pipeline: starts stages (evidence: `databricks_platform/jobs/run_pipeline.py`)
- Medallion pipeline → Text extraction: extracts text (evidence: `databricks_platform/src/lakehouse_pipeline.py`)
- Medallion pipeline → Legal chunking: builds chunks (evidence: `databricks_platform/src/lakehouse_pipeline.py`)
- Medallion pipeline → Gemini embeddings: embeds chunks (evidence: `databricks_platform/src/lakehouse_pipeline.py`)
- Medallion pipeline → Index writers: writes indexes (evidence: `databricks_platform/src/lakehouse_pipeline.py`)
- Index writers → Vector index: writes vectors (evidence: `README.md`)
- Index writers → Legal graph: writes graph (evidence: `README.md`)
