# abdurrahim2705/rag-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/abdurrahim2705/rag-chatbot
- Repository: https://github.com/abdurrahim2705/rag-chatbot

## Overview

Sunrise Learning Academy provides a student login API and a course-advisor chat API. Login checks credentials against PostgreSQL; chat retrieves catalog passages from Pinecone and sends them with the question to a Hugging Face model. A separate ingestion script reads the course catalog, embeds its paragraphs, and uploads them to Pinecone. The README is empty, so the map reflects the sampled source; external service relationships are shown where those calls are explicit.

Main entry points: [`rag.py`](https://github.com/abdurrahim2705/rag-chatbot/blob/main/rag.py) (Chat answer flow), [`ingest.py`](https://github.com/abdurrahim2705/rag-chatbot/blob/main/ingest.py) (Catalog ingestion), [`main.py`](https://github.com/abdurrahim2705/rag-chatbot/blob/main/main.py) (FastAPI endpoints), [`database.py`](https://github.com/abdurrahim2705/rag-chatbot/blob/main/database.py) (Login verification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_api_app["FastAPI endpoints<br/>[main.py]"]
  node_login_check["Login verification<br/>[database.py]"]
end

subgraph group_knowledge["Knowledge ingestion"]
  node_catalog_file["Course catalog<br/>[course_catalog.md]"]
  node_ingestion["Catalog ingestion<br/>[ingest.py]"]
end

subgraph group_chat["Chat retrieval"]
  node_chat_flow["Chat answer flow<br/>[rag.py]"]
end

subgraph group_services["External services"]
  node_postgres[("PostgreSQL")]
  node_embedder["SentenceTransformer"]
  node_pinecone[("Pinecone index")]
  node_hf_chat["Hugging Face inference"]
end

node_student(("Student"))

node_student -->|"sends requests"| node_api_app
node_api_app -->|"verifies login"| node_login_check
node_login_check -->|"queries students"| node_postgres
node_api_app -->|"gets answer"| node_chat_flow
node_ingestion -->|"reads catalog"| node_catalog_file
node_ingestion -->|"encodes paragraphs"| node_embedder
node_ingestion -->|"upserts vectors"| node_pinecone
node_chat_flow -->|"encodes question"| node_embedder
node_chat_flow -->|"queries matches"| node_pinecone
node_chat_flow -->|"requests answer"| node_hf_chat

click node_api_app "https://github.com/abdurrahim2705/rag-chatbot/blob/main/main.py"
click node_login_check "https://github.com/abdurrahim2705/rag-chatbot/blob/main/database.py"
click node_chat_flow "https://github.com/abdurrahim2705/rag-chatbot/blob/main/rag.py"
click node_catalog_file "https://github.com/abdurrahim2705/rag-chatbot/blob/main/course_catalog.md"
click node_ingestion "https://github.com/abdurrahim2705/rag-chatbot/blob/main/ingest.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_api_app,node_login_check toneBlue
class node_catalog_file,node_ingestion toneAmber
class node_chat_flow toneMint
class node_postgres,node_embedder,node_pinecone,node_hf_chat toneRose
class node_student toneIndigo
```

## Components

### API

- [FastAPI endpoints](https://github.com/abdurrahim2705/rag-chatbot/blob/main/main.py): `main.py`
- [Login verification](https://github.com/abdurrahim2705/rag-chatbot/blob/main/database.py): `database.py`

### Knowledge ingestion

- [Course catalog](https://github.com/abdurrahim2705/rag-chatbot/blob/main/course_catalog.md): `course_catalog.md`
- [Catalog ingestion](https://github.com/abdurrahim2705/rag-chatbot/blob/main/ingest.py): `ingest.py`

### Chat retrieval

- [Chat answer flow](https://github.com/abdurrahim2705/rag-chatbot/blob/main/rag.py): `rag.py`

### External services

- **PostgreSQL**
- **SentenceTransformer**
- **Pinecone index**
- **Hugging Face inference**

### Other components

- **Student**

## Connections

- Student → FastAPI endpoints: sends requests (evidence: `main.py`)
- FastAPI endpoints → Login verification: verifies login (evidence: `main.py`)
- Login verification → PostgreSQL: queries students (evidence: `database.py`)
- FastAPI endpoints → Chat answer flow: gets answer (evidence: `main.py`)
- Catalog ingestion → Course catalog: reads catalog (evidence: `ingest.py`)
- Catalog ingestion → SentenceTransformer: encodes paragraphs (evidence: `ingest.py`)
- Catalog ingestion → Pinecone index: upserts vectors (evidence: `ingest.py`)
- Chat answer flow → SentenceTransformer: encodes question (evidence: `rag.py`)
- Chat answer flow → Pinecone index: queries matches (evidence: `rag.py`)
- Chat answer flow → Hugging Face inference: requests answer (evidence: `rag.py`)
