# adrianhajdin/project_chat_application architecture

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

- Interactive diagram: https://gitdiagram.com/adrianhajdin/project_chat_application
- Repository: https://github.com/adrianhajdin/project_chat_application

## Overview

#### Purpose and Entry Points
This is a two-process realtime room-chat application: a React browser client connects to a Node.js Socket.io server for presence and message delivery. Start each package independently from `client/package.json` and `server/package.json`. Browser bootstrap is `client/src/index.js`; server bootstrap and Socket.io host are `server/index.js`.

#### Client Application Shell
`client/src/App.js` defines the client’s top-level navigation between joining and chatting, while `client/src/index.js` mounts the React application. The public document shell is `client/public/index.html`. The client is a single-page React application rather than a server-rendered web app.

#### Join and Connection Boundary
The join screen gathers a user name and room before entering chat in `client/src/components/Join/Join.js`. The chat view in `client/src/components/Chat/Chat.js` establishes and owns the Socket.io client connection, passing join parameters to the backend and subscribing to server events. This component is the main boundary between UI state and realtime transport.

#### Realtime Server and Event Flow
`server/index.js` creates the HTTP/Express runtime and attaches Socket.io. Its socket lifecycle delegates event handling to `server/router.js`: clients join a named room, send messages, receive room/presence updates, and are removed on disconnect. Socket.io is the material external runtime dependency and enables bidirectional events over the network rather than REST request/response messaging.

#### In-Memory User and Room State
`server/users.js` is the server-side state model for connected users. It tracks socket identity alongside name and room, supports lookup/removal, and supplies room membership for broadcasts. This is process-local state: no database, authentication provider, or durable message history is represented, so restarts discard active users and messages.

#### Message Rendering Pipeline
Outgoing text flows from `client/src/components/Input/Input.js` to the chat socket event managed by `client/src/components/Chat/Chat.js`; server routing broadcasts it to relevant room members. Received messages are retained in chat state and rendered through `client/src/components/Messages/Messages.js` and `client/src/components/Messages/Message/Message.js`. Message presentation distinguishes local versus other users at the UI layer.

#### Presence and Room Context
Room/user context is presented separately from messages: `client/src/components/InfoBar/InfoBar.js` exposes the current room and exit control, while `client/src/components/TextContainer/TextContainer.js` displays active room participants. Both are fed by socket-driven state from the chat container, keeping connection orchestration centralized rather than distributed across leaf UI components.

#### Deployment Shape
The repository includes a process declaration at `server/Procfile`, indicating the Node server is deployable as a standalone service. Netlify metadata exists in `.netlify/state.json`, consistent with static-client hosting, but the Socket.io server requires a persistent Node-capable host and cannot be replaced by static hosting alone.

