AWS Builder Center

Breathe Clean: Building a Smarter Indoor Air Quality Management System

Most of us don’t really know what we’re breathing indoors—or what to do about it. Breathe Clean changes that by tracking your indoor air in real time and telling you exactly when to open a window or turn on a purifier. In this post, we’ll break down why indoor air quality matters, how we built the system behind it, and the logic that keeps your home fresh and safe.

Breathe Clean: Building a Smarter Indoor Air Quality Management System

Introduction

Air pollution is tough to escape, especially in cities where smog levels swing dramatically between morning and evening. But staying inside isn't always a silver bullet. Closed doors, running electronics, and poor ventilation trap pollutants indoors, quietly spiking carbon dioxide (CO2) and particulate levels throughout the day.
We built Breathe Clean to solve this dilemma. Instead of looking at indoor sensors in isolation, the system weighs indoor conditions against outdoor air to guide smarter decisions about when to seal a room and when to air it out.

The Problem: The Indoor Dilemma

Picture this: you are working from a closed room in Delhi with an air purifier humming away. It captures fine dust, but after a few hours of breathing in that closed space, indoor CO2 climbs, leaving you feeling sluggish or unfocused.
Naturally, you want to open a window for fresh air. But if outdoor pollution is peaking outside, you risk flooding your workspace with hazardous particulates.
Managing indoor air isn't just about reading a single metric. It requires balancing conflicting priorities—ventilation versus filtration—based on what is happening both inside and outside.

The Solution

Breathe Clean bridges this gap with an automated decision engine. Rather than leaving you to guess what the numbers mean, the system continuously reads environmental conditions, cross-checks them, and translates them into clear, actionable recommendations.

Technical Architecture

The backend is built with Node.js and Express, serving API endpoints for sensor feeds, device control, automation logic, and test simulations.
Here is how the core pieces fit together:
  • Sensor APIs: Ingest real-time metrics including indoor AQI, outdoor AQI, CO2, temperature, and relative humidity.
  • Decision Engine: Evaluates live readings against configurable thresholds to determine the best course of action.
  • Safety Validation: Enforces sanity checks on device commands, preventing conflicting states (e.g., trying to ventilate while running maximum filtration).
  • Device APIs: Reports current equipment statuses and coordinates state changes across connected hardware.
  • SQLite Database: Handles local persistent storage, with a strong focus on crash recovery and maintaining consistent state across server restarts.

How the Decision Engine Works

The logic relies on practical, rule-based environmental thresholds:

  • High outdoor AQI: The system advises keeping windows shut and ramping up the air purifier.
  • Elevated indoor CO2 with clean outdoor air: It prompts you to open windows or turn on exhaust fans to circulate fresh oxygen.
  • Optimal readings across both: The system settles into an energy-efficient normal mode.Evaluating indoor and outdoor data side-by-side ensures you never ventilate a room when outdoor pollution does more harm than good.

Development and Testing

My focus was centered on the backend architecture: building out Express routes, coding the decision and safety validation engines, and putting automated test suites in place.
A major technical challenge was handling edge cases around state persistence. Using a simulated environment, I spent considerable time debugging race conditions between fast-changing sensor inputs, device state updates, and database recoveries on server reboots. Simulating varying weather and room conditions helped catch bugs early and harden overall system reliability.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article