# l1o2-k4i7/aquapro_new architecture

> Architecture diagram of the GitHub repository l1o2-k4i7/aquapro_new, 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/l1o2-k4i7/aquapro_new
- Repository: https://github.com/l1o2-k4i7/aquapro_new

## Overview

AquaPro is an offline aquaculture monitoring and fish-stocking recommendation system. Sensor readings arrive from ESP32 hardware over USB serial; the reader updates live monitoring and a Python snapshot. Users can review monitoring data or submit ammonia for a test: the Node.js controller combines it with the latest sensor snapshot, requests a Python prediction, and saves the result with the project. The graph includes monitoring history/trends, project and test management, and prediction rules. README documents serial and dashboard flows; the frontend files are absent from the supplied tree, so the dashboard is represented as external.

Main entry points: [`aquapro/routes/monitoringRoutes.js`](https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/routes/monitoringRoutes.js) (Monitoring routes), [`aquapro/server.js`](https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/server.js) (Node.js server), [`aquapro/controllers/projectController.js`](https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/controllers/projectController.js) (Project and tests), [`aquapro/routes/projectRoutes.js`](https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/routes/projectRoutes.js) (Project routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest_monitor["Sensor monitoring"]
  node_serial_reader["Serial reader<br/>[serial_reader.py]"]
  node_monitor_routes["Monitoring routes"]
  node_monitor_controller["Monitoring controller"]
end

subgraph group_api_domain["API and projects"]
  node_node_server["Node.js server<br/>[server.js]"]
  node_validation["Request validation<br/>[validation.js]"]
  node_project_routes["Project routes<br/>[projectRoutes.js]"]
  node_project_controller["Project and tests"]
end

subgraph group_prediction["Prediction engine"]
  node_python_bridge["Prediction bridge<br/>[python_bridge.py]"]
  node_prediction_engine["Species and stocking rules<br/>[p1.py]"]
end

subgraph group_persistence["Persistence"]
  node_monitor_model["Monitoring records"]
  node_project_model["Project records<br/>[Project.js]"]
  node_db_config["MongoDB connection<br/>[db.js]"]
  node_mongo[("MongoDB")]
  node_seed_data["Seed data utility<br/>[seed.js]"]
end

node_pond_sensors(("Pond sensors"))
node_esp32_link(("ESP32 receiver"))
node_dashboard(("Web dashboard"))

node_pond_sensors -->|"send signals"| node_esp32_link
node_esp32_link -->|"send serial data"| node_serial_reader
node_serial_reader -->|"posts readings"| node_monitor_routes
node_serial_reader -->|"updates snapshot"| node_python_bridge
node_dashboard -->|"submits tests"| node_project_routes
node_dashboard -->|"requests data"| node_monitor_routes
node_node_server -->|"connects database"| node_db_config
node_node_server -->|"mounts routes"| node_project_routes
node_node_server -->|"mounts routes"| node_monitor_routes
node_node_server -->|"schedules readings"| node_monitor_controller
node_monitor_routes -->|"validates readings"| node_validation
node_monitor_routes -->|"dispatches requests"| node_monitor_controller
node_project_routes -->|"validates projects"| node_validation
node_project_routes -->|"dispatches requests"| node_project_controller
node_monitor_controller -->|"reads and writes"| node_monitor_model
node_monitor_model -->|"persists readings"| node_mongo
node_project_controller -->|"reads and saves"| node_project_model
node_project_controller -->|"gets live snapshot"| node_monitor_controller
node_project_controller -->|"posts prediction input"| node_python_bridge
node_python_bridge -->|"runs prediction"| node_prediction_engine
node_project_model -->|"persists projects"| node_mongo
node_db_config -->|"opens connection"| node_mongo
node_seed_data -->|"seeds projects"| node_project_model
node_seed_data -->|"seeds readings"| node_monitor_model

click node_serial_reader "https://github.com/l1o2-k4i7/aquapro_new/blob/main/python/serial_reader.py"
click node_node_server "https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/server.js"
click node_monitor_routes "https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/routes/monitoringRoutes.js"
click node_validation "https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/middleware/validation.js"
click node_monitor_controller "https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/controllers/monitoringController.js"
click node_monitor_model "https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/models/WaterMonitoringData.js"
click node_project_routes "https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/routes/projectRoutes.js"
click node_project_controller "https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/controllers/projectController.js"
click node_project_model "https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/models/Project.js"
click node_db_config "https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/config/db.js"
click node_python_bridge "https://github.com/l1o2-k4i7/aquapro_new/blob/main/python/python_bridge.py"
click node_prediction_engine "https://github.com/l1o2-k4i7/aquapro_new/blob/main/python/p1.py"
click node_seed_data "https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/seed.js"

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_serial_reader,node_monitor_routes,node_monitor_controller toneBlue
class node_node_server,node_validation,node_project_routes,node_project_controller toneAmber
class node_python_bridge,node_prediction_engine toneMint
class node_monitor_model,node_project_model,node_db_config,node_mongo,node_seed_data toneRose
class node_pond_sensors,node_esp32_link,node_dashboard toneIndigo
```

## Components

### Sensor monitoring

- [Serial reader](https://github.com/l1o2-k4i7/aquapro_new/blob/main/python/serial_reader.py): `python/serial_reader.py`
- [Monitoring routes](https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/routes/monitoringRoutes.js): `aquapro/routes/monitoringRoutes.js`
- [Monitoring controller](https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/controllers/monitoringController.js): `aquapro/controllers/monitoringController.js`

### API and projects

- [Node.js server](https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/server.js): `aquapro/server.js`
- [Request validation](https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/middleware/validation.js): `aquapro/middleware/validation.js`
- [Project routes](https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/routes/projectRoutes.js): `aquapro/routes/projectRoutes.js`
- [Project and tests](https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/controllers/projectController.js): `aquapro/controllers/projectController.js`

### Prediction engine

- [Prediction bridge](https://github.com/l1o2-k4i7/aquapro_new/blob/main/python/python_bridge.py): `python/python_bridge.py`
- [Species and stocking rules](https://github.com/l1o2-k4i7/aquapro_new/blob/main/python/p1.py): `python/p1.py`

### Persistence

- [Monitoring records](https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/models/WaterMonitoringData.js): `aquapro/models/WaterMonitoringData.js`
- [Project records](https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/models/Project.js): `aquapro/models/Project.js`
- [MongoDB connection](https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/config/db.js): `aquapro/config/db.js`
- **MongoDB**
- [Seed data utility](https://github.com/l1o2-k4i7/aquapro_new/blob/main/aquapro/seed.js): `aquapro/seed.js`

### Other components

- **Pond sensors**
- **ESP32 receiver**
- **Web dashboard**

## Connections

- Pond sensors → ESP32 receiver: send signals (evidence: `README.md`)
- ESP32 receiver → Serial reader: send serial data (evidence: `README.md`)
- Serial reader → Monitoring routes: posts readings (evidence: `README.md`)
- Serial reader → Prediction bridge: updates snapshot (evidence: `README.md`)
- Web dashboard → Project routes: submits tests (evidence: `README.md`)
- Web dashboard → Monitoring routes: requests data (evidence: `README.md`)
- Node.js server → MongoDB connection: connects database (evidence: `aquapro/server.js`)
- Node.js server → Project routes: mounts routes (evidence: `aquapro/server.js`)
- Node.js server → Monitoring routes: mounts routes (evidence: `aquapro/server.js`)
- Node.js server → Monitoring controller: schedules readings (evidence: `aquapro/server.js`)
- Monitoring routes → Request validation: validates readings (evidence: `aquapro/routes/monitoringRoutes.js`)
- Monitoring routes → Monitoring controller: dispatches requests (evidence: `aquapro/routes/monitoringRoutes.js`)
- Project routes → Request validation: validates projects (evidence: `aquapro/routes/projectRoutes.js`)
- Project routes → Project and tests: dispatches requests (evidence: `aquapro/routes/projectRoutes.js`)
- Monitoring controller → Monitoring records: reads and writes (evidence: `aquapro/controllers/monitoringController.js`)
- Monitoring records → MongoDB: persists readings (evidence: `README.md`)
- Project and tests → Project records: reads and saves (evidence: `aquapro/controllers/projectController.js`)
- Project and tests → Monitoring controller: gets live snapshot (evidence: `aquapro/controllers/projectController.js`)
- Project and tests → Prediction bridge: posts prediction input (evidence: `aquapro/controllers/projectController.js`)
- Prediction bridge → Species and stocking rules: runs prediction (evidence: `python/python_bridge.py`)
- Project records → MongoDB: persists projects (evidence: `README.md`)
- MongoDB connection → MongoDB: opens connection (evidence: `aquapro/config/db.js`)
- Seed data utility → Project records: seeds projects (evidence: `aquapro/seed.js`)
- Seed data utility → Monitoring records: seeds readings (evidence: `aquapro/seed.js`)
