# mohamedwaleed77/iot_based_earthquakestation architecture

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

- Interactive diagram: https://gitdiagram.com/mohamedwaleed77/iot_based_earthquakestation
- Repository: https://github.com/mohamedwaleed77/iot_based_earthquakestation

## Overview

This is an IoT earthquake-monitoring system: STM32 stations sample motion, send readings to a server for earthquake classification, and expose station and event information through a web dashboard. The README documents the UDP and Random Forest workflow; the sampled files show sensor/display/network calls, backend persistence and APIs, and dashboard fetching. The classifier implementation and full server-side UDP ingress path are not shown, so those connections are documented but unverified here.

Main entry points: [`frontend/src/components/station_info.js`](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/components/station_info.js) (Live station view), [`backend/stationsModule/controller.js`](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/backend/stationsModule/controller.js) (Station API), [`frontend/src/App.js`](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/App.js) (Page router), [`frontend/src/components/home.js`](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/components/home.js) (Station listing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_station["Station firmware"]
  node_main["Station control<br/>[main.c]"]
  node_mpu["MPU-6050 sensor<br/>[MPU6050.c]"]
  node_esp["ESP UDP link<br/>[ESP01.c]"]
  node_display["Station display<br/>[st7735.c]"]
end

subgraph group_server["Server and data"]
  node_ingress["Data ingestion"]
  node_api["Station API<br/>[controller.js]"]
  node_routes["HTTP routes<br/>[routes.js]"]
  node_middleware["Station validation"]
  node_database[("MySQL database<br/>[database.js]")]
  node_serverentry["Server entry<br/>[index.js]"]
end

subgraph group_dashboard["Web dashboard"]
  node_app["Page router<br/>[App.js]"]
  node_home["Station listing<br/>[home.js]"]
  node_stationview["Live station view<br/>[station_info.js]"]
  node_history["History view<br/>[history.js]"]
  node_introduction["Introduction<br/>[Introduction.js]"]
  node_about["About page<br/>[about.js]"]
  node_navbar["Navigation<br/>[navbar.js]"]
end

subgraph group_ml["Classification"]
  node_classifier["Random Forest classifier"]
end

node_ground(("Ground motion"))
node_udp(("UDP readings"))
node_browser(("Dashboard user"))
node_maps["Google Maps"]

node_ground -.->|"causes motion"| node_mpu
node_main -->|"reads samples"| node_mpu
node_main -->|"sends readings"| node_esp
node_main -->|"updates status"| node_display
node_esp -.->|"transmits UDP"| node_udp
node_udp -.->|"delivers readings"| node_ingress
node_ingress -.->|"classifies data"| node_classifier
node_classifier -.->|"accepted events"| node_api
node_serverentry -->|"registers routes"| node_routes
node_routes -->|"validates history"| node_middleware
node_routes -->|"dispatches requests"| node_api
node_middleware -->|"checks station"| node_database
node_api -->|"reads and writes"| node_database
node_browser -.->|"opens dashboard"| node_app
node_app -->|"renders navigation"| node_navbar
node_app -->|"routes home"| node_home
node_app -->|"routes about"| node_about
node_home -.->|"fetches stations"| node_api
node_home -->|"renders stations"| node_stationview
node_home -->|"renders introduction"| node_introduction
node_stationview -.->|"requests history"| node_api
node_stationview -->|"renders history"| node_history
node_stationview -->|"embeds location"| node_maps
node_stationview -.->|"receives live feed"| node_serverentry

click node_main "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/stationSide/Core/Src/main.c"
click node_mpu "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/stationSide/Core/Src/MPU6050.c"
click node_esp "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/stationSide/Core/Src/ESP01.c"
click node_display "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/stationSide/Core/Src/st7735.c"
click node_ingress "https://github.com/mohamedwaleed77/iot_based_earthquakestation/tree/main/backend"
click node_classifier "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/random_forest_200.pkl"
click node_api "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/backend/stationsModule/controller.js"
click node_routes "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/backend/stationsModule/routes.js"
click node_middleware "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/backend/middlewares/checkStationExist.js"
click node_database "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/backend/database/database.js"
click node_serverentry "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/backend/index.js"
click node_app "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/App.js"
click node_home "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/components/home.js"
click node_stationview "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/components/station_info.js"
click node_history "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/components/history.js"
click node_introduction "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/components/Introduction.js"
click node_about "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/components/about.js"
click node_navbar "https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/components/navbar.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_main,node_mpu,node_esp,node_display,node_browser toneBlue
class node_ingress,node_api,node_routes,node_middleware,node_database,node_serverentry toneAmber
class node_app,node_home,node_stationview,node_history,node_introduction,node_about,node_navbar toneMint
class node_classifier toneRose
class node_ground,node_udp,node_maps toneIndigo
```

## Components

### Station firmware

- [Station control](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/stationSide/Core/Src/main.c): `stationSide/Core/Src/main.c`
- [MPU-6050 sensor](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/stationSide/Core/Src/MPU6050.c): `stationSide/Core/Src/MPU6050.c`
- [ESP UDP link](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/stationSide/Core/Src/ESP01.c): `stationSide/Core/Src/ESP01.c`
- [Station display](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/stationSide/Core/Src/st7735.c): `stationSide/Core/Src/st7735.c`

### Server and data

- [Data ingestion](https://github.com/mohamedwaleed77/iot_based_earthquakestation/tree/main/backend): `backend`
- [Station API](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/backend/stationsModule/controller.js): `backend/stationsModule/controller.js`
- [HTTP routes](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/backend/stationsModule/routes.js): `backend/stationsModule/routes.js`
- [Station validation](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/backend/middlewares/checkStationExist.js): `backend/middlewares/checkStationExist.js`
- [MySQL database](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/backend/database/database.js): `backend/database/database.js`
- [Server entry](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/backend/index.js): `backend/index.js`

### Web dashboard

- [Page router](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/App.js): `frontend/src/App.js`
- [Station listing](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/components/home.js): `frontend/src/components/home.js`
- [Live station view](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/components/station_info.js): `frontend/src/components/station_info.js`
- [History view](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/components/history.js): `frontend/src/components/history.js`
- [Introduction](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/components/Introduction.js): `frontend/src/components/Introduction.js`
- [About page](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/components/about.js): `frontend/src/components/about.js`
- [Navigation](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/frontend/src/components/navbar.js): `frontend/src/components/navbar.js`

### Classification

- [Random Forest classifier](https://github.com/mohamedwaleed77/iot_based_earthquakestation/blob/main/random_forest_200.pkl): `random_forest_200.pkl`

### Other components

- **Ground motion**
- **UDP readings**
- **Dashboard user**
- **Google Maps**

## Connections

- Ground motion → MPU-6050 sensor: causes motion (evidence: `README.md`)
- Station control → MPU-6050 sensor: reads samples (evidence: `stationSide/Core/Src/main.c`)
- Station control → ESP UDP link: sends readings (evidence: `stationSide/Core/Src/main.c`)
- Station control → Station display: updates status (evidence: `stationSide/Core/Src/main.c`)
- ESP UDP link → UDP readings: transmits UDP (evidence: `README.md`)
- UDP readings → Data ingestion: delivers readings (evidence: `README.md`)
- Data ingestion → Random Forest classifier: classifies data (evidence: `README.md`)
- Random Forest classifier → Station API: accepted events (evidence: `README.md`)
- Server entry → HTTP routes: registers routes (evidence: `backend/index.js`)
- HTTP routes → Station validation: validates history (evidence: `backend/stationsModule/routes.js`)
- HTTP routes → Station API: dispatches requests (evidence: `backend/stationsModule/routes.js`)
- Station validation → MySQL database: checks station (evidence: `backend/middlewares/checkStationExist.js`)
- Station API → MySQL database: reads and writes (evidence: `backend/stationsModule/controller.js`)
- Dashboard user → Page router: opens dashboard
- Page router → Navigation: renders navigation (evidence: `frontend/src/App.js`)
- Page router → Station listing: routes home (evidence: `frontend/src/App.js`)
- Page router → About page: routes about (evidence: `frontend/src/App.js`)
- Station listing → Station API: fetches stations
- Station listing → Live station view: renders stations (evidence: `frontend/src/components/home.js`)
- Station listing → Introduction: renders introduction (evidence: `frontend/src/components/home.js`)
- Live station view → Station API: requests history
- Live station view → History view: renders history (evidence: `frontend/src/components/station_info.js`)
- Live station view → Google Maps: embeds location (evidence: `frontend/src/components/station_info.js`)
- Live station view → Server entry: receives live feed
