# serogee/hive architecture

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

- Interactive diagram: https://gitdiagram.com/serogee/hive
- Repository: https://github.com/serogee/hive

## Overview

Hive is an offline-first Android quiz app for authoring and importing question stacks, solo review, and multiplayer sessions hosted nearby or through a Ktor server. The main user flow runs from Compose screens through repositories to local storage or shared room services: users create/review stacks, host or join sessions, answer questions, and receive live results. Account sync and app updates are additional capabilities. The repository provides shared quiz rules and API contracts to both embedded and standalone hosts. Edges are limited to relationships visible in the README or supplied excerpts/index; unsampled subsystems are represented by their exact enclosing directories.

Main entry points: [`client/src/main/kotlin/io/github/serogee/hive/ui`](https://github.com/serogee/hive/tree/main/client/src/main/kotlin/io/github/serogee/hive/ui) (Compose screens), [`shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomService.kt`](https://github.com/serogee/hive/blob/main/shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomService.kt) (Room service), [`client/src/main/kotlin/io/github/serogee/hive/data/rooms/RoomRepository.kt`](https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/data/rooms/RoomRepository.kt) (Room repository), [`shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomRoutes.kt`](https://github.com/serogee/hive/blob/main/shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomRoutes.kt) (Room routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Android app"]
  node_application["App startup<br/>[HiveApplication.kt]"]
  node_screens["Compose screens"]
  node_auth["Sign-in"]
  node_updates["App updates"]
end

subgraph group_content["Stacks and review"]
  node_stacks["Stack authoring"]
  node_stackdata["Stack repository<br/>[StackRepository.kt]"]
  node_localdb[("Local database<br/>[HiveDatabase.kt]")]
  node_import["Stack import"]
  node_review["Solo review"]
  node_reviewrules["Review rules<br/>[Review.kt]"]
end

subgraph group_sessions["Quiz sessions"]
  node_roomui["Room screens"]
  node_roomrepo["Room repository<br/>[RoomRepository.kt]"]
  node_localhost["Phone host<br/>[LocalHost.kt]"]
  node_roomroutes["Room routes<br/>[RoomRoutes.kt]"]
  node_roomservice["Room service<br/>[RoomService.kt]"]
  node_roomstore[("Room storage<br/>[RoomStore.kt]")]
  node_quizrules["Quiz rules"]
  node_events["Live events<br/>[RoomEventHub.kt]"]
end

subgraph group_platform["Shared and server"]
  node_standalone["Standalone server<br/>[Application.kt]"]
  node_sync["Account sync<br/>[SyncEngine.kt]"]
  node_syncservice["Sync service<br/>[SyncService.kt]"]
  node_postgres[("Postgres storage")]
end

node_user(("User"))
node_supabase["Supabase"]
node_github["GitHub releases"]
node_online["Online server"]

node_user -->|"uses"| node_screens
node_screens -->|"edits"| node_stacks
node_stacks -.->|"manages"| node_stackdata
node_stackdata -->|"stores"| node_localdb
node_screens -.->|"imports"| node_import
node_screens -->|"reviews"| node_review
node_review -->|"uses"| node_reviewrules
node_user -->|"hosts or joins"| node_roomui
node_roomui -.->|"requests"| node_roomrepo
node_roomrepo -->|"uses nearby"| node_localhost
node_roomrepo -.->|"calls online"| node_online
node_localhost -.->|"serves"| node_roomroutes
node_standalone -->|"registers"| node_roomroutes
node_roomroutes -->|"dispatches"| node_roomservice
node_roomservice -->|"reads and writes"| node_roomstore
node_roomservice -->|"applies"| node_quizrules
node_roomservice -->|"publishes"| node_events
node_standalone -->|"registers"| node_syncservice
node_syncservice -.->|"persists via"| node_postgres
node_sync -.->|"syncs with"| node_online
node_auth -.->|"authenticates"| node_supabase
node_updates -->|"checks releases"| node_github
node_sync -.->|"transfers data"| node_online

click node_application "https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/HiveApplication.kt"
click node_screens "https://github.com/serogee/hive/tree/main/client/src/main/kotlin/io/github/serogee/hive/ui"
click node_auth "https://github.com/serogee/hive/tree/main/client/src/main/kotlin/io/github/serogee/hive/data/auth"
click node_updates "https://github.com/serogee/hive/tree/main/client/src/main/kotlin/io/github/serogee/hive/data/updates"
click node_stacks "https://github.com/serogee/hive/tree/main/client/src/main/kotlin/io/github/serogee/hive/ui/stacks"
click node_stackdata "https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/data/stacks/StackRepository.kt"
click node_localdb "https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/data/local/HiveDatabase.kt"
click node_import "https://github.com/serogee/hive/tree/main/shared/core/src/main/kotlin/io/github/serogee/hive/core/transfer"
click node_review "https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/data/review/ReviewRepository.kt"
click node_reviewrules "https://github.com/serogee/hive/blob/main/shared/core/src/main/kotlin/io/github/serogee/hive/core/review/Review.kt"
click node_roomui "https://github.com/serogee/hive/tree/main/client/src/main/kotlin/io/github/serogee/hive/ui/rooms"
click node_roomrepo "https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/data/rooms/RoomRepository.kt"
click node_localhost "https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/localhost/LocalHost.kt"
click node_roomroutes "https://github.com/serogee/hive/blob/main/shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomRoutes.kt"
click node_roomservice "https://github.com/serogee/hive/blob/main/shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomService.kt"
click node_roomstore "https://github.com/serogee/hive/blob/main/shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomStore.kt"
click node_quizrules "https://github.com/serogee/hive/tree/main/shared/core/src/main/kotlin/io/github/serogee/hive/core/engine"
click node_events "https://github.com/serogee/hive/blob/main/shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomEventHub.kt"
click node_standalone "https://github.com/serogee/hive/blob/main/server/src/main/kotlin/io/github/serogee/hive/server/Application.kt"
click node_sync "https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/data/sync/SyncEngine.kt"
click node_syncservice "https://github.com/serogee/hive/blob/main/server/src/main/kotlin/io/github/serogee/hive/server/sync/SyncService.kt"
click node_postgres "https://github.com/serogee/hive/blob/main/server/src/main/kotlin/io/github/serogee/hive/server/postgres/PostgresDatabase.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_application,node_screens,node_auth,node_updates,node_user toneBlue
class node_stacks,node_stackdata,node_localdb,node_import,node_review,node_reviewrules toneAmber
class node_roomui,node_roomrepo,node_localhost,node_roomroutes,node_roomservice,node_roomstore,node_quizrules,node_events,node_online toneMint
class node_standalone,node_sync,node_syncservice,node_postgres toneRose
class node_supabase,node_github toneIndigo
```

## Components

### Android app

- [App startup](https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/HiveApplication.kt): `client/src/main/kotlin/io/github/serogee/hive/HiveApplication.kt`
- [Compose screens](https://github.com/serogee/hive/tree/main/client/src/main/kotlin/io/github/serogee/hive/ui): `client/src/main/kotlin/io/github/serogee/hive/ui`
- [Sign-in](https://github.com/serogee/hive/tree/main/client/src/main/kotlin/io/github/serogee/hive/data/auth): `client/src/main/kotlin/io/github/serogee/hive/data/auth`
- [App updates](https://github.com/serogee/hive/tree/main/client/src/main/kotlin/io/github/serogee/hive/data/updates): `client/src/main/kotlin/io/github/serogee/hive/data/updates`

### Stacks and review

- [Stack authoring](https://github.com/serogee/hive/tree/main/client/src/main/kotlin/io/github/serogee/hive/ui/stacks): `client/src/main/kotlin/io/github/serogee/hive/ui/stacks`
- [Stack repository](https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/data/stacks/StackRepository.kt): `client/src/main/kotlin/io/github/serogee/hive/data/stacks/StackRepository.kt`
- [Local database](https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/data/local/HiveDatabase.kt): `client/src/main/kotlin/io/github/serogee/hive/data/local/HiveDatabase.kt`
- [Stack import](https://github.com/serogee/hive/tree/main/shared/core/src/main/kotlin/io/github/serogee/hive/core/transfer): `shared/core/src/main/kotlin/io/github/serogee/hive/core/transfer`
- [Solo review](https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/data/review/ReviewRepository.kt): `client/src/main/kotlin/io/github/serogee/hive/data/review/ReviewRepository.kt`
- [Review rules](https://github.com/serogee/hive/blob/main/shared/core/src/main/kotlin/io/github/serogee/hive/core/review/Review.kt): `shared/core/src/main/kotlin/io/github/serogee/hive/core/review/Review.kt`

### Quiz sessions

- [Room screens](https://github.com/serogee/hive/tree/main/client/src/main/kotlin/io/github/serogee/hive/ui/rooms): `client/src/main/kotlin/io/github/serogee/hive/ui/rooms`
- [Room repository](https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/data/rooms/RoomRepository.kt): `client/src/main/kotlin/io/github/serogee/hive/data/rooms/RoomRepository.kt`
- [Phone host](https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/localhost/LocalHost.kt): `client/src/main/kotlin/io/github/serogee/hive/localhost/LocalHost.kt`
- [Room routes](https://github.com/serogee/hive/blob/main/shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomRoutes.kt): `shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomRoutes.kt`
- [Room service](https://github.com/serogee/hive/blob/main/shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomService.kt): `shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomService.kt`
- [Room storage](https://github.com/serogee/hive/blob/main/shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomStore.kt): `shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomStore.kt`
- [Quiz rules](https://github.com/serogee/hive/tree/main/shared/core/src/main/kotlin/io/github/serogee/hive/core/engine): `shared/core/src/main/kotlin/io/github/serogee/hive/core/engine`
- [Live events](https://github.com/serogee/hive/blob/main/shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomEventHub.kt): `shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomEventHub.kt`

### Shared and server

- [Standalone server](https://github.com/serogee/hive/blob/main/server/src/main/kotlin/io/github/serogee/hive/server/Application.kt): `server/src/main/kotlin/io/github/serogee/hive/server/Application.kt`
- [Account sync](https://github.com/serogee/hive/blob/main/client/src/main/kotlin/io/github/serogee/hive/data/sync/SyncEngine.kt): `client/src/main/kotlin/io/github/serogee/hive/data/sync/SyncEngine.kt`
- [Sync service](https://github.com/serogee/hive/blob/main/server/src/main/kotlin/io/github/serogee/hive/server/sync/SyncService.kt): `server/src/main/kotlin/io/github/serogee/hive/server/sync/SyncService.kt`
- [Postgres storage](https://github.com/serogee/hive/blob/main/server/src/main/kotlin/io/github/serogee/hive/server/postgres/PostgresDatabase.kt): `server/src/main/kotlin/io/github/serogee/hive/server/postgres/PostgresDatabase.kt`

### Other components

- **User**
- **Supabase**
- **GitHub releases**
- **Online server**

## Connections

- User → Compose screens: uses
- Compose screens → Stack authoring: edits
- Stack authoring → Stack repository: manages
- Stack repository → Local database: stores (evidence: `client/src/main/kotlin/io/github/serogee/hive/data/local/HiveDatabase.kt`)
- Compose screens → Stack import: imports
- Compose screens → Solo review: reviews
- Solo review → Review rules: uses (evidence: `client/src/main/kotlin/io/github/serogee/hive/data/review/ReviewRepository.kt`)
- User → Room screens: hosts or joins
- Room screens → Room repository: requests
- Room repository → Phone host: uses nearby (evidence: `client/src/main/kotlin/io/github/serogee/hive/data/rooms/RoomRepository.kt`)
- Room repository → Online server: calls online
- Phone host → Room routes: serves
- Standalone server → Room routes: registers (evidence: `server/src/main/kotlin/io/github/serogee/hive/server/Application.kt`)
- Room routes → Room service: dispatches (evidence: `shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomRoutes.kt`)
- Room service → Room storage: reads and writes (evidence: `shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomService.kt`)
- Room service → Quiz rules: applies (evidence: `shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomService.kt`)
- Room service → Live events: publishes (evidence: `shared/host/src/main/kotlin/io/github/serogee/hive/host/RoomService.kt`)
- Standalone server → Sync service: registers (evidence: `server/src/main/kotlin/io/github/serogee/hive/server/Application.kt`)
- Sync service → Postgres storage: persists via
- Account sync → Online server: syncs with
- Sign-in → Supabase: authenticates
- App updates → GitHub releases: checks releases
- Account sync → Online server: transfers data
