# viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit architecture

> Architecture diagram of the GitHub repository viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit, 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/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit
- Repository: https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit

## Overview

This is a single-file Streamlit legal-document assistant. Its runtime workflow accepts a court-order PDF, loads and splits it, indexes page content, then answers user questions through retrieval and a Gemini-backed document chain; answers and chat history appear in the UI. The README also advertises summary, petitioner, liquidator-observation, and deadline actions, but those actions are not present in the sampled source, so they are shown as documented capabilities rather than verified runtime stages.

Main entry points: [`Legal_Assistant_Chatbot_Streamlit.py`](https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py) (Streamlit chat UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_ui["Streamlit chat UI"]
  node_history[("Chat history")]
end

subgraph group_documents["Document retrieval"]
  node_pdf["PDF page loader"]
  node_embeddings["Sentence embeddings"]
  node_faiss[("FAISS index")]
  node_retriever["Page retriever"]
end

subgraph group_answering["Answer generation"]
  node_prompt["Legal prompt chain"]
  node_gemini{{"Gemini model"}}
  node_document_actions["Document Q&amp;A actions"]
end

node_user(("Legal user"))

node_user -->|"uploads PDF / asks"| node_ui
node_ui -->|"loads and splits"| node_pdf
node_ui -->|"creates vectors"| node_embeddings
node_ui -->|"indexes pages"| node_faiss
node_ui -->|"configures retrieval"| node_retriever
node_ui -->|"builds chain"| node_prompt
node_retriever -->|"searches pages"| node_faiss
node_prompt -->|"uses model"| node_gemini
node_ui -->|"reads and updates"| node_history
node_ui -.->|"offers quick actions"| node_document_actions
node_document_actions -.->|"asks document questions"| node_prompt

click node_ui "https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py"
click node_history "https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py"
click node_pdf "https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py"
click node_embeddings "https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py"
click node_faiss "https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py"
click node_retriever "https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py"
click node_prompt "https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py"
click node_document_actions "https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.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_ui,node_history,node_user toneBlue
class node_pdf,node_embeddings,node_faiss,node_retriever toneAmber
class node_prompt,node_gemini,node_document_actions toneMint
```

## Components

### User interface

- [Streamlit chat UI](https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py): `Legal_Assistant_Chatbot_Streamlit.py`
- [Chat history](https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py): `Legal_Assistant_Chatbot_Streamlit.py`

### Document retrieval

- [PDF page loader](https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py): `Legal_Assistant_Chatbot_Streamlit.py`
- [Sentence embeddings](https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py): `Legal_Assistant_Chatbot_Streamlit.py`
- [FAISS index](https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py): `Legal_Assistant_Chatbot_Streamlit.py`
- [Page retriever](https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py): `Legal_Assistant_Chatbot_Streamlit.py`

### Answer generation

- [Legal prompt chain](https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py): `Legal_Assistant_Chatbot_Streamlit.py`
- **Gemini model**
- [Document Q&A actions](https://github.com/viswandh-crypto/rag-based-legal-assistant-chatbot-streamlit/blob/main/Legal_Assistant_Chatbot_Streamlit.py): `Legal_Assistant_Chatbot_Streamlit.py`

### Other components

- **Legal user**

## Connections

- Legal user → Streamlit chat UI: uploads PDF / asks (evidence: `Legal_Assistant_Chatbot_Streamlit.py`)
- Streamlit chat UI → PDF page loader: loads and splits (evidence: `Legal_Assistant_Chatbot_Streamlit.py`)
- Streamlit chat UI → Sentence embeddings: creates vectors (evidence: `Legal_Assistant_Chatbot_Streamlit.py`)
- Streamlit chat UI → FAISS index: indexes pages (evidence: `Legal_Assistant_Chatbot_Streamlit.py`)
- Streamlit chat UI → Page retriever: configures retrieval (evidence: `Legal_Assistant_Chatbot_Streamlit.py`)
- Streamlit chat UI → Legal prompt chain: builds chain (evidence: `Legal_Assistant_Chatbot_Streamlit.py`)
- Page retriever → FAISS index: searches pages (evidence: `Legal_Assistant_Chatbot_Streamlit.py`)
- Legal prompt chain → Gemini model: uses model (evidence: `Legal_Assistant_Chatbot_Streamlit.py`)
- Streamlit chat UI → Chat history: reads and updates (evidence: `Legal_Assistant_Chatbot_Streamlit.py`)
- Streamlit chat UI → Document Q&A actions: offers quick actions (evidence: `README.md`)
- Document Q&A actions → Legal prompt chain: asks document questions (evidence: `README.md`)
