# leosumanth3-source/swarnasky_chatbot architecture

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

## Overview

This repository implements a Swarnasky website chatbot backed by retrieval-augmented generation, with a separate crawler and document-indexing toolchain. The user workflow is browser question → FastAPI chat handler → retrieval → LLM answer → browser display. The crawler extracts website pages; validation, chunking, embedding, and indexing support preparing searchable content. The README is empty, and the excerpts do not show how the offline pipeline stages are orchestrated or connected, so those links are omitted. Dashed edges mark integrations whose exact call sites were not shown.

Main entry points: [`main.py`](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/main.py) (Chat API), [`frontend/app.js`](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/frontend/app.js) (Chat interface), [`crawler/crawler.py`](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/crawler/crawler.py) (Site crawler), [`pipelines/retreiver.py`](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/pipelines/retreiver.py) (Context retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_acquisition["Website acquisition"]
  node_crawler["Site crawler<br/>[crawler.py]"]
  node_extractor["Page extractor<br/>[extractor.py]"]
  node_docmodel["Document schema<br/>[models.py]"]
end

subgraph group_preparation["Index preparation"]
  node_validator["Document validation"]
  node_chunker["Text chunking<br/>[chunker.py]"]
  node_embedder["Local embeddings<br/>[embedder.py]"]
  node_indexer["Vector indexing<br/>[indexer.py]"]
end

subgraph group_chat["Chat services"]
  node_qdrant[("Qdrant store")]
  node_api["Chat API<br/>[main.py]"]
  node_retriever["Context retrieval<br/>[retreiver.py]"]
  node_llmclient["Groq client<br/>[client.py]"]
end

subgraph group_interface["User interface"]
  node_frontend["Chat interface<br/>[app.js]"]
end

node_visitor(("Chat user"))
node_website["Swarnasky site"]
node_groq["Groq service"]

node_visitor -->|"asks"| node_frontend
node_frontend -->|"posts question"| node_api
node_api -->|"serves interface"| node_frontend
node_api -->|"retrieves context"| node_retriever
node_api -->|"generates answer"| node_llmclient
node_llmclient -->|"requests completion"| node_groq
node_retriever -.->|"queries vectors"| node_qdrant
node_crawler -->|"fetches pages"| node_website
node_crawler -->|"extracts pages"| node_extractor
node_validator -->|"validates against"| node_docmodel
node_indexer -->|"writes vectors"| node_qdrant
node_embedder -.->|"vectors eventually indexed"| node_qdrant

click node_crawler "https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/crawler/crawler.py"
click node_extractor "https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/crawler/extractor.py"
click node_docmodel "https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/crawler/models.py"
click node_validator "https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/pipelines/validate_documents.py"
click node_chunker "https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/pipelines/chunker.py"
click node_embedder "https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/pipelines/embedder.py"
click node_indexer "https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/pipelines/indexer.py"
click node_api "https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/main.py"
click node_retriever "https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/pipelines/retreiver.py"
click node_llmclient "https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/app/llm/client.py"
click node_frontend "https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/frontend/app.js"

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_crawler,node_extractor,node_docmodel,node_visitor toneBlue
class node_validator,node_chunker,node_embedder,node_indexer toneAmber
class node_qdrant,node_api,node_retriever,node_llmclient toneMint
class node_frontend toneRose
class node_website,node_groq toneIndigo
```

## Components

### Website acquisition

- [Site crawler](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/crawler/crawler.py): `crawler/crawler.py`
- [Page extractor](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/crawler/extractor.py): `crawler/extractor.py`
- [Document schema](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/crawler/models.py): `crawler/models.py`

### Index preparation

- [Document validation](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/pipelines/validate_documents.py): `pipelines/validate_documents.py`
- [Text chunking](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/pipelines/chunker.py): `pipelines/chunker.py`
- [Local embeddings](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/pipelines/embedder.py): `pipelines/embedder.py`
- [Vector indexing](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/pipelines/indexer.py): `pipelines/indexer.py`

### Chat services

- **Qdrant store**
- [Chat API](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/main.py): `main.py`
- [Context retrieval](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/pipelines/retreiver.py): `pipelines/retreiver.py`
- [Groq client](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/app/llm/client.py): `app/llm/client.py`

### User interface

- [Chat interface](https://github.com/leosumanth3-source/swarnasky_chatbot/blob/main/frontend/app.js): `frontend/app.js`

### Other components

- **Chat user**
- **Swarnasky site**
- **Groq service**

## Connections

- Chat user → Chat interface: asks (evidence: `frontend/app.js`)
- Chat interface → Chat API: posts question (evidence: `frontend/app.js`)
- Chat API → Chat interface: serves interface (evidence: `main.py`)
- Chat API → Context retrieval: retrieves context (evidence: `main.py`)
- Chat API → Groq client: generates answer (evidence: `main.py`)
- Groq client → Groq service: requests completion (evidence: `app/llm/client.py`)
- Context retrieval → Qdrant store: queries vectors
- Site crawler → Swarnasky site: fetches pages (evidence: `crawler/crawler.py`)
- Site crawler → Page extractor: extracts pages (evidence: `crawler/crawler.py`)
- Document validation → Document schema: validates against (evidence: `pipelines/validate_documents.py`)
- Vector indexing → Qdrant store: writes vectors (evidence: `pipelines/indexer.py`)
- Local embeddings → Qdrant store: vectors eventually indexed
