# didar-code/chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/didar-code/chatbot
- Repository: https://github.com/didar-code/chatbot

## Overview

This is a lightweight group-chat web app: users register, create or join groups, then exchange live messages and uploaded files. The browser loads chat history and shared files, sends chat events over Socket.IO, and uses HTTP for registration, group management, and uploads. The server persists users, groups, messages, and file metadata in JSON files. The sampled sources show these paths; other UI pages and data files are represented by their exact tree paths, but their contents were not inspected.

Main entry points: [`server.js`](https://github.com/didar-code/chatbot/blob/main/server.js) (HTTP and sockets), [`utils/jsonDB.js`](https://github.com/didar-code/chatbot/blob/main/utils/jsonDB.js) (JSON data access), [`js/chat.js`](https://github.com/didar-code/chatbot/blob/main/js/chat.js) (Chat interactions), [`public/chat.html`](https://github.com/didar-code/chatbot/blob/main/public/chat.html) (Chat page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat client"]
  node_home["Entry page<br/>[index.html]"]
  node_chatpage["Chat page<br/>[chat.html]"]
  node_chatui["Chat interactions<br/>[chat.js]"]
  node_styles["Chat styling<br/>[style.css]"]
end

subgraph group_server["Application server"]
  node_serverapp["HTTP and sockets<br/>[server.js]"]
  node_uploadstore["Uploaded files"]
end

subgraph group_storage["JSON storage"]
  node_db["JSON data access<br/>[jsonDB.js]"]
  node_users[("User records<br/>[users.json]")]
  node_groups[("Group records<br/>[groups.json]")]
  node_messages[("Message records<br/>[messages.json]")]
  node_filemeta[("File records<br/>[files.json]")]
end

node_visitor(("User"))

node_visitor -->|"opens"| node_home
node_visitor -->|"opens"| node_chatpage
node_home -.->|"loads page"| node_serverapp
node_chatpage -.->|"runs"| node_chatui
node_chatpage -.->|"uses styles"| node_styles
node_chatui -->|"sends events"| node_serverapp
node_serverapp -->|"calls"| node_db
node_serverapp -->|"stores uploads"| node_uploadstore
node_serverapp -->|"emits updates"| node_chatui
node_db -->|"reads/writes"| node_users
node_db -->|"reads/writes"| node_groups
node_db -->|"reads/writes"| node_messages
node_db -->|"reads/writes"| node_filemeta
node_chatui -->|"requests file list"| node_serverapp

click node_home "https://github.com/didar-code/chatbot/blob/main/public/index.html"
click node_chatpage "https://github.com/didar-code/chatbot/blob/main/public/chat.html"
click node_chatui "https://github.com/didar-code/chatbot/blob/main/js/chat.js"
click node_serverapp "https://github.com/didar-code/chatbot/blob/main/server.js"
click node_uploadstore "https://github.com/didar-code/chatbot/tree/main/public/uploads"
click node_db "https://github.com/didar-code/chatbot/blob/main/utils/jsonDB.js"
click node_users "https://github.com/didar-code/chatbot/blob/main/data/users.json"
click node_groups "https://github.com/didar-code/chatbot/blob/main/data/groups.json"
click node_messages "https://github.com/didar-code/chatbot/blob/main/data/messages.json"
click node_filemeta "https://github.com/didar-code/chatbot/blob/main/data/files.json"
click node_styles "https://github.com/didar-code/chatbot/blob/main/css/style.css"

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_home,node_chatpage,node_chatui,node_styles,node_visitor toneBlue
class node_serverapp,node_uploadstore toneAmber
class node_db,node_users,node_groups,node_messages,node_filemeta toneMint
```

## Components

### Chat client

- [Entry page](https://github.com/didar-code/chatbot/blob/main/public/index.html): `public/index.html`
- [Chat page](https://github.com/didar-code/chatbot/blob/main/public/chat.html): `public/chat.html`
- [Chat interactions](https://github.com/didar-code/chatbot/blob/main/js/chat.js): `js/chat.js`
- [Chat styling](https://github.com/didar-code/chatbot/blob/main/css/style.css): `css/style.css`

### Application server

- [HTTP and sockets](https://github.com/didar-code/chatbot/blob/main/server.js): `server.js`
- [Uploaded files](https://github.com/didar-code/chatbot/tree/main/public/uploads): `public/uploads`

### JSON storage

- [JSON data access](https://github.com/didar-code/chatbot/blob/main/utils/jsonDB.js): `utils/jsonDB.js`
- [User records](https://github.com/didar-code/chatbot/blob/main/data/users.json): `data/users.json`
- [Group records](https://github.com/didar-code/chatbot/blob/main/data/groups.json): `data/groups.json`
- [Message records](https://github.com/didar-code/chatbot/blob/main/data/messages.json): `data/messages.json`
- [File records](https://github.com/didar-code/chatbot/blob/main/data/files.json): `data/files.json`

### Other components

- **User**

## Connections

- User → Entry page: opens
- User → Chat page: opens
- Entry page → HTTP and sockets: loads page
- Chat page → Chat interactions: runs
- Chat page → Chat styling: uses styles
- Chat interactions → HTTP and sockets: sends events (evidence: `js/chat.js`)
- HTTP and sockets → JSON data access: calls (evidence: `server.js`)
- HTTP and sockets → Uploaded files: stores uploads (evidence: `server.js`)
- HTTP and sockets → Chat interactions: emits updates (evidence: `server.js`)
- JSON data access → User records: reads/writes (evidence: `utils/jsonDB.js`)
- JSON data access → Group records: reads/writes (evidence: `utils/jsonDB.js`)
- JSON data access → Message records: reads/writes (evidence: `utils/jsonDB.js`)
- JSON data access → File records: reads/writes (evidence: `utils/jsonDB.js`)
- Chat interactions → HTTP and sockets: requests file list (evidence: `js/chat.js`)
