# bigbread57/rassvet-chat architecture

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

- Interactive diagram: https://gitdiagram.com/bigbread57/rassvet-chat
- Repository: https://github.com/bigbread57/rassvet-chat

## Overview

Rassвет is an Android room-chat client backed by a Go service, with two-node synchronization as a core capability. The main user flow is device activation, room discovery and messaging, with attachments handled through permission checks and transfer; administrators also manage users and rooms. Service state is persisted in SQLite, and peer events are exchanged over mutually authenticated TLS. The sampled code confirms client requests, attachment handling, and sync ownership; unsampled API wiring is represented only at package level. Voice and video are documented requirements, not current implemented capabilities.

Main entry points: [`service/cmd/rassvetd/main.go`](https://github.com/bigbread57/rassvet-chat/blob/main/service/cmd/rassvetd/main.go) (Go service), [`android/app/src/main/java/ru/rassvet/chat/MainActivity.kt`](https://github.com/bigbread57/rassvet-chat/blob/main/android/app/src/main/java/ru/rassvet/chat/MainActivity.kt) (Chat and admin UI), [`service/migrations/001_initial.sql`](https://github.com/bigbread57/rassvet-chat/blob/main/service/migrations/001_initial.sql) (SQLite state), [`service/internal/api/attachments.go`](https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/api/attachments.go) (Attachment API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_android["Android client"]
  node_ui["Chat and admin UI<br/>[MainActivity.kt]"]
  node_chatui["Chat components<br/>[ChatUi.kt]"]
  node_deviceclient["Device client<br/>[DeviceClient.kt]"]
  node_pinlock["PIN lock<br/>[PinLock.kt]"]
  node_capture["Portrait capture"]
  node_share["Attachment sharing<br/>[ShareProvider.kt]"]
end

subgraph group_api["Service API"]
  node_service["Go service<br/>[main.go]"]
  node_activation["Device activation<br/>[activation.go]"]
  node_rooms["Room access<br/>[rooms.go]"]
  node_messages["Messages and receipts<br/>[messages.go]"]
  node_attachments["Attachment API<br/>[attachments.go]"]
  node_adminapi["Admin operations<br/>[admin.go]"]
end

subgraph group_sync["Peer service"]
  node_peerapi["Peer event API<br/>[peer.go]"]
end

subgraph group_security["Identity and state"]
  node_database[("SQLite state<br/>[001_initial.sql]")]
  node_files[("Attachment files")]
  node_auth["Device signature checks<br/>[verify.go]"]
  node_tls["Node TLS identity<br/>[nodetls.go]"]
  node_bootstrap["Admin bootstrap<br/>[admin.go]"]
  node_migrations["Schema migrations<br/>[migrate.go]"]
end

node_person(("Chat user"))
node_admin(("Administrator"))
node_peer["Second service node"]

node_person -->|"uses"| node_ui
node_admin -->|"uses"| node_ui
node_ui -->|"renders"| node_chatui
node_ui -->|"requests"| node_deviceclient
node_ui -->|"locks with"| node_pinlock
node_ui -.->|"captures"| node_capture
node_ui -.->|"shares"| node_share
node_deviceclient -->|"HTTPS requests"| node_service
node_service -->|"serves"| node_activation
node_service -->|"serves"| node_rooms
node_service -->|"serves"| node_messages
node_service -->|"serves"| node_attachments
node_service -->|"serves"| node_adminapi
node_service -->|"opens database"| node_migrations
node_activation -->|"reads and writes"| node_database
node_rooms -->|"reads and writes"| node_database
node_messages -->|"reads and writes"| node_database
node_attachments -->|"reads and writes"| node_database
node_attachments -->|"stores and reads"| node_files
node_attachments -->|"verifies requests"| node_auth
node_adminapi -->|"reads and writes"| node_database
node_service -->|"configures TLS"| node_tls
node_service -->|"runs sync"| node_peerapi
node_peerapi -->|"exchanges events"| node_peer
node_peerapi -->|"reads and writes"| node_database
node_peerapi -->|"replicates attachments"| node_files
node_bootstrap -->|"creates admin"| node_database

click node_ui "https://github.com/bigbread57/rassvet-chat/blob/main/android/app/src/main/java/ru/rassvet/chat/MainActivity.kt"
click node_chatui "https://github.com/bigbread57/rassvet-chat/blob/main/android/app/src/main/java/ru/rassvet/chat/ChatUi.kt"
click node_deviceclient "https://github.com/bigbread57/rassvet-chat/blob/main/android/app/src/main/java/ru/rassvet/chat/DeviceClient.kt"
click node_pinlock "https://github.com/bigbread57/rassvet-chat/blob/main/android/app/src/main/java/ru/rassvet/chat/PinLock.kt"
click node_capture "https://github.com/bigbread57/rassvet-chat/blob/main/android/app/src/main/java/ru/rassvet/chat/PortraitCaptureActivity.kt"
click node_share "https://github.com/bigbread57/rassvet-chat/blob/main/android/app/src/main/java/ru/rassvet/chat/ShareProvider.kt"
click node_service "https://github.com/bigbread57/rassvet-chat/blob/main/service/cmd/rassvetd/main.go"
click node_activation "https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/api/activation.go"
click node_rooms "https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/api/rooms.go"
click node_messages "https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/api/messages.go"
click node_attachments "https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/api/attachments.go"
click node_adminapi "https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/api/admin.go"
click node_peerapi "https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/api/peer.go"
click node_database "https://github.com/bigbread57/rassvet-chat/blob/main/service/migrations/001_initial.sql"
click node_auth "https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/deviceauth/verify.go"
click node_tls "https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/nodetls/nodetls.go"
click node_bootstrap "https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/bootstrap/admin.go"
click node_migrations "https://github.com/bigbread57/rassvet-chat/blob/main/service/migrations/migrate.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_ui,node_chatui,node_deviceclient,node_pinlock,node_capture,node_share,node_person toneBlue
class node_service,node_activation,node_rooms,node_messages,node_attachments,node_adminapi toneAmber
class node_peerapi toneMint
class node_database,node_files,node_auth,node_tls,node_bootstrap,node_migrations toneRose
class node_admin,node_peer toneIndigo
```

## Components

### Android client

- [Chat and admin UI](https://github.com/bigbread57/rassvet-chat/blob/main/android/app/src/main/java/ru/rassvet/chat/MainActivity.kt): `android/app/src/main/java/ru/rassvet/chat/MainActivity.kt`
- [Chat components](https://github.com/bigbread57/rassvet-chat/blob/main/android/app/src/main/java/ru/rassvet/chat/ChatUi.kt): `android/app/src/main/java/ru/rassvet/chat/ChatUi.kt`
- [Device client](https://github.com/bigbread57/rassvet-chat/blob/main/android/app/src/main/java/ru/rassvet/chat/DeviceClient.kt): `android/app/src/main/java/ru/rassvet/chat/DeviceClient.kt`
- [PIN lock](https://github.com/bigbread57/rassvet-chat/blob/main/android/app/src/main/java/ru/rassvet/chat/PinLock.kt): `android/app/src/main/java/ru/rassvet/chat/PinLock.kt`
- [Portrait capture](https://github.com/bigbread57/rassvet-chat/blob/main/android/app/src/main/java/ru/rassvet/chat/PortraitCaptureActivity.kt): `android/app/src/main/java/ru/rassvet/chat/PortraitCaptureActivity.kt`
- [Attachment sharing](https://github.com/bigbread57/rassvet-chat/blob/main/android/app/src/main/java/ru/rassvet/chat/ShareProvider.kt): `android/app/src/main/java/ru/rassvet/chat/ShareProvider.kt`

### Service API

- [Go service](https://github.com/bigbread57/rassvet-chat/blob/main/service/cmd/rassvetd/main.go): `service/cmd/rassvetd/main.go`
- [Device activation](https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/api/activation.go): `service/internal/api/activation.go`
- [Room access](https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/api/rooms.go): `service/internal/api/rooms.go`
- [Messages and receipts](https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/api/messages.go): `service/internal/api/messages.go`
- [Attachment API](https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/api/attachments.go): `service/internal/api/attachments.go`
- [Admin operations](https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/api/admin.go): `service/internal/api/admin.go`

### Peer service

- [Peer event API](https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/api/peer.go): `service/internal/api/peer.go`

### Identity and state

- [SQLite state](https://github.com/bigbread57/rassvet-chat/blob/main/service/migrations/001_initial.sql): `service/migrations/001_initial.sql`
- **Attachment files**
- [Device signature checks](https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/deviceauth/verify.go): `service/internal/deviceauth/verify.go`
- [Node TLS identity](https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/nodetls/nodetls.go): `service/internal/nodetls/nodetls.go`
- [Admin bootstrap](https://github.com/bigbread57/rassvet-chat/blob/main/service/internal/bootstrap/admin.go): `service/internal/bootstrap/admin.go`
- [Schema migrations](https://github.com/bigbread57/rassvet-chat/blob/main/service/migrations/migrate.go): `service/migrations/migrate.go`

### Other components

- **Chat user**
- **Administrator**
- **Second service node**

## Connections

- Chat user → Chat and admin UI: uses
- Administrator → Chat and admin UI: uses
- Chat and admin UI → Chat components: renders
- Chat and admin UI → Device client: requests
- Chat and admin UI → PIN lock: locks with
- Chat and admin UI → Portrait capture: captures
- Chat and admin UI → Attachment sharing: shares
- Device client → Go service: HTTPS requests
- Go service → Device activation: serves
- Go service → Room access: serves
- Go service → Messages and receipts: serves
- Go service → Attachment API: serves
- Go service → Admin operations: serves
- Go service → Schema migrations: opens database
- Device activation → SQLite state: reads and writes
- Room access → SQLite state: reads and writes
- Messages and receipts → SQLite state: reads and writes
- Attachment API → SQLite state: reads and writes
- Attachment API → Attachment files: stores and reads
- Attachment API → Device signature checks: verifies requests
- Admin operations → SQLite state: reads and writes
- Go service → Node TLS identity: configures TLS
- Go service → Peer event API: runs sync
- Peer event API → Second service node: exchanges events
- Peer event API → SQLite state: reads and writes
- Peer event API → Attachment files: replicates attachments
- Admin bootstrap → SQLite state: creates admin
