# franstio/coilbin architecture

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

- Interactive diagram: https://gitdiagram.com/franstio/coilbin
- Repository: https://github.com/franstio/coilbin

## Overview

CoilBin is an industrial bin-control application with an Avalonia desktop interface and web APIs, alongside a separate rack-management API. The main bin workflow starts or ends a collection/disposal transaction, persists its state, drives PLC outputs, and monitors sensors to update operator clients. Rack workflows select racks, trigger doors, and record transactions. Sampled source supports these connections; the README is empty, and omitted source leaves some wiring uncertain.

Main entry points: [`CoilBin.WebApi/Services/SaleableService.cs`](https://github.com/franstio/coilbin/blob/master/CoilBin.WebApi/Services/SaleableService.cs) (Sensor workflows), [`CoilBin.WebApi/Program.cs`](https://github.com/franstio/coilbin/blob/master/CoilBin.WebApi/Program.cs) (Bin API), [`CoilBin.PLC/Services/BinService.cs`](https://github.com/franstio/coilbin/blob/master/CoilBin.PLC/Services/BinService.cs) (Bin service), [`CoilBin.RackApi/Controllers/RackController.cs`](https://github.com/franstio/coilbin/blob/master/CoilBin.RackApi/Controllers/RackController.cs) (Rack controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bin["Bin operations"]
  node_webapi["Bin API<br/>[Program.cs]"]
  node_api["Slim bin API<br/>[Program.cs]"]
  node_binsvc["Bin service<br/>[BinService.cs]"]
  node_saleable["Sensor workflows<br/>[SaleableService.cs]"]
end

subgraph group_rack["Rack operations"]
  node_rackapi["Rack API<br/>[Program.cs]"]
  node_rackcontroller["Rack controller<br/>[RackController.cs]"]
  node_rackservice["Rack data service"]
  node_rackplc["Rack PLC service<br/>[RackPLCService.cs]"]
end

subgraph group_state["State and hardware"]
  node_plc["PLC service<br/>[PLCService.cs]"]
  node_transactions[("Transaction state")]
  node_bininfo[("Bin information<br/>[BinInfoManager.cs]")]
  node_mysql[("Rack database")]
end

subgraph group_clients["Operator interfaces"]
  node_desktop["Desktop host<br/>[Program.cs]"]
  node_avalonia["Avalonia UI<br/>[App.axaml.cs]"]
  node_viewmodel["Main view model<br/>[MainViewModel.cs]"]
  node_binhub["Bin hub<br/>[BinHub.cs]"]
  node_rackhub["Rack hub<br/>[RackHub.cs]"]
end

node_operator(("Operator"))
node_plcdevice{{"PLC hardware"}}
node_scale{{"Weighing system"}}

node_operator -->|"uses"| node_desktop
node_desktop -->|"starts"| node_avalonia
node_desktop -->|"hosts"| node_webapi
node_avalonia -->|"binds"| node_viewmodel
node_operator -->|"requests"| node_webapi
node_webapi -->|"dispatches"| node_binsvc
node_api -->|"dispatches"| node_binsvc
node_webapi -->|"reads status"| node_transactions
node_api -->|"reads status"| node_transactions
node_webapi -->|"starts loops"| node_saleable
node_saleable -->|"reads sensors"| node_binsvc
node_saleable -->|"reads and saves"| node_transactions
node_saleable -->|"reads bin data"| node_bininfo
node_saleable -->|"dispatches updates"| node_binhub
node_binsvc -->|"reads and writes"| node_plc
node_binsvc -->|"reads and saves"| node_transactions
node_plc -->|"communicates"| node_plcdevice
node_scale -.->|"sends weights"| node_api
node_api -->|"saves weights"| node_bininfo
node_operator -->|"requests"| node_rackapi
node_rackapi -->|"routes"| node_rackcontroller
node_rackcontroller -->|"queries and saves"| node_rackservice
node_rackcontroller -->|"triggers doors"| node_rackplc
node_rackcontroller -->|"publishes weight"| node_rackhub
node_rackservice -->|"queries and updates"| node_mysql
node_rackservice -.->|"syncs employees"| node_scale
node_rackapi -->|"syncs employees"| node_rackservice
node_rackplc -->|"controls racks"| node_plcdevice

click node_desktop "https://github.com/franstio/coilbin/blob/master/CoilBin.Desktop/Program.cs"
click node_avalonia "https://github.com/franstio/coilbin/blob/master/CoilBin/App.axaml.cs"
click node_viewmodel "https://github.com/franstio/coilbin/blob/master/CoilBin/ViewModels/MainViewModel.cs"
click node_webapi "https://github.com/franstio/coilbin/blob/master/CoilBin.WebApi/Program.cs"
click node_api "https://github.com/franstio/coilbin/blob/master/CoilBin.Api/Program.cs"
click node_binsvc "https://github.com/franstio/coilbin/blob/master/CoilBin.PLC/Services/BinService.cs"
click node_saleable "https://github.com/franstio/coilbin/blob/master/CoilBin.WebApi/Services/SaleableService.cs"
click node_binhub "https://github.com/franstio/coilbin/blob/master/CoilBin.WebApi/Hubs/BinHub/BinHub.cs"
click node_plc "https://github.com/franstio/coilbin/blob/master/CoilBin.PLC/PLCService.cs"
click node_transactions "https://github.com/franstio/coilbin/blob/master/CoilBin.PLC/RunningTransactionManager.cs"
click node_bininfo "https://github.com/franstio/coilbin/blob/master/CoilBin.PLC/BinInfoManager.cs"
click node_rackapi "https://github.com/franstio/coilbin/blob/master/CoilBin.RackApi/Program.cs"
click node_rackcontroller "https://github.com/franstio/coilbin/blob/master/CoilBin.RackApi/Controllers/RackController.cs"
click node_rackservice "https://github.com/franstio/coilbin/blob/master/CoilBin.RackApi/Services/RackSaleableServices.cs"
click node_rackplc "https://github.com/franstio/coilbin/blob/master/CoilBin.RackApi/Services/RackPLCService.cs"
click node_rackhub "https://github.com/franstio/coilbin/blob/master/CoilBin.RackApi/Hubs/Rack/RackHub.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_webapi,node_api,node_binsvc,node_saleable toneBlue
class node_rackapi,node_rackcontroller,node_rackservice,node_rackplc toneAmber
class node_plc,node_transactions,node_bininfo,node_mysql toneMint
class node_desktop,node_avalonia,node_viewmodel,node_binhub,node_rackhub toneRose
class node_operator,node_plcdevice,node_scale toneIndigo
```

## Components

### Bin operations

- [Bin API](https://github.com/franstio/coilbin/blob/master/CoilBin.WebApi/Program.cs): `CoilBin.WebApi/Program.cs`
- [Slim bin API](https://github.com/franstio/coilbin/blob/master/CoilBin.Api/Program.cs): `CoilBin.Api/Program.cs`
- [Bin service](https://github.com/franstio/coilbin/blob/master/CoilBin.PLC/Services/BinService.cs): `CoilBin.PLC/Services/BinService.cs`
- [Sensor workflows](https://github.com/franstio/coilbin/blob/master/CoilBin.WebApi/Services/SaleableService.cs): `CoilBin.WebApi/Services/SaleableService.cs`

### Rack operations

- [Rack API](https://github.com/franstio/coilbin/blob/master/CoilBin.RackApi/Program.cs): `CoilBin.RackApi/Program.cs`
- [Rack controller](https://github.com/franstio/coilbin/blob/master/CoilBin.RackApi/Controllers/RackController.cs): `CoilBin.RackApi/Controllers/RackController.cs`
- [Rack data service](https://github.com/franstio/coilbin/blob/master/CoilBin.RackApi/Services/RackSaleableServices.cs): `CoilBin.RackApi/Services/RackSaleableServices.cs`
- [Rack PLC service](https://github.com/franstio/coilbin/blob/master/CoilBin.RackApi/Services/RackPLCService.cs): `CoilBin.RackApi/Services/RackPLCService.cs`

### State and hardware

- [PLC service](https://github.com/franstio/coilbin/blob/master/CoilBin.PLC/PLCService.cs): `CoilBin.PLC/PLCService.cs`
- [Transaction state](https://github.com/franstio/coilbin/blob/master/CoilBin.PLC/RunningTransactionManager.cs): `CoilBin.PLC/RunningTransactionManager.cs`
- [Bin information](https://github.com/franstio/coilbin/blob/master/CoilBin.PLC/BinInfoManager.cs): `CoilBin.PLC/BinInfoManager.cs`
- **Rack database**

### Operator interfaces

- [Desktop host](https://github.com/franstio/coilbin/blob/master/CoilBin.Desktop/Program.cs): `CoilBin.Desktop/Program.cs`
- [Avalonia UI](https://github.com/franstio/coilbin/blob/master/CoilBin/App.axaml.cs): `CoilBin/App.axaml.cs`
- [Main view model](https://github.com/franstio/coilbin/blob/master/CoilBin/ViewModels/MainViewModel.cs): `CoilBin/ViewModels/MainViewModel.cs`
- [Bin hub](https://github.com/franstio/coilbin/blob/master/CoilBin.WebApi/Hubs/BinHub/BinHub.cs): `CoilBin.WebApi/Hubs/BinHub/BinHub.cs`
- [Rack hub](https://github.com/franstio/coilbin/blob/master/CoilBin.RackApi/Hubs/Rack/RackHub.cs): `CoilBin.RackApi/Hubs/Rack/RackHub.cs`

### Other components

- **Operator**
- **PLC hardware**
- **Weighing system**

## Connections

- Operator → Desktop host: uses
- Desktop host → Avalonia UI: starts
- Desktop host → Bin API: hosts
- Avalonia UI → Main view model: binds
- Operator → Bin API: requests
- Bin API → Bin service: dispatches
- Slim bin API → Bin service: dispatches
- Bin API → Transaction state: reads status
- Slim bin API → Transaction state: reads status
- Bin API → Sensor workflows: starts loops
- Sensor workflows → Bin service: reads sensors
- Sensor workflows → Transaction state: reads and saves
- Sensor workflows → Bin information: reads bin data
- Sensor workflows → Bin hub: dispatches updates
- Bin service → PLC service: reads and writes
- Bin service → Transaction state: reads and saves
- PLC service → PLC hardware: communicates
- Weighing system → Slim bin API: sends weights
- Slim bin API → Bin information: saves weights
- Operator → Rack API: requests
- Rack API → Rack controller: routes
- Rack controller → Rack data service: queries and saves
- Rack controller → Rack PLC service: triggers doors
- Rack controller → Rack hub: publishes weight
- Rack data service → Rack database: queries and updates
- Rack data service → Weighing system: syncs employees
- Rack API → Rack data service: syncs employees
- Rack PLC service → PLC hardware: controls racks
