# ishaan-bhalla/insaaf-insight-labour-laws-handbook architecture

> Architecture diagram of the GitHub repository ishaan-bhalla/insaaf-insight-labour-laws-handbook, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook
- Repository: https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook

## Overview

Insaaf Insight is a Streamlit legal-question assistant grounded in a labour-law handbook. A user submits a question in the chat UI, which calls the RAG pipeline; the pipeline retrieves handbook passages, generates a grounded answer, and returns the pages used for display. The map also shows the handbook viewer and the optional Groq/Ollama model backends. Relationships are based on the excerpts and README; unsampled UI text files are not treated as runtime components.

Main entry points: [`main.py`](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py) (RAG pipeline), [`app.py`](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/app.py) (Chat interface), [`A Handbook on Employee Relations and Labour Laws in India.pdf`](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/A%20Handbook%20on%20Employee%20Relations%20and%20Labour%20Laws%20in%20India.pdf) (Labour handbook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_chat["Chat interface<br/>[app.py]"]
  node_viewer["Handbook viewer<br/>[app.py]"]
end

subgraph group_knowledge["Handbook retrieval"]
  node_handbook["Labour handbook"]
  node_loader["PDF loading<br/>[main.py]"]
  node_chunking["Chunking<br/>[main.py]"]
  node_embeddings["Text embeddings<br/>[main.py]"]
  node_index[("FAISS index<br/>[main.py]")]
  node_retriever["Passage retrieval<br/>[main.py]"]
end

subgraph group_answering["Answer generation"]
  node_pipeline["RAG pipeline<br/>[main.py]"]
  node_prompt["Grounded prompt<br/>[main.py]"]
  node_model_choice["Model selection<br/>[main.py]"]
  node_result["Answer and pages<br/>[main.py]"]
end

node_user(("Questioner"))
node_groq["Groq Llama"]
node_ollama["Ollama Llama"]

node_user -->|"asks"| node_chat
node_chat -->|"calls"| node_pipeline
node_handbook -->|"loads"| node_loader
node_loader -->|"splits"| node_chunking
node_chunking -->|"embeds"| node_embeddings
node_embeddings -->|"indexes"| node_index
node_pipeline -->|"requests passages"| node_retriever
node_retriever -->|"searches"| node_index
node_retriever -->|"supplies passages"| node_prompt
node_pipeline -->|"builds"| node_prompt
node_prompt -->|"invokes"| node_model_choice
node_model_choice -.->|"selects with key"| node_groq
node_model_choice -->|"otherwise selects"| node_ollama
node_model_choice -->|"returns response"| node_result
node_pipeline -->|"adds page numbers"| node_result
node_result -->|"displays"| node_chat
node_viewer -->|"displays"| node_handbook

click node_chat "https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/app.py"
click node_viewer "https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/app.py"
click node_handbook "https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/A%20Handbook%20on%20Employee%20Relations%20and%20Labour%20Laws%20in%20India.pdf"
click node_loader "https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py"
click node_chunking "https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py"
click node_embeddings "https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py"
click node_index "https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py"
click node_retriever "https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py"
click node_pipeline "https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py"
click node_prompt "https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py"
click node_model_choice "https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py"
click node_result "https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.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_chat,node_viewer toneBlue
class node_handbook,node_loader,node_chunking,node_embeddings,node_index,node_retriever toneAmber
class node_pipeline,node_prompt,node_model_choice,node_result toneMint
class node_user,node_groq,node_ollama toneIndigo
```

## Components

### User interface

- [Chat interface](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/app.py): `app.py`
- [Handbook viewer](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/app.py): `app.py`

### Handbook retrieval

- [Labour handbook](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/A%20Handbook%20on%20Employee%20Relations%20and%20Labour%20Laws%20in%20India.pdf): `A Handbook on Employee Relations and Labour Laws in India.pdf`
- [PDF loading](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py): `main.py`
- [Chunking](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py): `main.py`
- [Text embeddings](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py): `main.py`
- [FAISS index](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py): `main.py`
- [Passage retrieval](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py): `main.py`

### Answer generation

- [RAG pipeline](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py): `main.py`
- [Grounded prompt](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py): `main.py`
- [Model selection](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py): `main.py`
- [Answer and pages](https://github.com/ishaan-bhalla/insaaf-insight-labour-laws-handbook/blob/main/main.py): `main.py`

### Other components

- **Questioner**
- **Groq Llama**
- **Ollama Llama**

## Connections

- Questioner → Chat interface: asks (evidence: `README.md`)
- Chat interface → RAG pipeline: calls (evidence: `app.py`)
- Labour handbook → PDF loading: loads (evidence: `main.py`)
- PDF loading → Chunking: splits (evidence: `main.py`)
- Chunking → Text embeddings: embeds (evidence: `README.md`)
- Text embeddings → FAISS index: indexes (evidence: `README.md`)
- RAG pipeline → Passage retrieval: requests passages (evidence: `main.py`)
- Passage retrieval → FAISS index: searches (evidence: `main.py`)
- Passage retrieval → Grounded prompt: supplies passages (evidence: `main.py`)
- RAG pipeline → Grounded prompt: builds (evidence: `main.py`)
- Grounded prompt → Model selection: invokes (evidence: `main.py`)
- Model selection → Groq Llama: selects with key (evidence: `main.py`)
- Model selection → Ollama Llama: otherwise selects (evidence: `main.py`)
- Model selection → Answer and pages: returns response (evidence: `main.py`)
- RAG pipeline → Answer and pages: adds page numbers (evidence: `main.py`)
- Answer and pages → Chat interface: displays (evidence: `app.py`)
- Handbook viewer → Labour handbook: displays (evidence: `app.py`)
