iot-full Knows the Difference Between a Flood and a Blockage
A drainage-monitoring dashboard reduces a city's flood response to two numbers per sensor and one rule that a threshold alarm would miss.
- A drainage sensor reading only becomes useful once it is classified, and iot-full classifies on two numbers: water level for severity and flow rate for cause.
- Above 75 percent of pipe capacity, flow rate is the signal that matters, because it separates a surging drain from a plugged one at the same water level.
- Splitting current state (Realtime Database) from history (Firestore) is the right data model, but dual writes with no transaction leave the two stores free to disagree.
- The classification rule is production-worthy while the code around it is a six-commit prototype with committed credentials, no tests, and a frontend that stops reconnecting after a single network blip.
A Full Pipe Is Not Always a Flood
A drainage pipe at 80 percent capacity is telling you one of two completely different things. Either water is racing through it and the drain cannot keep up, or water is stuck and something is blocking it. Same water level. Opposite emergency. Different crew, different tools, different fix.
Most flood alarms look at water level alone. That works until it doesn't. A threshold alarm that fires at 75 percent capacity will scream FLOOD whether the pipe is surging or plugged, and the response team that shows up expecting to clear a drain finds a wall of still water instead. The sensor was right about the water and wrong about the problem.
const H = 2.0; // pipe height, metres
const LOW_FLOW_THRESHOLD = 2.0; // L/min
export function getAlertStatus(waterLevelCm, flowRate) {
const h = waterLevelCm / 100;
// Above the critical line, flow decides the cause.
if (h >= 0.75 * H && flowRate <= LOW_FLOW_THRESHOLD) return "BLOCKAGE";
if (h >= 0.75 * H && flowRate > LOW_FLOW_THRESHOLD) return "FLOOD";
if (h >= 0.50 * H && h < 0.75 * H) return "WARNING";
return "NORMAL";
}
The rule is small. It reads two numbers per sensor, water height and flow rate, and it lands in one of four states. The interesting part is what happens above the critical line. Once the pipe is more than three quarters full, height stops being the deciding signal. Flow takes over. High flow means the drain is overwhelmed (FLOOD). Low flow means it is blocked (BLOCKAGE).
The repository describes itself as a "Flood-Detection Dashboard" that is "designed for real-time drainage sensor networks." Read that description carefully and the ambition is modest. It is a dashboard. The cleverness lives in the classification underneath it, not in the interface on top.
What iot-full Actually Is
Set expectations before the praise. This is a full-stack prototype with one contributor, six commits, and no license. The sample data is set in Kochi, Kerala, with node names like Marine Drive, MG Road Junction, and Kaloor Stadium. There is no hardware. A set of Python scripts simulates the sensors and pushes readings into Firebase.
- One contributor, six commits, no license field
- Ten simulated nodes in the largest demo dataset
- Firebase Realtime Database for current state, Cloud Firestore for history
- Flask backend with Server-Sent Events, React frontend on Vite
- No tests, and CI that cannot run where it lives
So it is a teaching artifact and a template, not a product. That framing is not a knock. It is what makes the classification rule worth reading on its own terms, separate from the scaffolding around it.
The Rule That Separates a Flood from a Blockage
Everything runs off a single constant. The pipe is modeled as 2.0 metres tall, and a reading in centimetres is normalized against it. Three lines divide the range into four states.
| State | Water level | Flow rate | Meaning |
|---|---|---|---|
| NORMAL | below 1.0 m | any | Pipe is clear |
| WARNING | 1.0 to 1.5 m | any | Pipe is filling |
| FLOOD | at or above 1.5 m | above 2.0 L/min | Drain is overwhelmed |
| BLOCKAGE | at or above 1.5 m | at or below 2.0 L/min | Something is stuck |
The WARNING band is where the value is. A pipe between half full and three quarters full is not yet in trouble, but it is the window where a slow blockage announces itself. A system that waits for the critical line to fire has already spent the lead time it needed to react.
The diagram is the whole rule. Push the water level above the critical line with a low flow rate and you get a BLOCKAGE; raise the flow and the same height becomes a FLOOD. Two readings, four states, no ambiguity. The physical pipe sketch on the side keeps the abstraction honest, because the point is always about water in an actual drain.
Two Databases, One Pipeline
The project splits its storage across two Firebase products on purpose. The Realtime Database holds the current state of every node at a path like sensors/{node_id}, optimized for cheap, low-latency reads. Cloud Firestore holds the append-only history at sensor_history/{node_id}/records/{auto_id}, optimized for querying the past.
The split is sound. "What is it now" and "what was it an hour ago" are different questions with different access patterns, and using the right store for each avoids overloading either one. History queries filter on ISO-8601 timestamp strings, which works cleanly as long as every writer agrees on the format and timezone.
query = ref.order_by("timestamp", direction=direction)
if start: query = query.where("timestamp", ">=", start)
if end: query = query.where("timestamp", "<=", end)
query = query.limit(limit)
The fragility is in the writes. The simulators update both stores inside the same loop with no transaction. If the second write fails, the live view and the history disagree, and nothing reconciles them. For a demo this is fine. For anything with real sensors, it is the kind of gap that produces two teams looking at two different truths.
Streaming Without a Broker
The backend does not run a message broker. It polls Firebase instead. The /stream route opens a Server-Sent Events connection and, every three seconds, reads the full sensor map, serializes it, and pushes it downstream only if the string changed.
@app.route('/stream')
def stream():
def event_stream():
last_data = None
while True:
sensors = get_all_sensors()
current_json = json.dumps(sensors, sort_keys=True)
if current_json != last_data:
last_data = current_json
yield f"data: {current_json}\n\n"
time.sleep(3)
return Response(event_stream(), mimetype='text/event-stream')
Three design choices ride along with this. Each connected client gets its own poll loop, so read volume scales with the number of open dashboards. Change detection is done by comparing serialized JSON, which is simple and correct but re-reads everything on every tick. And because nothing is sent when nothing changes, there is no heartbeat, so a dead connection looks exactly like a quiet network.
The deployment config matches the design. Gunicorn runs with the gevent worker class, so each long-lived stream is a greenlet rather than a blocked thread, and the worker timeout is raised to 120 seconds to keep those connections alive. It is a coherent set of choices for a small number of viewers.
There is one frontend bug worth naming. The data hook sets src.onerror to close the EventSource. The browser would normally reconnect on its own after a transient error. Closing it permanently means a single network blip, or a backend restart during a deploy, freezes the dashboard until someone reloads the page, with no on-screen sign that the data has stopped.
A Prototype, Honestly
A project earns trust when it tells you what it is not. Here is the list.
| Gap | Where | Why it matters |
|---|---|---|
| Exceptions swallowed | get_all_sensors() returns {} | A database outage looks like an empty city |
| Committed credentials | serviceAccountKey.json in the tree | Anyone with the repo has the keys |
| Workflows misplaced | backend/.github/workflows/ | GitHub Actions will not find them there |
| No tests | The pytest step is a no-op | Nothing catches regressions |
| Dual writes, no transaction | demopush3.py and demopush4.py | Live state and history can diverge |
| Reconnect disabled | useSensorData.js onerror closes the stream | One network blip freezes the dashboard |
None of these are exotic. They are the difference between a prototype and a system you would put in front of a city. The classification rule is the good idea. The scaffolding around it is a starting point.
Where It Sits in the Field
The open-source IoT landscape is crowded, but it is crowded at different layers. Tasmota is firmware. EMQX is a broker. Node-RED is a flow editor. ThingsBoard, OpenRemote, Home Assistant, and openHAB are platforms with device management, plugin ecosystems, and years of production hardening.
| Project | Layer | Data store | Realtime transport | Domain logic | Production readiness |
|---|---|---|---|---|---|
| iot-full | Dashboard + domain logic | Firebase RTDB + Firestore | SSE | Flood vs blockage rule | Prototype |
| ThingsBoard | Device and data platform | Cassandra + Postgres | MQTT + WebSocket | Generic rule engine | Production |
| Home Assistant | Home automation | SQLite + Postgres | WebSocket | Automation rules | Production |
| Node-RED | Flow integration | Stateless | WebSocket | User-built flows | Production |
| EMQX | MQTT broker | Built-in store | MQTT | None | Production |
| OpenRemote | Asset management | Postgres | MQTT + WebSocket | WHEN-THEN rules | Production |
| openHAB | Home automation | Multiple backends | SSE + WebSocket | Rules | Production |
| iot-full (verified deployment) | None found | n/a | n/a | n/a | n/a |
iot-full does none of the platform work. It has no device management, no broker, no plugin system, and no verified deployment. What it has is a domain-specific classification layer that the general platforms leave to you to build. That is a design decision, not a deficiency. It also means the interesting comparison is not feature count. It is whether the classification rule is worth copying, and it is.





