# moon-chm/collabsphere architecture

> Architecture diagram of the GitHub repository moon-chm/collabsphere, 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/moon-chm/collabsphere
- Repository: https://github.com/moon-chm/collabsphere

## Overview

CollabSphere is a local-first team collaboration platform: Android users authenticate and work across workspaces, messaging, tasks, notes, and files, with local data and background synchronization supporting offline use. The Ktor backend serves the client, persists shared state, and supports real-time communication and integrations. The graph combines the README’s documented workflow and capabilities with sampled source and the SOURCE INDEX; several feature implementations were not sampled, so their internal links are documented at subsystem level rather than inferred in detail.

Main entry points: [`collabsphere_app/app/src/main/java/com/collabsphere/app/MainActivity.kt`](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/MainActivity.kt) (Compose app), [`collabsphere_app/app/src/main/java/com/collabsphere/app/model`](https://github.com/moon-chm/collabsphere/tree/main/collabsphere_app/app/src/main/java/com/collabsphere/app/model) (Feature repositories), [`collabsphere_server/src/main/kotlin/plugins/Routing.kt`](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/plugins/Routing.kt) (REST and feature routes), [`collabsphere_server/src/main/kotlin/main.kt`](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/main.kt) (Ktor server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_android["Android client"]
  node_app["Compose app<br/>[MainActivity.kt]"]
  node_auth["Authentication<br/>[LoginScreen.kt]"]
  node_workspaces["Workspaces"]
  node_messaging["Channels and DMs<br/>[DMScreen.kt]"]
  node_productivity["Tasks and notes<br/>[TaskScreen.kt]"]
  node_files["File sharing<br/>[FileScreen.kt]"]
  node_profile_search["Profiles and search"]
  node_notifications["Notifications"]
  node_api_client["REST APIs"]
  node_dm_socket["DM WebSocket"]
end

subgraph group_offline["Local data and sync"]
  node_local_store[("Room data<br/>[AppDatabase.kt]")]
  node_repositories["Feature repositories"]
  node_sync_workers["Background sync"]
  node_sync_protocol["Delta sync<br/>[SyncPage.kt]"]
end

subgraph group_backend["Backend services"]
  node_server["Ktor server<br/>[main.kt]"]
  node_routes["REST and feature routes<br/>[Routing.kt]"]
  node_ws_broker["WebSocket broker<br/>[WebSocketBroker.kt]"]
  node_server_db[("PostgreSQL<br/>[DatabaseFactory.kt]")]
  node_files_server["Uploaded files<br/>[UploadStaging.kt]"]
  node_link_preview["Link previews"]
end

subgraph group_integrations["External integrations"]
  node_github["GitHub integration<br/>[GitHubRoutes.kt]"]
  node_github_api["GitHub services<br/>[GitHubService.kt]"]
end

node_user(("Team member"))
node_postgres_external[("PostgreSQL service")]

node_user -->|"uses"| node_app
node_app -->|"opens"| node_auth
node_app -->|"opens"| node_workspaces
node_app -->|"opens"| node_messaging
node_app -->|"opens"| node_productivity
node_app -->|"opens"| node_files
node_app -->|"opens"| node_profile_search
node_app -.->|"receives"| node_notifications
node_auth -->|"uses"| node_repositories
node_workspaces -->|"uses"| node_repositories
node_messaging -->|"uses"| node_repositories
node_productivity -->|"uses"| node_repositories
node_files -->|"uses"| node_repositories
node_repositories -->|"reads and writes"| node_local_store
node_repositories -->|"enqueues retries"| node_sync_workers
node_repositories -->|"calls"| node_api_client
node_sync_workers -->|"syncs through"| node_api_client
node_api_client -->|"uses cursors"| node_sync_protocol
node_messaging -.->|"uses"| node_dm_socket
node_api_client -->|"calls REST"| node_server
node_dm_socket -->|"connects"| node_ws_broker
node_server -->|"registers routes"| node_routes
node_routes -->|"queries"| node_server_db
node_server -->|"configures"| node_ws_broker
node_server -->|"connects"| node_postgres_external
node_routes -.->|"stages uploads"| node_files_server
node_routes -->|"routes GitHub features"| node_github
node_github -->|"calls"| node_github_api
node_routes -->|"uses"| node_link_preview
node_notifications -.->|"receives pushes"| node_server

click node_app "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/MainActivity.kt"
click node_auth "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/view/LoginScreen.kt"
click node_workspaces "https://github.com/moon-chm/collabsphere/tree/main/collabsphere_app/app/src/main/java/com/collabsphere/app/view/WorkspaceUI"
click node_messaging "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/view/dmUI/DMScreen.kt"
click node_productivity "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/view/TaskUI/TaskScreen.kt"
click node_files "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/view/FileUI/FileScreen.kt"
click node_profile_search "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/view/UserUI/UserSearchScreen.kt"
click node_notifications "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/remote/fcm/CollabFirebaseMessagingService.kt"
click node_local_store "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/model/AppDatabase.kt"
click node_repositories "https://github.com/moon-chm/collabsphere/tree/main/collabsphere_app/app/src/main/java/com/collabsphere/app/model"
click node_sync_workers "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/model/workspace/WorkspaceSyncWorker.kt"
click node_sync_protocol "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/remote/SyncPage.kt"
click node_api_client "https://github.com/moon-chm/collabsphere/tree/main/collabsphere_app/app/src/main/java/com/collabsphere/app/remote"
click node_dm_socket "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/remote/dm/DmWebSocketService.kt"
click node_server "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/main.kt"
click node_routes "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/plugins/Routing.kt"
click node_ws_broker "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/plugins/WebSocketBroker.kt"
click node_server_db "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/DatabaseFactory.kt"
click node_files_server "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/plugins/UploadStaging.kt"
click node_github "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/plugins/GitHubRoutes.kt"
click node_github_api "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/util/GitHubService.kt"
click node_link_preview "https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/util/LinkPreviewService.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_app,node_auth,node_workspaces,node_messaging,node_productivity,node_files,node_profile_search,node_notifications,node_api_client,node_dm_socket toneBlue
class node_local_store,node_repositories,node_sync_workers,node_sync_protocol,node_postgres_external toneAmber
class node_server,node_routes,node_ws_broker,node_server_db,node_files_server,node_link_preview toneMint
class node_github,node_github_api toneRose
class node_user toneIndigo
```

## Components

### Android client

- [Compose app](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/MainActivity.kt): `collabsphere_app/app/src/main/java/com/collabsphere/app/MainActivity.kt`
- [Authentication](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/view/LoginScreen.kt): `collabsphere_app/app/src/main/java/com/collabsphere/app/view/LoginScreen.kt`
- [Workspaces](https://github.com/moon-chm/collabsphere/tree/main/collabsphere_app/app/src/main/java/com/collabsphere/app/view/WorkspaceUI): `collabsphere_app/app/src/main/java/com/collabsphere/app/view/WorkspaceUI`
- [Channels and DMs](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/view/dmUI/DMScreen.kt): `collabsphere_app/app/src/main/java/com/collabsphere/app/view/dmUI/DMScreen.kt`
- [Tasks and notes](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/view/TaskUI/TaskScreen.kt): `collabsphere_app/app/src/main/java/com/collabsphere/app/view/TaskUI/TaskScreen.kt`
- [File sharing](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/view/FileUI/FileScreen.kt): `collabsphere_app/app/src/main/java/com/collabsphere/app/view/FileUI/FileScreen.kt`
- [Profiles and search](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/view/UserUI/UserSearchScreen.kt): `collabsphere_app/app/src/main/java/com/collabsphere/app/view/UserUI/UserSearchScreen.kt`
- [Notifications](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/remote/fcm/CollabFirebaseMessagingService.kt): `collabsphere_app/app/src/main/java/com/collabsphere/app/remote/fcm/CollabFirebaseMessagingService.kt`
- [REST APIs](https://github.com/moon-chm/collabsphere/tree/main/collabsphere_app/app/src/main/java/com/collabsphere/app/remote): `collabsphere_app/app/src/main/java/com/collabsphere/app/remote`
- [DM WebSocket](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/remote/dm/DmWebSocketService.kt): `collabsphere_app/app/src/main/java/com/collabsphere/app/remote/dm/DmWebSocketService.kt`

### Local data and sync

- [Room data](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/model/AppDatabase.kt): `collabsphere_app/app/src/main/java/com/collabsphere/app/model/AppDatabase.kt`
- [Feature repositories](https://github.com/moon-chm/collabsphere/tree/main/collabsphere_app/app/src/main/java/com/collabsphere/app/model): `collabsphere_app/app/src/main/java/com/collabsphere/app/model`
- [Background sync](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/model/workspace/WorkspaceSyncWorker.kt): `collabsphere_app/app/src/main/java/com/collabsphere/app/model/workspace/WorkspaceSyncWorker.kt`
- [Delta sync](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_app/app/src/main/java/com/collabsphere/app/remote/SyncPage.kt): `collabsphere_app/app/src/main/java/com/collabsphere/app/remote/SyncPage.kt`

### Backend services

- [Ktor server](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/main.kt): `collabsphere_server/src/main/kotlin/main.kt`
- [REST and feature routes](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/plugins/Routing.kt): `collabsphere_server/src/main/kotlin/plugins/Routing.kt`
- [WebSocket broker](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/plugins/WebSocketBroker.kt): `collabsphere_server/src/main/kotlin/plugins/WebSocketBroker.kt`
- [PostgreSQL](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/DatabaseFactory.kt): `collabsphere_server/src/main/kotlin/DatabaseFactory.kt`
- [Uploaded files](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/plugins/UploadStaging.kt): `collabsphere_server/src/main/kotlin/plugins/UploadStaging.kt`
- [Link previews](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/util/LinkPreviewService.kt): `collabsphere_server/src/main/kotlin/util/LinkPreviewService.kt`

### External integrations

- [GitHub integration](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/plugins/GitHubRoutes.kt): `collabsphere_server/src/main/kotlin/plugins/GitHubRoutes.kt`
- [GitHub services](https://github.com/moon-chm/collabsphere/blob/main/collabsphere_server/src/main/kotlin/util/GitHubService.kt): `collabsphere_server/src/main/kotlin/util/GitHubService.kt`

### Other components

- **Team member**
- **PostgreSQL service**

## Connections

- Team member → Compose app: uses
- Compose app → Authentication: opens
- Compose app → Workspaces: opens
- Compose app → Channels and DMs: opens
- Compose app → Tasks and notes: opens
- Compose app → File sharing: opens
- Compose app → Profiles and search: opens
- Compose app → Notifications: receives
- Authentication → Feature repositories: uses
- Workspaces → Feature repositories: uses
- Channels and DMs → Feature repositories: uses
- Tasks and notes → Feature repositories: uses
- File sharing → Feature repositories: uses
- Feature repositories → Room data: reads and writes
- Feature repositories → Background sync: enqueues retries
- Feature repositories → REST APIs: calls (evidence: `collabsphere_app/app/src/main/java/com/collabsphere/app/remote/dm/DmWebSocketService.kt`)
- Background sync → REST APIs: syncs through
- REST APIs → Delta sync: uses cursors (evidence: `collabsphere_app/app/src/main/java/com/collabsphere/app/remote/SyncPage.kt`)
- Channels and DMs → DM WebSocket: uses
- REST APIs → Ktor server: calls REST
- DM WebSocket → WebSocket broker: connects
- Ktor server → REST and feature routes: registers routes (evidence: `collabsphere_server/src/main/kotlin/main.kt`)
- REST and feature routes → PostgreSQL: queries
- Ktor server → WebSocket broker: configures (evidence: `collabsphere_server/src/main/kotlin/main.kt`)
- Ktor server → PostgreSQL service: connects
- REST and feature routes → Uploaded files: stages uploads
- REST and feature routes → GitHub integration: routes GitHub features (evidence: `collabsphere_server/src/main/kotlin/plugins/Routing.kt`)
- GitHub integration → GitHub services: calls (evidence: `collabsphere_server/src/main/kotlin/plugins/GitHubRoutes.kt`)
- REST and feature routes → Link previews: uses (evidence: `collabsphere_server/src/main/kotlin/plugins/Routing.kt`)
- Notifications → Ktor server: receives pushes
