# graduation-work-2025-26-hasslspaceapp/hasslspace-backend architecture

> Architecture diagram of the GitHub repository graduation-work-2025-26-hasslspaceapp/hasslspace-backend, 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/graduation-work-2025-26-hasslspaceapp/hasslspace-backend
- Repository: https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend

## Overview

HasslSpace is a multi-service chat and community backend: users register and authenticate, form friendships, create and administer servers/channels, then exchange messages or obtain voice-room tokens. The graph captures those domain services plus notification delivery and object storage. Relationships are limited to explicit calls in the excerpts or indexed references; several service-to-service links and unsampled controller routing are therefore omitted rather than inferred.

Main entry points: [`user-service/src/main/kotlin/ru/hse/hasslspace/userservice/service/AuthService.kt`](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/user-service/src/main/kotlin/ru/hse/hasslspace/userservice/service/AuthService.kt) (Authentication), [`notification-service/src/main/kotlin/ru/hse/hasslspace/notificationservice/service/EmailSenderService.kt`](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/notification-service/src/main/kotlin/ru/hse/hasslspace/notificationservice/service/EmailSenderService.kt) (Email sender), [`server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/repository/ServerRepository.kt`](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/repository/ServerRepository.kt) (Server data), [`chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/service/ChatService.kt`](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/service/ChatService.kt) (Chat & messages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity &amp; friends"]
  node_user["User API<br/>[AuthController.kt]"]
  node_auth["Authentication<br/>[AuthService.kt]"]
  node_friendship["Friendships"]
  node_userstore[("User records<br/>[UserRepository.kt]")]
end

subgraph group_community["Servers &amp; channels"]
  node_serverapi["Server APIs"]
  node_server["Server management<br/>[ServerService.kt]"]
  node_membership["Membership &amp; invites"]
  node_channels["Channel permissions<br/>[ChannelService.kt]"]
  node_serverstore[("Server data")]
end

subgraph group_messaging["Chat &amp; media"]
  node_chatapi["Chat API<br/>[ChatController.kt]"]
  node_chat["Chat &amp; messages<br/>[ChatService.kt]"]
  node_chatstore[("Chat records")]
  node_realtime["Realtime publish"]
  node_chatmedia["Chat file storage<br/>[S3Service.kt]"]
end

subgraph group_integrations["Notifications &amp; voice"]
  node_voiceapi["Voice API"]
  node_voice["Voice tokens"]
  node_notifyapi["Notification API<br/>[MailController.kt]"]
  node_listener["Email event listener"]
  node_email["Email sender"]
end

node_s3[("S3 storage")]
node_livekit["LiveKit"]
node_mail["Mail transport"]
node_actor(("Client"))

node_actor -->|"requests"| node_user
node_actor -->|"requests"| node_serverapi
node_actor -->|"requests"| node_chatapi
node_actor -->|"requests"| node_voiceapi
node_actor -->|"requests"| node_notifyapi
node_auth -->|"reads/writes"| node_userstore
node_auth -.->|"issues tokens"| node_user
node_friendship -->|"loads users"| node_userstore
node_server -->|"reads/writes"| node_serverstore
node_membership -->|"manages membership"| node_serverstore
node_channels -->|"checks permissions"| node_serverstore
node_chat -->|"saves messages"| node_chatstore
node_chat -->|"publishes message"| node_realtime
node_chatmedia -->|"uploads/downloads"| node_s3
node_voice -->|"creates token"| node_livekit
node_listener -->|"delegates email"| node_email
node_notifyapi -.->|"sends request"| node_email
node_email -->|"sends mail"| node_mail
node_auth -.->|"verification event"| node_listener

click node_user "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/user-service/src/main/kotlin/ru/hse/hasslspace/userservice/controller/AuthController.kt"
click node_auth "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/user-service/src/main/kotlin/ru/hse/hasslspace/userservice/service/AuthService.kt"
click node_friendship "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/user-service/src/main/kotlin/ru/hse/hasslspace/userservice/service/FriendshipService.kt"
click node_userstore "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/user-service/src/main/kotlin/ru/hse/hasslspace/userservice/repository/UserRepository.kt"
click node_serverapi "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/controller/ServerController.kt"
click node_server "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/service/ServerService.kt"
click node_membership "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/service/ServerMemberService.kt"
click node_channels "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/service/ChannelService.kt"
click node_serverstore "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/repository/ServerRepository.kt"
click node_chatapi "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/controller/ChatController.kt"
click node_chat "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/service/ChatService.kt"
click node_chatstore "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/repository/MessageRepository.kt"
click node_realtime "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/service/CentrifugoService.kt"
click node_chatmedia "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/service/S3Service.kt"
click node_voiceapi "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/voice-service/src/main/kotlin/ru/hse/hasslspace/voiceservice/controller/VoiceChatController.kt"
click node_voice "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/voice-service/src/main/kotlin/ru/hse/hasslspace/voiceservice/service/VoiceChatService.kt"
click node_notifyapi "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/notification-service/src/main/kotlin/ru/hse/hasslspace/notificationservice/controller/MailController.kt"
click node_listener "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/notification-service/src/main/kotlin/ru/hse/hasslspace/notificationservice/service/KafkaListenerService.kt"
click node_email "https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/notification-service/src/main/kotlin/ru/hse/hasslspace/notificationservice/service/EmailSenderService.kt"

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_user,node_auth,node_friendship,node_userstore,node_actor toneBlue
class node_serverapi,node_server,node_membership,node_channels,node_serverstore,node_s3 toneAmber
class node_chatapi,node_chat,node_chatstore,node_realtime,node_chatmedia toneMint
class node_voiceapi,node_voice,node_notifyapi,node_listener,node_email toneRose
class node_livekit,node_mail toneIndigo
```

## Components

### Identity & friends

- [User API](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/user-service/src/main/kotlin/ru/hse/hasslspace/userservice/controller/AuthController.kt): `user-service/src/main/kotlin/ru/hse/hasslspace/userservice/controller/AuthController.kt`
- [Authentication](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/user-service/src/main/kotlin/ru/hse/hasslspace/userservice/service/AuthService.kt): `user-service/src/main/kotlin/ru/hse/hasslspace/userservice/service/AuthService.kt`
- [Friendships](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/user-service/src/main/kotlin/ru/hse/hasslspace/userservice/service/FriendshipService.kt): `user-service/src/main/kotlin/ru/hse/hasslspace/userservice/service/FriendshipService.kt`
- [User records](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/user-service/src/main/kotlin/ru/hse/hasslspace/userservice/repository/UserRepository.kt): `user-service/src/main/kotlin/ru/hse/hasslspace/userservice/repository/UserRepository.kt`

### Servers & channels

- [Server APIs](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/controller/ServerController.kt): `server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/controller/ServerController.kt`
- [Server management](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/service/ServerService.kt): `server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/service/ServerService.kt`
- [Membership & invites](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/service/ServerMemberService.kt): `server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/service/ServerMemberService.kt`
- [Channel permissions](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/service/ChannelService.kt): `server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/service/ChannelService.kt`
- [Server data](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/repository/ServerRepository.kt): `server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/repository/ServerRepository.kt`

### Chat & media

- [Chat API](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/controller/ChatController.kt): `chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/controller/ChatController.kt`
- [Chat & messages](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/service/ChatService.kt): `chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/service/ChatService.kt`
- [Chat records](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/repository/MessageRepository.kt): `chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/repository/MessageRepository.kt`
- [Realtime publish](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/service/CentrifugoService.kt): `chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/service/CentrifugoService.kt`
- [Chat file storage](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/service/S3Service.kt): `chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/service/S3Service.kt`

### Notifications & voice

- [Voice API](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/voice-service/src/main/kotlin/ru/hse/hasslspace/voiceservice/controller/VoiceChatController.kt): `voice-service/src/main/kotlin/ru/hse/hasslspace/voiceservice/controller/VoiceChatController.kt`
- [Voice tokens](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/voice-service/src/main/kotlin/ru/hse/hasslspace/voiceservice/service/VoiceChatService.kt): `voice-service/src/main/kotlin/ru/hse/hasslspace/voiceservice/service/VoiceChatService.kt`
- [Notification API](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/notification-service/src/main/kotlin/ru/hse/hasslspace/notificationservice/controller/MailController.kt): `notification-service/src/main/kotlin/ru/hse/hasslspace/notificationservice/controller/MailController.kt`
- [Email event listener](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/notification-service/src/main/kotlin/ru/hse/hasslspace/notificationservice/service/KafkaListenerService.kt): `notification-service/src/main/kotlin/ru/hse/hasslspace/notificationservice/service/KafkaListenerService.kt`
- [Email sender](https://github.com/graduation-work-2025-26-hasslspaceapp/hasslspace-backend/blob/develop/notification-service/src/main/kotlin/ru/hse/hasslspace/notificationservice/service/EmailSenderService.kt): `notification-service/src/main/kotlin/ru/hse/hasslspace/notificationservice/service/EmailSenderService.kt`

### Other components

- **S3 storage**
- **LiveKit**
- **Mail transport**
- **Client**

## Connections

- Client → User API: requests
- Client → Server APIs: requests
- Client → Chat API: requests
- Client → Voice API: requests
- Client → Notification API: requests
- Authentication → User records: reads/writes (evidence: `user-service/src/main/kotlin/ru/hse/hasslspace/userservice/service/AuthService.kt`)
- Authentication → User API: issues tokens
- Friendships → User records: loads users (evidence: `user-service/src/main/kotlin/ru/hse/hasslspace/userservice/service/FriendshipService.kt`)
- Server management → Server data: reads/writes (evidence: `server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/service/ServerService.kt`)
- Membership & invites → Server data: manages membership (evidence: `server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/service/ServerMemberService.kt`)
- Channel permissions → Server data: checks permissions (evidence: `server-service/src/main/kotlin/ru/hse/hasslspace/serverservice/service/ChannelService.kt`)
- Chat & messages → Chat records: saves messages (evidence: `chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/service/ChatService.kt`)
- Chat & messages → Realtime publish: publishes message (evidence: `chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/service/ChatService.kt`)
- Chat file storage → S3 storage: uploads/downloads (evidence: `chat-service/src/main/kotlin/ru/hse/hasslspace/chatservice/service/S3Service.kt`)
- Voice tokens → LiveKit: creates token (evidence: `voice-service/src/main/kotlin/ru/hse/hasslspace/voiceservice/service/VoiceChatService.kt`)
- Email event listener → Email sender: delegates email (evidence: `notification-service/src/main/kotlin/ru/hse/hasslspace/notificationservice/service/KafkaListenerService.kt`)
- Notification API → Email sender: sends request (evidence: `notification-service/src/main/kotlin/ru/hse/hasslspace/notificationservice/controller/MailController.kt`)
- Email sender → Mail transport: sends mail (evidence: `notification-service/src/main/kotlin/ru/hse/hasslspace/notificationservice/service/EmailSenderService.kt`)
- Authentication → Email event listener: verification event
