# peeyush1-lab/python-live-chatting architecture

> Architecture diagram of the GitHub repository peeyush1-lab/python-live-chatting, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/peeyush1-lab/python-live-chatting
- Repository: https://github.com/peeyush1-lab/python-live-chatting

## Overview

Python Live Chatting is a browser-based, real-time chat application with public rooms and persistent message history. A user connects, joins a room with a display name, exchanges validated messages, and can reload that room’s recent history. The browser client also handles connection status, retries, and rendering; FastAPI serves the frontend and health endpoint, while Socket.IO handlers own room and messaging behavior. SQLite stores messages. README documents frontend and accessibility capabilities not fully shown in the sampled source; relationships below are limited to excerpted code or documented behavior.

Main entry points: [`main.py`](https://github.com/peeyush1-lab/python-live-chatting/blob/main/main.py) (Room and message handlers), [`Frontend/index.html`](https://github.com/peeyush1-lab/python-live-chatting/blob/main/Frontend/index.html) (Chat interface), [`Frontend/script.js`](https://github.com/peeyush1-lab/python-live-chatting/blob/main/Frontend/script.js) (Socket.IO client), [`database.py`](https://github.com/peeyush1-lab/python-live-chatting/blob/main/database.py) (Message persistence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Browser experience"]
  node_frontend["Chat interface<br/>[index.html]"]
  node_client["Socket.IO client<br/>[script.js]"]
end

subgraph group_server["Chat server"]
  node_http["HTTP routes<br/>[main.py]"]
  node_handlers["Room and message handlers<br/>[main.py]"]
  node_socket_service["Socket.IO service<br/>[main.py]"]
end

subgraph group_storage["Message storage"]
  node_persistence["Message persistence<br/>[database.py]"]
  node_sqlite[("SQLite message store<br/>[database.py]")]
end

node_user(("Chat user"))

node_user -->|"uses"| node_frontend
node_frontend -->|"loads"| node_client
node_client -->|"connects"| node_socket_service
node_socket_service -->|"dispatches"| node_handlers
node_handlers -->|"emits events"| node_client
node_http -->|"serves"| node_frontend
node_handlers -->|"saves and reads"| node_persistence
node_persistence -->|"queries"| node_sqlite
node_http -->|"initializes"| node_persistence

click node_frontend "https://github.com/peeyush1-lab/python-live-chatting/blob/main/Frontend/index.html"
click node_client "https://github.com/peeyush1-lab/python-live-chatting/blob/main/Frontend/script.js"
click node_http "https://github.com/peeyush1-lab/python-live-chatting/blob/main/main.py"
click node_handlers "https://github.com/peeyush1-lab/python-live-chatting/blob/main/main.py"
click node_persistence "https://github.com/peeyush1-lab/python-live-chatting/blob/main/database.py"
click node_sqlite "https://github.com/peeyush1-lab/python-live-chatting/blob/main/database.py"
click node_socket_service "https://github.com/peeyush1-lab/python-live-chatting/blob/main/main.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_frontend,node_client,node_user toneBlue
class node_http,node_handlers,node_socket_service toneAmber
class node_persistence,node_sqlite toneMint
```

## Components

### Browser experience

- [Chat interface](https://github.com/peeyush1-lab/python-live-chatting/blob/main/Frontend/index.html): `Frontend/index.html`
- [Socket.IO client](https://github.com/peeyush1-lab/python-live-chatting/blob/main/Frontend/script.js): `Frontend/script.js`

### Chat server

- [HTTP routes](https://github.com/peeyush1-lab/python-live-chatting/blob/main/main.py): `main.py`
- [Room and message handlers](https://github.com/peeyush1-lab/python-live-chatting/blob/main/main.py): `main.py`
- [Socket.IO service](https://github.com/peeyush1-lab/python-live-chatting/blob/main/main.py): `main.py`

### Message storage

- [Message persistence](https://github.com/peeyush1-lab/python-live-chatting/blob/main/database.py): `database.py`
- [SQLite message store](https://github.com/peeyush1-lab/python-live-chatting/blob/main/database.py): `database.py`

### Other components

- **Chat user**

## Connections

- Chat user → Chat interface: uses (evidence: `README.md`)
- Chat interface → Socket.IO client: loads (evidence: `README.md`)
- Socket.IO client → Socket.IO service: connects (evidence: `Frontend/script.js`)
- Socket.IO service → Room and message handlers: dispatches (evidence: `main.py`)
- Room and message handlers → Socket.IO client: emits events (evidence: `main.py`)
- HTTP routes → Chat interface: serves (evidence: `main.py`)
- Room and message handlers → Message persistence: saves and reads (evidence: `main.py`)
- Message persistence → SQLite message store: queries (evidence: `database.py`)
- HTTP routes → Message persistence: initializes (evidence: `main.py`)
