# anil0401/cnc-app architecture

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

- Interactive diagram: https://gitdiagram.com/anil0401/cnc-app
- Repository: https://github.com/anil0401/cnc-app

## Overview

This Blazor Server production-monitoring app turns PLC machine counts and downtime signals into live dashboards, persisted production/alarm records, and reports/exports. Its central runtime path is background PLC polling, shift-aware interpretation, SQL persistence, and browser-facing dashboards or reporting. The README documents additional report and dashboard capabilities whose page-level wiring was not sampled; those links are therefore not asserted. Relationships shown below are limited to the README and excerpted source; unsampled UI and report-helper internals are represented by their exact tree paths.

Main entry points: [`Data/DatabaseHelper.cs`](https://github.com/anil0401/cnc-app/blob/main/Data/DatabaseHelper.cs) (AndonDB), [`Components/Pages`](https://github.com/anil0401/cnc-app/tree/main/Components/Pages) (Reports and history), [`Reporting/ReportStyleHelper.cs`](https://github.com/anil0401/cnc-app/blob/main/Reporting/ReportStyleHelper.cs) (Report formatting), [`Communication/PlcPollingService.cs`](https://github.com/anil0401/cnc-app/blob/main/Communication/PlcPollingService.cs) (PLC polling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_blazor["Blazor app<br/>[App.razor]"]
  node_home["Home dashboard<br/>[Home.razor]"]
  node_machine_dash["Machine dashboards"]
  node_reports_ui["Reports and history"]
  node_login["Login and users<br/>[Login.razor]"]
  node_user_context["User context"]
  node_trend_page["Trend graphs<br/>[TrendGraph.razor]"]
  node_planning_page["Machine planning"]
  node_settings_page["Settings<br/>[Settings.razor]"]
end

subgraph group_monitor["Production monitoring"]
  node_poller["PLC polling"]
  node_mc_client["MC Protocol client<br/>[PLCconnection.cs]"]
  node_shift["Shift rules<br/>[ShiftHelper.cs]"]
end

subgraph group_data["Persistence"]
  node_sql[("AndonDB<br/>[DatabaseHelper.cs]")]
end

subgraph group_insight["Reporting"]
  node_daily_report["Daily reports"]
  node_hourly_report["Hourly reports"]
  node_history_report["Production history"]
  node_alarm_report["Alarm history"]
  node_report_style["Report formatting"]
  node_email["Email helper<br/>[EmailHelper.cs]"]
end

node_operator(("Shop-floor user"))

node_operator -->|"uses"| node_blazor
node_blazor -.->|"renders"| node_home
node_home -.->|"shows"| node_machine_dash
node_operator -.->|"requests"| node_reports_ui
node_operator -.->|"signs in"| node_login
node_login -->|"sets claims"| node_user_context
node_poller -->|"reads devices"| node_mc_client
node_poller -->|"uses shift rules"| node_shift
node_poller -->|"persists readings"| node_sql
node_home -.->|"reads dashboards"| node_sql
node_reports_ui -.->|"requests reports"| node_daily_report
node_reports_ui -.->|"requests reports"| node_hourly_report
node_reports_ui -.->|"requests history"| node_history_report
node_reports_ui -.->|"requests alarms"| node_alarm_report
node_daily_report -->|"queries data"| node_sql
node_hourly_report -->|"queries data"| node_sql
node_history_report -->|"queries data"| node_sql
node_alarm_report -->|"queries data"| node_sql
node_daily_report -->|"formats workbook"| node_report_style
node_hourly_report -->|"formats workbook"| node_report_style
node_history_report -->|"formats workbook"| node_report_style
node_alarm_report -->|"formats workbook"| node_report_style
node_operator -.->|"views trends"| node_trend_page
node_operator -.->|"plans production"| node_planning_page
node_operator -.->|"configures system"| node_settings_page

click node_blazor "https://github.com/anil0401/cnc-app/blob/main/Components/App.razor"
click node_home "https://github.com/anil0401/cnc-app/blob/main/Components/Pages/Home.razor"
click node_machine_dash "https://github.com/anil0401/cnc-app/blob/main/Components/Shared/MachineGroupDashboard.razor"
click node_reports_ui "https://github.com/anil0401/cnc-app/tree/main/Components/Pages"
click node_login "https://github.com/anil0401/cnc-app/blob/main/Components/Pages/Login.razor"
click node_user_context "https://github.com/anil0401/cnc-app/blob/main/Security/CurrentUserAccessor.cs"
click node_poller "https://github.com/anil0401/cnc-app/blob/main/Communication/PlcPollingService.cs"
click node_mc_client "https://github.com/anil0401/cnc-app/blob/main/Communication/PLCconnection.cs"
click node_shift "https://github.com/anil0401/cnc-app/blob/main/Communication/ShiftHelper.cs"
click node_sql "https://github.com/anil0401/cnc-app/blob/main/Data/DatabaseHelper.cs"
click node_daily_report "https://github.com/anil0401/cnc-app/blob/main/Reporting/DailyReportHelper.cs"
click node_hourly_report "https://github.com/anil0401/cnc-app/blob/main/Reporting/HourlyReportHelper.cs"
click node_history_report "https://github.com/anil0401/cnc-app/blob/main/Reporting/ProductionHistoryHelper.cs"
click node_alarm_report "https://github.com/anil0401/cnc-app/blob/main/Reporting/AlarmHistoryHelper.cs"
click node_report_style "https://github.com/anil0401/cnc-app/blob/main/Reporting/ReportStyleHelper.cs"
click node_trend_page "https://github.com/anil0401/cnc-app/blob/main/Components/Pages/TrendGraph.razor"
click node_planning_page "https://github.com/anil0401/cnc-app/blob/main/Components/Pages/MachinePlanning.razor"
click node_settings_page "https://github.com/anil0401/cnc-app/blob/main/Components/Pages/Settings.razor"
click node_email "https://github.com/anil0401/cnc-app/blob/main/Communication/EmailHelper.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_blazor,node_home,node_machine_dash,node_reports_ui,node_login,node_user_context,node_trend_page,node_planning_page,node_settings_page,node_operator toneBlue
class node_poller,node_mc_client,node_shift toneAmber
class node_sql toneMint
class node_daily_report,node_hourly_report,node_history_report,node_alarm_report,node_report_style,node_email toneRose
```

## Components

### Web experience

- [Blazor app](https://github.com/anil0401/cnc-app/blob/main/Components/App.razor): `Components/App.razor`
- [Home dashboard](https://github.com/anil0401/cnc-app/blob/main/Components/Pages/Home.razor): `Components/Pages/Home.razor`
- [Machine dashboards](https://github.com/anil0401/cnc-app/blob/main/Components/Shared/MachineGroupDashboard.razor): `Components/Shared/MachineGroupDashboard.razor`
- [Reports and history](https://github.com/anil0401/cnc-app/tree/main/Components/Pages): `Components/Pages`
- [Login and users](https://github.com/anil0401/cnc-app/blob/main/Components/Pages/Login.razor): `Components/Pages/Login.razor`
- [User context](https://github.com/anil0401/cnc-app/blob/main/Security/CurrentUserAccessor.cs): `Security/CurrentUserAccessor.cs`
- [Trend graphs](https://github.com/anil0401/cnc-app/blob/main/Components/Pages/TrendGraph.razor): `Components/Pages/TrendGraph.razor`
- [Machine planning](https://github.com/anil0401/cnc-app/blob/main/Components/Pages/MachinePlanning.razor): `Components/Pages/MachinePlanning.razor`
- [Settings](https://github.com/anil0401/cnc-app/blob/main/Components/Pages/Settings.razor): `Components/Pages/Settings.razor`

### Production monitoring

- [PLC polling](https://github.com/anil0401/cnc-app/blob/main/Communication/PlcPollingService.cs): `Communication/PlcPollingService.cs`
- [MC Protocol client](https://github.com/anil0401/cnc-app/blob/main/Communication/PLCconnection.cs): `Communication/PLCconnection.cs`
- [Shift rules](https://github.com/anil0401/cnc-app/blob/main/Communication/ShiftHelper.cs): `Communication/ShiftHelper.cs`

### Persistence

- [AndonDB](https://github.com/anil0401/cnc-app/blob/main/Data/DatabaseHelper.cs): `Data/DatabaseHelper.cs`

### Reporting

- [Daily reports](https://github.com/anil0401/cnc-app/blob/main/Reporting/DailyReportHelper.cs): `Reporting/DailyReportHelper.cs`
- [Hourly reports](https://github.com/anil0401/cnc-app/blob/main/Reporting/HourlyReportHelper.cs): `Reporting/HourlyReportHelper.cs`
- [Production history](https://github.com/anil0401/cnc-app/blob/main/Reporting/ProductionHistoryHelper.cs): `Reporting/ProductionHistoryHelper.cs`
- [Alarm history](https://github.com/anil0401/cnc-app/blob/main/Reporting/AlarmHistoryHelper.cs): `Reporting/AlarmHistoryHelper.cs`
- [Report formatting](https://github.com/anil0401/cnc-app/blob/main/Reporting/ReportStyleHelper.cs): `Reporting/ReportStyleHelper.cs`
- [Email helper](https://github.com/anil0401/cnc-app/blob/main/Communication/EmailHelper.cs): `Communication/EmailHelper.cs`

### Other components

- **Shop-floor user**

## Connections

- Shop-floor user → Blazor app: uses (evidence: `README.md`)
- Blazor app → Home dashboard: renders
- Home dashboard → Machine dashboards: shows
- Shop-floor user → Reports and history: requests
- Shop-floor user → Login and users: signs in
- Login and users → User context: sets claims (evidence: `Security/CurrentUserAccessor.cs`)
- PLC polling → MC Protocol client: reads devices (evidence: `Communication/PlcPollingService.cs`)
- PLC polling → Shift rules: uses shift rules (evidence: `Communication/PlcPollingService.cs`)
- PLC polling → AndonDB: persists readings (evidence: `Communication/PlcPollingService.cs`)
- Home dashboard → AndonDB: reads dashboards
- Reports and history → Daily reports: requests reports
- Reports and history → Hourly reports: requests reports
- Reports and history → Production history: requests history
- Reports and history → Alarm history: requests alarms
- Daily reports → AndonDB: queries data (evidence: `Reporting/DailyReportHelper.cs`)
- Hourly reports → AndonDB: queries data (evidence: `Reporting/HourlyReportHelper.cs`)
- Production history → AndonDB: queries data (evidence: `Reporting/ProductionHistoryHelper.cs`)
- Alarm history → AndonDB: queries data (evidence: `Reporting/AlarmHistoryHelper.cs`)
- Daily reports → Report formatting: formats workbook (evidence: `Reporting/DailyReportHelper.cs`)
- Hourly reports → Report formatting: formats workbook (evidence: `Reporting/HourlyReportHelper.cs`)
- Production history → Report formatting: formats workbook (evidence: `Reporting/ProductionHistoryHelper.cs`)
- Alarm history → Report formatting: formats workbook (evidence: `Reporting/AlarmHistoryHelper.cs`)
- Shop-floor user → Trend graphs: views trends
- Shop-floor user → Machine planning: plans production
- Shop-floor user → Settings: configures system
