# nicrepository/nchat architecture

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

- Interactive diagram: https://gitdiagram.com/nicrepository/nchat
- Repository: https://github.com/nicrepository/nchat

## Overview

NChat is a corporate internal chat product, with separate employee and administrative web applications backed by Go services. The main employee workflow is composing and viewing conversations, with HTTP and realtime chat behavior, plus supporting file, search, identity, notification, and call capabilities. Administration provides a separate console for operational tasks. The README documents the broad stack and product boundaries; sampled source and the SOURCE INDEX support only some internal links, so uncertain service-to-service and UI-to-service connections are omitted or dashed.

Main entry points: [`services/chat-service/internal/app/app.go`](https://github.com/nicrepository/nchat/blob/develop/services/chat-service/internal/app/app.go) (Chat service), [`apps/web/src/chat/AppShell.tsx`](https://github.com/nicrepository/nchat/blob/develop/apps/web/src/chat/AppShell.tsx) (Conversation UI), [`apps/web/src/App.tsx`](https://github.com/nicrepository/nchat/blob/develop/apps/web/src/App.tsx) (Chat web app), [`apps/web/src/chat/chatApi.ts`](https://github.com/nicrepository/nchat/blob/develop/apps/web/src/chat/chatApi.ts) (Chat API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collaboration["Chat and collaboration"]
  node_webapp["Chat web app<br/>[App.tsx]"]
  node_chatui["Conversation UI<br/>[AppShell.tsx]"]
  node_chatapi["Chat API client<br/>[chatApi.ts]"]
  node_realtime["Chat realtime"]
  node_files["File client<br/>[filesApi.ts]"]
  node_search["Global search<br/>[useGlobalSearch.ts]"]
end

subgraph group_identity["Identity and calling"]
  node_authui["Sign-in UI<br/>[LoginPage.tsx]"]
  node_authservice["Authentication<br/>[auth_handler.go]"]
  node_callmedia["Call media<br/>[useCallMedia.ts]"]
end

subgraph group_services["Backend services"]
  node_chatservice["Chat service<br/>[app.go]"]
  node_messages["Message handling<br/>[message_service.go]"]
  node_filepreview["File previews<br/>[preview_service.go]"]
  node_searchservice["Search service<br/>[search_handler.go]"]
  node_media["Media service<br/>[app.go]"]
  node_notifications["Notifications<br/>[app.go]"]
  node_adminservice["Admin service<br/>[routes.go]"]
end

subgraph group_operations["Administration"]
  node_admin["Admin console<br/>[App.tsx]"]
  node_adminsession["Admin session"]
  node_adminapi["Admin API client<br/>[client.ts]"]
end

node_employee(("Employee"))
node_postgres[("PostgreSQL")]
node_valkey[("Valkey")]
node_seaweed[("SeaweedFS")]
node_livekit["LiveKit"]

node_employee -->|"uses"| node_webapp
node_webapp -.->|"presents"| node_chatui
node_chatui -.->|"loads conversations"| node_chatapi
node_chatui -.->|"receives updates"| node_realtime
node_chatapi -.->|"HTTP requests"| node_chatservice
node_realtime -.->|"WebSocket updates"| node_chatservice
node_chatservice -->|"builds services"| node_messages
node_chatservice -->|"uses cache and bus"| node_valkey
node_chatservice -->|"uses database"| node_postgres
node_files -.->|"requests previews"| node_filepreview
node_filepreview -.->|"stores files"| node_seaweed
node_search -.->|"search requests"| node_searchservice
node_authui -.->|"sign-in requests"| node_authservice
node_employee -.->|"signs in"| node_authui
node_callmedia -.->|"requests call tokens"| node_media
node_media -.->|"issues call tokens"| node_livekit
node_chatservice -.->|"notification events"| node_notifications
node_admin -->|"manages session"| node_adminsession
node_adminsession -->|"loads session"| node_adminapi
node_adminapi -.->|"admin requests"| node_adminservice
node_adminservice -.->|"uses database"| node_postgres

click node_webapp "https://github.com/nicrepository/nchat/blob/develop/apps/web/src/App.tsx"
click node_chatui "https://github.com/nicrepository/nchat/blob/develop/apps/web/src/chat/AppShell.tsx"
click node_chatapi "https://github.com/nicrepository/nchat/blob/develop/apps/web/src/chat/chatApi.ts"
click node_realtime "https://github.com/nicrepository/nchat/blob/develop/apps/web/src/chat/useChatWebSocket.ts"
click node_chatservice "https://github.com/nicrepository/nchat/blob/develop/services/chat-service/internal/app/app.go"
click node_messages "https://github.com/nicrepository/nchat/blob/develop/services/chat-service/internal/service/message_service.go"
click node_files "https://github.com/nicrepository/nchat/blob/develop/apps/web/src/chat/filesApi.ts"
click node_filepreview "https://github.com/nicrepository/nchat/blob/develop/services/file-service/internal/service/preview_service.go"
click node_search "https://github.com/nicrepository/nchat/blob/develop/apps/web/src/search/useGlobalSearch.ts"
click node_searchservice "https://github.com/nicrepository/nchat/blob/develop/services/search-service/internal/server/search_handler.go"
click node_authui "https://github.com/nicrepository/nchat/blob/develop/apps/web/src/auth/LoginPage.tsx"
click node_authservice "https://github.com/nicrepository/nchat/blob/develop/services/auth-service/internal/http/auth_handler.go"
click node_callmedia "https://github.com/nicrepository/nchat/blob/develop/apps/web/src/chat/useCallMedia.ts"
click node_media "https://github.com/nicrepository/nchat/blob/develop/services/media-service/internal/app/app.go"
click node_notifications "https://github.com/nicrepository/nchat/blob/develop/services/notification-service/internal/app/app.go"
click node_admin "https://github.com/nicrepository/nchat/blob/develop/apps/admin-web/src/App.tsx"
click node_adminsession "https://github.com/nicrepository/nchat/blob/develop/apps/admin-web/src/session/AdminSessionProvider.tsx"
click node_adminapi "https://github.com/nicrepository/nchat/blob/develop/apps/admin-web/src/api/client.ts"
click node_adminservice "https://github.com/nicrepository/nchat/blob/develop/services/admin-service/internal/http/routes.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_webapp,node_chatui,node_chatapi,node_realtime,node_files,node_search toneBlue
class node_authui,node_authservice,node_callmedia,node_postgres,node_valkey,node_seaweed toneAmber
class node_chatservice,node_messages,node_filepreview,node_searchservice,node_media,node_notifications,node_adminservice toneMint
class node_admin,node_adminsession,node_adminapi toneRose
class node_employee,node_livekit toneIndigo
```

## Components

### Chat and collaboration

- [Chat web app](https://github.com/nicrepository/nchat/blob/develop/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Conversation UI](https://github.com/nicrepository/nchat/blob/develop/apps/web/src/chat/AppShell.tsx): `apps/web/src/chat/AppShell.tsx`
- [Chat API client](https://github.com/nicrepository/nchat/blob/develop/apps/web/src/chat/chatApi.ts): `apps/web/src/chat/chatApi.ts`
- [Chat realtime](https://github.com/nicrepository/nchat/blob/develop/apps/web/src/chat/useChatWebSocket.ts): `apps/web/src/chat/useChatWebSocket.ts`
- [File client](https://github.com/nicrepository/nchat/blob/develop/apps/web/src/chat/filesApi.ts): `apps/web/src/chat/filesApi.ts`
- [Global search](https://github.com/nicrepository/nchat/blob/develop/apps/web/src/search/useGlobalSearch.ts): `apps/web/src/search/useGlobalSearch.ts`

### Identity and calling

- [Sign-in UI](https://github.com/nicrepository/nchat/blob/develop/apps/web/src/auth/LoginPage.tsx): `apps/web/src/auth/LoginPage.tsx`
- [Authentication](https://github.com/nicrepository/nchat/blob/develop/services/auth-service/internal/http/auth_handler.go): `services/auth-service/internal/http/auth_handler.go`
- [Call media](https://github.com/nicrepository/nchat/blob/develop/apps/web/src/chat/useCallMedia.ts): `apps/web/src/chat/useCallMedia.ts`

### Backend services

- [Chat service](https://github.com/nicrepository/nchat/blob/develop/services/chat-service/internal/app/app.go): `services/chat-service/internal/app/app.go`
- [Message handling](https://github.com/nicrepository/nchat/blob/develop/services/chat-service/internal/service/message_service.go): `services/chat-service/internal/service/message_service.go`
- [File previews](https://github.com/nicrepository/nchat/blob/develop/services/file-service/internal/service/preview_service.go): `services/file-service/internal/service/preview_service.go`
- [Search service](https://github.com/nicrepository/nchat/blob/develop/services/search-service/internal/server/search_handler.go): `services/search-service/internal/server/search_handler.go`
- [Media service](https://github.com/nicrepository/nchat/blob/develop/services/media-service/internal/app/app.go): `services/media-service/internal/app/app.go`
- [Notifications](https://github.com/nicrepository/nchat/blob/develop/services/notification-service/internal/app/app.go): `services/notification-service/internal/app/app.go`
- [Admin service](https://github.com/nicrepository/nchat/blob/develop/services/admin-service/internal/http/routes.go): `services/admin-service/internal/http/routes.go`

### Administration

- [Admin console](https://github.com/nicrepository/nchat/blob/develop/apps/admin-web/src/App.tsx): `apps/admin-web/src/App.tsx`
- [Admin session](https://github.com/nicrepository/nchat/blob/develop/apps/admin-web/src/session/AdminSessionProvider.tsx): `apps/admin-web/src/session/AdminSessionProvider.tsx`
- [Admin API client](https://github.com/nicrepository/nchat/blob/develop/apps/admin-web/src/api/client.ts): `apps/admin-web/src/api/client.ts`

### Other components

- **Employee**
- **PostgreSQL**
- **Valkey**
- **SeaweedFS**
- **LiveKit**

## Connections

- Employee → Chat web app: uses (evidence: `README.md`)
- Chat web app → Conversation UI: presents
- Conversation UI → Chat API client: loads conversations
- Conversation UI → Chat realtime: receives updates
- Chat API client → Chat service: HTTP requests
- Chat realtime → Chat service: WebSocket updates
- Chat service → Message handling: builds services (evidence: `services/chat-service/internal/app/app.go`)
- Chat service → Valkey: uses cache and bus (evidence: `README.md`)
- Chat service → PostgreSQL: uses database (evidence: `README.md`)
- File client → File previews: requests previews
- File previews → SeaweedFS: stores files
- Global search → Search service: search requests
- Sign-in UI → Authentication: sign-in requests
- Employee → Sign-in UI: signs in
- Call media → Media service: requests call tokens
- Media service → LiveKit: issues call tokens
- Chat service → Notifications: notification events
- Admin console → Admin session: manages session
- Admin session → Admin API client: loads session
- Admin API client → Admin service: admin requests
- Admin service → PostgreSQL: uses database
