# vinita-byte/rag-mvp architecture

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

- Interactive diagram: https://gitdiagram.com/vinita-byte/rag-mvp
- Repository: https://github.com/vinita-byte/rag-mvp

## Overview

This repository is a small ad-copy RAG pipeline: it turns CSV rows into Gemini embeddings, stores them in Parquet, and supports local or Supabase-backed semantic search. The main user workflow is to build embeddings, push them to Supabase, then submit a natural-language query. The graph also shows the local-search alternative and the database RPC used for hosted retrieval. Relationships are based on the sampled scripts and README; no other source modules appear in the tree.

Main entry points: [`embed_ads.py`](https://github.com/vinita-byte/rag-mvp/blob/main/embed_ads.py) (Embedding builder), [`embeddings.parquet`](https://github.com/vinita-byte/rag-mvp/blob/main/embeddings.parquet) (Embedding Parquet), [`push_to_supabase.py`](https://github.com/vinita-byte/rag-mvp/blob/main/push_to_supabase.py) (Hosted semantic search), [`ad_copy_dataset.csv`](https://github.com/vinita-byte/rag-mvp/blob/main/ad_copy_dataset.csv) (Ad copy CSV)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Embedding preparation"]
  node_csv["Ad copy CSV"]
  node_embed["Embedding builder<br/>[embed_ads.py]"]
  node_parquet["Embedding Parquet<br/>[embeddings.parquet]"]
end

subgraph group_search["Search and storage"]
  node_local["Local semantic search<br/>[embed_ads.py]"]
  node_push["Supabase uploader"]
  node_query["Hosted semantic search"]
end

node_user(("User"))
node_gemini["Gemini embeddings"]
node_db[("Supabase pgvector")]
node_rpc["match_ads RPC"]

node_user -->|"builds embeddings"| node_embed
node_csv -->|"provides rows"| node_embed
node_embed -->|"requests embeddings"| node_gemini
node_embed -->|"writes vectors"| node_parquet
node_user -->|"uploads dataset"| node_push
node_parquet -->|"provides vectors"| node_push
node_push -->|"upserts rows"| node_db
node_user -->|"searches locally"| node_local
node_parquet -->|"provides vectors"| node_local
node_local -->|"embeds query"| node_gemini
node_user -->|"searches hosted"| node_query
node_query -->|"embeds query"| node_gemini
node_query -->|"calls RPC"| node_db
node_db -->|"executes"| node_rpc

click node_csv "https://github.com/vinita-byte/rag-mvp/blob/main/ad_copy_dataset.csv"
click node_embed "https://github.com/vinita-byte/rag-mvp/blob/main/embed_ads.py"
click node_parquet "https://github.com/vinita-byte/rag-mvp/blob/main/embeddings.parquet"
click node_local "https://github.com/vinita-byte/rag-mvp/blob/main/embed_ads.py"
click node_push "https://github.com/vinita-byte/rag-mvp/blob/main/push_to_supabase.py"
click node_query "https://github.com/vinita-byte/rag-mvp/blob/main/push_to_supabase.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_csv,node_embed,node_parquet,node_user toneBlue
class node_local,node_push,node_query,node_db toneAmber
class node_gemini,node_rpc toneIndigo
```

## Components

### Embedding preparation

- [Ad copy CSV](https://github.com/vinita-byte/rag-mvp/blob/main/ad_copy_dataset.csv): `ad_copy_dataset.csv`
- [Embedding builder](https://github.com/vinita-byte/rag-mvp/blob/main/embed_ads.py): `embed_ads.py`
- [Embedding Parquet](https://github.com/vinita-byte/rag-mvp/blob/main/embeddings.parquet): `embeddings.parquet`

### Search and storage

- [Local semantic search](https://github.com/vinita-byte/rag-mvp/blob/main/embed_ads.py): `embed_ads.py`
- [Supabase uploader](https://github.com/vinita-byte/rag-mvp/blob/main/push_to_supabase.py): `push_to_supabase.py`
- [Hosted semantic search](https://github.com/vinita-byte/rag-mvp/blob/main/push_to_supabase.py): `push_to_supabase.py`

### Other components

- **User**
- **Gemini embeddings**
- **Supabase pgvector**
- **match_ads RPC**

## Connections

- User → Embedding builder: builds embeddings (evidence: `README.md`)
- Ad copy CSV → Embedding builder: provides rows (evidence: `README.md`)
- Embedding builder → Gemini embeddings: requests embeddings (evidence: `embed_ads.py`)
- Embedding builder → Embedding Parquet: writes vectors (evidence: `README.md`)
- User → Supabase uploader: uploads dataset (evidence: `README.md`)
- Embedding Parquet → Supabase uploader: provides vectors (evidence: `push_to_supabase.py`)
- Supabase uploader → Supabase pgvector: upserts rows (evidence: `push_to_supabase.py`)
- User → Local semantic search: searches locally (evidence: `README.md`)
- Embedding Parquet → Local semantic search: provides vectors (evidence: `embed_ads.py`)
- Local semantic search → Gemini embeddings: embeds query (evidence: `embed_ads.py`)
- User → Hosted semantic search: searches hosted (evidence: `README.md`)
- Hosted semantic search → Gemini embeddings: embeds query (evidence: `push_to_supabase.py`)
- Hosted semantic search → Supabase pgvector: calls RPC (evidence: `push_to_supabase.py`)
- Supabase pgvector → match_ads RPC: executes (evidence: `README.md`)
