# saayam-for-all/ai architecture

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

- Interactive diagram: https://gitdiagram.com/saayam-for-all/ai
- Repository: https://github.com/saayam-for-all/ai
- Video tour (about a minute): https://gitdiagram.com/saayam-for-all/ai/video

## Overview

Saayam AI Assistant accepts a question through its Flask web interface, predicts relevant categories, generates and formats an answer with the selected model, and returns performance metrics. The repository also contains a separate Meta AI-only Flask implementation and an Issue42 volunteer-to-task matching utility. The main app and both utilities were excerpted; the frontend and Issue42 data relationships are shown only where code or the README supports them.

Main entry points: [`app.py`](https://github.com/saayam-for-all/ai/blob/main/app.py) (Answer generation), [`Issue42/volunteer_match.py`](https://github.com/saayam-for-all/ai/blob/main/Issue42/volunteer_match.py) (Volunteer matching), [`templates/index.html`](https://github.com/saayam-for-all/ai/blob/main/templates/index.html) (Web interface), [`MetaAIAPI_app.py`](https://github.com/saayam-for-all/ai/blob/main/MetaAIAPI_app.py) (Meta-only app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_flask_app["Flask routes<br/>[app.py]"]
  node_web_ui["Web interface<br/>[index.html]"]
end

subgraph group_assistant["Assistant workflow"]
  node_classifier["Category classifier<br/>[app.py]"]
  node_answer_handler["Answer generation<br/>[app.py]"]
  node_response_format["Response formatting<br/>[app.py]"]
  node_metrics["Metrics logging<br/>[app.py]"]
  node_metrics_log["Metrics log"]
end

subgraph group_integrations["AI integrations"]
  node_meta_model["Meta AI"]
  node_gemini_model["Gemini"]
  node_openai_model["OpenAI"]
  node_grok_model["Grok"]
  node_legacy_app["Meta-only app<br/>[MetaAIAPI_app.py]"]
end

subgraph group_matching["Volunteer matching"]
  node_volunteer_data[("Volunteer records<br/>[volunteers.csv]")]
  node_task_data[("Task records<br/>[task_table.csv]")]
  node_matching_logic["Volunteer matching<br/>[volunteer_match.py]"]
  node_assignments["Task assignments<br/>[volunteer_match.py]"]
end

node_user(("User"))

node_user -->|"submits query"| node_web_ui
node_web_ui -->|"sends requests"| node_flask_app
node_flask_app -->|"renders page"| node_web_ui
node_flask_app -->|"classifies query"| node_classifier
node_flask_app -->|"routes question"| node_answer_handler
node_answer_handler -->|"prompts when selected"| node_meta_model
node_answer_handler -->|"queries when selected"| node_gemini_model
node_answer_handler -->|"queries when selected"| node_openai_model
node_answer_handler -->|"queries when selected"| node_grok_model
node_answer_handler -->|"formats response"| node_response_format
node_answer_handler -->|"records timings"| node_metrics
node_metrics -->|"writes metrics"| node_metrics_log
node_user -.->|"can use standalone app"| node_legacy_app
node_legacy_app -->|"prompts model"| node_meta_model
node_matching_logic -->|"loads records"| node_volunteer_data
node_matching_logic -->|"loads tasks"| node_task_data
node_matching_logic -->|"produces assignments"| node_assignments

click node_flask_app "https://github.com/saayam-for-all/ai/blob/main/app.py"
click node_web_ui "https://github.com/saayam-for-all/ai/blob/main/templates/index.html"
click node_classifier "https://github.com/saayam-for-all/ai/blob/main/app.py"
click node_answer_handler "https://github.com/saayam-for-all/ai/blob/main/app.py"
click node_response_format "https://github.com/saayam-for-all/ai/blob/main/app.py"
click node_metrics "https://github.com/saayam-for-all/ai/blob/main/app.py"
click node_legacy_app "https://github.com/saayam-for-all/ai/blob/main/MetaAIAPI_app.py"
click node_volunteer_data "https://github.com/saayam-for-all/ai/blob/main/Issue42/volunteers.csv"
click node_task_data "https://github.com/saayam-for-all/ai/blob/main/Issue42/task_table.csv"
click node_matching_logic "https://github.com/saayam-for-all/ai/blob/main/Issue42/volunteer_match.py"
click node_assignments "https://github.com/saayam-for-all/ai/blob/main/Issue42/volunteer_match.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_flask_app,node_web_ui,node_user toneBlue
class node_classifier,node_answer_handler,node_response_format,node_metrics,node_metrics_log toneAmber
class node_meta_model,node_gemini_model,node_openai_model,node_grok_model,node_legacy_app toneMint
class node_volunteer_data,node_task_data,node_matching_logic,node_assignments toneRose
```

## Components

### Web interface

- [Flask routes](https://github.com/saayam-for-all/ai/blob/main/app.py): `app.py`
- [Web interface](https://github.com/saayam-for-all/ai/blob/main/templates/index.html): `templates/index.html`

### Assistant workflow

- [Category classifier](https://github.com/saayam-for-all/ai/blob/main/app.py): `app.py`
- [Answer generation](https://github.com/saayam-for-all/ai/blob/main/app.py): `app.py`
- [Response formatting](https://github.com/saayam-for-all/ai/blob/main/app.py): `app.py`
- [Metrics logging](https://github.com/saayam-for-all/ai/blob/main/app.py): `app.py`
- **Metrics log**

### AI integrations

- **Meta AI**
- **Gemini**
- **OpenAI**
- **Grok**
- [Meta-only app](https://github.com/saayam-for-all/ai/blob/main/MetaAIAPI_app.py): `MetaAIAPI_app.py`

### Volunteer matching

- [Volunteer records](https://github.com/saayam-for-all/ai/blob/main/Issue42/volunteers.csv): `Issue42/volunteers.csv`
- [Task records](https://github.com/saayam-for-all/ai/blob/main/Issue42/task_table.csv): `Issue42/task_table.csv`
- [Volunteer matching](https://github.com/saayam-for-all/ai/blob/main/Issue42/volunteer_match.py): `Issue42/volunteer_match.py`
- [Task assignments](https://github.com/saayam-for-all/ai/blob/main/Issue42/volunteer_match.py): `Issue42/volunteer_match.py`

### Other components

- **User**

## Connections

- User → Web interface: submits query (evidence: `README.md`)
- Web interface → Flask routes: sends requests (evidence: `README.md`)
- Flask routes → Web interface: renders page (evidence: `app.py`)
- Flask routes → Category classifier: classifies query (evidence: `app.py`)
- Flask routes → Answer generation: routes question (evidence: `app.py`)
- Answer generation → Meta AI: prompts when selected (evidence: `app.py`)
- Answer generation → Gemini: queries when selected (evidence: `app.py`)
- Answer generation → OpenAI: queries when selected (evidence: `app.py`)
- Answer generation → Grok: queries when selected (evidence: `app.py`)
- Answer generation → Response formatting: formats response (evidence: `app.py`)
- Answer generation → Metrics logging: records timings (evidence: `app.py`)
- Metrics logging → Metrics log: writes metrics (evidence: `app.py`)
- User → Meta-only app: can use standalone app (evidence: `README.md`)
- Meta-only app → Meta AI: prompts model (evidence: `MetaAIAPI_app.py`)
- Volunteer matching → Volunteer records: loads records (evidence: `Issue42/volunteer_match.py`)
- Volunteer matching → Task records: loads tasks (evidence: `Issue42/volunteer_match.py`)
- Volunteer matching → Task assignments: produces assignments (evidence: `Issue42/volunteer_match.py`)
