# mohansai5942/brandique-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/mohansai5942/brandique-chatbot
- Repository: https://github.com/mohansai5942/brandique-chatbot

## Overview

BrandiQue ChatBot is a browser-based customer-support assistant. A visitor sends a message through the chat UI; the server uses conversation context and built-in business answers, optionally consults Google Sheets for missing facts, and generates a response through an AI provider when needed. The README documents OpenRouter; sampled server code also exposes Gemini support. The server excerpts omit parts of the request orchestration, so uncertain internal call links are left out.

Main entry points: [`server.js`](https://github.com/mohansai5942/brandique-chatbot/blob/main/server.js) (Chat endpoint), [`public/app.js`](https://github.com/mohansai5942/brandique-chatbot/blob/main/public/app.js) (Chat client logic), [`public/index.html`](https://github.com/mohansai5942/brandique-chatbot/blob/main/public/index.html) (Chat interface), [`google-apps-script/Code.gs`](https://github.com/mohansai5942/brandique-chatbot/blob/main/google-apps-script/Code.gs) (Sheets script)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat client"]
  node_chat_ui["Chat interface<br/>[index.html]"]
  node_chat_client["Chat client logic<br/>[app.js]"]
  node_history[("Browser history<br/>[app.js]")]
end

subgraph group_runtime["Chat runtime"]
  node_chat_server["HTTP server<br/>[server.js]"]
  node_chat_api["Chat endpoint<br/>[server.js]"]
  node_health_api["Health endpoint<br/>[server.js]"]
end

subgraph group_knowledge["Business knowledge"]
  node_conversation_memory["Conversation memory<br/>[server.js]"]
  node_built_in_answers["Built-in answers<br/>[server.js]"]
  node_sheet_lookup["Sheets lookup<br/>[server.js]"]
  node_sheet_script["Sheets script<br/>[Code.gs]"]
end

subgraph group_integrations["External integrations"]
  node_openrouter["OpenRouter"]
  node_gemini["Gemini"]
  node_google_sheets[("Google Sheets")]
end

node_visitor(("Visitor"))

node_visitor -->|"uses"| node_chat_ui
node_chat_ui -->|"submits messages"| node_chat_client
node_chat_client -->|"reads and writes"| node_history
node_chat_client -->|"posts conversation"| node_chat_api
node_chat_server -->|"serves"| node_chat_api
node_chat_server -->|"serves"| node_health_api
node_chat_api -->|"extracts context"| node_conversation_memory
node_chat_api -->|"checks facts"| node_built_in_answers
node_chat_api -.->|"queries if needed"| node_sheet_lookup
node_sheet_lookup -.->|"fetches knowledge"| node_google_sheets
node_google_sheets -.->|"serves queries"| node_sheet_script
node_chat_api -->|"requests generation"| node_openrouter
node_chat_api -.->|"requests generation"| node_gemini
node_chat_api -->|"returns reply"| node_chat_client
node_chat_client -->|"renders reply"| node_chat_ui

click node_chat_ui "https://github.com/mohansai5942/brandique-chatbot/blob/main/public/index.html"
click node_chat_client "https://github.com/mohansai5942/brandique-chatbot/blob/main/public/app.js"
click node_history "https://github.com/mohansai5942/brandique-chatbot/blob/main/public/app.js"
click node_chat_server "https://github.com/mohansai5942/brandique-chatbot/blob/main/server.js"
click node_chat_api "https://github.com/mohansai5942/brandique-chatbot/blob/main/server.js"
click node_health_api "https://github.com/mohansai5942/brandique-chatbot/blob/main/server.js"
click node_conversation_memory "https://github.com/mohansai5942/brandique-chatbot/blob/main/server.js"
click node_built_in_answers "https://github.com/mohansai5942/brandique-chatbot/blob/main/server.js"
click node_sheet_lookup "https://github.com/mohansai5942/brandique-chatbot/blob/main/server.js"
click node_sheet_script "https://github.com/mohansai5942/brandique-chatbot/blob/main/google-apps-script/Code.gs"

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_chat_client,node_history toneBlue
class node_chat_server,node_chat_api,node_health_api toneAmber
class node_conversation_memory,node_built_in_answers,node_sheet_lookup,node_sheet_script toneMint
class node_openrouter,node_gemini,node_google_sheets toneRose
class node_visitor toneIndigo
```

## Components

### Chat client

- [Chat interface](https://github.com/mohansai5942/brandique-chatbot/blob/main/public/index.html): `public/index.html`
- [Chat client logic](https://github.com/mohansai5942/brandique-chatbot/blob/main/public/app.js): `public/app.js`
- [Browser history](https://github.com/mohansai5942/brandique-chatbot/blob/main/public/app.js): `public/app.js`

### Chat runtime

- [HTTP server](https://github.com/mohansai5942/brandique-chatbot/blob/main/server.js): `server.js`
- [Chat endpoint](https://github.com/mohansai5942/brandique-chatbot/blob/main/server.js): `server.js`
- [Health endpoint](https://github.com/mohansai5942/brandique-chatbot/blob/main/server.js): `server.js`

### Business knowledge

- [Conversation memory](https://github.com/mohansai5942/brandique-chatbot/blob/main/server.js): `server.js`
- [Built-in answers](https://github.com/mohansai5942/brandique-chatbot/blob/main/server.js): `server.js`
- [Sheets lookup](https://github.com/mohansai5942/brandique-chatbot/blob/main/server.js): `server.js`
- [Sheets script](https://github.com/mohansai5942/brandique-chatbot/blob/main/google-apps-script/Code.gs): `google-apps-script/Code.gs`

### External integrations

- **OpenRouter**
- **Gemini**
- **Google Sheets**

### Other components

- **Visitor**

## Connections

- Visitor → Chat interface: uses
- Chat interface → Chat client logic: submits messages
- Chat client logic → Browser history: reads and writes
- Chat client logic → Chat endpoint: posts conversation
- HTTP server → Chat endpoint: serves
- HTTP server → Health endpoint: serves
- Chat endpoint → Conversation memory: extracts context
- Chat endpoint → Built-in answers: checks facts
- Chat endpoint → Sheets lookup: queries if needed
- Sheets lookup → Google Sheets: fetches knowledge
- Google Sheets → Sheets script: serves queries
- Chat endpoint → OpenRouter: requests generation
- Chat endpoint → Gemini: requests generation
- Chat endpoint → Chat client logic: returns reply
- Chat client logic → Chat interface: renders reply
