# harshbhanushali26/hari architecture

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

- Interactive diagram: https://gitdiagram.com/harshbhanushali26/hari
- Repository: https://github.com/harshbhanushali26/hari

## Overview

hArI is a Streamlit document-intelligence application: users upload PDFs or spreadsheets, ask questions, and receive cited document answers or tabular analysis. Its principal workflow enters through the UI handlers, which ingest files, route questions, retrieve PDF context or execute generated SQL, and request a final response. The graph preserves both engines, chat memory/persistence, and authentication. Evidence is limited to the README and supplied excerpts/index; unsampled subsystems are included only where documented, with uncertain links omitted.

Main entry points: [`ui/handlers.py`](https://github.com/harshbhanushali26/hari/blob/main/ui/handlers.py) (Workflow Handlers), [`app.py`](https://github.com/harshbhanushali26/hari/blob/main/app.py) (Streamlit App), [`ui/components.py`](https://github.com/harshbhanushali26/hari/blob/main/ui/components.py) (Chat Components), [`rag/retriever.py`](https://github.com/harshbhanushali26/hari/blob/main/rag/retriever.py) (Hybrid Retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_app["Streamlit App<br/>[app.py]"]
  node_auth["Authentication UI<br/>[auth.py]"]
  node_ui["Chat Components<br/>[components.py]"]
  node_handlers["Workflow Handlers<br/>[handlers.py]"]
  node_state["Session State<br/>[state.py]"]
  node_supabase_auth["Supabase Auth"]
end

subgraph group_ingestion["File Ingestion"]
  node_processor["File Extraction<br/>[file_processor.py]"]
end

subgraph group_pdf["PDF Retrieval"]
  node_embedder["Chunking &amp; Embedding<br/>[embedder.py]"]
  node_vector[("Vector Store<br/>[vector_store.py]")]
  node_retriever["Hybrid Retrieval<br/>[retriever.py]"]
  node_database[("Supabase PostgreSQL")]
end

subgraph group_analytics["Tabular Analytics"]
  node_duckdb[("Sandboxed DuckDB<br/>[handlers.py]")]
end

subgraph group_conversation["Conversation Services"]
  node_intent["Query Router<br/>[query_intent.py]"]
  node_groq["Groq LLM"]
  node_responser["Response Generation<br/>[responser.py]"]
  node_memory["Chat Memory<br/>[memory.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_auth
node_app -->|"initializes"| node_state
node_app -->|"renders"| node_ui
node_ui -->|"invokes"| node_handlers
node_auth -->|"authenticates"| node_supabase_auth
node_handlers -->|"loads files"| node_processor
node_handlers -->|"embeds chunks"| node_embedder
node_handlers -->|"stores chunks"| node_vector
node_embedder -->|"chunks documents"| node_processor
node_vector -->|"writes chunks"| node_database
node_handlers -->|"routes query"| node_intent
node_handlers -->|"retrieves context"| node_retriever
node_retriever -->|"embeds query"| node_embedder
node_retriever -->|"hybrid search"| node_database
node_handlers -->|"executes SQL"| node_duckdb
node_handlers -->|"generates SQL"| node_groq
node_handlers -->|"requests answer"| node_responser
node_responser -->|"generates response"| node_groq
node_handlers -->|"loads context"| node_memory
node_memory -.->|"summarizes history"| node_groq
node_handlers -->|"persists chats"| node_database
node_user -->|"asks questions"| node_ui
node_ui -->|"shows answers"| node_user

click node_app "https://github.com/harshbhanushali26/hari/blob/main/app.py"
click node_auth "https://github.com/harshbhanushali26/hari/blob/main/ui/auth.py"
click node_ui "https://github.com/harshbhanushali26/hari/blob/main/ui/components.py"
click node_handlers "https://github.com/harshbhanushali26/hari/blob/main/ui/handlers.py"
click node_state "https://github.com/harshbhanushali26/hari/blob/main/ui/state.py"
click node_processor "https://github.com/harshbhanushali26/hari/blob/main/core/file_processor.py"
click node_embedder "https://github.com/harshbhanushali26/hari/blob/main/rag/embedder.py"
click node_vector "https://github.com/harshbhanushali26/hari/blob/main/rag/vector_store.py"
click node_retriever "https://github.com/harshbhanushali26/hari/blob/main/rag/retriever.py"
click node_intent "https://github.com/harshbhanushali26/hari/blob/main/core/query_intent.py"
click node_duckdb "https://github.com/harshbhanushali26/hari/blob/main/ui/handlers.py"
click node_responser "https://github.com/harshbhanushali26/hari/blob/main/core/responser.py"
click node_memory "https://github.com/harshbhanushali26/hari/blob/main/core/memory.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_app,node_auth,node_ui,node_handlers,node_state,node_supabase_auth,node_user toneBlue
class node_processor toneAmber
class node_embedder,node_vector,node_retriever,node_database toneMint
class node_duckdb toneRose
class node_intent,node_groq,node_responser,node_memory toneIndigo
```

## Components

### User Interface

- [Streamlit App](https://github.com/harshbhanushali26/hari/blob/main/app.py): `app.py`
- [Authentication UI](https://github.com/harshbhanushali26/hari/blob/main/ui/auth.py): `ui/auth.py`
- [Chat Components](https://github.com/harshbhanushali26/hari/blob/main/ui/components.py): `ui/components.py`
- [Workflow Handlers](https://github.com/harshbhanushali26/hari/blob/main/ui/handlers.py): `ui/handlers.py`
- [Session State](https://github.com/harshbhanushali26/hari/blob/main/ui/state.py): `ui/state.py`
- **Supabase Auth**

### File Ingestion

- [File Extraction](https://github.com/harshbhanushali26/hari/blob/main/core/file_processor.py): `core/file_processor.py`

### PDF Retrieval

- [Chunking & Embedding](https://github.com/harshbhanushali26/hari/blob/main/rag/embedder.py): `rag/embedder.py`
- [Vector Store](https://github.com/harshbhanushali26/hari/blob/main/rag/vector_store.py): `rag/vector_store.py`
- [Hybrid Retrieval](https://github.com/harshbhanushali26/hari/blob/main/rag/retriever.py): `rag/retriever.py`
- **Supabase PostgreSQL**

### Tabular Analytics

- [Sandboxed DuckDB](https://github.com/harshbhanushali26/hari/blob/main/ui/handlers.py): `ui/handlers.py`

### Conversation Services

- [Query Router](https://github.com/harshbhanushali26/hari/blob/main/core/query_intent.py): `core/query_intent.py`
- **Groq LLM**
- [Response Generation](https://github.com/harshbhanushali26/hari/blob/main/core/responser.py): `core/responser.py`
- [Chat Memory](https://github.com/harshbhanushali26/hari/blob/main/core/memory.py): `core/memory.py`

### Other components

- **User**

## Connections

- User → Streamlit App: uses (evidence: `README.md`)
- Streamlit App → Authentication UI: renders (evidence: `app.py`)
- Streamlit App → Session State: initializes (evidence: `app.py`)
- Streamlit App → Chat Components: renders (evidence: `app.py`)
- Chat Components → Workflow Handlers: invokes (evidence: `ui/components.py`)
- Authentication UI → Supabase Auth: authenticates (evidence: `ui/auth.py`)
- Workflow Handlers → File Extraction: loads files (evidence: `ui/handlers.py`)
- Workflow Handlers → Chunking & Embedding: embeds chunks (evidence: `ui/handlers.py`)
- Workflow Handlers → Vector Store: stores chunks (evidence: `ui/handlers.py`)
- Chunking & Embedding → File Extraction: chunks documents (evidence: `rag/embedder.py`)
- Vector Store → Supabase PostgreSQL: writes chunks (evidence: `rag/vector_store.py`)
- Workflow Handlers → Query Router: routes query (evidence: `ui/handlers.py`)
- Workflow Handlers → Hybrid Retrieval: retrieves context (evidence: `ui/handlers.py`)
- Hybrid Retrieval → Chunking & Embedding: embeds query (evidence: `rag/retriever.py`)
- Hybrid Retrieval → Supabase PostgreSQL: hybrid search (evidence: `rag/retriever.py`)
- Workflow Handlers → Sandboxed DuckDB: executes SQL (evidence: `ui/handlers.py`)
- Workflow Handlers → Groq LLM: generates SQL (evidence: `ui/handlers.py`)
- Workflow Handlers → Response Generation: requests answer (evidence: `ui/handlers.py`)
- Response Generation → Groq LLM: generates response (evidence: `core/responser.py`)
- Workflow Handlers → Chat Memory: loads context (evidence: `ui/handlers.py`)
- Chat Memory → Groq LLM: summarizes history
- Workflow Handlers → Supabase PostgreSQL: persists chats (evidence: `ui/handlers.py`)
- User → Chat Components: asks questions (evidence: `README.md`)
- Chat Components → User: shows answers (evidence: `ui/components.py`)
