# mathias143000/sharechat-realtime-lab architecture

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

- Interactive diagram: https://gitdiagram.com/mathias143000/sharechat-realtime-lab
- Repository: https://github.com/mathias143000/sharechat-realtime-lab

## Overview

ShareChat is a production-like lab for a realtime, stateful chat and file-sharing service. A browser user reaches the app through an Nginx WebSocket edge; the client coordinates chat selection, message rendering, mentions, theme, and uploads through HTTP and Socket.IO. App replicas share state and fan-out through Redis and store uploads in MinIO. Prometheus scrapes runtime metrics for the Grafana dashboard surface, with Alertmanager documented as part of operations. Source excerpts show client-module calls and server metrics/storage use; deployment links are documented in the README, while exact configuration wiring was not sampled.

Main entry points: [`src/client/main.ts`](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/main.ts) (Client entrypoint), [`src/server/index.ts`](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/server/index.ts) (App replicas), [`prometheus/prometheus.yml`](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/prometheus/prometheus.yml) (Prometheus), [`nginx/default.conf`](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/nginx/default.conf) (Nginx edge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_main["Client entrypoint<br/>[main.ts]"]
  node_api["HTTP API client<br/>[api.ts]"]
  node_socket["Realtime socket client<br/>[socket.ts]"]
  node_chats["Chat selection<br/>[chats.ts]"]
  node_chatview["Message rendering<br/>[chat-view.ts]"]
  node_mentions["Mention controller<br/>[mentions.ts]"]
  node_uploads["Upload interface<br/>[uploads.ts]"]
  node_theme["Theme controls<br/>[theme.ts]"]
end

subgraph group_runtime["App runtime"]
  node_replicas["App replicas<br/>[index.ts]"]
  node_server["HTTP and chat service<br/>[index.ts]"]
end

subgraph group_persistence["Shared state and files"]
  node_storage["Storage adapters<br/>[storage.ts]"]
  node_redis[("Redis shared state")]
  node_minio[("MinIO object storage")]
end

subgraph group_edge["Traffic edge"]
  node_nginx["Nginx edge<br/>[default.conf]"]
end

subgraph group_observability["Observability"]
  node_metrics["Runtime metrics<br/>[metrics.ts]"]
  node_prometheus["Prometheus<br/>[prometheus.yml]"]
  node_grafana["Grafana dashboards"]
  node_alertmanager["Alertmanager<br/>[alertmanager.yml]"]
end

node_user(("Browser user"))

node_user -->|"uses"| node_main
node_main -->|"calls"| node_api
node_main -->|"connects"| node_socket
node_main -->|"manages"| node_chats
node_main -->|"renders"| node_chatview
node_main -->|"coordinates"| node_mentions
node_main -->|"initializes"| node_uploads
node_main -->|"initializes"| node_theme
node_main -->|"sends app traffic"| node_nginx
node_nginx -->|"routes traffic"| node_replicas
node_replicas -->|"shares state and fan-out"| node_redis
node_replicas -->|"stores uploads"| node_minio
node_server -->|"uses"| node_storage
node_server -->|"records and renders"| node_metrics
node_prometheus -->|"scrapes metrics"| node_replicas
node_grafana -->|"visualizes metrics"| node_prometheus
node_prometheus -.->|"sends alerts"| node_alertmanager

click node_main "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/main.ts"
click node_api "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/api.ts"
click node_socket "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/socket.ts"
click node_chats "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/chats.ts"
click node_chatview "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/chat-view.ts"
click node_mentions "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/mentions.ts"
click node_uploads "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/uploads.ts"
click node_theme "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/theme.ts"
click node_nginx "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/nginx/default.conf"
click node_replicas "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/server/index.ts"
click node_server "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/server/index.ts"
click node_metrics "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/server/metrics.ts"
click node_storage "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/server/storage.ts"
click node_prometheus "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/prometheus/prometheus.yml"
click node_grafana "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/grafana/dashboards/sharechat-overview.json"
click node_alertmanager "https://github.com/mathias143000/sharechat-realtime-lab/blob/main/alertmanager.yml"

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_main,node_api,node_socket,node_chats,node_chatview,node_mentions,node_uploads,node_theme,node_user toneBlue
class node_replicas,node_server toneAmber
class node_storage,node_redis,node_minio toneMint
class node_nginx toneRose
class node_metrics,node_prometheus,node_grafana,node_alertmanager toneIndigo
```

## Components

### Browser client

- [Client entrypoint](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/main.ts): `src/client/main.ts`
- [HTTP API client](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/api.ts): `src/client/api.ts`
- [Realtime socket client](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/socket.ts): `src/client/socket.ts`
- [Chat selection](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/chats.ts): `src/client/chats.ts`
- [Message rendering](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/chat-view.ts): `src/client/chat-view.ts`
- [Mention controller](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/mentions.ts): `src/client/mentions.ts`
- [Upload interface](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/uploads.ts): `src/client/uploads.ts`
- [Theme controls](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/client/theme.ts): `src/client/theme.ts`

### App runtime

- [App replicas](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/server/index.ts): `src/server/index.ts`
- [HTTP and chat service](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/server/index.ts): `src/server/index.ts`

### Shared state and files

- [Storage adapters](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/server/storage.ts): `src/server/storage.ts`
- **Redis shared state**
- **MinIO object storage**

### Traffic edge

- [Nginx edge](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/nginx/default.conf): `nginx/default.conf`

### Observability

- [Runtime metrics](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/src/server/metrics.ts): `src/server/metrics.ts`
- [Prometheus](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/prometheus/prometheus.yml): `prometheus/prometheus.yml`
- [Grafana dashboards](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/grafana/dashboards/sharechat-overview.json): `grafana/dashboards/sharechat-overview.json`
- [Alertmanager](https://github.com/mathias143000/sharechat-realtime-lab/blob/main/alertmanager.yml): `alertmanager.yml`

### Other components

- **Browser user**

## Connections

- Browser user → Client entrypoint: uses (evidence: `README.md`)
- Client entrypoint → HTTP API client: calls (evidence: `src/client/main.ts`)
- Client entrypoint → Realtime socket client: connects (evidence: `src/client/main.ts`)
- Client entrypoint → Chat selection: manages (evidence: `src/client/main.ts`)
- Client entrypoint → Message rendering: renders (evidence: `src/client/main.ts`)
- Client entrypoint → Mention controller: coordinates (evidence: `src/client/main.ts`)
- Client entrypoint → Upload interface: initializes (evidence: `src/client/main.ts`)
- Client entrypoint → Theme controls: initializes (evidence: `src/client/main.ts`)
- Client entrypoint → Nginx edge: sends app traffic (evidence: `README.md`)
- Nginx edge → App replicas: routes traffic (evidence: `README.md`)
- App replicas → Redis shared state: shares state and fan-out (evidence: `README.md`)
- App replicas → MinIO object storage: stores uploads (evidence: `README.md`)
- HTTP and chat service → Storage adapters: uses (evidence: `src/server/index.ts`)
- HTTP and chat service → Runtime metrics: records and renders (evidence: `src/server/index.ts`)
- Prometheus → App replicas: scrapes metrics (evidence: `README.md`)
- Grafana dashboards → Prometheus: visualizes metrics (evidence: `README.md`)
- Prometheus → Alertmanager: sends alerts
