# rht-iot/reactweb architecture

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

- Interactive diagram: https://gitdiagram.com/rht-iot/reactweb
- Repository: https://github.com/rht-iot/reactweb

## Overview

This is a Next.js IoT monitoring and control web application. Users authenticate, discover authorized devices, and view live, historical, IAQ, or spatial telemetry; the control panel reads device state and sends control values. Administrators manage user/device access and Microsoft device-token flows. The frontend calls external AWS-backed APIs; the README also documents scheduled and stream-triggered data preparation, but those backend workers and tables are not present in the supplied tree. Edges reflect excerpts or README statements; unsampled API wiring is not inferred.

Main entry points: [`app/controlPanel/page.tsx`](https://github.com/rht-iot/reactweb/blob/main/app/controlPanel/page.tsx) (Control panel), [`app/lib/aws.ts`](https://github.com/rht-iot/reactweb/blob/main/app/lib/aws.ts) (AWS data client), [`app/login/page.tsx`](https://github.com/rht-iot/reactweb/blob/main/app/login/page.tsx) (Device dashboard), [`app/IAQ/Dashboard.tsx`](https://github.com/rht-iot/reactweb/blob/main/app/IAQ/Dashboard.tsx) (IAQ dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity"]
  node_oidc["OIDC configuration<br/>[authConfig.ts]"]
  node_cognito["Amazon Cognito"]
  node_microsoft["Microsoft identity"]
end

subgraph group_monitoring["Monitoring"]
  node_login["Device dashboard<br/>[page.tsx]"]
  node_iaq["IAQ dashboard<br/>[Dashboard.tsx]"]
  node_iaqmetric["IAQ metrics<br/>[MetricCard.tsx]"]
  node_iaqchart["IAQ history chart<br/>[ChartDisplay.tsx]"]
  node_map2d["2D device map<br/>[page.tsx]"]
  node_map3d["3D device map<br/>[three.tsx]"]
  node_gauges["Live gauges"]
  node_gaugecard["Gauge display<br/>[GaugeCard.tsx]"]
  node_linechart["Realtime charts"]
  node_device_monitor["Device monitor<br/>[device-monitor.tsx]"]
end

subgraph group_control["Device control"]
  node_controlpage["Control panel<br/>[page.tsx]"]
  node_aircon["Air conditioner controls<br/>[AirConPanel.tsx]"]
  node_purifier["Air purifier controls<br/>[EC490.tsx]"]
end

subgraph group_admin["Administration"]
  node_adminpage["Access administration<br/>[page.tsx]"]
end

subgraph group_integration["External services"]
  node_awsclient["AWS data client<br/>[aws.ts]"]
  node_api["IoT API"]
  node_access_table[("UserLocationAccess")]
  node_sensor_table[("SensorBoxModel")]
  node_control_table[("controlIDTable")]
  node_iaq_table[("IAQSensorData")]
  node_bdzl["BDZL service"]
end

node_user(("User"))

node_user -->|"authenticates via"| node_oidc
node_user -->|"opens dashboard"| node_login
node_login -->|"renders"| node_gauges
node_gauges -->|"renders"| node_gaugecard
node_login -->|"requests device data"| node_awsclient
node_awsclient -->|"calls"| node_api
node_user -->|"opens IAQ view"| node_iaq
node_iaq -->|"loads telemetry"| node_awsclient
node_iaq -->|"renders metrics"| node_iaqmetric
node_iaq -->|"renders history"| node_iaqchart
node_user -.->|"opens map"| node_map2d
node_user -->|"opens map"| node_map3d
node_map3d -->|"requests telemetry"| node_awsclient
node_map3d -->|"renders"| node_gauges
node_map3d -->|"renders"| node_linechart
node_user -->|"opens controls"| node_controlpage
node_controlpage -->|"loads device data"| node_awsclient
node_controlpage -->|"sends control values"| node_api
node_controlpage -->|"renders controls"| node_aircon
node_controlpage -->|"renders controls"| node_purifier
node_user -->|"manages access"| node_adminpage
node_adminpage -->|"updates access"| node_access_table
node_adminpage -.->|"exchanges device token"| node_microsoft
node_oidc -->|"configures sign-in"| node_cognito
node_login -->|"requests device authorization"| node_access_table
node_api -->|"reads device records"| node_sensor_table
node_api -->|"reads device identifiers"| node_control_table
node_api -->|"writes telemetry"| node_iaq_table
node_bdzl -->|"provides identifiers"| node_control_table
node_bdzl -->|"provides latest data"| node_iaq_table
node_sensor_table -->|"stream updates trigger refresh"| node_control_table
node_sensor_table -->|"scheduled fetch selects devices"| node_bdzl

click node_oidc "https://github.com/rht-iot/reactweb/blob/main/app/authConfig.ts"
click node_login "https://github.com/rht-iot/reactweb/blob/main/app/login/page.tsx"
click node_awsclient "https://github.com/rht-iot/reactweb/blob/main/app/lib/aws.ts"
click node_iaq "https://github.com/rht-iot/reactweb/blob/main/app/IAQ/Dashboard.tsx"
click node_iaqmetric "https://github.com/rht-iot/reactweb/blob/main/app/IAQ/MetricCard.tsx"
click node_iaqchart "https://github.com/rht-iot/reactweb/blob/main/app/IAQ/ChartDisplay.tsx"
click node_map2d "https://github.com/rht-iot/reactweb/blob/main/app/2d/page.tsx"
click node_map3d "https://github.com/rht-iot/reactweb/blob/main/app/3d/three.tsx"
click node_gauges "https://github.com/rht-iot/reactweb/blob/main/app/components/DashboardGauges.tsx"
click node_gaugecard "https://github.com/rht-iot/reactweb/blob/main/app/components/GaugeCard.tsx"
click node_linechart "https://github.com/rht-iot/reactweb/blob/main/app/components/LatestLineChart.tsx"
click node_device_monitor "https://github.com/rht-iot/reactweb/blob/main/app/components/device-monitor.tsx"
click node_controlpage "https://github.com/rht-iot/reactweb/blob/main/app/controlPanel/page.tsx"
click node_aircon "https://github.com/rht-iot/reactweb/blob/main/app/controlPanel/AirConPanel.tsx"
click node_purifier "https://github.com/rht-iot/reactweb/blob/main/app/controlPanel/EC490.tsx"
click node_adminpage "https://github.com/rht-iot/reactweb/blob/main/app/admin/page.tsx"

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_oidc,node_cognito,node_microsoft,node_user toneBlue
class node_login,node_iaq,node_iaqmetric,node_iaqchart,node_map2d,node_map3d,node_gauges,node_gaugecard,node_linechart,node_device_monitor toneAmber
class node_controlpage,node_aircon,node_purifier toneMint
class node_adminpage toneRose
class node_awsclient,node_api,node_access_table,node_sensor_table,node_control_table,node_iaq_table,node_bdzl toneIndigo
```

## Components

### Identity

- [OIDC configuration](https://github.com/rht-iot/reactweb/blob/main/app/authConfig.ts): `app/authConfig.ts`
- **Amazon Cognito**
- **Microsoft identity**

### Monitoring

- [Device dashboard](https://github.com/rht-iot/reactweb/blob/main/app/login/page.tsx): `app/login/page.tsx`
- [IAQ dashboard](https://github.com/rht-iot/reactweb/blob/main/app/IAQ/Dashboard.tsx): `app/IAQ/Dashboard.tsx`
- [IAQ metrics](https://github.com/rht-iot/reactweb/blob/main/app/IAQ/MetricCard.tsx): `app/IAQ/MetricCard.tsx`
- [IAQ history chart](https://github.com/rht-iot/reactweb/blob/main/app/IAQ/ChartDisplay.tsx): `app/IAQ/ChartDisplay.tsx`
- [2D device map](https://github.com/rht-iot/reactweb/blob/main/app/2d/page.tsx): `app/2d/page.tsx`
- [3D device map](https://github.com/rht-iot/reactweb/blob/main/app/3d/three.tsx): `app/3d/three.tsx`
- [Live gauges](https://github.com/rht-iot/reactweb/blob/main/app/components/DashboardGauges.tsx): `app/components/DashboardGauges.tsx`
- [Gauge display](https://github.com/rht-iot/reactweb/blob/main/app/components/GaugeCard.tsx): `app/components/GaugeCard.tsx`
- [Realtime charts](https://github.com/rht-iot/reactweb/blob/main/app/components/LatestLineChart.tsx): `app/components/LatestLineChart.tsx`
- [Device monitor](https://github.com/rht-iot/reactweb/blob/main/app/components/device-monitor.tsx): `app/components/device-monitor.tsx`

### Device control

- [Control panel](https://github.com/rht-iot/reactweb/blob/main/app/controlPanel/page.tsx): `app/controlPanel/page.tsx`
- [Air conditioner controls](https://github.com/rht-iot/reactweb/blob/main/app/controlPanel/AirConPanel.tsx): `app/controlPanel/AirConPanel.tsx`
- [Air purifier controls](https://github.com/rht-iot/reactweb/blob/main/app/controlPanel/EC490.tsx): `app/controlPanel/EC490.tsx`

### Administration

- [Access administration](https://github.com/rht-iot/reactweb/blob/main/app/admin/page.tsx): `app/admin/page.tsx`

### External services

- [AWS data client](https://github.com/rht-iot/reactweb/blob/main/app/lib/aws.ts): `app/lib/aws.ts`
- **IoT API**
- **UserLocationAccess**
- **SensorBoxModel**
- **controlIDTable**
- **IAQSensorData**
- **BDZL service**

### Other components

- **User**

## Connections

- User → OIDC configuration: authenticates via (evidence: `app/authConfig.ts`)
- User → Device dashboard: opens dashboard (evidence: `app/login/page.tsx`)
- Device dashboard → Live gauges: renders (evidence: `app/login/page.tsx`)
- Live gauges → Gauge display: renders (evidence: `app/components/DashboardGauges.tsx`)
- Device dashboard → AWS data client: requests device data (evidence: `app/login/page.tsx`)
- AWS data client → IoT API: calls (evidence: `app/lib/aws.ts`)
- User → IAQ dashboard: opens IAQ view (evidence: `app/IAQ/Dashboard.tsx`)
- IAQ dashboard → AWS data client: loads telemetry (evidence: `app/IAQ/Dashboard.tsx`)
- IAQ dashboard → IAQ metrics: renders metrics (evidence: `app/IAQ/Dashboard.tsx`)
- IAQ dashboard → IAQ history chart: renders history (evidence: `app/IAQ/Dashboard.tsx`)
- User → 2D device map: opens map
- User → 3D device map: opens map
- 3D device map → AWS data client: requests telemetry (evidence: `app/3d/three.tsx`)
- 3D device map → Live gauges: renders (evidence: `app/3d/three.tsx`)
- 3D device map → Realtime charts: renders (evidence: `app/3d/three.tsx`)
- User → Control panel: opens controls (evidence: `app/controlPanel/page.tsx`)
- Control panel → AWS data client: loads device data (evidence: `app/controlPanel/page.tsx`)
- Control panel → IoT API: sends control values (evidence: `app/controlPanel/page.tsx`)
- Control panel → Air conditioner controls: renders controls (evidence: `app/controlPanel/page.tsx`)
- Control panel → Air purifier controls: renders controls (evidence: `app/controlPanel/page.tsx`)
- User → Access administration: manages access (evidence: `app/admin/page.tsx`)
- Access administration → UserLocationAccess: updates access (evidence: `README.md`)
- Access administration → Microsoft identity: exchanges device token
- OIDC configuration → Amazon Cognito: configures sign-in (evidence: `app/authConfig.ts`)
- Device dashboard → UserLocationAccess: requests device authorization (evidence: `README.md`)
- IoT API → SensorBoxModel: reads device records (evidence: `README.md`)
- IoT API → controlIDTable: reads device identifiers (evidence: `README.md`)
- IoT API → IAQSensorData: writes telemetry (evidence: `README.md`)
- BDZL service → controlIDTable: provides identifiers (evidence: `README.md`)
- BDZL service → IAQSensorData: provides latest data (evidence: `README.md`)
- SensorBoxModel → controlIDTable: stream updates trigger refresh (evidence: `README.md`)
- SensorBoxModel → BDZL service: scheduled fetch selects devices (evidence: `README.md`)
