# emnahr/aquaguard architecture

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

- Interactive diagram: https://gitdiagram.com/emnahr/aquaguard
- Repository: https://github.com/emnahr/aquaguard

## Overview

AquaGuard is a frontend for monitoring water supply and floor-level flow in a university residence. Its main workflow is to evaluate simulated readings, expose building status and alerts, then let authorized staff acknowledge and resolve incidents; residents have a read-only dashboard. Separate capabilities include account registration and role-based access, user administration, alert filtering, and administrator demo scenarios. The supplied excerpts show routing, authentication, and detection logic; other page and provider relationships are based on the SOURCE INDEX, so unsampled behavior is not expanded beyond those references.

Main entry points: [`frontend/src/App.jsx`](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/App.jsx) (App routing), [`frontend/src/pages/Building.jsx`](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/pages/Building.jsx) (Building status), [`frontend/src/context/BuildingProvider.jsx`](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/context/BuildingProvider.jsx) (Building state), [`frontend/src/components/LigneAlerte.jsx`](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/components/LigneAlerte.jsx) (Alert presentation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and accounts"]
  node_app["App routing<br/>[App.jsx]"]
  node_auth["Authentication state<br/>[AuthProvider.jsx]"]
  node_authapi["Sign-in API<br/>[auth.js]"]
  node_client["API client<br/>[client.js]"]
  node_users["User administration<br/>[Users.jsx]"]
end

subgraph group_monitor["Water monitoring"]
  node_buildingstate["Building state"]
  node_seed[("Mock data and settings<br/>[seed.js]")]
  node_detection["Reading evaluation<br/>[evaluate.js]"]
  node_scenarios["Demo scenarios<br/>[scenarios.js]"]
  node_selectors["Building selectors<br/>[selecteurs.js]"]
end

subgraph group_incidents["Incident operations"]
  node_alertspage["Alert list<br/>[Alerts.jsx]"]
  node_alertrow["Alert presentation<br/>[LigneAlerte.jsx]"]
  node_resolution["Resolution dialog"]
end

subgraph group_views["Product views"]
  node_buildingpage["Building status<br/>[Building.jsx]"]
  node_dashboard["Resident dashboard<br/>[Dashboard.jsx]"]
  node_demopage["Scenario demo<br/>[Demo.jsx]"]
  node_buildingcards["Floor and live charts<br/>[CarteEtage.jsx]"]
  node_statcard["Status cards<br/>[CarteStat.jsx]"]
  node_livechart["Live charts<br/>[CourbeLive.jsx]"]
end

node_user(("Resident or staff"))

node_user -->|"uses"| node_app
node_app -->|"provides"| node_auth
node_app -->|"provides"| node_buildingstate
node_app -->|"routes"| node_buildingpage
node_app -->|"routes"| node_dashboard
node_app -->|"routes"| node_alertspage
node_app -->|"routes"| node_users
node_app -->|"routes"| node_demopage
node_app -->|"shows"| node_resolution
node_auth -->|"initializes users"| node_seed
node_auth -->|"authenticates"| node_authapi
node_authapi -->|"uses"| node_client
node_buildingstate -->|"loads mock data"| node_seed
node_buildingstate -->|"evaluates readings"| node_detection
node_scenarios -->|"uses evaluator"| node_detection
node_buildingpage -->|"reads state"| node_buildingstate
node_buildingpage -->|"derives status"| node_selectors
node_buildingpage -->|"renders alerts"| node_alertrow
node_buildingpage -->|"renders floors"| node_buildingcards
node_buildingpage -->|"renders statistics"| node_statcard
node_buildingpage -->|"renders readings"| node_livechart
node_dashboard -->|"reads state"| node_buildingstate
node_dashboard -->|"renders alerts"| node_alertrow
node_alertspage -->|"reads alerts"| node_buildingstate
node_alertspage -->|"renders alerts"| node_alertrow
node_alertrow -->|"requests resolution"| node_resolution
node_resolution -->|"resolves alert"| node_buildingstate
node_demopage -->|"uses scenarios"| node_scenarios

click node_app "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/App.jsx"
click node_auth "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/context/AuthProvider.jsx"
click node_authapi "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/api/auth.js"
click node_client "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/api/client.js"
click node_users "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/pages/Users.jsx"
click node_buildingstate "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/context/BuildingProvider.jsx"
click node_seed "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/data/seed.js"
click node_detection "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/engine/evaluate.js"
click node_scenarios "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/engine/scenarios.js"
click node_selectors "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/engine/selecteurs.js"
click node_buildingpage "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/pages/Building.jsx"
click node_dashboard "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/pages/Dashboard.jsx"
click node_demopage "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/pages/Demo.jsx"
click node_alertspage "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/pages/Alerts.jsx"
click node_alertrow "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/components/LigneAlerte.jsx"
click node_resolution "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/components/ModaleResolution.jsx"
click node_buildingcards "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/components/CarteEtage.jsx"
click node_statcard "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/components/CarteStat.jsx"
click node_livechart "https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/components/CourbeLive.jsx"

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_app,node_auth,node_authapi,node_client,node_users toneBlue
class node_buildingstate,node_seed,node_detection,node_scenarios,node_selectors toneAmber
class node_alertspage,node_alertrow,node_resolution toneMint
class node_buildingpage,node_dashboard,node_demopage,node_buildingcards,node_statcard,node_livechart toneRose
class node_user toneIndigo
```

## Components

### Access and accounts

- [App routing](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Authentication state](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/context/AuthProvider.jsx): `frontend/src/context/AuthProvider.jsx`
- [Sign-in API](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/api/auth.js): `frontend/src/api/auth.js`
- [API client](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/api/client.js): `frontend/src/api/client.js`
- [User administration](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/pages/Users.jsx): `frontend/src/pages/Users.jsx`

### Water monitoring

- [Building state](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/context/BuildingProvider.jsx): `frontend/src/context/BuildingProvider.jsx`
- [Mock data and settings](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/data/seed.js): `frontend/src/data/seed.js`
- [Reading evaluation](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/engine/evaluate.js): `frontend/src/engine/evaluate.js`
- [Demo scenarios](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/engine/scenarios.js): `frontend/src/engine/scenarios.js`
- [Building selectors](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/engine/selecteurs.js): `frontend/src/engine/selecteurs.js`

### Incident operations

- [Alert list](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/pages/Alerts.jsx): `frontend/src/pages/Alerts.jsx`
- [Alert presentation](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/components/LigneAlerte.jsx): `frontend/src/components/LigneAlerte.jsx`
- [Resolution dialog](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/components/ModaleResolution.jsx): `frontend/src/components/ModaleResolution.jsx`

### Product views

- [Building status](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/pages/Building.jsx): `frontend/src/pages/Building.jsx`
- [Resident dashboard](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Scenario demo](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/pages/Demo.jsx): `frontend/src/pages/Demo.jsx`
- [Floor and live charts](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/components/CarteEtage.jsx): `frontend/src/components/CarteEtage.jsx`
- [Status cards](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/components/CarteStat.jsx): `frontend/src/components/CarteStat.jsx`
- [Live charts](https://github.com/emnahr/aquaguard/blob/frontend/dashboards/frontend/src/components/CourbeLive.jsx): `frontend/src/components/CourbeLive.jsx`

### Other components

- **Resident or staff**

## Connections

- Resident or staff → App routing: uses (evidence: `frontend/src/App.jsx`)
- App routing → Authentication state: provides (evidence: `frontend/src/App.jsx`)
- App routing → Building state: provides (evidence: `frontend/src/App.jsx`)
- App routing → Building status: routes (evidence: `frontend/src/App.jsx`)
- App routing → Resident dashboard: routes (evidence: `frontend/src/App.jsx`)
- App routing → Alert list: routes (evidence: `frontend/src/App.jsx`)
- App routing → User administration: routes (evidence: `frontend/src/App.jsx`)
- App routing → Scenario demo: routes (evidence: `frontend/src/App.jsx`)
- App routing → Resolution dialog: shows (evidence: `frontend/src/App.jsx`)
- Authentication state → Mock data and settings: initializes users (evidence: `frontend/src/context/AuthProvider.jsx`)
- Authentication state → Sign-in API: authenticates (evidence: `frontend/src/context/AuthProvider.jsx`)
- Sign-in API → API client: uses (evidence: `frontend/src/api/auth.js`)
- Building state → Mock data and settings: loads mock data (evidence: `frontend/src/context/BuildingProvider.jsx`)
- Building state → Reading evaluation: evaluates readings (evidence: `frontend/src/context/BuildingProvider.jsx`)
- Demo scenarios → Reading evaluation: uses evaluator (evidence: `frontend/src/engine/scenarios.js`)
- Building status → Building state: reads state (evidence: `frontend/src/pages/Building.jsx`)
- Building status → Building selectors: derives status (evidence: `frontend/src/pages/Building.jsx`)
- Building status → Alert presentation: renders alerts (evidence: `frontend/src/pages/Building.jsx`)
- Building status → Floor and live charts: renders floors (evidence: `frontend/src/pages/Building.jsx`)
- Building status → Status cards: renders statistics (evidence: `frontend/src/pages/Building.jsx`)
- Building status → Live charts: renders readings (evidence: `frontend/src/pages/Building.jsx`)
- Resident dashboard → Building state: reads state (evidence: `frontend/src/pages/Dashboard.jsx`)
- Resident dashboard → Alert presentation: renders alerts (evidence: `frontend/src/pages/Dashboard.jsx`)
- Alert list → Building state: reads alerts (evidence: `frontend/src/pages/Alerts.jsx`)
- Alert list → Alert presentation: renders alerts (evidence: `frontend/src/pages/Alerts.jsx`)
- Alert presentation → Resolution dialog: requests resolution
- Resolution dialog → Building state: resolves alert (evidence: `frontend/src/App.jsx`)
- Scenario demo → Demo scenarios: uses scenarios (evidence: `frontend/src/pages/Demo.jsx`)
