# mrpapermoon/sharethebutton architecture

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

- Interactive diagram: https://gitdiagram.com/mrpapermoon/sharethebutton
- Repository: https://github.com/mrpapermoon/sharethebutton

## Overview

Share the Button is a Compose Multiplatform app whose Android host lets a guest create a personalized button, save it locally, and publish an invitation. The invitation screen presents a link and QR code, with copy and Android sharing actions. Room stores buttons and Preferences DataStore stores the guest session; publication uses a build-selected backend. Incoming invitations, QR scanning, and adding received buttons are documented as unfinished. The main workflow and platform branches are documented in the README; unsampled screen implementations are represented by their exact source directories.

Main entry points: [`shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/ButtonRepositoryImpl.kt`](https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/ButtonRepositoryImpl.kt) (Button repository), [`shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/share`](https://github.com/mrpapermoon/sharethebutton/tree/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/share) (Invitation screen), [`shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/create`](https://github.com/mrpapermoon/sharethebutton/tree/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/create) (Button wizard), [`shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/ButtonRemoteDataSource.kt`](https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/ButtonRemoteDataSource.kt) (Invitation source)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["App host"]
  node_android["Android host"]
  node_clipboard["System clipboard"]
  node_share_sheet["Android share sheet"]
  node_qr["QR generator"]
end

subgraph group_presentation["User experience"]
  node_navigation["Screen navigation"]
  node_welcome["Guest entry"]
  node_home["Button list"]
  node_creator["Button wizard"]
  node_draft["Button draft"]
  node_invitation["Invitation screen"]
end

subgraph group_domain["Application services"]
  node_button_model["Button model<br/>[SharedButton.kt]"]
  node_button_repo["Button repository"]
  node_session_repo["Guest session"]
  node_share_usecase["Share invitation"]
end

subgraph group_storage["Local persistence"]
  node_room[("Button database<br/>[ButtonDatabase.kt]")]
  node_preferences[("Session preferences")]
end

subgraph group_publication["Invitation backends"]
  node_remote_contract["Invitation source"]
  node_debug_backend[("Debug local backend")]
  node_firestore_backend["Firestore backend"]
end

node_guest(("Guest user"))
node_firebase["Firebase services"]

node_guest -->|"opens app"| node_android
node_android -->|"hosts screens"| node_navigation
node_navigation -.->|"routes to"| node_welcome
node_guest -->|"enters as guest"| node_welcome
node_guest -->|"creates button"| node_creator
node_creator -->|"edits draft"| node_draft
node_creator -->|"saves button"| node_button_repo
node_home -->|"observes buttons"| node_button_repo
node_button_repo -->|"reads and writes"| node_room
node_welcome -.->|"checks session"| node_session_repo
node_session_repo -->|"reads and writes"| node_preferences
node_button_repo -->|"publishes button"| node_remote_contract
node_remote_contract -->|"selects in debug"| node_debug_backend
node_remote_contract -->|"selects in release"| node_firestore_backend
node_firestore_backend -->|"uses services"| node_firebase
node_button_repo -.->|"returns token"| node_invitation
node_guest -->|"views invitation"| node_invitation
node_invitation -.->|"requests sharing"| node_share_usecase
node_invitation -->|"renders QR"| node_qr
node_guest -->|"copies link"| node_clipboard
node_guest -->|"sends link"| node_share_sheet

click node_android "https://github.com/mrpapermoon/sharethebutton/blob/master/app/src/main/java/mrpapermoon/customebutton/CustomButtonActivity.kt"
click node_navigation "https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/CustomeButtonNavigation.kt"
click node_welcome "https://github.com/mrpapermoon/sharethebutton/tree/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/welcome"
click node_home "https://github.com/mrpapermoon/sharethebutton/tree/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/home"
click node_creator "https://github.com/mrpapermoon/sharethebutton/tree/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/create"
click node_draft "https://github.com/mrpapermoon/sharethebutton/tree/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/create/draft"
click node_invitation "https://github.com/mrpapermoon/sharethebutton/tree/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/share"
click node_button_model "https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/entity/SharedButton.kt"
click node_button_repo "https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/ButtonRepositoryImpl.kt"
click node_session_repo "https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/SessionRepositoryImpl.kt"
click node_share_usecase "https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/usecase/ShareInvitationUseCase.kt"
click node_room "https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/database/ButtonDatabase.kt"
click node_preferences "https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/storage/LightDataStorage.kt"
click node_clipboard "https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/androidMain/kotlin/mrpapermoon/customebutton/repository/AndroidClipboardRepository.kt"
click node_share_sheet "https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/androidMain/kotlin/mrpapermoon/customebutton/usecase/AndroidShareInvitationUseCase.kt"
click node_qr "https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/androidMain/kotlin/mrpapermoon/customebutton/qr/ZxingQrGenerator.kt"
click node_remote_contract "https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/ButtonRemoteDataSource.kt"
click node_debug_backend "https://github.com/mrpapermoon/sharethebutton/blob/master/app/src/debug/kotlin/mrpapermoon/customebutton/data/StubButtonRemoteDataSource.kt"
click node_firestore_backend "https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/FirestoreButtonDataSource.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_android,node_clipboard,node_share_sheet,node_qr,node_guest toneBlue
class node_navigation,node_welcome,node_home,node_creator,node_draft,node_invitation toneAmber
class node_button_model,node_button_repo,node_session_repo,node_share_usecase toneMint
class node_room,node_preferences toneRose
class node_remote_contract,node_debug_backend,node_firestore_backend,node_firebase toneIndigo
```

## Components

### App host

- [Android host](https://github.com/mrpapermoon/sharethebutton/blob/master/app/src/main/java/mrpapermoon/customebutton/CustomButtonActivity.kt): `app/src/main/java/mrpapermoon/customebutton/CustomButtonActivity.kt`
- [System clipboard](https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/androidMain/kotlin/mrpapermoon/customebutton/repository/AndroidClipboardRepository.kt): `shared/src/androidMain/kotlin/mrpapermoon/customebutton/repository/AndroidClipboardRepository.kt`
- [Android share sheet](https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/androidMain/kotlin/mrpapermoon/customebutton/usecase/AndroidShareInvitationUseCase.kt): `shared/src/androidMain/kotlin/mrpapermoon/customebutton/usecase/AndroidShareInvitationUseCase.kt`
- [QR generator](https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/androidMain/kotlin/mrpapermoon/customebutton/qr/ZxingQrGenerator.kt): `shared/src/androidMain/kotlin/mrpapermoon/customebutton/qr/ZxingQrGenerator.kt`

### User experience

- [Screen navigation](https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/CustomeButtonNavigation.kt): `shared/src/commonMain/kotlin/mrpapermoon/customebutton/CustomeButtonNavigation.kt`
- [Guest entry](https://github.com/mrpapermoon/sharethebutton/tree/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/welcome): `shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/welcome`
- [Button list](https://github.com/mrpapermoon/sharethebutton/tree/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/home): `shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/home`
- [Button wizard](https://github.com/mrpapermoon/sharethebutton/tree/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/create): `shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/create`
- [Button draft](https://github.com/mrpapermoon/sharethebutton/tree/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/create/draft): `shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/create/draft`
- [Invitation screen](https://github.com/mrpapermoon/sharethebutton/tree/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/share): `shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/share`

### Application services

- [Button model](https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/entity/SharedButton.kt): `shared/src/commonMain/kotlin/mrpapermoon/customebutton/entity/SharedButton.kt`
- [Button repository](https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/ButtonRepositoryImpl.kt): `shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/ButtonRepositoryImpl.kt`
- [Guest session](https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/SessionRepositoryImpl.kt): `shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/SessionRepositoryImpl.kt`
- [Share invitation](https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/usecase/ShareInvitationUseCase.kt): `shared/src/commonMain/kotlin/mrpapermoon/customebutton/usecase/ShareInvitationUseCase.kt`

### Local persistence

- [Button database](https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/database/ButtonDatabase.kt): `shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/database/ButtonDatabase.kt`
- [Session preferences](https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/storage/LightDataStorage.kt): `shared/src/commonMain/kotlin/mrpapermoon/customebutton/storage/LightDataStorage.kt`

### Invitation backends

- [Invitation source](https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/ButtonRemoteDataSource.kt): `shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/ButtonRemoteDataSource.kt`
- [Debug local backend](https://github.com/mrpapermoon/sharethebutton/blob/master/app/src/debug/kotlin/mrpapermoon/customebutton/data/StubButtonRemoteDataSource.kt): `app/src/debug/kotlin/mrpapermoon/customebutton/data/StubButtonRemoteDataSource.kt`
- [Firestore backend](https://github.com/mrpapermoon/sharethebutton/blob/master/shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/FirestoreButtonDataSource.kt): `shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/FirestoreButtonDataSource.kt`

### Other components

- **Guest user**
- **Firebase services**

## Connections

- Guest user → Android host: opens app
- Android host → Screen navigation: hosts screens (evidence: `app/src/main/java/mrpapermoon/customebutton/CustomButtonActivity.kt`)
- Screen navigation → Guest entry: routes to
- Guest user → Guest entry: enters as guest
- Guest user → Button wizard: creates button
- Button wizard → Button draft: edits draft
- Button wizard → Button repository: saves button
- Button list → Button repository: observes buttons
- Button repository → Button database: reads and writes
- Guest entry → Guest session: checks session
- Guest session → Session preferences: reads and writes (evidence: `shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/SessionRepositoryImpl.kt`)
- Button repository → Invitation source: publishes button (evidence: `shared/src/commonMain/kotlin/mrpapermoon/customebutton/data/ButtonRepositoryImpl.kt`)
- Invitation source → Debug local backend: selects in debug (evidence: `app/src/debug/kotlin/mrpapermoon/customebutton/data/StubButtonRemoteDataSource.kt`)
- Invitation source → Firestore backend: selects in release
- Firestore backend → Firebase services: uses services
- Button repository → Invitation screen: returns token
- Guest user → Invitation screen: views invitation
- Invitation screen → Share invitation: requests sharing (evidence: `shared/src/commonMain/kotlin/mrpapermoon/customebutton/ui/share/ShareButtonViewModel.kt`)
- Invitation screen → QR generator: renders QR
- Guest user → System clipboard: copies link
- Guest user → Android share sheet: sends link
