# r-g-made/chatsite architecture

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

- Interactive diagram: https://gitdiagram.com/r-g-made/chatsite
- Repository: https://github.com/r-g-made/chatsite

## Overview

ЧатТоэ is a web assistant for finding answers in a seeded FAQ collection. A user submits a question in the Vue chat; the frontend posts it to the FastAPI chat endpoint, which searches FAQ candidates, ranks them, and returns up to three results for the interface to display or offer as suggestions. The backend also exposes an FAQ-list endpoint and initializes its SQLite and full-text search structures at startup. The excerpts show these runtime boundaries; frontend behavior beyond the sampled chat flow and any deployment wiring is not inferred.

Main entry points: [`backend/app.py`](https://github.com/r-g-made/chatsite/blob/main/backend/app.py) (Chat and FAQ API), [`backend/repository.py`](https://github.com/r-g-made/chatsite/blob/main/backend/repository.py) (FAQ repository), [`backend/search.py`](https://github.com/r-g-made/chatsite/blob/main/backend/search.py) (Search service), [`backend/db.py`](https://github.com/r-g-made/chatsite/blob/main/backend/db.py) (Full-text index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat client"]
  node_chat_ui["Chat interface<br/>[App.vue]"]
  node_vue_entry["Vue entry<br/>[main.js]"]
end

subgraph group_api["API and startup"]
  node_chat_api["Chat and FAQ API<br/>[app.py]"]
  node_api_schemas["API schemas<br/>[schemas.py]"]
  node_db_setup["DB setup<br/>[db.py]"]
end

subgraph group_search["FAQ search"]
  node_search_service["Search service<br/>[search.py]"]
  node_fuzzy_ranker["Fuzzy ranker<br/>[search.py]"]
  node_fts_manager["Full-text index<br/>[db.py]"]
end

subgraph group_storage["FAQ storage"]
  node_seeder["FAQ seeder<br/>[repository.py]"]
  node_seed_faq["FAQ seed data<br/>[seed_faq.json]"]
  node_faq_repository["FAQ repository<br/>[repository.py]"]
  node_faq_model["FAQ model<br/>[models.py]"]
  node_sqlite_db[("SQLite database<br/>[db.py]")]
end

node_visitor(("Chat user"))

node_visitor -->|"asks question"| node_chat_ui
node_vue_entry -->|"mounts"| node_chat_ui
node_chat_ui -->|"posts question"| node_chat_api
node_chat_api -->|"validates and shapes"| node_api_schemas
node_chat_api -->|"searches FAQs"| node_search_service
node_chat_api -->|"lists FAQs"| node_faq_repository
node_chat_api -->|"initializes database"| node_db_setup
node_chat_api -->|"seeds on startup"| node_seeder
node_seeder -->|"reads seed data"| node_seed_faq
node_search_service -->|"scores candidates"| node_fuzzy_ranker
node_search_service -->|"loads candidates"| node_faq_repository
node_search_service -->|"gets ranked IDs"| node_fts_manager
node_faq_repository -->|"queries and creates"| node_faq_model
node_faq_repository -->|"gets candidate IDs"| node_fts_manager
node_db_setup -->|"creates tables for"| node_faq_model
node_db_setup -->|"sets up index"| node_fts_manager
node_fts_manager -->|"queries and indexes"| node_sqlite_db
node_faq_repository -->|"reads and writes"| node_sqlite_db

click node_chat_ui "https://github.com/r-g-made/chatsite/blob/main/frontend/src/App.vue"
click node_vue_entry "https://github.com/r-g-made/chatsite/blob/main/frontend/src/main.js"
click node_chat_api "https://github.com/r-g-made/chatsite/blob/main/backend/app.py"
click node_api_schemas "https://github.com/r-g-made/chatsite/blob/main/backend/schemas.py"
click node_db_setup "https://github.com/r-g-made/chatsite/blob/main/backend/db.py"
click node_seeder "https://github.com/r-g-made/chatsite/blob/main/backend/repository.py"
click node_seed_faq "https://github.com/r-g-made/chatsite/blob/main/backend/seed_faq.json"
click node_search_service "https://github.com/r-g-made/chatsite/blob/main/backend/search.py"
click node_fuzzy_ranker "https://github.com/r-g-made/chatsite/blob/main/backend/search.py"
click node_faq_repository "https://github.com/r-g-made/chatsite/blob/main/backend/repository.py"
click node_fts_manager "https://github.com/r-g-made/chatsite/blob/main/backend/db.py"
click node_faq_model "https://github.com/r-g-made/chatsite/blob/main/backend/models.py"
click node_sqlite_db "https://github.com/r-g-made/chatsite/blob/main/backend/db.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_chat_ui,node_vue_entry,node_visitor toneBlue
class node_chat_api,node_api_schemas,node_db_setup toneAmber
class node_search_service,node_fuzzy_ranker,node_fts_manager toneMint
class node_seeder,node_seed_faq,node_faq_repository,node_faq_model,node_sqlite_db toneRose
```

## Components

### Chat client

- [Chat interface](https://github.com/r-g-made/chatsite/blob/main/frontend/src/App.vue): `frontend/src/App.vue`
- [Vue entry](https://github.com/r-g-made/chatsite/blob/main/frontend/src/main.js): `frontend/src/main.js`

### API and startup

- [Chat and FAQ API](https://github.com/r-g-made/chatsite/blob/main/backend/app.py): `backend/app.py`
- [API schemas](https://github.com/r-g-made/chatsite/blob/main/backend/schemas.py): `backend/schemas.py`
- [DB setup](https://github.com/r-g-made/chatsite/blob/main/backend/db.py): `backend/db.py`

### FAQ search

- [Search service](https://github.com/r-g-made/chatsite/blob/main/backend/search.py): `backend/search.py`
- [Fuzzy ranker](https://github.com/r-g-made/chatsite/blob/main/backend/search.py): `backend/search.py`
- [Full-text index](https://github.com/r-g-made/chatsite/blob/main/backend/db.py): `backend/db.py`

### FAQ storage

- [FAQ seeder](https://github.com/r-g-made/chatsite/blob/main/backend/repository.py): `backend/repository.py`
- [FAQ seed data](https://github.com/r-g-made/chatsite/blob/main/backend/seed_faq.json): `backend/seed_faq.json`
- [FAQ repository](https://github.com/r-g-made/chatsite/blob/main/backend/repository.py): `backend/repository.py`
- [FAQ model](https://github.com/r-g-made/chatsite/blob/main/backend/models.py): `backend/models.py`
- [SQLite database](https://github.com/r-g-made/chatsite/blob/main/backend/db.py): `backend/db.py`

### Other components

- **Chat user**

## Connections

- Chat user → Chat interface: asks question (evidence: `frontend/src/App.vue`)
- Vue entry → Chat interface: mounts (evidence: `frontend/src/main.js`)
- Chat interface → Chat and FAQ API: posts question (evidence: `frontend/src/App.vue`)
- Chat and FAQ API → API schemas: validates and shapes (evidence: `backend/app.py`)
- Chat and FAQ API → Search service: searches FAQs (evidence: `backend/app.py`)
- Chat and FAQ API → FAQ repository: lists FAQs (evidence: `backend/app.py`)
- Chat and FAQ API → DB setup: initializes database (evidence: `backend/app.py`)
- Chat and FAQ API → FAQ seeder: seeds on startup (evidence: `backend/app.py`)
- FAQ seeder → FAQ seed data: reads seed data (evidence: `backend/repository.py`)
- Search service → Fuzzy ranker: scores candidates (evidence: `backend/search.py`)
- Search service → FAQ repository: loads candidates (evidence: `backend/search.py`)
- Search service → Full-text index: gets ranked IDs (evidence: `backend/search.py`)
- FAQ repository → FAQ model: queries and creates (evidence: `backend/repository.py`)
- FAQ repository → Full-text index: gets candidate IDs (evidence: `backend/repository.py`)
- DB setup → FAQ model: creates tables for (evidence: `backend/db.py`)
- DB setup → Full-text index: sets up index (evidence: `backend/db.py`)
- Full-text index → SQLite database: queries and indexes (evidence: `backend/db.py`)
- FAQ repository → SQLite database: reads and writes (evidence: `backend/repository.py`)