Main entry points: [`client/src/components/Chat/Chat.js`](https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/Chat/Chat.js) (Chat container), [`client/src/App.js`](https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/App.js) (App navigation), [`server/router.js`](https://github.com/adrianhajdin/project_chat_application/blob/master/server/router.js) (Socket lifecycle router), [`server/index.js`](https://github.com/adrianhajdin/project_chat_application/blob/master/server/index.js) (HTTP and Socket.io host)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React browser client"]
  node_document["Document shell<br/>HTML<br/>[index.html]"]
  node_client_bootstrap["React bootstrap<br/>browser entry<br/>[index.js]"]
  node_app["App navigation<br/>React shell<br/>[App.js]"]
  node_join["Join screen<br/>React view<br/>[Join.js]"]
  node_chat{{"Chat container<br/>React realtime boundary<br/>[Chat.js]"}}
  node_input["Message input<br/>React view<br/>[Input.js]"]
  node_messages["Message list<br/>React view<br/>[Messages.js]"]
  node_message["Message item<br/>React view<br/>[Message.js]"]
  node_info_bar["Room header<br/>React view<br/>[InfoBar.js]"]
  node_participants["Participant list<br/>React view<br/>[TextContainer.js]"]
end

subgraph group_server["Node realtime server"]
  node_server_bootstrap{{"HTTP and Socket.io host<br/>Node entry<br/>[index.js]"}}
  node_router["Socket lifecycle router<br/>event handler<br/>[router.js]"]
  node_users[("Connected user state<br/>in-memory state<br/>[users.js]")]
  node_procfile["Service process declaration<br/>deployment manifest"]
end

node_socket_transport{{"Socket.io transport<br/>bidirectional network"}}
node_netlify["Static client hosting metadata<br/>deployment metadata<br/>[state.json]"]

node_document -->|"loads"| node_client_bootstrap
node_client_bootstrap -->|"mounts"| node_app
node_app -->|"shows before join"| node_join
node_app -->|"shows after join"| node_chat
node_join -->|"supplies name and room"| node_chat
node_chat -->|"provides send handler"| node_input
node_input -->|"outgoing text"| node_chat
node_chat -->|"received message state"| node_messages
node_messages -->|"renders items"| node_message
node_chat -->|"room context"| node_info_bar
node_chat -->|"presence state"| node_participants
node_chat -->|"join and chat events"| node_socket_transport
node_socket_transport -->|"Socket.io connection"| node_server_bootstrap
node_server_bootstrap -->|"delegates socket events"| node_router
node_router -->|"tracks membership"| node_users
node_router -->|"broadcasts messages and presence"| node_socket_transport
node_procfile -.->|"runs"| node_server_bootstrap
node_netlify -.->|"static client deployment"| node_document

click node_document "https://github.com/adrianhajdin/project_chat_application/blob/master/client/public/index.html"
click node_client_bootstrap "https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/index.js"
click node_app "https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/App.js"
click node_join "https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/Join/Join.js"
click node_chat "https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/Chat/Chat.js"
click node_input "https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/Input/Input.js"
click node_messages "https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/Messages/Messages.js"
click node_message "https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/Messages/Message/Message.js"
click node_info_bar "https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/InfoBar/InfoBar.js"
click node_participants "https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/TextContainer/TextContainer.js"
click node_server_bootstrap "https://github.com/adrianhajdin/project_chat_application/blob/master/server/index.js"
click node_router "https://github.com/adrianhajdin/project_chat_application/blob/master/server/router.js"
click node_users "https://github.com/adrianhajdin/project_chat_application/blob/master/server/users.js"
click node_procfile "https://github.com/adrianhajdin/project_chat_application/blob/master/server/Procfile"
click node_netlify "https://github.com/adrianhajdin/project_chat_application/blob/master/.netlify/state.json"

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_document,node_client_bootstrap,node_app,node_join,node_chat,node_input,node_messages,node_message,node_info_bar,node_participants toneBlue
class node_server_bootstrap,node_router,node_users,node_procfile toneAmber
class node_socket_transport,node_netlify toneNeutral
```

## Components

### React browser client

- [Document shell](https://github.com/adrianhajdin/project_chat_application/blob/master/client/public/index.html): HTML · `client/public/index.html`
- [React bootstrap](https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/index.js): browser entry · `client/src/index.js`
- [App navigation](https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/App.js): React shell · Switches between join and chat views. · `client/src/App.js`
- [Join screen](https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/Join/Join.js): React view · Collects user name and room. · `client/src/components/Join/Join.js`
- [Chat container](https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/Chat/Chat.js): React realtime boundary · Owns socket connection and socket-driven chat state. · `client/src/components/Chat/Chat.js`
- [Message input](https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/Input/Input.js): React view · `client/src/components/Input/Input.js`
- [Message list](https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/Messages/Messages.js): React view · Renders received chat state. · `client/src/components/Messages/Messages.js`
- [Message item](https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/Messages/Message/Message.js): React view · Distinguishes local and remote messages. · `client/src/components/Messages/Message/Message.js`
- [Room header](https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/InfoBar/InfoBar.js): React view · Shows room context and exit control. · `client/src/components/InfoBar/InfoBar.js`
- [Participant list](https://github.com/adrianhajdin/project_chat_application/blob/master/client/src/components/TextContainer/TextContainer.js): React view · Shows active room members. · `client/src/components/TextContainer/TextContainer.js`

### Node realtime server

- [HTTP and Socket.io host](https://github.com/adrianhajdin/project_chat_application/blob/master/server/index.js): Node entry · Creates Express runtime and Socket.io host. · `server/index.js`
- [Socket lifecycle router](https://github.com/adrianhajdin/project_chat_application/blob/master/server/router.js): event handler · Handles join, message, presence, and disconnect events. · `server/router.js`
- [Connected user state](https://github.com/adrianhajdin/project_chat_application/blob/master/server/users.js): in-memory state · Process-local socket, user, and room membership model. · `server/users.js`
- [Service process declaration](https://github.com/adrianhajdin/project_chat_application/blob/master/server/Procfile): deployment manifest · Declares standalone Node server deployment. · `server/Procfile`

### Other components

- **Socket.io transport**: bidirectional network · Realtime browser-to-server event channel.
- [Static client hosting metadata](https://github.com/adrianhajdin/project_chat_application/blob/master/.netlify/state.json): deployment metadata · Static hosting cannot replace the persistent Socket.io service. · `.netlify/state.json`

## Connections

- Document shell → React bootstrap: loads
- React bootstrap → App navigation: mounts
- App navigation → Join screen: shows before join
- App navigation → Chat container: shows after join
- Join screen → Chat container: supplies name and room
- Chat container → Message input: provides send handler
- Message input → Chat container: outgoing text
- Chat container → Message list: received message state
- Message list → Message item: renders items
- Chat container → Room header: room context
- Chat container → Participant list: presence state
- Chat container → Socket.io transport: join and chat events
- Socket.io transport → HTTP and Socket.io host: Socket.io connection
- HTTP and Socket.io host → Socket lifecycle router: delegates socket events
- Socket lifecycle router → Connected user state: tracks membership
- Socket lifecycle router → Socket.io transport: broadcasts messages and presence
- Service process declaration → HTTP and Socket.io host: runs
- Static client hosting metadata → Document shell: static client deployment
