# volotdmitriy/chat-core architecture

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

- Interactive diagram: https://gitdiagram.com/volotdmitriy/chat-core
- Repository: https://github.com/volotdmitriy/chat-core

## Overview

chat-core is a browser-based chat application with a NestJS backend. The principal workflow is user authentication, chat discovery/creation and membership, then message sending and history retrieval; a chat gateway and client socket hook indicate a realtime capability. The README only names the product, and most client and domain-service implementations were not sampled, so their detailed wiring is intentionally left unspecified.

Main entry points: [`client/app/page.tsx`](https://github.com/volotdmitriy/chat-core/blob/main/client/app/page.tsx) (Chat app page), [`server/src/prisma/prisma.service.ts`](https://github.com/volotdmitriy/chat-core/blob/main/server/src/prisma/prisma.service.ts) (Prisma service), [`client/app/(auth)/login/page.tsx`](https://github.com/volotdmitriy/chat-core/blob/main/client/app/(auth)/login/page.tsx) (Login page), [`client/app/(auth)/register/page.tsx`](https://github.com/volotdmitriy/chat-core/blob/main/client/app/(auth)/register/page.tsx) (Register page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_login["Login page<br/>[page.tsx]"]
  node_register["Register page<br/>[page.tsx]"]
  node_app["Chat app page<br/>[page.tsx]"]
  node_authcontext["Auth context<br/>[auth-context.tsx]"]
  node_api["API client<br/>[api.ts]"]
  node_chathooks["Chat hooks<br/>[use-chats.ts]"]
  node_messagehooks["Message hooks<br/>[use-messages.ts]"]
  node_sockethook["Socket hook<br/>[use-socket.ts]"]
end

subgraph group_identity["Identity"]
  node_authcontroller["Auth controller<br/>[auth.controller.ts]"]
  node_authservice["Auth service<br/>[auth.service.ts]"]
  node_usercontroller["User controller<br/>[user.controller.ts]"]
  node_userservice["User service<br/>[user.service.ts]"]
end

subgraph group_chat["Chat domain"]
  node_chatcontroller["Chat controller<br/>[chat.controller.ts]"]
  node_chatservice["Chat service<br/>[chat.service.ts]"]
  node_messagecontroller["Message controller"]
  node_messageservice["Message service<br/>[message.service.ts]"]
  node_gateway["Chat gateway<br/>[chat.gateway.ts]"]
  node_participants["Participant service"]
end

subgraph group_data["Persistence"]
  node_prisma["Prisma service<br/>[prisma.service.ts]"]
end

node_person(("User"))
node_database[("PostgreSQL")]

node_person -->|"enters credentials"| node_login
node_person -->|"creates account"| node_register
node_person -->|"uses chat"| node_app
node_login -->|"uses auth"| node_authcontext
node_register -->|"uses auth"| node_authcontext
node_app -->|"loads chats"| node_chathooks
node_app -->|"uses messages"| node_messagehooks
node_app -->|"uses socket"| node_sockethook
node_authcontroller -->|"calls"| node_authservice
node_chatcontroller -->|"calls"| node_chatservice
node_messagecontroller -->|"calls"| node_messageservice
node_usercontroller -->|"calls"| node_userservice
node_authservice -->|"reads and writes"| node_prisma
node_participants -->|"checks membership"| node_prisma
node_prisma -->|"queries"| node_database

click node_login "https://github.com/volotdmitriy/chat-core/blob/main/client/app/(auth)/login/page.tsx"
click node_register "https://github.com/volotdmitriy/chat-core/blob/main/client/app/(auth)/register/page.tsx"
click node_app "https://github.com/volotdmitriy/chat-core/blob/main/client/app/page.tsx"
click node_authcontext "https://github.com/volotdmitriy/chat-core/blob/main/client/context/auth-context.tsx"
click node_api "https://github.com/volotdmitriy/chat-core/blob/main/client/lib/api.ts"
click node_chathooks "https://github.com/volotdmitriy/chat-core/blob/main/client/hooks/use-chats.ts"
click node_messagehooks "https://github.com/volotdmitriy/chat-core/blob/main/client/hooks/use-messages.ts"
click node_sockethook "https://github.com/volotdmitriy/chat-core/blob/main/client/hooks/use-socket.ts"
click node_authcontroller "https://github.com/volotdmitriy/chat-core/blob/main/server/src/auth/auth.controller.ts"
click node_authservice "https://github.com/volotdmitriy/chat-core/blob/main/server/src/auth/auth.service.ts"
click node_chatcontroller "https://github.com/volotdmitriy/chat-core/blob/main/server/src/chat/chat.controller.ts"
click node_chatservice "https://github.com/volotdmitriy/chat-core/blob/main/server/src/chat/chat.service.ts"
click node_messagecontroller "https://github.com/volotdmitriy/chat-core/blob/main/server/src/message/message.controller.ts"
click node_messageservice "https://github.com/volotdmitriy/chat-core/blob/main/server/src/message/message.service.ts"
click node_gateway "https://github.com/volotdmitriy/chat-core/blob/main/server/src/chat/chat.gateway.ts"
click node_usercontroller "https://github.com/volotdmitriy/chat-core/blob/main/server/src/user/user.controller.ts"
click node_userservice "https://github.com/volotdmitriy/chat-core/blob/main/server/src/user/user.service.ts"
click node_participants "https://github.com/volotdmitriy/chat-core/blob/main/server/src/participant/participant.service.ts"
click node_prisma "https://github.com/volotdmitriy/chat-core/blob/main/server/src/prisma/prisma.service.ts"

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_login,node_register,node_app,node_authcontext,node_api,node_chathooks,node_messagehooks,node_sockethook,node_person toneBlue
class node_authcontroller,node_authservice,node_usercontroller,node_userservice,node_database toneAmber
class node_chatcontroller,node_chatservice,node_messagecontroller,node_messageservice,node_gateway,node_participants toneMint
class node_prisma toneRose
```

## Components

### Web client

- [Login page](https://github.com/volotdmitriy/chat-core/blob/main/client/app/(auth)/login/page.tsx): `client/app/(auth)/login/page.tsx`
- [Register page](https://github.com/volotdmitriy/chat-core/blob/main/client/app/(auth)/register/page.tsx): `client/app/(auth)/register/page.tsx`
- [Chat app page](https://github.com/volotdmitriy/chat-core/blob/main/client/app/page.tsx): `client/app/page.tsx`
- [Auth context](https://github.com/volotdmitriy/chat-core/blob/main/client/context/auth-context.tsx): `client/context/auth-context.tsx`
- [API client](https://github.com/volotdmitriy/chat-core/blob/main/client/lib/api.ts): `client/lib/api.ts`
- [Chat hooks](https://github.com/volotdmitriy/chat-core/blob/main/client/hooks/use-chats.ts): `client/hooks/use-chats.ts`
- [Message hooks](https://github.com/volotdmitriy/chat-core/blob/main/client/hooks/use-messages.ts): `client/hooks/use-messages.ts`
- [Socket hook](https://github.com/volotdmitriy/chat-core/blob/main/client/hooks/use-socket.ts): `client/hooks/use-socket.ts`

### Identity

- [Auth controller](https://github.com/volotdmitriy/chat-core/blob/main/server/src/auth/auth.controller.ts): `server/src/auth/auth.controller.ts`
- [Auth service](https://github.com/volotdmitriy/chat-core/blob/main/server/src/auth/auth.service.ts): `server/src/auth/auth.service.ts`
- [User controller](https://github.com/volotdmitriy/chat-core/blob/main/server/src/user/user.controller.ts): `server/src/user/user.controller.ts`
- [User service](https://github.com/volotdmitriy/chat-core/blob/main/server/src/user/user.service.ts): `server/src/user/user.service.ts`

### Chat domain

- [Chat controller](https://github.com/volotdmitriy/chat-core/blob/main/server/src/chat/chat.controller.ts): `server/src/chat/chat.controller.ts`
- [Chat service](https://github.com/volotdmitriy/chat-core/blob/main/server/src/chat/chat.service.ts): `server/src/chat/chat.service.ts`
- [Message controller](https://github.com/volotdmitriy/chat-core/blob/main/server/src/message/message.controller.ts): `server/src/message/message.controller.ts`
- [Message service](https://github.com/volotdmitriy/chat-core/blob/main/server/src/message/message.service.ts): `server/src/message/message.service.ts`
- [Chat gateway](https://github.com/volotdmitriy/chat-core/blob/main/server/src/chat/chat.gateway.ts): `server/src/chat/chat.gateway.ts`
- [Participant service](https://github.com/volotdmitriy/chat-core/blob/main/server/src/participant/participant.service.ts): `server/src/participant/participant.service.ts`

### Persistence

- [Prisma service](https://github.com/volotdmitriy/chat-core/blob/main/server/src/prisma/prisma.service.ts): `server/src/prisma/prisma.service.ts`

### Other components

- **User**
- **PostgreSQL**

## Connections

- User → Login page: enters credentials
- User → Register page: creates account
- User → Chat app page: uses chat
- Login page → Auth context: uses auth
- Register page → Auth context: uses auth
- Chat app page → Chat hooks: loads chats
- Chat app page → Message hooks: uses messages
- Chat app page → Socket hook: uses socket
- Auth controller → Auth service: calls
- Chat controller → Chat service: calls
- Message controller → Message service: calls
- User controller → User service: calls
- Auth service → Prisma service: reads and writes
- Participant service → Prisma service: checks membership
- Prisma service → PostgreSQL: queries
