# fmustapha78-svg/water-backend-oran architecture

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

- Interactive diagram: https://gitdiagram.com/fmustapha78-svg/water-backend-oran
- Repository: https://github.com/fmustapha78-svg/water-backend-oran

## Overview

This small Node.js service monitors water pressure from an MQTT device, serves status over HTTP, stores periodic pressure history, and sends Firebase topic notifications for water outages and recovery. The main runtime flow is MQTT messages into in-memory sensor state, with threshold alerts and rate-limited Supabase logging; HTTP clients read status or trigger a notification test. The excerpt does not show every route or the full notification configuration, so the graph includes only evidenced relationships.

Main entry points: [`index.js`](https://github.com/fmustapha78-svg/water-backend-oran/blob/main/index.js) (Backend service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Device ingestion"]
  node_service["Backend service<br/>[index.js]"]
  node_state["Live water state<br/>[index.js]"]
end

subgraph group_http["HTTP API"]
  node_api["Status and utility routes<br/>[index.js]"]
end

subgraph group_integrations["External services"]
  node_history[("Pressure history<br/>[index.js]")]
  node_broker["MQTT broker"]
  node_supabase[("Supabase")]
  node_firebase["Firebase Messaging"]
end

node_sensor(("Water sensor"))
node_clients(("HTTP clients"))
node_subscribers(("Alert subscribers"))

node_sensor -->|"publishes telemetry"| node_broker
node_service -->|"subscribes to topics"| node_broker
node_broker -->|"delivers messages"| node_service
node_service -->|"updates readings"| node_state
node_service -->|"inserts logs"| node_history
node_service -->|"sends alerts"| node_firebase
node_clients -->|"requests routes"| node_api
node_api -->|"reads status"| node_state
node_api -->|"triggers test alert"| node_firebase
node_firebase -->|"delivers topic alert"| node_subscribers

click node_service "https://github.com/fmustapha78-svg/water-backend-oran/blob/main/index.js"
click node_state "https://github.com/fmustapha78-svg/water-backend-oran/blob/main/index.js"
click node_history "https://github.com/fmustapha78-svg/water-backend-oran/blob/main/index.js"
click node_api "https://github.com/fmustapha78-svg/water-backend-oran/blob/main/index.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_service,node_state,node_clients toneBlue
class node_api toneAmber
class node_history,node_broker,node_supabase,node_firebase toneMint
class node_sensor,node_subscribers toneIndigo
```

## Components

### Device ingestion

- [Backend service](https://github.com/fmustapha78-svg/water-backend-oran/blob/main/index.js): `index.js`
- [Live water state](https://github.com/fmustapha78-svg/water-backend-oran/blob/main/index.js): `index.js`

### HTTP API

- [Status and utility routes](https://github.com/fmustapha78-svg/water-backend-oran/blob/main/index.js): `index.js`

### External services

- [Pressure history](https://github.com/fmustapha78-svg/water-backend-oran/blob/main/index.js): `index.js`
- **MQTT broker**
- **Supabase**
- **Firebase Messaging**

### Other components

- **Water sensor**
- **HTTP clients**
- **Alert subscribers**

## Connections

- Water sensor → MQTT broker: publishes telemetry
- Backend service → MQTT broker: subscribes to topics (evidence: `index.js`)
- MQTT broker → Backend service: delivers messages (evidence: `index.js`)
- Backend service → Live water state: updates readings (evidence: `index.js`)
- Backend service → Pressure history: inserts logs (evidence: `index.js`)
- Backend service → Firebase Messaging: sends alerts (evidence: `index.js`)
- HTTP clients → Status and utility routes: requests routes (evidence: `index.js`)
- Status and utility routes → Live water state: reads status (evidence: `index.js`)
- Status and utility routes → Firebase Messaging: triggers test alert (evidence: `index.js`)
- Firebase Messaging → Alert subscribers: delivers topic alert
