# soumyaatanna/querychat architecture

> Architecture diagram of the GitHub repository soumyaatanna/querychat, 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/soumyaatanna/querychat
- Repository: https://github.com/soumyaatanna/querychat

## Overview

QueryChat AI is a natural-language database query application. Users connect a SQLite or MySQL database (or try the demo), ask questions in chat, and receive executed SQL results, explanations, and visualizations. The React app routes users among connection, upload, analytics, settings, and chat screens; its API requests reach FastAPI, which coordinates SQL generation, database execution, and supporting database operations. The README describes additional chart, table, and upload capabilities; source excerpts show only part of their implementation, so those details are represented at the product-component level.

Main entry points: [`frontend/src/App.jsx`](https://github.com/soumyaatanna/querychat/blob/main/frontend/src/App.jsx) (App coordinator), [`backend/main.py`](https://github.com/soumyaatanna/querychat/blob/main/backend/main.py) (FastAPI endpoints), [`backend/database.py`](https://github.com/soumyaatanna/querychat/blob/main/backend/database.py) (Connection and query manager), [`backend/gemini_service.py`](https://github.com/soumyaatanna/querychat/blob/main/backend/gemini_service.py) (SQL generation and insights)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React interface"]
  node_app["App coordinator<br/>[App.jsx]"]
  node_landing["Demo and landing<br/>[LandingPage.jsx]"]
  node_sidebar["Navigation and theme<br/>[Sidebar.jsx]"]
  node_connection_ui["Connection screen"]
  node_chat_ui["Chat and results<br/>[ChatArea.jsx]"]
  node_upload_ui["Data upload screen<br/>[UploadScreen.jsx]"]
  node_analytics_ui["Analytics screen"]
  node_settings_ui["Settings screen<br/>[SettingsScreen.jsx]"]
end

subgraph group_api["API and query services"]
  node_api["FastAPI endpoints<br/>[main.py]"]
  node_sql_ai["SQL generation and insights<br/>[gemini_service.py]"]
end

subgraph group_data["Database management"]
  node_db_manager["Connection and query manager<br/>[database.py]"]
end

subgraph group_external["External systems"]
  node_db[("Connected database")]
  node_gemini{{"Google Gemini"}}
  node_sqlite_demo[("Seeded SQLite demo")]
end

node_user(("User"))

node_user -->|"starts demo"| node_landing
node_user -->|"uses application"| node_app
node_app -->|"renders"| node_landing
node_app -->|"renders"| node_sidebar
node_app -->|"renders"| node_connection_ui
node_app -->|"renders"| node_chat_ui
node_app -->|"renders"| node_upload_ui
node_app -->|"renders"| node_analytics_ui
node_app -->|"renders"| node_settings_ui
node_app -->|"requests connect and chat"| node_api
node_connection_ui -->|"connects database"| node_api
node_chat_ui -->|"sends questions"| node_app
node_upload_ui -->|"uploads files"| node_api
node_analytics_ui -->|"requests telemetry"| node_api
node_api -->|"generates SQL"| node_sql_ai
node_api -->|"executes and manages queries"| node_db_manager
node_api -->|"reads analytics and tables"| node_db_manager
node_api -->|"loads tabular uploads"| node_db_manager
node_sql_ai -->|"generates SQL and summaries"| node_gemini
node_sql_ai -->|"falls back to heuristics"| node_sql_ai
node_db_manager -->|"connects and queries"| node_db
node_db_manager -->|"seeds demo data"| node_sqlite_demo
node_app -->|"tries demo via API"| node_sqlite_demo

click node_app "https://github.com/soumyaatanna/querychat/blob/main/frontend/src/App.jsx"
click node_landing "https://github.com/soumyaatanna/querychat/blob/main/frontend/src/components/LandingPage.jsx"
click node_sidebar "https://github.com/soumyaatanna/querychat/blob/main/frontend/src/components/Sidebar.jsx"
click node_connection_ui "https://github.com/soumyaatanna/querychat/blob/main/frontend/src/components/ConnectionScreen.jsx"
click node_chat_ui "https://github.com/soumyaatanna/querychat/blob/main/frontend/src/components/ChatArea.jsx"
click node_upload_ui "https://github.com/soumyaatanna/querychat/blob/main/frontend/src/components/UploadScreen.jsx"
click node_analytics_ui "https://github.com/soumyaatanna/querychat/blob/main/frontend/src/components/AnalyticsScreen.jsx"
click node_settings_ui "https://github.com/soumyaatanna/querychat/blob/main/frontend/src/components/SettingsScreen.jsx"
click node_api "https://github.com/soumyaatanna/querychat/blob/main/backend/main.py"
click node_sql_ai "https://github.com/soumyaatanna/querychat/blob/main/backend/gemini_service.py"
click node_db_manager "https://github.com/soumyaatanna/querychat/blob/main/backend/database.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_landing,node_sidebar,node_connection_ui,node_chat_ui,node_upload_ui,node_analytics_ui,node_settings_ui,node_user toneBlue
class node_api,node_sql_ai toneAmber
class node_db_manager toneMint
class node_db,node_gemini,node_sqlite_demo toneRose
```

## Components

### React interface

- [App coordinator](https://github.com/soumyaatanna/querychat/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Demo and landing](https://github.com/soumyaatanna/querychat/blob/main/frontend/src/components/LandingPage.jsx): `frontend/src/components/LandingPage.jsx`
- [Navigation and theme](https://github.com/soumyaatanna/querychat/blob/main/frontend/src/components/Sidebar.jsx): `frontend/src/components/Sidebar.jsx`
- [Connection screen](https://github.com/soumyaatanna/querychat/blob/main/frontend/src/components/ConnectionScreen.jsx): `frontend/src/components/ConnectionScreen.jsx`
- [Chat and results](https://github.com/soumyaatanna/querychat/blob/main/frontend/src/components/ChatArea.jsx): `frontend/src/components/ChatArea.jsx`
- [Data upload screen](https://github.com/soumyaatanna/querychat/blob/main/frontend/src/components/UploadScreen.jsx): `frontend/src/components/UploadScreen.jsx`
- [Analytics screen](https://github.com/soumyaatanna/querychat/blob/main/frontend/src/components/AnalyticsScreen.jsx): `frontend/src/components/AnalyticsScreen.jsx`
- [Settings screen](https://github.com/soumyaatanna/querychat/blob/main/frontend/src/components/SettingsScreen.jsx): `frontend/src/components/SettingsScreen.jsx`

### API and query services

- [FastAPI endpoints](https://github.com/soumyaatanna/querychat/blob/main/backend/main.py): `backend/main.py`
- [SQL generation and insights](https://github.com/soumyaatanna/querychat/blob/main/backend/gemini_service.py): `backend/gemini_service.py`

### Database management

- [Connection and query manager](https://github.com/soumyaatanna/querychat/blob/main/backend/database.py): `backend/database.py`

### External systems

- **Connected database**
- **Google Gemini**
- **Seeded SQLite demo**

### Other components

- **User**

## Connections

- User → Demo and landing: starts demo (evidence: `frontend/src/components/LandingPage.jsx`)
- User → App coordinator: uses application (evidence: `README.md`)
- App coordinator → Demo and landing: renders (evidence: `frontend/src/App.jsx`)
- App coordinator → Navigation and theme: renders (evidence: `frontend/src/App.jsx`)
- App coordinator → Connection screen: renders (evidence: `frontend/src/App.jsx`)
- App coordinator → Chat and results: renders (evidence: `frontend/src/App.jsx`)
- App coordinator → Data upload screen: renders (evidence: `frontend/src/App.jsx`)
- App coordinator → Analytics screen: renders (evidence: `frontend/src/App.jsx`)
- App coordinator → Settings screen: renders (evidence: `frontend/src/App.jsx`)
- App coordinator → FastAPI endpoints: requests connect and chat (evidence: `frontend/src/App.jsx`)
- Connection screen → FastAPI endpoints: connects database (evidence: `README.md`)
- Chat and results → App coordinator: sends questions (evidence: `frontend/src/App.jsx`)
- Data upload screen → FastAPI endpoints: uploads files (evidence: `README.md`)
- Analytics screen → FastAPI endpoints: requests telemetry (evidence: `README.md`)
- FastAPI endpoints → SQL generation and insights: generates SQL (evidence: `backend/main.py`)
- FastAPI endpoints → Connection and query manager: executes and manages queries (evidence: `backend/main.py`)
- FastAPI endpoints → Connection and query manager: reads analytics and tables (evidence: `backend/main.py`)
- FastAPI endpoints → Connection and query manager: loads tabular uploads (evidence: `README.md`)
- SQL generation and insights → Google Gemini: generates SQL and summaries (evidence: `README.md`)
- SQL generation and insights → SQL generation and insights: falls back to heuristics (evidence: `backend/gemini_service.py`)
- Connection and query manager → Connected database: connects and queries (evidence: `backend/database.py`)
- Connection and query manager → Seeded SQLite demo: seeds demo data (evidence: `backend/database.py`)
- App coordinator → Seeded SQLite demo: tries demo via API (evidence: `frontend/src/App.jsx`)
