# haffi24/181_chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/haffi24/181_chatbot
- Repository: https://github.com/haffi24/181_chatbot

## Overview

This is a small browser-based chat bot: the user submits a message, the page retains conversation history and posts it to the Express endpoint, which requests a streamed completion from OpenRouter and relays tokens back for display. The browser also supports clearing the session and shows busy/error states. The README identifies the deployed chat site but documents no other product capabilities. The map is based on the sampled client and server sources; HTML and styling details were not inspected.

Main entry points: [`public/script.js`](https://github.com/haffi24/181_chatbot/blob/main/public/script.js) (Chat interaction), [`index.js`](https://github.com/haffi24/181_chatbot/blob/main/index.js) (Express app), [`public/index.html`](https://github.com/haffi24/181_chatbot/blob/main/public/index.html) (Chat page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Chat interface"]
  node_page["Chat page<br/>[index.html]"]
  node_client["Chat interaction<br/>[script.js]"]
end

subgraph group_server["Chat service"]
  node_server_app["Express app<br/>[index.js]"]
end

node_user(("Chat user"))
node_openrouter{{"OpenRouter API"}}

node_user -.->|"opens"| node_page
node_page -.->|"loads"| node_client
node_user -->|"submits"| node_client
node_client -->|"posts messages"| node_server_app
node_server_app -->|"requests completion"| node_openrouter
node_server_app -->|"streams tokens"| node_client
node_client -->|"renders reply"| node_user

click node_page "https://github.com/haffi24/181_chatbot/blob/main/public/index.html"
click node_client "https://github.com/haffi24/181_chatbot/blob/main/public/script.js"
click node_server_app "https://github.com/haffi24/181_chatbot/blob/main/index.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_page,node_client,node_user toneBlue
class node_server_app toneAmber
class node_openrouter toneMint
```

## Components

### Chat interface

- [Chat page](https://github.com/haffi24/181_chatbot/blob/main/public/index.html): `public/index.html`
- [Chat interaction](https://github.com/haffi24/181_chatbot/blob/main/public/script.js): `public/script.js`

### Chat service

- [Express app](https://github.com/haffi24/181_chatbot/blob/main/index.js): `index.js`

### Other components

- **Chat user**
- **OpenRouter API**

## Connections

- Chat user → Chat page: opens (evidence: `README.md`)
- Chat page → Chat interaction: loads
- Chat user → Chat interaction: submits (evidence: `public/script.js`)
- Chat interaction → Express app: posts messages (evidence: `public/script.js`)
- Express app → OpenRouter API: requests completion (evidence: `index.js`)
- Express app → Chat interaction: streams tokens (evidence: `index.js`)
- Chat interaction → Chat user: renders reply (evidence: `public/script.js`)
