# mamoon-17/hydrogrid architecture

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

- Interactive diagram: https://gitdiagram.com/mamoon-17/hydrogrid
- Repository: https://github.com/mamoon-17/hydrogrid

## Overview

HydroGrid is a multi-tenant water-treatment operations platform. Operators authenticate, establish or join a team, manage plants and memberships, submit quality and maintenance reports with media, then review work history and analytics. The graph follows the shown frontend routing/API and backend controller/service paths; documented analytics, invitations, and media capabilities are included where the tree supports them. Some backend service wiring and analytics implementation were not sampled, so unsupported internal calls are omitted.

Main entry points: [`frontend/src/lib/api.ts`](https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/lib/api.ts) (API client), [`backend/src/reports/reports.controller.ts`](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/reports/reports.controller.ts) (Report endpoints), [`backend/src/app.module.ts`](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/app.module.ts) (Nest runtime), [`frontend/src/App.tsx`](https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/App.tsx) (App routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Operator experience"]
  node_app["App routes<br/>[App.tsx]"]
  node_authui["Session context<br/>[AuthContext.tsx]"]
  node_apiclient["API client<br/>[api.ts]"]
  node_teamsetup["Team setup<br/>[TeamSetup.tsx]"]
  node_plantui["Plant management<br/>[ManagePlants.tsx]"]
  node_reportui["Quality reports<br/>[QualityReports.tsx]"]
  node_fillreport["Report entry<br/>[FillReport.tsx]"]
  node_history["Work history<br/>[WorkHistory.tsx]"]
  node_analytics["Analytics<br/>[Analytics.tsx]"]
end

subgraph group_identity["Identity and teams"]
  node_authcontroller["Auth endpoints<br/>[auth.controller.ts]"]
  node_authservice["Auth service<br/>[auth.service.ts]"]
  node_users["User management"]
  node_userservice["User service<br/>[users.service.ts]"]
  node_teams["Team management"]
  node_teamservice["Team service<br/>[teams.service.ts]"]
  node_teamstate[("Team membership<br/>[teams.entity.ts]")]
  node_userstate[("User records<br/>[users.entity.ts]")]
end

subgraph group_operations["Plant operations"]
  node_plantcontroller["Plant endpoints"]
  node_plantservice["Plant service<br/>[plants.service.ts]"]
  node_reportcontroller["Report endpoints"]
  node_reportservice["Report service<br/>[reports.service.ts]"]
  node_media[("Report attachments")]
end

subgraph group_platform["Backend platform"]
  node_runtime["Nest runtime<br/>[app.module.ts]"]
  node_tokens[("Refresh tokens")]
  node_cron["Token cleanup"]
  node_upload["File upload<br/>[upload.service.ts]"]
end

node_operator(("Operator"))
node_database[("PostgreSQL")]

node_operator -->|"uses"| node_app
node_app -->|"provides session"| node_authui
node_app -->|"routes to"| node_teamsetup
node_authui -->|"requests through"| node_apiclient
node_teamsetup -->|"requests through"| node_apiclient
node_plantui -.->|"requests through"| node_apiclient
node_reportui -->|"requests through"| node_apiclient
node_fillreport -.->|"requests through"| node_apiclient
node_history -->|"requests through"| node_apiclient
node_analytics -.->|"requests through"| node_apiclient
node_apiclient -.->|"calls HTTP"| node_authcontroller
node_authcontroller -->|"delegates"| node_authservice
node_authservice -->|"reads/writes"| node_userstate
node_authservice -->|"creates/rotates"| node_tokens
node_authcontroller -.->|"calls HTTP"| node_users
node_users -->|"delegates"| node_userservice
node_userservice -->|"manages"| node_userstate
node_userservice -->|"uses membership"| node_teamstate
node_teamsetup -->|"calls HTTP"| node_teams
node_teams -->|"delegates"| node_teamservice
node_teamservice -->|"manages"| node_teamstate
node_teamservice -->|"manages members"| node_userstate
node_plantui -.->|"calls HTTP"| node_plantcontroller
node_plantcontroller -->|"delegates"| node_plantservice
node_reportui -.->|"calls HTTP"| node_reportcontroller
node_history -.->|"loads reports"| node_reportcontroller
node_fillreport -.->|"submits reports"| node_reportcontroller
node_reportcontroller -->|"delegates"| node_reportservice
node_runtime -->|"configures PostgreSQL"| node_database
node_runtime -->|"registers"| node_cron
node_cron -.->|"cleans expired"| node_tokens
node_runtime -->|"registers shared service"| node_upload
node_reportservice -.->|"uses attachments"| node_media

click node_app "https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/App.tsx"
click node_authui "https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/contexts/AuthContext.tsx"
click node_apiclient "https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/lib/api.ts"
click node_teamsetup "https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/pages/TeamSetup.tsx"
click node_plantui "https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/pages/admin/ManagePlants.tsx"
click node_reportui "https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/pages/admin/QualityReports.tsx"
click node_fillreport "https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/pages/employee/FillReport.tsx"
click node_history "https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/pages/employee/WorkHistory.tsx"
click node_analytics "https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/pages/admin/Analytics.tsx"
click node_authcontroller "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/auth/auth.controller.ts"
click node_authservice "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/auth/auth.service.ts"
click node_users "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/users/users.controller.ts"
click node_userservice "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/users/users.service.ts"
click node_teams "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/teams/teams.controller.ts"
click node_teamservice "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/teams/teams.service.ts"
click node_teamstate "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/teams/teams.entity.ts"
click node_userstate "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/users/users.entity.ts"
click node_plantcontroller "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/plants/plants.controller.ts"
click node_plantservice "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/plants/plants.service.ts"
click node_reportcontroller "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/reports/reports.controller.ts"
click node_reportservice "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/reports/reports.service.ts"
click node_media "https://github.com/mamoon-17/hydrogrid/tree/main/backend/src/report_media"
click node_runtime "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/app.module.ts"
click node_tokens "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/refresh_tokens/refresh_tokens.entity.ts"
click node_cron "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/cron-tasks/cron-tasks.service.ts"
click node_upload "https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/shared/upload.service.ts"

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_authui,node_apiclient,node_teamsetup,node_plantui,node_reportui,node_fillreport,node_history,node_analytics toneBlue
class node_authcontroller,node_authservice,node_users,node_userservice,node_teams,node_teamservice,node_teamstate,node_userstate,node_database toneAmber
class node_plantcontroller,node_plantservice,node_reportcontroller,node_reportservice,node_media toneMint
class node_runtime,node_tokens,node_cron,node_upload toneRose
class node_operator toneIndigo
```

## Components

### Operator experience

- [App routes](https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Session context](https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/contexts/AuthContext.tsx): `frontend/src/contexts/AuthContext.tsx`
- [API client](https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Team setup](https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/pages/TeamSetup.tsx): `frontend/src/pages/TeamSetup.tsx`
- [Plant management](https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/pages/admin/ManagePlants.tsx): `frontend/src/pages/admin/ManagePlants.tsx`
- [Quality reports](https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/pages/admin/QualityReports.tsx): `frontend/src/pages/admin/QualityReports.tsx`
- [Report entry](https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/pages/employee/FillReport.tsx): `frontend/src/pages/employee/FillReport.tsx`
- [Work history](https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/pages/employee/WorkHistory.tsx): `frontend/src/pages/employee/WorkHistory.tsx`
- [Analytics](https://github.com/mamoon-17/hydrogrid/blob/main/frontend/src/pages/admin/Analytics.tsx): `frontend/src/pages/admin/Analytics.tsx`

### Identity and teams

- [Auth endpoints](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/auth/auth.controller.ts): `backend/src/auth/auth.controller.ts`
- [Auth service](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/auth/auth.service.ts): `backend/src/auth/auth.service.ts`
- [User management](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/users/users.controller.ts): `backend/src/users/users.controller.ts`
- [User service](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/users/users.service.ts): `backend/src/users/users.service.ts`
- [Team management](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/teams/teams.controller.ts): `backend/src/teams/teams.controller.ts`
- [Team service](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/teams/teams.service.ts): `backend/src/teams/teams.service.ts`
- [Team membership](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/teams/teams.entity.ts): `backend/src/teams/teams.entity.ts`
- [User records](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/users/users.entity.ts): `backend/src/users/users.entity.ts`

### Plant operations

- [Plant endpoints](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/plants/plants.controller.ts): `backend/src/plants/plants.controller.ts`
- [Plant service](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/plants/plants.service.ts): `backend/src/plants/plants.service.ts`
- [Report endpoints](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/reports/reports.controller.ts): `backend/src/reports/reports.controller.ts`
- [Report service](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/reports/reports.service.ts): `backend/src/reports/reports.service.ts`
- [Report attachments](https://github.com/mamoon-17/hydrogrid/tree/main/backend/src/report_media): `backend/src/report_media`

### Backend platform

- [Nest runtime](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/app.module.ts): `backend/src/app.module.ts`
- [Refresh tokens](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/refresh_tokens/refresh_tokens.entity.ts): `backend/src/refresh_tokens/refresh_tokens.entity.ts`
- [Token cleanup](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/cron-tasks/cron-tasks.service.ts): `backend/src/cron-tasks/cron-tasks.service.ts`
- [File upload](https://github.com/mamoon-17/hydrogrid/blob/main/backend/src/shared/upload.service.ts): `backend/src/shared/upload.service.ts`

### Other components

- **Operator**
- **PostgreSQL**

## Connections

- Operator → App routes: uses (evidence: `frontend/src/App.tsx`)
- App routes → Session context: provides session (evidence: `frontend/src/App.tsx`)
- App routes → Team setup: routes to (evidence: `frontend/src/App.tsx`)
- Session context → API client: requests through (evidence: `frontend/src/contexts/AuthContext.tsx`)
- Team setup → API client: requests through (evidence: `frontend/src/pages/TeamSetup.tsx`)
- Plant management → API client: requests through
- Quality reports → API client: requests through (evidence: `frontend/src/pages/admin/QualityReports.tsx`)
- Report entry → API client: requests through
- Work history → API client: requests through (evidence: `frontend/src/pages/employee/WorkHistory.tsx`)
- Analytics → API client: requests through
- API client → Auth endpoints: calls HTTP
- Auth endpoints → Auth service: delegates (evidence: `backend/src/auth/auth.controller.ts`)
- Auth service → User records: reads/writes (evidence: `backend/src/auth/auth.service.ts`)
- Auth service → Refresh tokens: creates/rotates (evidence: `backend/src/auth/auth.service.ts`)
- Auth endpoints → User management: calls HTTP
- User management → User service: delegates (evidence: `backend/src/users/users.controller.ts`)
- User service → User records: manages (evidence: `backend/src/users/users.service.ts`)
- User service → Team membership: uses membership (evidence: `backend/src/users/users.service.ts`)
- Team setup → Team management: calls HTTP (evidence: `frontend/src/pages/TeamSetup.tsx`)
- Team management → Team service: delegates (evidence: `backend/src/teams/teams.controller.ts`)
- Team service → Team membership: manages (evidence: `backend/src/teams/teams.service.ts`)
- Team service → User records: manages members (evidence: `backend/src/teams/teams.service.ts`)
- Plant management → Plant endpoints: calls HTTP
- Plant endpoints → Plant service: delegates (evidence: `backend/src/plants/plants.controller.ts`)
- Quality reports → Report endpoints: calls HTTP
- Work history → Report endpoints: loads reports
- Report entry → Report endpoints: submits reports
- Report endpoints → Report service: delegates (evidence: `backend/src/reports/reports.controller.ts`)
- Nest runtime → PostgreSQL: configures PostgreSQL (evidence: `backend/src/app.module.ts`)
- Nest runtime → Token cleanup: registers (evidence: `backend/src/app.module.ts`)
- Token cleanup → Refresh tokens: cleans expired
- Nest runtime → File upload: registers shared service (evidence: `backend/src/app.module.ts`)
- Report service → Report attachments: uses attachments
