# kaarthik108/snowchat architecture

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

- Interactive diagram: https://gitdiagram.com/kaarthik108/snowchat
- Repository: https://github.com/kaarthik108/snowchat

## Overview

snowChat is a Streamlit application for asking natural-language questions about Snowflake data. Its main workflow accepts a chat prompt, invokes a model-backed LangGraph agent, and displays the streamed response; the agent can retrieve schema context and search the web. A separate ingestion workflow embeds Markdown schema documents into Supabase. Snowflake query execution and Cloudflare caching are implemented in helper code, but the active agent does not register the SQL executor tool, and the UI notes data retrieval is disabled. The README also describes conversational memory and self-healing SQL; the current excerpts show memory, but not a working repair flow.

Main entry points: [`agent.py`](https://github.com/kaarthik108/snowchat/blob/main/agent.py) (Agent graph), [`main.py`](https://github.com/kaarthik108/snowchat/blob/main/main.py) (Streamlit app), [`ingest.py`](https://github.com/kaarthik108/snowchat/blob/main/ingest.py) (Document ingestion), [`tools.py`](https://github.com/kaarthik108/snowchat/blob/main/tools.py) (Schema retriever)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chat["Chat interface"]
  node_app["Streamlit app<br/>[main.py]"]
  node_chatui["Chat rendering<br/>[snowchat_ui.py]"]
  node_ddl["DDL browser<br/>[snowddl.py]"]
end

subgraph group_agent["Agent runtime"]
  node_agent["Agent graph<br/>[agent.py]"]
  node_memory[("Conversation memory<br/>[agent.py]")]
  node_model["Chat model"]
end

subgraph group_knowledge["Schema knowledge"]
  node_retrieval["Schema retriever<br/>[tools.py]"]
  node_search["Web search<br/>[tools.py]"]
  node_ingest["Document ingestion<br/>[ingest.py]"]
  node_schema_docs["Schema documents"]
end

subgraph group_data["Data integrations"]
  node_supabase[("Supabase")]
  node_embeddings["OpenAI embeddings"]
  node_snow_helper["SQL executor tool<br/>[tools.py]"]
  node_snow_conn["Snowflake connection<br/>[snow_connect.py]"]
  node_snowflake[("Snowflake")]
  node_cache[("Cloudflare KV")]
end

node_user(("User"))

node_user -->|"asks"| node_app
node_app -->|"invokes"| node_agent
node_app -->|"renders"| node_chatui
node_app -->|"loads"| node_ddl
node_agent -->|"calls"| node_model
node_agent -->|"checkpoints"| node_memory
node_agent -->|"dispatches"| node_retrieval
node_agent -->|"dispatches"| node_search
node_retrieval -->|"retrieves from"| node_supabase
node_retrieval -->|"embeds with"| node_embeddings
node_ingest -->|"loads"| node_schema_docs
node_ingest -->|"stores vectors"| node_supabase
node_ingest -->|"embeds with"| node_embeddings
node_snow_helper -->|"executes through"| node_snow_conn
node_snow_conn -->|"queries"| node_snowflake
node_snow_conn -->|"reads and writes"| node_cache

click node_app "https://github.com/kaarthik108/snowchat/blob/main/main.py"
click node_chatui "https://github.com/kaarthik108/snowchat/blob/main/utils/snowchat_ui.py"
click node_ddl "https://github.com/kaarthik108/snowchat/blob/main/utils/snowddl.py"
click node_agent "https://github.com/kaarthik108/snowchat/blob/main/agent.py"
click node_memory "https://github.com/kaarthik108/snowchat/blob/main/agent.py"
click node_retrieval "https://github.com/kaarthik108/snowchat/blob/main/tools.py"
click node_search "https://github.com/kaarthik108/snowchat/blob/main/tools.py"
click node_ingest "https://github.com/kaarthik108/snowchat/blob/main/ingest.py"
click node_schema_docs "https://github.com/kaarthik108/snowchat/tree/main/docs"
click node_snow_helper "https://github.com/kaarthik108/snowchat/blob/main/tools.py"
click node_snow_conn "https://github.com/kaarthik108/snowchat/blob/main/utils/snow_connect.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_chatui,node_ddl,node_user toneBlue
class node_agent,node_memory,node_model toneAmber
class node_retrieval,node_search,node_ingest,node_schema_docs toneMint
class node_supabase,node_embeddings,node_snow_helper,node_snow_conn,node_snowflake,node_cache toneRose
```

## Components

### Chat interface

- [Streamlit app](https://github.com/kaarthik108/snowchat/blob/main/main.py): `main.py`
- [Chat rendering](https://github.com/kaarthik108/snowchat/blob/main/utils/snowchat_ui.py): `utils/snowchat_ui.py`
- [DDL browser](https://github.com/kaarthik108/snowchat/blob/main/utils/snowddl.py): `utils/snowddl.py`

### Agent runtime

- [Agent graph](https://github.com/kaarthik108/snowchat/blob/main/agent.py): `agent.py`
- [Conversation memory](https://github.com/kaarthik108/snowchat/blob/main/agent.py): `agent.py`
- **Chat model**

### Schema knowledge

- [Schema retriever](https://github.com/kaarthik108/snowchat/blob/main/tools.py): `tools.py`
- [Web search](https://github.com/kaarthik108/snowchat/blob/main/tools.py): `tools.py`
- [Document ingestion](https://github.com/kaarthik108/snowchat/blob/main/ingest.py): `ingest.py`
- [Schema documents](https://github.com/kaarthik108/snowchat/tree/main/docs): `docs`

### Data integrations

- **Supabase**
- **OpenAI embeddings**
- [SQL executor tool](https://github.com/kaarthik108/snowchat/blob/main/tools.py): `tools.py`
- [Snowflake connection](https://github.com/kaarthik108/snowchat/blob/main/utils/snow_connect.py): `utils/snow_connect.py`
- **Snowflake**
- **Cloudflare KV**

### Other components

- **User**

## Connections

- User → Streamlit app: asks (evidence: `README.md`)
- Streamlit app → Agent graph: invokes (evidence: `main.py`)
- Streamlit app → Chat rendering: renders (evidence: `main.py`)
- Streamlit app → DDL browser: loads (evidence: `main.py`)
- Agent graph → Chat model: calls (evidence: `agent.py`)
- Agent graph → Conversation memory: checkpoints (evidence: `agent.py`)
- Agent graph → Schema retriever: dispatches (evidence: `agent.py`)
- Agent graph → Web search: dispatches (evidence: `agent.py`)
- Schema retriever → Supabase: retrieves from (evidence: `tools.py`)
- Schema retriever → OpenAI embeddings: embeds with (evidence: `tools.py`)
- Document ingestion → Schema documents: loads (evidence: `ingest.py`)
- Document ingestion → Supabase: stores vectors (evidence: `ingest.py`)
- Document ingestion → OpenAI embeddings: embeds with (evidence: `ingest.py`)
- SQL executor tool → Snowflake connection: executes through (evidence: `tools.py`)
- Snowflake connection → Snowflake: queries (evidence: `utils/snow_connect.py`)
- Snowflake connection → Cloudflare KV: reads and writes (evidence: `utils/snow_connect.py`)
