All projects
2025, Web, AI / ML

Risk AI

Industrial IoT safety monitor that predicts gas leaks

README.md updated Dec 24, 2025 view on GitHub

Risk AI is a real-time IoT and AI-powered dashboard designed to predict industrial hazards before they happen. It monitors environmental conditions (Temperature, Humidity, CO2, Acetone) and uses a predictive algorithm to detect gas leaks and critical trends in real-time.

(Replace this link later with a screenshot of your actual dashboard)


๐Ÿš€ Features

  • Real-time Monitoring: Live updates every 2 seconds from ESP32 sensors.
  • AI Risk Prediction: Algorithms analyze the rate of change (slope) to predict leaks before hazardous levels are reached.
  • Critical Alerts: "Zooming" Red Alert overlay when danger is detected.
  • Historical Analytics: Aggregates data by "Hour of Day" to show long-term safety trends (e.g., "Is 2 PM always dangerous?").
  • Dark Mode Dashboard: Professional React-based UI with Recharts visualization.

๐Ÿ› ๏ธ Hardware Requirements

Microcontroller: ESP32 (NodeMCU / Wemos)

Sensors:

  • DHT11 (Temperature & Humidity)
  • MQ-135 (Air Quality / Gas)

Actuators:

  • Relay
  • WaterPump
  • Buzzer
  • Servo motor

Wiring:

  • DHT11 Data โ†’ Pin D4
  • DHT11 VCC โ†’ Pin 3V3
  • MQ-135 Analog โ†’ Pin D34
  • Servo โ†’ Pin D27
  • waterpump โ†’ red โ†’ NC , Black โ†’ VCC powersupply
  • Relay "in" โ†’ Pin D26 , GND โ†’ GND ESP , VR โ†’ 5V ESP , COM โ†’ common groung , NC โ†’ Pump
  • Buzzer โ†’ Pin D18 , small leg โ†’ ground

๐Ÿ’ป Installation & Usage

You can run this project in two ways: Docker (Recommended) or Manual Setup.


Option 1: Docker (Fastest for Windows & Linux)

This method requires no installation of Python or Node.js. It runs the entire system in an isolated container.

1. Install Docker

  • Windows: Install Docker Desktop.
  • Linux:
    sudo apt install docker.io docker-compose-v2

2. Clone the Repository

git clone git@github.com:mohammedmokhtar2/RiskAI-IoT-System.git
cd RiskAI-IoT-System

3. Run the App

docker compose up --build

4. Access


Option 2: Manual Setup (For Development)

If you want to edit the code, run it manually.

Prerequisites

  • Python 3.9+
  • Node.js 20+

1. Setup Backend (Python)

# Open a terminal in the root folder
python3 -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate
pip install -r requirements.txt
python app.py

2. Setup Frontend (React)

# Open a NEW terminal
cd frontend
npm install
npm run dev

๐Ÿ“ก Connecting the Hardware

  1. Power on the ESP32.
  2. It will create a WiFi Hotspot named RiskAI_Hotspot.
  3. Connect your laptop WiFi to this hotspot.
    • Password: 12345678
  4. Once connected, the Python Backend will automatically start fetching live sensor data.

If testing without hardware, open app.py and set MOCK_MODE = True to simulate sensor data.


๐Ÿ“‚ Project Structure

RiskAI/
โ”œโ”€โ”€ app.py                 # Flask Backend (API & Database Logic)
โ”œโ”€โ”€ risk_ai.db             # SQLite Database (Auto-created)
โ”œโ”€โ”€ requirements.txt       # Python Dependencies
โ”œโ”€โ”€ docker-compose.yml     # Docker Orchestration
โ”œโ”€โ”€ frontend/              # React Frontend
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx        # Main Dashboard Logic & Charts
โ”‚   โ”‚   โ””โ”€โ”€ App.css        # Dark Mode Styling
โ”‚   โ””โ”€โ”€ Dockerfile         # Frontend Container Config
โ””โ”€โ”€ README.md              # Documentation

๐Ÿ‘ฅ Developers

  • Hardware Engineer:ย Hossam Mostafa
  • Software Engineer: Mohammed Mokhtar , Eyad Rezk , Tarek shereen , Amr Khaled

Built with React, Flask, Recharts, and ESP32.