A Flask-based web application for monitoring and analyzing chemical purity metrics with interactive visualization and statistical quality control analysis.
This application monitors ethanol purity batches in real-time, calculating rolling averages and control limits using 3-Sigma statistical methods. It provides an interactive web dashboard to visualize production data against quality thresholds.
- Real-time Monitoring: Tracks daily batch purity percentages
- Statistical Analysis: Calculates rolling averages and 3-Sigma lower control limits
- Interactive Dashboard: Visual chart representation of quality metrics
- Quality Status Alerts: Flags batches that fall below control limits as "SYSTEM FAILURE"
- Database Integration: Connects to MySQL for persistent data storage
quality_control_analysis/
├── app.py # Main Flask application
├── .env # Environment variables (not in repo)
├── .gitignore # Git ignore rules
└── README.md # This file
- Python 3.8+
- Flask
- MySQL Connector
- Python-dotenv
-
Clone or navigate to the project directory
cd quality_control_analysis -
Create a virtual environment (recommended)
python -m venv .venv
-
Activate the virtual environment
- Windows:
.venv\Scripts\activate
- macOS/Linux:
source .venv/bin/activate
- Windows:
-
Install dependencies
pip install -r requirements.txt
Or manually install:
pip install flask mysql-connector-python python-dotenv
Create a .env file in the project root with the following variables:
DB_HOST=your_mysql_host
DB_USER=your_mysql_user
DB_PASSWORD=your_mysql_password
DB_NAME=your_database_nameEnsure your MySQL database contains a chemical_purity table with columns:
batch_id(INT)purity_percentage(FLOAT)production_date(DATE)
-
Start the Flask development server
python app.py
-
Access the dashboard
- Open your browser and navigate to:
http://localhost:5000/
- Open your browser and navigate to:
The dashboard will display:
- Blue line: Actual batch purity percentages
- Red dashed line: 3-Sigma lower control limit
The application:
- Connects to MySQL and retrieves chemical purity data
- Calculates a 7-period rolling average
- Computes the standard deviation and 3-Sigma lower control limit
- Marks batches as "STABLE" or "SYSTEM FAILURE" based on control limits
- Visualizes the data using Chart.js
GET /- Returns the interactive quality control dashboard
- Backend: Flask (Python web framework)
- Database: MySQL
- Frontend: HTML5, Chart.js
- Styling: CSS3
This project is for internal quality control monitoring.
Quality Control Analytics Team
For issues or questions, please contact your system administrator.