# asmit-3009/cpp-chat-app architecture

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

- Interactive diagram: https://gitdiagram.com/asmit-3009/cpp-chat-app
- Repository: https://github.com/asmit-3009/cpp-chat-app

## Overview

This is a multi-client TCP chat with a React browser UI and a Node.js Socket.IO-to-TCP bridge. A browser user joins with a username, sends messages through the bridge to the C++ server, and receives broadcasts and join/leave events back through the bridge. A terminal client is also supported. The C++ server accepts clients and handles each connection in a thread. README capabilities are included; the sampled code does not establish a separate persistence layer.

Main entry points: [`src/server.cpp`](https://github.com/asmit-3009/cpp-chat-app/blob/main/src/server.cpp) (Client handler), [`backend/server.js`](https://github.com/asmit-3009/cpp-chat-app/blob/main/backend/server.js) (Socket.IO bridge), [`src/client.cpp`](https://github.com/asmit-3009/cpp-chat-app/blob/main/src/client.cpp) (Terminal client), [`frontend/src/App.js`](https://github.com/asmit-3009/cpp-chat-app/blob/main/frontend/src/App.js) (Chat interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser chat"]
  node_ui["Chat interface<br/>[App.js]"]
end

subgraph group_bridge["Socket bridge"]
  node_bridge_service["Socket.IO bridge<br/>[server.js]"]
  node_message_parser["Message parser<br/>[server.js]"]
end

subgraph group_tcp["TCP chat"]
  node_tcp_server["TCP listener<br/>[server.cpp]"]
  node_client_handler["Client handler<br/>[server.cpp]"]
  node_broadcast["Message broadcast<br/>[server.cpp]"]
  node_terminal_client["Terminal client<br/>[client.cpp]"]
  node_shared_config["Socket settings<br/>[common.h]"]
end

node_user(("Chat user"))

node_user -->|"uses"| node_ui
node_ui -->|"Socket.IO events"| node_bridge_service
node_bridge_service -->|"emits events"| node_ui
node_bridge_service -->|"opens TCP connection"| node_tcp_server
node_bridge_service -->|"writes username/messages"| node_client_handler
node_client_handler -->|"sends prompts/messages"| node_bridge_service
node_client_handler -->|"formats chat lines"| node_message_parser
node_bridge_service -->|"parses received lines"| node_message_parser
node_tcp_server -->|"dispatches clients"| node_client_handler
node_client_handler -->|"broadcasts events"| node_broadcast
node_broadcast -->|"sends to peers"| node_client_handler
node_terminal_client -->|"connects to"| node_tcp_server
node_terminal_client -->|"sends chat input"| node_client_handler
node_client_handler -->|"sends chat output"| node_terminal_client
node_shared_config -->|"defines limits"| node_tcp_server
node_shared_config -->|"defines connection settings"| node_terminal_client

click node_ui "https://github.com/asmit-3009/cpp-chat-app/blob/main/frontend/src/App.js"
click node_bridge_service "https://github.com/asmit-3009/cpp-chat-app/blob/main/backend/server.js"
click node_message_parser "https://github.com/asmit-3009/cpp-chat-app/blob/main/backend/server.js"
click node_tcp_server "https://github.com/asmit-3009/cpp-chat-app/blob/main/src/server.cpp"
click node_client_handler "https://github.com/asmit-3009/cpp-chat-app/blob/main/src/server.cpp"
click node_broadcast "https://github.com/asmit-3009/cpp-chat-app/blob/main/src/server.cpp"
click node_terminal_client "https://github.com/asmit-3009/cpp-chat-app/blob/main/src/client.cpp"
click node_shared_config "https://github.com/asmit-3009/cpp-chat-app/blob/main/include/common.h"

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_ui,node_user toneBlue
class node_bridge_service,node_message_parser toneAmber
class node_tcp_server,node_client_handler,node_broadcast,node_terminal_client,node_shared_config toneMint
```

## Components

### Browser chat

- [Chat interface](https://github.com/asmit-3009/cpp-chat-app/blob/main/frontend/src/App.js): `frontend/src/App.js`

### Socket bridge

- [Socket.IO bridge](https://github.com/asmit-3009/cpp-chat-app/blob/main/backend/server.js): `backend/server.js`
- [Message parser](https://github.com/asmit-3009/cpp-chat-app/blob/main/backend/server.js): `backend/server.js`

### TCP chat

- [TCP listener](https://github.com/asmit-3009/cpp-chat-app/blob/main/src/server.cpp): `src/server.cpp`
- [Client handler](https://github.com/asmit-3009/cpp-chat-app/blob/main/src/server.cpp): `src/server.cpp`
- [Message broadcast](https://github.com/asmit-3009/cpp-chat-app/blob/main/src/server.cpp): `src/server.cpp`
- [Terminal client](https://github.com/asmit-3009/cpp-chat-app/blob/main/src/client.cpp): `src/client.cpp`
- [Socket settings](https://github.com/asmit-3009/cpp-chat-app/blob/main/include/common.h): `include/common.h`

### Other components

- **Chat user**

## Connections

- Chat user → Chat interface: uses
- Chat interface → Socket.IO bridge: Socket.IO events
- Socket.IO bridge → Chat interface: emits events
- Socket.IO bridge → TCP listener: opens TCP connection
- Socket.IO bridge → Client handler: writes username/messages
- Client handler → Socket.IO bridge: sends prompts/messages
- Client handler → Message parser: formats chat lines
- Socket.IO bridge → Message parser: parses received lines
- TCP listener → Client handler: dispatches clients
- Client handler → Message broadcast: broadcasts events
- Message broadcast → Client handler: sends to peers
- Terminal client → TCP listener: connects to
- Terminal client → Client handler: sends chat input
- Client handler → Terminal client: sends chat output
- Socket settings → TCP listener: defines limits
- Socket settings → Terminal client: defines connection settings
