# rico-knots/labelstock architecture

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

- Interactive diagram: https://gitdiagram.com/rico-knots/labelstock
- Repository: https://github.com/rico-knots/labelstock

## Overview

LabelStock is an Avalonia desktop app for scanning or searching stock labels, viewing quantities, and maintaining label records. The main workflow runs from the scan screen through label lookup to a detail screen, where stock can be adjusted and saved. Admin screens provide label management and invoke backup; restore, spreadsheet export, and backup-location selection are explicitly unfinished. Source excerpts show label persistence and UI calls, but do not establish the active backup implementation or all service wiring.

Main entry points: [`LabelStock.Desktop/ViewModels/ScanViewModel.cs`](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/ScanViewModel.cs) (Scan and search), [`LabelStock.Desktop/Services/Navigator.cs`](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/Services/Navigator.cs) (Screen navigation), [`LabelStock.Desktop/ViewModels/AdminViewModel.cs`](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/AdminViewModel.cs) (Admin tools), [`LabelStock.Core/DependencyInjection.cs`](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/DependencyInjection.cs) (Core registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop UI"]
  node_startup["App startup<br/>[App.axaml.cs]"]
  node_navigation["Screen navigation<br/>[Navigator.cs]"]
  node_scan["Scan and search<br/>[ScanViewModel.cs]"]
  node_labelrow["Label rows"]
  node_newlabel["New label"]
  node_detail["Stock detail"]
  node_adminlogin["Admin login"]
  node_admin["Admin tools<br/>[AdminViewModel.cs]"]
  node_mainwindow["Main window state"]
end

subgraph group_core["Core services"]
  node_labelapi["Label service API<br/>[ILabelService.cs]"]
  node_labelservice["Label operations<br/>[LabelService.cs]"]
  node_stockapi["Stock service API<br/>[IStockService.cs]"]
  node_stockservice["Stock operations<br/>[StockService.cs]"]
  node_authapi["Auth service API<br/>[IAuthService.cs]"]
  node_authservice["Authentication<br/>[AuthService.cs]"]
  node_backupapi["Backup service API<br/>[IBackupService.cs]"]
  node_backupservice["Backup service<br/>[BackupService.cs]"]
  node_exportservice["Export service<br/>[ExportService.cs]"]
  node_registration["Core registration"]
  node_summary["Label read model<br/>[LabelSummary.cs]"]
end

subgraph group_data["Persistence"]
  node_database[("SQLite context")]
end

node_operator(("Operator"))

node_operator -->|"scans or searches"| node_scan
node_startup -->|"creates"| node_navigation
node_startup -->|"creates"| node_mainwindow
node_startup -->|"runs migrations"| node_database
node_startup -->|"registers services"| node_registration
node_navigation -->|"resolves screen"| node_scan
node_scan -->|"searches and loads recent"| node_labelapi
node_scan -->|"opens screens"| node_navigation
node_scan -->|"builds rows"| node_labelrow
node_scan -->|"opens unknown barcode"| node_newlabel
node_scan -->|"opens match"| node_detail
node_newlabel -->|"creates label"| node_labelapi
node_newlabel -->|"returns to screen"| node_navigation
node_detail -->|"saves quantity"| node_stockapi
node_detail -->|"returns to scan"| node_navigation
node_adminlogin -->|"authenticates"| node_authapi
node_adminlogin -->|"switches screens"| node_navigation
node_admin -->|"lists and deletes"| node_labelapi
node_admin -->|"requests backup"| node_backupapi
node_admin -->|"builds rows"| node_labelrow
node_admin -->|"opens screens"| node_navigation
node_admin -.->|"export not implemented"| node_exportservice
node_labelservice -->|"queries and writes"| node_database
node_labelservice -->|"projects results"| node_summary
node_stockservice -->|"uses context"| node_database
node_authservice -->|"implements"| node_authapi
node_registration -->|"registers"| node_labelservice
node_registration -->|"registers"| node_stockservice
node_registration -->|"registers"| node_authservice
node_registration -->|"configures factory"| node_database

click node_startup "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/App.axaml.cs"
click node_navigation "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/Services/Navigator.cs"
click node_scan "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/ScanViewModel.cs"
click node_labelrow "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/LabelRowViewModel.cs"
click node_newlabel "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/NewLabelViewModel.cs"
click node_detail "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/LabelDetailViewModel.cs"
click node_adminlogin "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/AdminLoginViewModel.cs"
click node_admin "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/AdminViewModel.cs"
click node_mainwindow "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/MainWindowViewModel.cs"
click node_labelapi "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Abstractions/ILabelService.cs"
click node_labelservice "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Services/LabelService.cs"
click node_stockapi "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Abstractions/IStockService.cs"
click node_stockservice "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Services/StockService.cs"
click node_authapi "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Abstractions/IAuthService.cs"
click node_authservice "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Services/AuthService.cs"
click node_backupapi "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Abstractions/IBackupService.cs"
click node_backupservice "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Services/BackupService.cs"
click node_exportservice "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Services/ExportService.cs"
click node_registration "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/DependencyInjection.cs"
click node_summary "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Models/LabelSummary.cs"
click node_database "https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Data/LabelStockDbContext.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_startup,node_navigation,node_scan,node_labelrow,node_newlabel,node_detail,node_adminlogin,node_admin,node_mainwindow toneBlue
class node_labelapi,node_labelservice,node_stockapi,node_stockservice,node_authapi,node_authservice,node_backupapi,node_backupservice,node_exportservice,node_registration,node_summary toneAmber
class node_database toneMint
class node_operator toneIndigo
```

## Components

### Desktop UI

- [App startup](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/App.axaml.cs): `LabelStock.Desktop/App.axaml.cs`
- [Screen navigation](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/Services/Navigator.cs): `LabelStock.Desktop/Services/Navigator.cs`
- [Scan and search](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/ScanViewModel.cs): `LabelStock.Desktop/ViewModels/ScanViewModel.cs`
- [Label rows](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/LabelRowViewModel.cs): `LabelStock.Desktop/ViewModels/LabelRowViewModel.cs`
- [New label](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/NewLabelViewModel.cs): `LabelStock.Desktop/ViewModels/NewLabelViewModel.cs`
- [Stock detail](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/LabelDetailViewModel.cs): `LabelStock.Desktop/ViewModels/LabelDetailViewModel.cs`
- [Admin login](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/AdminLoginViewModel.cs): `LabelStock.Desktop/ViewModels/AdminLoginViewModel.cs`
- [Admin tools](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/AdminViewModel.cs): `LabelStock.Desktop/ViewModels/AdminViewModel.cs`
- [Main window state](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Desktop/ViewModels/MainWindowViewModel.cs): `LabelStock.Desktop/ViewModels/MainWindowViewModel.cs`

### Core services

- [Label service API](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Abstractions/ILabelService.cs): `LabelStock.Core/Abstractions/ILabelService.cs`
- [Label operations](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Services/LabelService.cs): `LabelStock.Core/Services/LabelService.cs`
- [Stock service API](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Abstractions/IStockService.cs): `LabelStock.Core/Abstractions/IStockService.cs`
- [Stock operations](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Services/StockService.cs): `LabelStock.Core/Services/StockService.cs`
- [Auth service API](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Abstractions/IAuthService.cs): `LabelStock.Core/Abstractions/IAuthService.cs`
- [Authentication](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Services/AuthService.cs): `LabelStock.Core/Services/AuthService.cs`
- [Backup service API](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Abstractions/IBackupService.cs): `LabelStock.Core/Abstractions/IBackupService.cs`
- [Backup service](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Services/BackupService.cs): `LabelStock.Core/Services/BackupService.cs`
- [Export service](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Services/ExportService.cs): `LabelStock.Core/Services/ExportService.cs`
- [Core registration](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/DependencyInjection.cs): `LabelStock.Core/DependencyInjection.cs`
- [Label read model](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Models/LabelSummary.cs): `LabelStock.Core/Models/LabelSummary.cs`

### Persistence

- [SQLite context](https://github.com/rico-knots/labelstock/blob/main/LabelStock.Core/Data/LabelStockDbContext.cs): `LabelStock.Core/Data/LabelStockDbContext.cs`

### Other components

- **Operator**

## Connections

- Operator → Scan and search: scans or searches (evidence: `LabelStock.Desktop/ViewModels/ScanViewModel.cs`)
- App startup → Screen navigation: creates (evidence: `LabelStock.Desktop/App.axaml.cs`)
- App startup → Main window state: creates (evidence: `LabelStock.Desktop/App.axaml.cs`)
- App startup → SQLite context: runs migrations (evidence: `LabelStock.Desktop/App.axaml.cs`)
- App startup → Core registration: registers services (evidence: `LabelStock.Desktop/App.axaml.cs`)
- Screen navigation → Scan and search: resolves screen (evidence: `LabelStock.Desktop/Services/Navigator.cs`)
- Scan and search → Label service API: searches and loads recent (evidence: `LabelStock.Desktop/ViewModels/ScanViewModel.cs`)
- Scan and search → Screen navigation: opens screens (evidence: `LabelStock.Desktop/ViewModels/ScanViewModel.cs`)
- Scan and search → Label rows: builds rows (evidence: `LabelStock.Desktop/ViewModels/ScanViewModel.cs`)
- Scan and search → New label: opens unknown barcode (evidence: `LabelStock.Desktop/ViewModels/ScanViewModel.cs`)
- Scan and search → Stock detail: opens match (evidence: `LabelStock.Desktop/ViewModels/ScanViewModel.cs`)
- New label → Label service API: creates label (evidence: `LabelStock.Desktop/ViewModels/NewLabelViewModel.cs`)
- New label → Screen navigation: returns to screen (evidence: `LabelStock.Desktop/ViewModels/NewLabelViewModel.cs`)
- Stock detail → Stock service API: saves quantity (evidence: `LabelStock.Desktop/ViewModels/LabelDetailViewModel.cs`)
- Stock detail → Screen navigation: returns to scan (evidence: `LabelStock.Desktop/ViewModels/LabelDetailViewModel.cs`)
- Admin login → Auth service API: authenticates (evidence: `LabelStock.Desktop/ViewModels/AdminLoginViewModel.cs`)
- Admin login → Screen navigation: switches screens (evidence: `LabelStock.Desktop/ViewModels/AdminLoginViewModel.cs`)
- Admin tools → Label service API: lists and deletes (evidence: `LabelStock.Desktop/ViewModels/AdminViewModel.cs`)
- Admin tools → Backup service API: requests backup (evidence: `LabelStock.Desktop/ViewModels/AdminViewModel.cs`)
- Admin tools → Label rows: builds rows (evidence: `LabelStock.Desktop/ViewModels/AdminViewModel.cs`)
- Admin tools → Screen navigation: opens screens (evidence: `LabelStock.Desktop/ViewModels/AdminViewModel.cs`)
- Admin tools → Export service: export not implemented (evidence: `LabelStock.Desktop/ViewModels/AdminViewModel.cs`)
- Label operations → SQLite context: queries and writes (evidence: `LabelStock.Core/Services/LabelService.cs`)
- Label operations → Label read model: projects results (evidence: `LabelStock.Core/Services/LabelService.cs`)
- Stock operations → SQLite context: uses context (evidence: `LabelStock.Core/Services/StockService.cs`)
- Authentication → Auth service API: implements (evidence: `LabelStock.Core/Services/AuthService.cs`)
- Core registration → Label operations: registers (evidence: `LabelStock.Core/DependencyInjection.cs`)
- Core registration → Stock operations: registers (evidence: `LabelStock.Core/DependencyInjection.cs`)
- Core registration → Authentication: registers (evidence: `LabelStock.Core/DependencyInjection.cs`)
- Core registration → SQLite context: configures factory (evidence: `LabelStock.Core/DependencyInjection.cs`)
