# ameygupta25/rmp-rag architecture

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

- Interactive diagram: https://gitdiagram.com/ameygupta25/rmp-rag
- Repository: https://github.com/ameygupta25/rmp-rag

## Overview

UCSD ProfAI combines a weekly professor/review data pipeline with a student-facing search and cited-answer app. Students ask questions or browse professor and course data; the frontend calls the API, which retrieves and reranks review evidence, optionally runs guarded SQL for ranking questions, and generates cited answers. The pipeline extracts and validates source data, models it into serving tables, and separately embeds reviews and enriches them with LLM-derived attributes and summaries. Several backend and frontend details are unsampled; those relationships are shown only where the README or excerpts support them.

Main entry points: [`frontend/src/main.jsx`](https://github.com/ameygupta25/rmp-rag/blob/main/frontend/src/main.jsx) (React app), [`api/main.py`](https://github.com/ameygupta25/rmp-rag/blob/main/api/main.py) (FastAPI service), [`frontend/src/api.js`](https://github.com/ameygupta25/rmp-rag/blob/main/frontend/src/api.js) (API client), [`api/router.py`](https://github.com/ameygupta25/rmp-rag/blob/main/api/router.py) (Guarded SQL router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Student app"]
  node_frontend["React app<br/>[main.jsx]"]
  node_ask["Ask page<br/>[Ask.jsx]"]
  node_browse["Browse pages<br/>[Search.jsx]"]
  node_profiles["Profile and compare<br/>[Professor.jsx]"]
  node_shortlist["Shortlist state<br/>[shortlist.jsx]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_serve["API and retrieval"]
  node_api["FastAPI service<br/>[main.py]"]
  node_sql_router["Guarded SQL router<br/>[router.py]"]
  node_retrieval["Review retrieval<br/>[vectorstore.py]"]
  node_pinecone[("Pinecone index")]
end

subgraph group_data["Data pipeline"]
  node_extract["Review extraction<br/>[extract.py]"]
  node_validation["Record validation<br/>[validate.py]"]
  node_raw[("S3 raw layer")]
  node_embedding["Review embedding<br/>[embed.py]"]
end

subgraph group_warehouse["Warehouse"]
  node_transform["dbt models"]
  node_serving[("Serving DuckDB")]
end

subgraph group_enrich["LLM enrichment"]
  node_attributes["Review attributes<br/>[attributes.py]"]
  node_summaries["Professor summaries<br/>[summaries.py]"]
  node_backfill["Backfill runner<br/>[backfill.py]"]
end

node_student(("Student"))
node_groq{{"Groq LLM"}}
node_rmp{{"Rate My Professor"}}

node_student -->|"uses"| node_frontend
node_frontend -->|"routes to"| node_ask
node_frontend -->|"routes to"| node_browse
node_frontend -->|"routes to"| node_profiles
node_frontend -->|"provides state"| node_shortlist
node_ask -->|"requests"| node_api_client
node_browse -->|"requests"| node_api_client
node_profiles -->|"requests"| node_api_client
node_api_client -->|"calls HTTP API"| node_api
node_api -->|"retrieves reviews"| node_retrieval
node_retrieval -->|"searches and reranks"| node_pinecone
node_api -->|"generates cited answer"| node_groq
node_api -->|"routes rankings"| node_sql_router
node_sql_router -->|"requests SQL"| node_groq
node_sql_router -->|"queries guarded tables"| node_serving
node_groq -->|"returns answer"| node_api
node_rmp -->|"provides review data"| node_extract
node_extract -->|"validates records"| node_validation
node_validation -->|"lands accepted data"| node_raw
node_raw -->|"models raw data"| node_transform
node_transform -->|"publishes tables"| node_serving
node_raw -->|"supplies reviews"| node_embedding
node_embedding -->|"writes embeddings"| node_pinecone
node_backfill -->|"runs extraction"| node_attributes
node_backfill -->|"runs summaries"| node_summaries
node_attributes -->|"extracts fields"| node_groq
node_summaries -->|"generates summaries"| node_groq
node_attributes -->|"writes enriched data"| node_raw
node_summaries -->|"writes summaries"| node_raw

click node_frontend "https://github.com/ameygupta25/rmp-rag/blob/main/frontend/src/main.jsx"
click node_ask "https://github.com/ameygupta25/rmp-rag/blob/main/frontend/src/pages/Ask.jsx"
click node_browse "https://github.com/ameygupta25/rmp-rag/blob/main/frontend/src/pages/Search.jsx"
click node_profiles "https://github.com/ameygupta25/rmp-rag/blob/main/frontend/src/pages/Professor.jsx"
click node_shortlist "https://github.com/ameygupta25/rmp-rag/blob/main/frontend/src/shortlist.jsx"
click node_api_client "https://github.com/ameygupta25/rmp-rag/blob/main/frontend/src/api.js"
click node_api "https://github.com/ameygupta25/rmp-rag/blob/main/api/main.py"
click node_sql_router "https://github.com/ameygupta25/rmp-rag/blob/main/api/router.py"
click node_retrieval "https://github.com/ameygupta25/rmp-rag/blob/main/data/vectorstore.py"
click node_extract "https://github.com/ameygupta25/rmp-rag/blob/main/pipeline/extract.py"
click node_validation "https://github.com/ameygupta25/rmp-rag/blob/main/pipeline/validate.py"
click node_transform "https://github.com/ameygupta25/rmp-rag/tree/main/transform/models"
click node_serving "https://github.com/ameygupta25/rmp-rag/tree/main/data"
click node_embedding "https://github.com/ameygupta25/rmp-rag/blob/main/pipeline/embed.py"
click node_attributes "https://github.com/ameygupta25/rmp-rag/blob/main/pipeline/attributes.py"
click node_summaries "https://github.com/ameygupta25/rmp-rag/blob/main/pipeline/summaries.py"
click node_backfill "https://github.com/ameygupta25/rmp-rag/blob/main/pipeline/backfill.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_frontend,node_ask,node_browse,node_profiles,node_shortlist,node_api_client toneBlue
class node_api,node_sql_router,node_retrieval,node_pinecone toneAmber
class node_extract,node_validation,node_raw,node_embedding toneMint
class node_transform,node_serving toneRose
class node_attributes,node_summaries,node_backfill,node_student,node_groq,node_rmp toneIndigo
```

## Components

### Student app

- [React app](https://github.com/ameygupta25/rmp-rag/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`
- [Ask page](https://github.com/ameygupta25/rmp-rag/blob/main/frontend/src/pages/Ask.jsx): `frontend/src/pages/Ask.jsx`
- [Browse pages](https://github.com/ameygupta25/rmp-rag/blob/main/frontend/src/pages/Search.jsx): `frontend/src/pages/Search.jsx`
- [Profile and compare](https://github.com/ameygupta25/rmp-rag/blob/main/frontend/src/pages/Professor.jsx): `frontend/src/pages/Professor.jsx`
- [Shortlist state](https://github.com/ameygupta25/rmp-rag/blob/main/frontend/src/shortlist.jsx): `frontend/src/shortlist.jsx`
- [API client](https://github.com/ameygupta25/rmp-rag/blob/main/frontend/src/api.js): `frontend/src/api.js`

### API and retrieval

- [FastAPI service](https://github.com/ameygupta25/rmp-rag/blob/main/api/main.py): `api/main.py`
- [Guarded SQL router](https://github.com/ameygupta25/rmp-rag/blob/main/api/router.py): `api/router.py`
- [Review retrieval](https://github.com/ameygupta25/rmp-rag/blob/main/data/vectorstore.py): `data/vectorstore.py`
- **Pinecone index**

### Data pipeline

- [Review extraction](https://github.com/ameygupta25/rmp-rag/blob/main/pipeline/extract.py): `pipeline/extract.py`
- [Record validation](https://github.com/ameygupta25/rmp-rag/blob/main/pipeline/validate.py): `pipeline/validate.py`
- **S3 raw layer**
- [Review embedding](https://github.com/ameygupta25/rmp-rag/blob/main/pipeline/embed.py): `pipeline/embed.py`

### Warehouse

- [dbt models](https://github.com/ameygupta25/rmp-rag/tree/main/transform/models): `transform/models`
- [Serving DuckDB](https://github.com/ameygupta25/rmp-rag/tree/main/data): `data`

### LLM enrichment

- [Review attributes](https://github.com/ameygupta25/rmp-rag/blob/main/pipeline/attributes.py): `pipeline/attributes.py`
- [Professor summaries](https://github.com/ameygupta25/rmp-rag/blob/main/pipeline/summaries.py): `pipeline/summaries.py`
- [Backfill runner](https://github.com/ameygupta25/rmp-rag/blob/main/pipeline/backfill.py): `pipeline/backfill.py`

### Other components

- **Student**
- **Groq LLM**
- **Rate My Professor**

## Connections

- Student → React app: uses (evidence: `README.md`)
- React app → Ask page: routes to (evidence: `frontend/src/main.jsx`)
- React app → Browse pages: routes to (evidence: `frontend/src/main.jsx`)
- React app → Profile and compare: routes to (evidence: `frontend/src/main.jsx`)
- React app → Shortlist state: provides state (evidence: `frontend/src/main.jsx`)
- Ask page → API client: requests (evidence: `frontend/src/pages/Ask.jsx`)
- Browse pages → API client: requests (evidence: `frontend/src/pages/Search.jsx`)
- Profile and compare → API client: requests (evidence: `frontend/src/pages/Professor.jsx`)
- API client → FastAPI service: calls HTTP API (evidence: `README.md`)
- FastAPI service → Review retrieval: retrieves reviews (evidence: `README.md`)
- Review retrieval → Pinecone index: searches and reranks (evidence: `README.md`)
- FastAPI service → Groq LLM: generates cited answer (evidence: `README.md`)
- FastAPI service → Guarded SQL router: routes rankings (evidence: `README.md`)
- Guarded SQL router → Groq LLM: requests SQL (evidence: `api/router.py`)
- Guarded SQL router → Serving DuckDB: queries guarded tables (evidence: `README.md`)
- Groq LLM → FastAPI service: returns answer (evidence: `README.md`)
- Rate My Professor → Review extraction: provides review data (evidence: `README.md`)
- Review extraction → Record validation: validates records (evidence: `pipeline/extract.py`)
- Record validation → S3 raw layer: lands accepted data (evidence: `README.md`)
- S3 raw layer → dbt models: models raw data (evidence: `README.md`)
- dbt models → Serving DuckDB: publishes tables (evidence: `README.md`)
- S3 raw layer → Review embedding: supplies reviews (evidence: `README.md`)
- Review embedding → Pinecone index: writes embeddings (evidence: `README.md`)
- Backfill runner → Review attributes: runs extraction (evidence: `pipeline/backfill.py`)
- Backfill runner → Professor summaries: runs summaries (evidence: `pipeline/backfill.py`)
- Review attributes → Groq LLM: extracts fields (evidence: `pipeline/attributes.py`)
- Professor summaries → Groq LLM: generates summaries (evidence: `README.md`)
- Review attributes → S3 raw layer: writes enriched data (evidence: `pipeline/attributes.py`)
- Professor summaries → S3 raw layer: writes summaries (evidence: `pipeline/summaries.py`)
