# jeyaharinishree-ops/faq--chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/jeyaharinishree-ops/faq--chatbot
- Repository: https://github.com/jeyaharinishree-ops/faq--chatbot

## Overview

This is a Flask FAQ chatbot. A user asks a question in the browser; the chat UI sends it to Flask, which preprocesses it, compares its TF-IDF representation with FAQ questions, applies category keyword boosts and a similarity threshold, then returns an answer or fallback. The UI displays the response and match metadata. The README also documents suggested questions and an endpoint to list FAQs. The inspected source confirms the backend flow and chat request; HTML and styling were not sampled, so their internal details are not expanded.

Main entry points: [`app.py`](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.py) (Chat endpoint), [`script.js`](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/script.js) (Chat UI), [`faq_data.json`](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/faq_data.json) (FAQ entries), [`index.html`](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/index.html) (Suggested questions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Chat interface"]
  node_chat_ui["Chat UI<br/>[script.js]"]
  node_suggestions["Suggested questions<br/>[index.html]"]
  node_page["Chat page<br/>[index.html]"]
end

subgraph group_backend["FAQ service"]
  node_flask["Flask routes<br/>[app.py]"]
  node_chat_api["Chat endpoint<br/>[app.py]"]
  node_faq_api["FAQ list endpoint<br/>[app.py]"]
  node_faq_data[("FAQ entries<br/>[faq_data.json]")]
end

subgraph group_matching["FAQ matching"]
  node_preprocess["Preprocessing<br/>[app.py]"]
  node_vectorize["TF-IDF vectorization<br/>[app.py]"]
  node_match["Similarity matching<br/>[app.py]"]
  node_threshold["Threshold and fallback<br/>[app.py]"]
end

node_user(("User"))

node_user -->|"asks"| node_chat_ui
node_suggestions -.->|"fills input"| node_chat_ui
node_chat_ui -->|"POSTs question"| node_chat_api
node_flask -->|"serves"| node_page
node_flask -->|"routes to"| node_chat_api
node_flask -->|"routes to"| node_faq_api
node_chat_api -->|"preprocesses"| node_preprocess
node_faq_data -->|"supplies questions"| node_vectorize
node_preprocess -->|"transforms text"| node_vectorize
node_vectorize -->|"provides vectors"| node_match
node_chat_api -->|"calls matcher"| node_match
node_match -->|"scores candidates"| node_threshold
node_threshold -->|"selects answer"| node_faq_data
node_faq_api -->|"returns entries"| node_faq_data
node_chat_api -->|"returns response"| node_chat_ui

click node_chat_ui "https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/script.js"
click node_suggestions "https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/index.html"
click node_page "https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/index.html"
click node_flask "https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.py"
click node_chat_api "https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.py"
click node_faq_api "https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.py"
click node_faq_data "https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/faq_data.json"
click node_preprocess "https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.py"
click node_vectorize "https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.py"
click node_match "https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.py"
click node_threshold "https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.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_suggestions,node_page,node_user toneBlue
class node_flask,node_chat_api,node_faq_api,node_faq_data toneAmber
class node_preprocess,node_vectorize,node_match,node_threshold toneMint
```

## Components

### Chat interface

- [Chat UI](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/script.js): `script.js`
- [Suggested questions](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/index.html): `index.html`
- [Chat page](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/index.html): `index.html`

### FAQ service

- [Flask routes](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.py): `app.py`
- [Chat endpoint](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.py): `app.py`
- [FAQ list endpoint](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.py): `app.py`
- [FAQ entries](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/faq_data.json): `faq_data.json`

### FAQ matching

- [Preprocessing](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.py): `app.py`
- [TF-IDF vectorization](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.py): `app.py`
- [Similarity matching](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.py): `app.py`
- [Threshold and fallback](https://github.com/jeyaharinishree-ops/faq--chatbot/blob/main/app.py): `app.py`

### Other components

- **User**

## Connections

- User → Chat UI: asks (evidence: `README.md`)
- Suggested questions → Chat UI: fills input (evidence: `README.md`)
- Chat UI → Chat endpoint: POSTs question (evidence: `script.js`)
- Flask routes → Chat page: serves (evidence: `app.py`)
- Flask routes → Chat endpoint: routes to (evidence: `app.py`)
- Flask routes → FAQ list endpoint: routes to (evidence: `app.py`)
- Chat endpoint → Preprocessing: preprocesses (evidence: `app.py`)
- FAQ entries → TF-IDF vectorization: supplies questions (evidence: `app.py`)
- Preprocessing → TF-IDF vectorization: transforms text (evidence: `app.py`)
- TF-IDF vectorization → Similarity matching: provides vectors (evidence: `app.py`)
- Chat endpoint → Similarity matching: calls matcher (evidence: `app.py`)
- Similarity matching → Threshold and fallback: scores candidates (evidence: `app.py`)
- Threshold and fallback → FAQ entries: selects answer (evidence: `app.py`)
- FAQ list endpoint → FAQ entries: returns entries (evidence: `app.py`)
- Chat endpoint → Chat UI: returns response (evidence: `script.js`)
