# sonexapp/sonex architecture

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

- Interactive diagram: https://gitdiagram.com/sonexapp/sonex
- Repository: https://github.com/sonexapp/sonex

## Overview

Sonex is a native iOS vinyl-collection app centered on registering records, valuing and grading them, and browsing them in personal crates. Its main registration workflow starts with an NFC tag, sleeve-photo identification, or Discogs search, then resolves metadata, grades condition, sets a price, and saves the entry. Collection browsing, Discover, and Profile are major parallel product areas; Exchange remains a scaffold. The excerpts show selected data-layer and routing behavior, while other links below rely on README descriptions rather than inspected implementation.

Main entry points: [`Sonex/Sonex/Features/Scan/ScanTabView.swift`](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Scan/ScanTabView.swift) (Scan Flow), [`Sonex/Sonex/Navigation/TabContentRouter.swift`](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Navigation/TabContentRouter.swift) (Tab Router), [`Sonex/Sonex/Backend Services/SonexDBManager.swift`](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Backend%20Services/SonexDBManager.swift) (Data And Offline Manager), [`Sonex/Sonex/Features/Discover/DiscoverTabView.swift`](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Discover/DiscoverTabView.swift) (Discover Map And Posts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_catalog["Record Cataloging"]
  node_scan["Scan Flow<br/>[ScanTabView.swift]"]
  node_nfc["NFC Registration<br/>[NFCManager.swift]"]
  node_camera["Sleeve Capture"]
  node_ocr["Vision OCR"]
  node_suggestions["Gemini Suggestions"]
  node_discogs["Discogs Catalog"]
  node_musicbrainz["MusicBrainz Lookup"]
  node_registration["Registration Data"]
  node_grading["Grading And Pricing<br/>[GradingView.swift]"]
  node_vinylmodel["Vinyl Entry Model<br/>[VinylEntry.swift]"]
end

subgraph group_collection["Collection Management"]
  node_collection["Crate Browser"]
  node_details["Album Details"]
end

subgraph group_community["Community"]
  node_discover["Discover Map And Posts"]
  node_discovermodel["Discover Post Model<br/>[DiscoverPost.swift]"]
  node_profile["Profile And Following"]
  node_userdetails["User Details"]
  node_exchange["Exchange Scaffold"]
end

subgraph group_platform["App And Data"]
  node_app["Sonex App<br/>[SonexApp.swift]"]
  node_tabrouter["Tab Router"]
  node_db["Data And Offline Manager"]
  node_supabase[("Supabase")]
end

node_collector(("Collector"))
node_mapkit["MapKit"]
node_discogsapi["Discogs API"]
node_geminiapi["Gemini API"]

node_collector -->|"opens"| node_app
node_app -->|"shows tabs"| node_tabrouter
node_tabrouter -->|"routes to"| node_scan
node_tabrouter -->|"routes to"| node_collection
node_tabrouter -->|"routes to"| node_discover
node_tabrouter -->|"routes to"| node_exchange
node_tabrouter -->|"routes to"| node_profile
node_collector -->|"taps tag"| node_nfc
node_nfc -->|"starts registration"| node_scan
node_collector -->|"captures sleeve"| node_camera
node_camera -->|"provides image"| node_ocr
node_ocr -->|"sends recognized text"| node_suggestions
node_suggestions -->|"suggests search"| node_discogs
node_scan -->|"searches catalog"| node_discogs
node_scan -.->|"resolves metadata"| node_musicbrainz
node_scan -->|"updates"| node_registration
node_scan -->|"collects grades"| node_grading
node_grading -->|"sets valuation"| node_registration
node_scan -->|"saves entry"| node_db
node_registration -->|"builds record"| node_vinylmodel
node_collector -->|"browses crates"| node_collection
node_collection -.->|"loads cached and live data"| node_db
node_collection -->|"opens record"| node_details
node_db -->|"queries and writes"| node_supabase
node_db -->|"syncs queued writes"| node_supabase
node_collector -->|"explores nearby"| node_discover
node_discover -->|"plots nearby posts"| node_mapkit
node_discover -->|"loads posts and RSVPs"| node_db
node_discover -->|"presents posts"| node_discovermodel
node_collector -->|"views profile"| node_profile
node_profile -->|"loads stats and social data"| node_db
node_profile -->|"opens user"| node_userdetails
node_collector -->|"opens scaffold"| node_exchange
node_discogs -->|"requests catalog data"| node_discogsapi
node_suggestions -->|"requests suggestions"| node_geminiapi

click node_app "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/App/SonexApp.swift"
click node_tabrouter "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Navigation/TabContentRouter.swift"
click node_scan "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Scan/ScanTabView.swift"
click node_nfc "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Backend%20Services/NFCManager.swift"
click node_camera "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Scan/CameraCaptureView.swift"
click node_ocr "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Backend%20Services/TextRecognitionManager.swift"
click node_suggestions "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Backend%20Services/GeminiManager.swift"
click node_discogs "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Backend%20Services/DiscogsManager.swift"
click node_musicbrainz "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Backend%20Services/MusicBrainzAPIManager.swift"
click node_registration "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Scan/VinylRegistrationData.swift"
click node_grading "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Scan/GradingView.swift"
click node_vinylmodel "https://github.com/sonexapp/sonex/blob/main/SonexShared/Sources/SonexShared/Models/VinylEntry.swift"
click node_collection "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Collection/CollectionListView.swift"
click node_details "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Details/AlbumDetailsView.swift"
click node_db "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Backend%20Services/SonexDBManager.swift"
click node_discover "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Discover/DiscoverTabView.swift"
click node_discovermodel "https://github.com/sonexapp/sonex/blob/main/SonexShared/Sources/SonexShared/Models/DiscoverPost.swift"
click node_profile "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Profile/ProfileTabView.swift"
click node_userdetails "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Profile/UserDetailsView.swift"
click node_exchange "https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Exchange/ExchangeTabView.swift"

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_scan,node_nfc,node_camera,node_ocr,node_suggestions,node_discogs,node_musicbrainz,node_registration,node_grading,node_vinylmodel toneBlue
class node_collection,node_details toneAmber
class node_discover,node_discovermodel,node_profile,node_userdetails,node_exchange,node_discogsapi,node_geminiapi toneMint
class node_app,node_tabrouter,node_db,node_supabase toneRose
class node_collector,node_mapkit toneIndigo
```

## Components

### Record Cataloging

- [Scan Flow](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Scan/ScanTabView.swift): `Sonex/Sonex/Features/Scan/ScanTabView.swift`
- [NFC Registration](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Backend%20Services/NFCManager.swift): `Sonex/Sonex/Backend Services/NFCManager.swift`
- [Sleeve Capture](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Scan/CameraCaptureView.swift): `Sonex/Sonex/Features/Scan/CameraCaptureView.swift`
- [Vision OCR](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Backend%20Services/TextRecognitionManager.swift): `Sonex/Sonex/Backend Services/TextRecognitionManager.swift`
- [Gemini Suggestions](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Backend%20Services/GeminiManager.swift): `Sonex/Sonex/Backend Services/GeminiManager.swift`
- [Discogs Catalog](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Backend%20Services/DiscogsManager.swift): `Sonex/Sonex/Backend Services/DiscogsManager.swift`
- [MusicBrainz Lookup](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Backend%20Services/MusicBrainzAPIManager.swift): `Sonex/Sonex/Backend Services/MusicBrainzAPIManager.swift`
- [Registration Data](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Scan/VinylRegistrationData.swift): `Sonex/Sonex/Features/Scan/VinylRegistrationData.swift`
- [Grading And Pricing](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Scan/GradingView.swift): `Sonex/Sonex/Features/Scan/GradingView.swift`
- [Vinyl Entry Model](https://github.com/sonexapp/sonex/blob/main/SonexShared/Sources/SonexShared/Models/VinylEntry.swift): `SonexShared/Sources/SonexShared/Models/VinylEntry.swift`

### Collection Management

- [Crate Browser](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Collection/CollectionListView.swift): `Sonex/Sonex/Features/Collection/CollectionListView.swift`
- [Album Details](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Details/AlbumDetailsView.swift): `Sonex/Sonex/Features/Details/AlbumDetailsView.swift`

### Community

- [Discover Map And Posts](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Discover/DiscoverTabView.swift): `Sonex/Sonex/Features/Discover/DiscoverTabView.swift`
- [Discover Post Model](https://github.com/sonexapp/sonex/blob/main/SonexShared/Sources/SonexShared/Models/DiscoverPost.swift): `SonexShared/Sources/SonexShared/Models/DiscoverPost.swift`
- [Profile And Following](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Profile/ProfileTabView.swift): `Sonex/Sonex/Features/Profile/ProfileTabView.swift`
- [User Details](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Profile/UserDetailsView.swift): `Sonex/Sonex/Features/Profile/UserDetailsView.swift`
- [Exchange Scaffold](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Features/Exchange/ExchangeTabView.swift): `Sonex/Sonex/Features/Exchange/ExchangeTabView.swift`

### App And Data

- [Sonex App](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/App/SonexApp.swift): `Sonex/Sonex/App/SonexApp.swift`
- [Tab Router](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Navigation/TabContentRouter.swift): `Sonex/Sonex/Navigation/TabContentRouter.swift`
- [Data And Offline Manager](https://github.com/sonexapp/sonex/blob/main/Sonex/Sonex/Backend%20Services/SonexDBManager.swift): `Sonex/Sonex/Backend Services/SonexDBManager.swift`
- **Supabase**

### Other components

- **Collector**
- **MapKit**
- **Discogs API**
- **Gemini API**

## Connections

- Collector → Sonex App: opens
- Sonex App → Tab Router: shows tabs (evidence: `Sonex/Sonex/Navigation/TabContentRouter.swift`)
- Tab Router → Scan Flow: routes to (evidence: `Sonex/Sonex/Navigation/TabContentRouter.swift`)
- Tab Router → Crate Browser: routes to (evidence: `Sonex/Sonex/Navigation/TabContentRouter.swift`)
- Tab Router → Discover Map And Posts: routes to (evidence: `Sonex/Sonex/Navigation/TabContentRouter.swift`)
- Tab Router → Exchange Scaffold: routes to (evidence: `Sonex/Sonex/Navigation/TabContentRouter.swift`)
- Tab Router → Profile And Following: routes to (evidence: `Sonex/Sonex/Navigation/TabContentRouter.swift`)
- Collector → NFC Registration: taps tag
- NFC Registration → Scan Flow: starts registration (evidence: `Sonex/Sonex/Features/Scan/ScanTabView.swift`)
- Collector → Sleeve Capture: captures sleeve
- Sleeve Capture → Vision OCR: provides image
- Vision OCR → Gemini Suggestions: sends recognized text
- Gemini Suggestions → Discogs Catalog: suggests search
- Scan Flow → Discogs Catalog: searches catalog
- Scan Flow → MusicBrainz Lookup: resolves metadata
- Scan Flow → Registration Data: updates (evidence: `Sonex/Sonex/Features/Scan/ScanTabView.swift`)
- Scan Flow → Grading And Pricing: collects grades (evidence: `Sonex/Sonex/Features/Scan/ScanTabView.swift`)
- Grading And Pricing → Registration Data: sets valuation
- Scan Flow → Data And Offline Manager: saves entry (evidence: `Sonex/Sonex/Features/Scan/ScanTabView.swift`)
- Registration Data → Vinyl Entry Model: builds record (evidence: `Sonex/Sonex/Features/Scan/VinylRegistrationData.swift`)
- Collector → Crate Browser: browses crates
- Crate Browser → Data And Offline Manager: loads cached and live data
- Crate Browser → Album Details: opens record (evidence: `Sonex/Sonex/Features/Details/AlbumDetailsView.swift`)
- Data And Offline Manager → Supabase: queries and writes (evidence: `Sonex/Sonex/Backend Services/SonexDBManager.swift`)
- Data And Offline Manager → Supabase: syncs queued writes (evidence: `Sonex/Sonex/Backend Services/SonexDBManager.swift`)
- Collector → Discover Map And Posts: explores nearby
- Discover Map And Posts → MapKit: plots nearby posts
- Discover Map And Posts → Data And Offline Manager: loads posts and RSVPs (evidence: `Sonex/Sonex/Features/Discover/DiscoverTabView.swift`)
- Discover Map And Posts → Discover Post Model: presents posts (evidence: `Sonex/Sonex/Features/Discover/DiscoverTabView.swift`)
- Collector → Profile And Following: views profile
- Profile And Following → Data And Offline Manager: loads stats and social data (evidence: `Sonex/Sonex/Features/Profile/ProfileTabView.swift`)
- Profile And Following → User Details: opens user (evidence: `Sonex/Sonex/Features/Profile/ProfileTabView.swift`)
- Collector → Exchange Scaffold: opens scaffold
- Discogs Catalog → Discogs API: requests catalog data (evidence: `Sonex/Sonex/Backend Services/DiscogsManager.swift`)
- Gemini Suggestions → Gemini API: requests suggestions
