# larson-logan/medal-sync architecture

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

- Interactive diagram: https://gitdiagram.com/larson-logan/medal-sync
- Repository: https://github.com/larson-logan/medal-sync

## Overview

Medal Sync is a Windows companion that gives Medal an SSD-backed recording drive while maintaining a persistent shared clip library and optional verified cloud copies. The main workflow is configure or join a library, launch Medal through Medal Sync, record while media is replicated, then verify the library and release ownership so another PC can take over. The README documents the storage modes and handoff; sampled source and the SOURCE INDEX support the session, configuration, library, and replication components. Some subsystem links are therefore documented rather than independently verified in source.

Main entry points: [`tools/medal-sync/MedalSync/Session/SessionCoordinator.cs`](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Session/SessionCoordinator.cs) (Session coordinator), [`tools/medal-sync/MedalSync/Platform/StorageReplication.cs`](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Platform/StorageReplication.cs) (Media replication), [`tools/medal-sync/MedalSync/Config/MedalSyncConfig.cs`](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Config/MedalSyncConfig.cs) (Configuration), [`tools/medal-sync/MedalSync/Library/LibraryDatabase.cs`](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Library/LibraryDatabase.cs) (Medal library adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Setup and commands"]
  node_cli["CLI commands<br/>[CommandRunner.cs]"]
  node_config["Configuration<br/>[MedalSyncConfig.cs]"]
end

subgraph group_session["Recording session"]
  node_session["Session coordinator"]
end

subgraph group_library["Library and handoff"]
  node_librarydb["Medal library adapter<br/>[LibraryDatabase.cs]"]
  node_snapshot["Library snapshots<br/>[LibrarySnapshot.cs]"]
  node_coord[("Coordination store")]
  node_ownership["Ownership journal<br/>[Ownership.cs]"]
end

subgraph group_storage["Media storage"]
  node_volume["Storage volumes<br/>[StorageVolume.cs]"]
  node_replication["Media replication"]
  node_cache[("SSD cache")]
  node_primary[("Primary storage")]
  node_rclone[("rclone remotes")]
  node_cloud[("Optional cloud copies")]
end

subgraph group_desktop["Windows interface"]
  node_wizard["Setup wizard"]
  node_launcher["Windows launcher<br/>[Program.cs]"]
  node_status["Tray status"]
end

node_user(("User"))
node_medal(("Medal"))

node_user -->|"configures"| node_wizard
node_wizard -->|"previews settings"| node_config
node_user -->|"starts Medal"| node_launcher
node_launcher -->|"launches session"| node_session
node_cli -->|"runs session commands"| node_session
node_config -.->|"configures"| node_session
node_session -->|"claims ownership"| node_coord
node_coord -.->|"tracks ownership"| node_ownership
node_session -->|"starts and supervises"| node_medal
node_medal -->|"records clips"| node_cache
node_cache -->|"uploads media"| node_primary
node_replication -->|"runs transfers"| node_rclone
node_rclone -.->|"writes primary"| node_primary
node_replication -->|"verifies copies"| node_cloud
node_session -->|"finishes uploads"| node_replication
node_session -.->|"checks library"| node_librarydb
node_librarydb -->|"reads snapshot"| node_snapshot
node_session -->|"releases when ready"| node_ownership
node_session -->|"reports readiness"| node_status
node_volume -.->|"checks suitability"| node_cache

click node_cli "https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Cli/CommandRunner.cs"
click node_config "https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Config/MedalSyncConfig.cs"
click node_wizard "https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync.Launch/WindowsConfigurationWizard.cs"
click node_launcher "https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync.Launch/Program.cs"
click node_session "https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Session/SessionCoordinator.cs"
click node_status "https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync.Launch/WindowsTrayStatus.cs"
click node_librarydb "https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Library/LibraryDatabase.cs"
click node_snapshot "https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Library/LibrarySnapshot.cs"
click node_coord "https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Coordination/CoordinationStore.cs"
click node_ownership "https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Coordination/Ownership.cs"
click node_volume "https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Storage/StorageVolume.cs"
click node_replication "https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Platform/StorageReplication.cs"

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_cli,node_config,node_user toneBlue
class node_session toneAmber
class node_librarydb,node_snapshot,node_coord,node_ownership toneMint
class node_volume,node_replication,node_cache,node_primary,node_rclone,node_cloud toneRose
class node_wizard,node_launcher,node_status,node_medal toneIndigo
```

## Components

### Setup and commands

- [CLI commands](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Cli/CommandRunner.cs): `tools/medal-sync/MedalSync/Cli/CommandRunner.cs`
- [Configuration](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Config/MedalSyncConfig.cs): `tools/medal-sync/MedalSync/Config/MedalSyncConfig.cs`

### Recording session

- [Session coordinator](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Session/SessionCoordinator.cs): `tools/medal-sync/MedalSync/Session/SessionCoordinator.cs`

### Library and handoff

- [Medal library adapter](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Library/LibraryDatabase.cs): `tools/medal-sync/MedalSync/Library/LibraryDatabase.cs`
- [Library snapshots](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Library/LibrarySnapshot.cs): `tools/medal-sync/MedalSync/Library/LibrarySnapshot.cs`
- [Coordination store](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Coordination/CoordinationStore.cs): `tools/medal-sync/MedalSync/Coordination/CoordinationStore.cs`
- [Ownership journal](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Coordination/Ownership.cs): `tools/medal-sync/MedalSync/Coordination/Ownership.cs`

### Media storage

- [Storage volumes](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Storage/StorageVolume.cs): `tools/medal-sync/MedalSync/Storage/StorageVolume.cs`
- [Media replication](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync/Platform/StorageReplication.cs): `tools/medal-sync/MedalSync/Platform/StorageReplication.cs`
- **SSD cache**
- **Primary storage**
- **rclone remotes**
- **Optional cloud copies**

### Windows interface

- [Setup wizard](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync.Launch/WindowsConfigurationWizard.cs): `tools/medal-sync/MedalSync.Launch/WindowsConfigurationWizard.cs`
- [Windows launcher](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync.Launch/Program.cs): `tools/medal-sync/MedalSync.Launch/Program.cs`
- [Tray status](https://github.com/larson-logan/medal-sync/blob/dev/tools/medal-sync/MedalSync.Launch/WindowsTrayStatus.cs): `tools/medal-sync/MedalSync.Launch/WindowsTrayStatus.cs`

### Other components

- **User**
- **Medal**

## Connections

- User → Setup wizard: configures (evidence: `README.md`)
- Setup wizard → Configuration: previews settings (evidence: `README.md`)
- User → Windows launcher: starts Medal (evidence: `README.md`)
- Windows launcher → Session coordinator: launches session (evidence: `tools/medal-sync/MedalSync.Launch/Program.cs`)
- CLI commands → Session coordinator: runs session commands
- Configuration → Session coordinator: configures
- Session coordinator → Coordination store: claims ownership (evidence: `README.md`)
- Coordination store → Ownership journal: tracks ownership (evidence: `tools/medal-sync/MedalSync/Coordination/CoordinationStore.cs`)
- Session coordinator → Medal: starts and supervises (evidence: `README.md`)
- Medal → SSD cache: records clips (evidence: `README.md`)
- SSD cache → Primary storage: uploads media (evidence: `README.md`)
- Media replication → rclone remotes: runs transfers (evidence: `tools/medal-sync/MedalSync/Platform/StorageReplication.cs`)
- rclone remotes → Primary storage: writes primary
- Media replication → Optional cloud copies: verifies copies (evidence: `README.md`)
- Session coordinator → Media replication: finishes uploads (evidence: `README.md`)
- Session coordinator → Medal library adapter: checks library
- Medal library adapter → Library snapshots: reads snapshot (evidence: `tools/medal-sync/MedalSync/Library/LibraryDatabase.cs`)
- Session coordinator → Ownership journal: releases when ready (evidence: `README.md`)
- Session coordinator → Tray status: reports readiness (evidence: `README.md`)
- Storage volumes → SSD cache: checks suitability
