# lylio/chatty architecture

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

- Interactive diagram: https://gitdiagram.com/lylio/chatty
- Repository: https://github.com/lylio/chatty

## Overview

Chatty is a Spring Boot, browser-based real-time chat demo. A user enters a name, connects over SockJS/STOMP, joins the public topic, sends messages, and renders messages broadcast to subscribers; disconnects generate leave notifications. The runtime is a small set of frontend, WebSocket routing, message handling, and event-listener components, with no persistent chat store shown. The README and sampled sources establish the main flow; static page wiring and runtime configuration details beyond the excerpts are not inferred.

Main entry points: [`src/main/java/com/lylechristine/chatty/controller/ChatController.java`](https://github.com/lylio/chatty/blob/master/src/main/java/com/lylechristine/chatty/controller/ChatController.java) (Chat controller), [`src/main/resources/static/js/main.js`](https://github.com/lylio/chatty/blob/master/src/main/resources/static/js/main.js) (Chat client), [`src/main/java/com/lylechristine/chatty/controller/WebSocketEventListener.java`](https://github.com/lylio/chatty/blob/master/src/main/java/com/lylechristine/chatty/controller/WebSocketEventListener.java) (Session listener), [`src/main/java/com/lylechristine/chatty/config/WebSocketConfig.java`](https://github.com/lylio/chatty/blob/master/src/main/java/com/lylechristine/chatty/config/WebSocketConfig.java) (WebSocket config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser chat"]
  node_browser["Chat page<br/>[index.html]"]
  node_client["Chat client<br/>[main.js]"]
end

subgraph group_realtime["WebSocket transport"]
  node_application["Spring application<br/>[Application.java]"]
  node_wsconfig["WebSocket config"]
  node_broker["Topic broker"]
end

subgraph group_chat["Chat handling"]
  node_controller["Chat controller"]
  node_events["Session listener"]
  node_message["Chat message<br/>[ChatMessage.java]"]
end

node_user(("Chat user"))

node_user -->|"opens chat"| node_browser
node_client -->|"connects at /ws"| node_wsconfig
node_wsconfig -->|"enables /topic"| node_broker
node_client -->|"sends /app messages"| node_controller
node_controller -->|"publishes /topic/public"| node_broker
node_broker -->|"delivers subscribed messages"| node_client
node_controller -->|"accepts and returns"| node_message
node_events -->|"creates leave event"| node_message
node_events -->|"broadcasts leave"| node_broker

click node_browser "https://github.com/lylio/chatty/blob/master/src/main/resources/static/index.html"
click node_client "https://github.com/lylio/chatty/blob/master/src/main/resources/static/js/main.js"
click node_application "https://github.com/lylio/chatty/blob/master/src/main/java/com/lylechristine/chatty/Application.java"
click node_wsconfig "https://github.com/lylio/chatty/blob/master/src/main/java/com/lylechristine/chatty/config/WebSocketConfig.java"
click node_controller "https://github.com/lylio/chatty/blob/master/src/main/java/com/lylechristine/chatty/controller/ChatController.java"
click node_events "https://github.com/lylio/chatty/blob/master/src/main/java/com/lylechristine/chatty/controller/WebSocketEventListener.java"
click node_message "https://github.com/lylio/chatty/blob/master/src/main/java/com/lylechristine/chatty/model/ChatMessage.java"

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_browser,node_client,node_user toneBlue
class node_application,node_wsconfig,node_broker toneAmber
class node_controller,node_events,node_message toneMint
```

## Components

### Browser chat

- [Chat page](https://github.com/lylio/chatty/blob/master/src/main/resources/static/index.html): `src/main/resources/static/index.html`
- [Chat client](https://github.com/lylio/chatty/blob/master/src/main/resources/static/js/main.js): `src/main/resources/static/js/main.js`

### WebSocket transport

- [Spring application](https://github.com/lylio/chatty/blob/master/src/main/java/com/lylechristine/chatty/Application.java): `src/main/java/com/lylechristine/chatty/Application.java`
- [WebSocket config](https://github.com/lylio/chatty/blob/master/src/main/java/com/lylechristine/chatty/config/WebSocketConfig.java): `src/main/java/com/lylechristine/chatty/config/WebSocketConfig.java`
- **Topic broker**

### Chat handling

- [Chat controller](https://github.com/lylio/chatty/blob/master/src/main/java/com/lylechristine/chatty/controller/ChatController.java): `src/main/java/com/lylechristine/chatty/controller/ChatController.java`
- [Session listener](https://github.com/lylio/chatty/blob/master/src/main/java/com/lylechristine/chatty/controller/WebSocketEventListener.java): `src/main/java/com/lylechristine/chatty/controller/WebSocketEventListener.java`
- [Chat message](https://github.com/lylio/chatty/blob/master/src/main/java/com/lylechristine/chatty/model/ChatMessage.java): `src/main/java/com/lylechristine/chatty/model/ChatMessage.java`

### Other components

- **Chat user**

## Connections

- Chat user → Chat page: opens chat (evidence: `README.md`)
- Chat client → WebSocket config: connects at /ws (evidence: `src/main/resources/static/js/main.js`)
- WebSocket config → Topic broker: enables /topic (evidence: `src/main/java/com/lylechristine/chatty/config/WebSocketConfig.java`)
- Chat client → Chat controller: sends /app messages (evidence: `src/main/resources/static/js/main.js`)
- Chat controller → Topic broker: publishes /topic/public (evidence: `src/main/java/com/lylechristine/chatty/controller/ChatController.java`)
- Topic broker → Chat client: delivers subscribed messages (evidence: `src/main/resources/static/js/main.js`)
- Chat controller → Chat message: accepts and returns (evidence: `src/main/java/com/lylechristine/chatty/controller/ChatController.java`)
- Session listener → Chat message: creates leave event (evidence: `src/main/java/com/lylechristine/chatty/controller/WebSocketEventListener.java`)
- Session listener → Topic broker: broadcasts leave (evidence: `src/main/java/com/lylechristine/chatty/controller/WebSocketEventListener.java`)
