# gowtham95bi/airag architecture

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

- Interactive diagram: https://gitdiagram.com/gowtham95bi/airag
- Repository: https://github.com/gowtham95bi/airag

## Overview

This is a small Q&A assistant capstone: a Streamlit client sends questions to a FastAPI service, which delegates answer generation to an async pipeline. The pipeline loads CSV questions for batch runs, retries model calls, summarizes executions, and writes JSON and SQLite results; saved runs can be queried separately. The README also documents switching between a fake model and a real API. The learning examples are intentionally excluded. Edges reflect the sampled call sites and README; unsampled wiring is not inferred.

Main entry points: [`src/pipeline/pipeline.py`](https://github.com/gowtham95bi/airag/blob/main/src/pipeline/pipeline.py) (Async Pipeline), [`ui/app.py`](https://github.com/gowtham95bi/airag/blob/main/ui/app.py) (Streamlit UI), [`api/main.py`](https://github.com/gowtham95bi/airag/blob/main/api/main.py) (HTTP API), [`src/pipeline/store.py`](https://github.com/gowtham95bi/airag/blob/main/src/pipeline/store.py) (SQLite Persistence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User Interface"]
  node_ui["Streamlit UI<br/>[app.py]"]
end

subgraph group_service["API Service"]
  node_api["HTTP API<br/>[main.py]"]
end

subgraph group_runtime["Answer Pipeline"]
  node_pipeline["Async Pipeline<br/>[pipeline.py]"]
  node_batch["Batch and Retry<br/>[pipeline.py]"]
  node_model["Model Adapter<br/>[pipeline.py]"]
  node_fake["Fake Model<br/>[fake_llm.py]"]
  node_settings["Runtime Settings<br/>[settings.py]"]
  node_logger["JSON Logging<br/>[logging_config.py]"]
  node_questions["Question CSV<br/>[questions.csv]"]
end

subgraph group_records["Run Records"]
  node_summary["Run Summary<br/>[settings.py]"]
  node_jsonout["JSON Results"]
  node_store[("SQLite Persistence<br/>[store.py]")]
  node_query["Run Query<br/>[query_results.py]"]
end

node_user(("Questioner"))
node_openai{{"OpenAI API"}}

node_user -->|"asks"| node_ui
node_ui -->|"posts question"| node_api
node_api -->|"calls"| node_pipeline
node_pipeline -->|"loads"| node_questions
node_pipeline -->|"runs"| node_batch
node_batch -->|"retries calls"| node_model
node_pipeline -->|"reads config"| node_settings
node_pipeline -->|"logs events"| node_logger
node_model -->|"uses when enabled"| node_fake
node_model -.->|"calls when enabled"| node_openai
node_pipeline -->|"aggregates"| node_summary
node_pipeline -->|"writes results"| node_jsonout
node_pipeline -->|"persists run and answers"| node_store
node_query -->|"queries saved records"| node_store

click node_ui "https://github.com/gowtham95bi/airag/blob/main/ui/app.py"
click node_api "https://github.com/gowtham95bi/airag/blob/main/api/main.py"
click node_pipeline "https://github.com/gowtham95bi/airag/blob/main/src/pipeline/pipeline.py"
click node_batch "https://github.com/gowtham95bi/airag/blob/main/src/pipeline/pipeline.py"
click node_model "https://github.com/gowtham95bi/airag/blob/main/src/pipeline/pipeline.py"
click node_fake "https://github.com/gowtham95bi/airag/blob/main/src/pipeline/fake_llm.py"
click node_settings "https://github.com/gowtham95bi/airag/blob/main/src/pipeline/settings.py"
click node_logger "https://github.com/gowtham95bi/airag/blob/main/src/pipeline/logging_config.py"
click node_questions "https://github.com/gowtham95bi/airag/blob/main/data/questions.csv"
click node_summary "https://github.com/gowtham95bi/airag/blob/main/src/pipeline/settings.py"
click node_store "https://github.com/gowtham95bi/airag/blob/main/src/pipeline/store.py"
click node_query "https://github.com/gowtham95bi/airag/blob/main/src/pipeline/query_results.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 toneBlue
class node_api toneAmber
class node_pipeline,node_batch,node_model,node_fake,node_settings,node_logger,node_questions,node_openai toneMint
class node_summary,node_jsonout,node_store,node_query toneRose
class node_user toneIndigo
```

## Components

### User Interface

- [Streamlit UI](https://github.com/gowtham95bi/airag/blob/main/ui/app.py): `ui/app.py`

### API Service

- [HTTP API](https://github.com/gowtham95bi/airag/blob/main/api/main.py): `api/main.py`

### Answer Pipeline

- [Async Pipeline](https://github.com/gowtham95bi/airag/blob/main/src/pipeline/pipeline.py): `src/pipeline/pipeline.py`
- [Batch and Retry](https://github.com/gowtham95bi/airag/blob/main/src/pipeline/pipeline.py): `src/pipeline/pipeline.py`
- [Model Adapter](https://github.com/gowtham95bi/airag/blob/main/src/pipeline/pipeline.py): `src/pipeline/pipeline.py`
- [Fake Model](https://github.com/gowtham95bi/airag/blob/main/src/pipeline/fake_llm.py): `src/pipeline/fake_llm.py`
- [Runtime Settings](https://github.com/gowtham95bi/airag/blob/main/src/pipeline/settings.py): `src/pipeline/settings.py`
- [JSON Logging](https://github.com/gowtham95bi/airag/blob/main/src/pipeline/logging_config.py): `src/pipeline/logging_config.py`
- [Question CSV](https://github.com/gowtham95bi/airag/blob/main/data/questions.csv): `data/questions.csv`

### Run Records

- [Run Summary](https://github.com/gowtham95bi/airag/blob/main/src/pipeline/settings.py): `src/pipeline/settings.py`
- **JSON Results**
- [SQLite Persistence](https://github.com/gowtham95bi/airag/blob/main/src/pipeline/store.py): `src/pipeline/store.py`
- [Run Query](https://github.com/gowtham95bi/airag/blob/main/src/pipeline/query_results.py): `src/pipeline/query_results.py`

### Other components

- **Questioner**
- **OpenAI API**

## Connections

- Questioner → Streamlit UI: asks (evidence: `ui/app.py`)
- Streamlit UI → HTTP API: posts question (evidence: `ui/app.py`)
- HTTP API → Async Pipeline: calls (evidence: `api/main.py`)
- Async Pipeline → Question CSV: loads (evidence: `src/pipeline/pipeline.py`)
- Async Pipeline → Batch and Retry: runs (evidence: `src/pipeline/pipeline.py`)
- Batch and Retry → Model Adapter: retries calls (evidence: `src/pipeline/pipeline.py`)
- Async Pipeline → Runtime Settings: reads config (evidence: `src/pipeline/pipeline.py`)
- Async Pipeline → JSON Logging: logs events (evidence: `src/pipeline/pipeline.py`)
- Model Adapter → Fake Model: uses when enabled (evidence: `src/pipeline/pipeline.py`)
- Model Adapter → OpenAI API: calls when enabled
- Async Pipeline → Run Summary: aggregates (evidence: `src/pipeline/pipeline.py`)
- Async Pipeline → JSON Results: writes results (evidence: `src/pipeline/pipeline.py`)
- Async Pipeline → SQLite Persistence: persists run and answers (evidence: `src/pipeline/pipeline.py`)
- Run Query → SQLite Persistence: queries saved records (evidence: `src/pipeline/query_results.py`)
