# itrm98/namaa-proj architecture

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

- Interactive diagram: https://gitdiagram.com/itrm98/namaa-proj
- Repository: https://github.com/itrm98/namaa-proj

## Overview

NAMAA monitors parks through sensor readings, camera frames, and satellite vegetation data; it turns those signals into alerts and maintenance work, then presents status and outcomes in role-specific dashboards. The backend is the hub for ingestion, rules, irrigation control, AI requests, persistence, and live updates. The README documents the broad service connections; sampled backend excerpts additionally show rules-to-alert/pump behavior and camera processing. Other unsampled subsystem links are limited to documented relationships.

Main entry points: [`backend/routes/api.php`](https://github.com/itrm98/namaa-proj/blob/main/backend/routes/api.php) (Laravel API), [`backend/app/Services/RulesEngine.php`](https://github.com/itrm98/namaa-proj/blob/main/backend/app/Services/RulesEngine.php) (Rules and irrigation), [`backend/app/Models/Park.php`](https://github.com/itrm98/namaa-proj/blob/main/backend/app/Models/Park.php) (Park data models), [`backend/app/Services/CameraPipeline.php`](https://github.com/itrm98/namaa-proj/blob/main/backend/app/Services/CameraPipeline.php) (Camera pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_devices["Park devices"]
  node_sensor_firmware["Sensor firmware<br/>[main.cpp]"]
  node_camera["Park camera"]
end

subgraph group_backend["Backend operations"]
  node_api["Laravel API<br/>[api.php]"]
  node_reading_ingest["Reading ingest"]
  node_camera_pipeline["Camera pipeline<br/>[CameraPipeline.php]"]
  node_rules["Rules and irrigation<br/>[RulesEngine.php]"]
  node_tasks["Tasks and verification<br/>[TaskService.php]"]
  node_park_ops["Park operations"]
  node_models[("Park data models<br/>[Park.php]")]
end

subgraph group_insights["Monitoring insights"]
  node_ndvi["Satellite NDVI<br/>[NdviService.php]"]
  node_vision["Vision service<br/>[main.py]"]
end

subgraph group_experience["Dashboard experience"]
  node_frontend["React dashboard<br/>[App.tsx]"]
  node_admin_ui["Admin operations<br/>[OverviewPage.tsx]"]
  node_worker_ui["Worker tasks<br/>[MyTasksPage.tsx]"]
  node_municipality_ui["Municipality view<br/>[OverviewPage.tsx]"]
end

subgraph group_platform["Runtime services"]
  node_database[("MySQL database")]
  node_realtime["Live updates<br/>[Realtime.php]"]
end

node_field_staff(("Park staff"))
node_satellite["Sentinel-2 data"]

node_sensor_firmware -->|"posts readings"| node_api
node_api -.->|"routes readings"| node_reading_ingest
node_reading_ingest -.->|"stores readings"| node_models
node_reading_ingest -.->|"evaluates readings"| node_rules
node_rules -->|"recalculates status"| node_park_ops
node_rules -.->|"raises work"| node_tasks
node_rules -->|"reads park data"| node_models
node_rules -->|"writes alerts"| node_models
node_rules -->|"controls pump"| node_api
node_camera -->|"supplies frames"| node_camera_pipeline
node_camera_pipeline -->|"requests detection"| node_vision
node_camera_pipeline -.->|"stores detections"| node_models
node_camera_pipeline -->|"publishes detection"| node_realtime
node_satellite -->|"provides imagery"| node_ndvi
node_ndvi -->|"requests NDVI"| node_vision
node_ndvi -.->|"stores park metrics"| node_models
node_models -->|"persists records"| node_database
node_frontend -->|"requests dashboard data"| node_api
node_api -->|"serves park operations"| node_admin_ui
node_api -->|"serves assigned tasks"| node_worker_ui
node_api -.->|"serves regional overview"| node_municipality_ui
node_realtime -->|"pushes live updates"| node_frontend
node_field_staff -->|"completes maintenance"| node_worker_ui
node_admin_ui -.->|"manages tasks"| node_tasks
node_worker_ui -.->|"reports task outcome"| node_tasks

click node_sensor_firmware "https://github.com/itrm98/namaa-proj/blob/main/firmware/node-sensor/src/main.cpp"
click node_api "https://github.com/itrm98/namaa-proj/blob/main/backend/routes/api.php"
click node_reading_ingest "https://github.com/itrm98/namaa-proj/blob/main/backend/app/Services/ReadingIngestor.php"
click node_camera_pipeline "https://github.com/itrm98/namaa-proj/blob/main/backend/app/Services/CameraPipeline.php"
click node_rules "https://github.com/itrm98/namaa-proj/blob/main/backend/app/Services/RulesEngine.php"
click node_tasks "https://github.com/itrm98/namaa-proj/blob/main/backend/app/Services/TaskService.php"
click node_park_ops "https://github.com/itrm98/namaa-proj/blob/main/backend/app/Services/ParkStatusService.php"
click node_ndvi "https://github.com/itrm98/namaa-proj/blob/main/backend/app/Services/NdviService.php"
click node_vision "https://github.com/itrm98/namaa-proj/blob/main/vision-service/app/main.py"
click node_models "https://github.com/itrm98/namaa-proj/blob/main/backend/app/Models/Park.php"
click node_frontend "https://github.com/itrm98/namaa-proj/blob/main/frontend/src/App.tsx"
click node_admin_ui "https://github.com/itrm98/namaa-proj/blob/main/frontend/src/pages/admin/OverviewPage.tsx"
click node_worker_ui "https://github.com/itrm98/namaa-proj/blob/main/frontend/src/pages/worker/MyTasksPage.tsx"
click node_municipality_ui "https://github.com/itrm98/namaa-proj/blob/main/frontend/src/pages/municipality/OverviewPage.tsx"
click node_realtime "https://github.com/itrm98/namaa-proj/blob/main/backend/app/Support/Realtime.php"

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_sensor_firmware,node_camera toneBlue
class node_api,node_reading_ingest,node_camera_pipeline,node_rules,node_tasks,node_park_ops,node_models toneAmber
class node_ndvi,node_vision toneMint
class node_frontend,node_admin_ui,node_worker_ui,node_municipality_ui toneRose
class node_database,node_realtime,node_field_staff,node_satellite toneIndigo
```

## Components

### Park devices

- [Sensor firmware](https://github.com/itrm98/namaa-proj/blob/main/firmware/node-sensor/src/main.cpp): `firmware/node-sensor/src/main.cpp`
- **Park camera**

### Backend operations

- [Laravel API](https://github.com/itrm98/namaa-proj/blob/main/backend/routes/api.php): `backend/routes/api.php`
- [Reading ingest](https://github.com/itrm98/namaa-proj/blob/main/backend/app/Services/ReadingIngestor.php): `backend/app/Services/ReadingIngestor.php`
- [Camera pipeline](https://github.com/itrm98/namaa-proj/blob/main/backend/app/Services/CameraPipeline.php): `backend/app/Services/CameraPipeline.php`
- [Rules and irrigation](https://github.com/itrm98/namaa-proj/blob/main/backend/app/Services/RulesEngine.php): `backend/app/Services/RulesEngine.php`
- [Tasks and verification](https://github.com/itrm98/namaa-proj/blob/main/backend/app/Services/TaskService.php): `backend/app/Services/TaskService.php`
- [Park operations](https://github.com/itrm98/namaa-proj/blob/main/backend/app/Services/ParkStatusService.php): `backend/app/Services/ParkStatusService.php`
- [Park data models](https://github.com/itrm98/namaa-proj/blob/main/backend/app/Models/Park.php): `backend/app/Models/Park.php`

### Monitoring insights

- [Satellite NDVI](https://github.com/itrm98/namaa-proj/blob/main/backend/app/Services/NdviService.php): `backend/app/Services/NdviService.php`
- [Vision service](https://github.com/itrm98/namaa-proj/blob/main/vision-service/app/main.py): `vision-service/app/main.py`

### Dashboard experience

- [React dashboard](https://github.com/itrm98/namaa-proj/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Admin operations](https://github.com/itrm98/namaa-proj/blob/main/frontend/src/pages/admin/OverviewPage.tsx): `frontend/src/pages/admin/OverviewPage.tsx`
- [Worker tasks](https://github.com/itrm98/namaa-proj/blob/main/frontend/src/pages/worker/MyTasksPage.tsx): `frontend/src/pages/worker/MyTasksPage.tsx`
- [Municipality view](https://github.com/itrm98/namaa-proj/blob/main/frontend/src/pages/municipality/OverviewPage.tsx): `frontend/src/pages/municipality/OverviewPage.tsx`

### Runtime services

- **MySQL database**
- [Live updates](https://github.com/itrm98/namaa-proj/blob/main/backend/app/Support/Realtime.php): `backend/app/Support/Realtime.php`

### Other components

- **Park staff**
- **Sentinel-2 data**

## Connections

- Sensor firmware → Laravel API: posts readings
- Laravel API → Reading ingest: routes readings
- Reading ingest → Park data models: stores readings
- Reading ingest → Rules and irrigation: evaluates readings
- Rules and irrigation → Park operations: recalculates status (evidence: `backend/app/Services/RulesEngine.php`)
- Rules and irrigation → Tasks and verification: raises work
- Rules and irrigation → Park data models: reads park data (evidence: `backend/app/Services/RulesEngine.php`)
- Rules and irrigation → Park data models: writes alerts (evidence: `backend/app/Services/RulesEngine.php`)
- Rules and irrigation → Laravel API: controls pump (evidence: `backend/app/Services/RulesEngine.php`)
- Park camera → Camera pipeline: supplies frames
- Camera pipeline → Vision service: requests detection (evidence: `backend/app/Services/CameraPipeline.php`)
- Camera pipeline → Park data models: stores detections
- Camera pipeline → Live updates: publishes detection (evidence: `backend/app/Services/CameraPipeline.php`)
- Sentinel-2 data → Satellite NDVI: provides imagery
- Satellite NDVI → Vision service: requests NDVI
- Satellite NDVI → Park data models: stores park metrics
- Park data models → MySQL database: persists records
- React dashboard → Laravel API: requests dashboard data
- Laravel API → Admin operations: serves park operations
- Laravel API → Worker tasks: serves assigned tasks
- Laravel API → Municipality view: serves regional overview
- Live updates → React dashboard: pushes live updates
- Park staff → Worker tasks: completes maintenance
- Admin operations → Tasks and verification: manages tasks
- Worker tasks → Tasks and verification: reports task outcome
