# saell-s/gin_chat_app architecture

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

- Interactive diagram: https://gitdiagram.com/saell-s/gin_chat_app
- Repository: https://github.com/saell-s/gin_chat_app

## Overview

Gin Chat is a browser-based messaging and calling app with account management, presence, dashboards, and reports. Users sign in, load conversations and directory data, exchange messages and call events over REST and WebSocket, and use WebRTC media for calls. The backend routes requests to feature handlers and services, with PostgreSQL-backed repositories and shared realtime infrastructure. The README names the web stack; source excerpts show client API and WebSocket usage and server wiring. Unsampled feature internals are represented by their source directories, without asserting unshown calls.

Main entry points: [`main.go`](https://github.com/saell-s/gin_chat_app/blob/main/main.go) (Gin server), [`web/ts/app.ts`](https://github.com/saell-s/gin_chat_app/blob/main/web/ts/app.ts) (Chat application), [`app/features/chat/service.go`](https://github.com/saell-s/gin_chat_app/blob/main/app/features/chat/service.go) (Chat and presence), [`app/features/call/service.go`](https://github.com/saell-s/gin_chat_app/blob/main/app/features/call/service.go) (Call service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web client"]
  node_client["Chat application<br/>[app.ts]"]
  node_webapi["HTTP client<br/>[api.ts]"]
  node_wsclient["WebSocket client<br/>[ws.ts]"]
  node_media["WebRTC manager<br/>[webrtc.ts]"]
  node_pages["Templ pages<br/>[app_templ.go]"]
end

subgraph group_identity["Identity and users"]
  node_auth["Authentication<br/>[service.go]"]
  node_users["User management<br/>[service.go]"]
end

subgraph group_messaging["Messaging and calls"]
  node_chat["Chat and presence<br/>[service.go]"]
  node_calls["Call service<br/>[service.go]"]
end

subgraph group_operations["Dashboard and reports"]
  node_dashboard["Dashboard<br/>[service.go]"]
  node_reports["Reporting<br/>[service.go]"]
end

subgraph group_platform["Shared platform"]
  node_server["Gin server<br/>[main.go]"]
  node_hub["Realtime hub<br/>[hub.go]"]
  node_database[("Database<br/>[db.go]")]
  node_migrations["Schema migrations<br/>[migrate.go]"]
  node_events["Event repository<br/>[events.go]"]
  node_kafka["Kafka producer<br/>[producer.go]"]
  node_config["Configuration<br/>[config.go]"]
  node_jwt["JWT security<br/>[jwt.go]"]
  node_middleware["Auth middleware<br/>[auth.go]"]
end

node_person(("User"))

node_person -->|"uses"| node_client
node_client -->|"requests API"| node_webapi
node_client -->|"sends events"| node_wsclient
node_client -->|"manages media"| node_media
node_server -->|"registers pages"| node_pages
node_server -->|"registers routes"| node_auth
node_server -->|"registers routes"| node_users
node_server -->|"registers routes"| node_chat
node_server -->|"registers routes"| node_calls
node_server -->|"registers routes"| node_dashboard
node_server -->|"registers routes"| node_reports
node_server -->|"serves WebSocket"| node_hub
node_server -->|"dispatches chat events"| node_chat
node_server -->|"dispatches call events"| node_calls
node_server -->|"opens database"| node_database
node_server -->|"runs migrations"| node_migrations
node_server -->|"creates repository"| node_events
node_server -->|"creates producer"| node_kafka
node_server -->|"loads settings"| node_config
node_server -->|"creates token manager"| node_jwt
node_server -->|"configures authorization"| node_middleware

click node_client "https://github.com/saell-s/gin_chat_app/blob/main/web/ts/app.ts"
click node_webapi "https://github.com/saell-s/gin_chat_app/blob/main/web/ts/api.ts"
click node_wsclient "https://github.com/saell-s/gin_chat_app/blob/main/web/ts/ws.ts"
click node_media "https://github.com/saell-s/gin_chat_app/blob/main/web/ts/webrtc.ts"
click node_pages "https://github.com/saell-s/gin_chat_app/blob/main/web/app_templ.go"
click node_server "https://github.com/saell-s/gin_chat_app/blob/main/main.go"
click node_auth "https://github.com/saell-s/gin_chat_app/blob/main/app/features/auth/service.go"
click node_users "https://github.com/saell-s/gin_chat_app/blob/main/app/features/user/service.go"
click node_chat "https://github.com/saell-s/gin_chat_app/blob/main/app/features/chat/service.go"
click node_calls "https://github.com/saell-s/gin_chat_app/blob/main/app/features/call/service.go"
click node_dashboard "https://github.com/saell-s/gin_chat_app/blob/main/app/features/dashboard/service.go"
click node_reports "https://github.com/saell-s/gin_chat_app/blob/main/app/features/reporting/service.go"
click node_hub "https://github.com/saell-s/gin_chat_app/blob/main/app/shared/realtime/hub.go"
click node_database "https://github.com/saell-s/gin_chat_app/blob/main/app/shared/db/db.go"
click node_migrations "https://github.com/saell-s/gin_chat_app/blob/main/app/shared/db/migrate.go"
click node_events "https://github.com/saell-s/gin_chat_app/blob/main/app/shared/db/events.go"
click node_kafka "https://github.com/saell-s/gin_chat_app/blob/main/app/shared/kafka/producer.go"
click node_config "https://github.com/saell-s/gin_chat_app/blob/main/app/shared/configs/config.go"
click node_jwt "https://github.com/saell-s/gin_chat_app/blob/main/app/shared/security/jwt.go"
click node_middleware "https://github.com/saell-s/gin_chat_app/blob/main/app/shared/middleware/auth.go"

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_client,node_webapi,node_wsclient,node_media,node_pages,node_person toneBlue
class node_auth,node_users toneAmber
class node_chat,node_calls toneMint
class node_dashboard,node_reports toneRose
class node_server,node_hub,node_database,node_migrations,node_events,node_kafka,node_config,node_jwt,node_middleware toneIndigo
```

## Components

### Web client

- [Chat application](https://github.com/saell-s/gin_chat_app/blob/main/web/ts/app.ts): `web/ts/app.ts`
- [HTTP client](https://github.com/saell-s/gin_chat_app/blob/main/web/ts/api.ts): `web/ts/api.ts`
- [WebSocket client](https://github.com/saell-s/gin_chat_app/blob/main/web/ts/ws.ts): `web/ts/ws.ts`
- [WebRTC manager](https://github.com/saell-s/gin_chat_app/blob/main/web/ts/webrtc.ts): `web/ts/webrtc.ts`
- [Templ pages](https://github.com/saell-s/gin_chat_app/blob/main/web/app_templ.go): `web/app_templ.go`

### Identity and users

- [Authentication](https://github.com/saell-s/gin_chat_app/blob/main/app/features/auth/service.go): `app/features/auth/service.go`
- [User management](https://github.com/saell-s/gin_chat_app/blob/main/app/features/user/service.go): `app/features/user/service.go`

### Messaging and calls

- [Chat and presence](https://github.com/saell-s/gin_chat_app/blob/main/app/features/chat/service.go): `app/features/chat/service.go`
- [Call service](https://github.com/saell-s/gin_chat_app/blob/main/app/features/call/service.go): `app/features/call/service.go`

### Dashboard and reports

- [Dashboard](https://github.com/saell-s/gin_chat_app/blob/main/app/features/dashboard/service.go): `app/features/dashboard/service.go`
- [Reporting](https://github.com/saell-s/gin_chat_app/blob/main/app/features/reporting/service.go): `app/features/reporting/service.go`

### Shared platform

- [Gin server](https://github.com/saell-s/gin_chat_app/blob/main/main.go): `main.go`
- [Realtime hub](https://github.com/saell-s/gin_chat_app/blob/main/app/shared/realtime/hub.go): `app/shared/realtime/hub.go`
- [Database](https://github.com/saell-s/gin_chat_app/blob/main/app/shared/db/db.go): `app/shared/db/db.go`
- [Schema migrations](https://github.com/saell-s/gin_chat_app/blob/main/app/shared/db/migrate.go): `app/shared/db/migrate.go`
- [Event repository](https://github.com/saell-s/gin_chat_app/blob/main/app/shared/db/events.go): `app/shared/db/events.go`
- [Kafka producer](https://github.com/saell-s/gin_chat_app/blob/main/app/shared/kafka/producer.go): `app/shared/kafka/producer.go`
- [Configuration](https://github.com/saell-s/gin_chat_app/blob/main/app/shared/configs/config.go): `app/shared/configs/config.go`
- [JWT security](https://github.com/saell-s/gin_chat_app/blob/main/app/shared/security/jwt.go): `app/shared/security/jwt.go`
- [Auth middleware](https://github.com/saell-s/gin_chat_app/blob/main/app/shared/middleware/auth.go): `app/shared/middleware/auth.go`

### Other components

- **User**

## Connections

- User → Chat application: uses
- Chat application → HTTP client: requests API (evidence: `web/ts/app.ts`)
- Chat application → WebSocket client: sends events (evidence: `web/ts/app.ts`)
- Chat application → WebRTC manager: manages media (evidence: `web/ts/app.ts`)
- Gin server → Templ pages: registers pages (evidence: `main.go`)
- Gin server → Authentication: registers routes (evidence: `main.go`)
- Gin server → User management: registers routes (evidence: `main.go`)
- Gin server → Chat and presence: registers routes (evidence: `main.go`)
- Gin server → Call service: registers routes (evidence: `main.go`)
- Gin server → Dashboard: registers routes (evidence: `main.go`)
- Gin server → Reporting: registers routes (evidence: `main.go`)
- Gin server → Realtime hub: serves WebSocket (evidence: `main.go`)
- Gin server → Chat and presence: dispatches chat events (evidence: `main.go`)
- Gin server → Call service: dispatches call events (evidence: `main.go`)
- Gin server → Database: opens database (evidence: `main.go`)
- Gin server → Schema migrations: runs migrations (evidence: `main.go`)
- Gin server → Event repository: creates repository (evidence: `main.go`)
- Gin server → Kafka producer: creates producer (evidence: `main.go`)
- Gin server → Configuration: loads settings (evidence: `main.go`)
- Gin server → JWT security: creates token manager (evidence: `main.go`)
- Gin server → Auth middleware: configures authorization (evidence: `main.go`)
