VERITAS is a state-of-the-art environmental risk assessment system which is designed to monitor, analyze, and provide actionable intelligence on indoor air quality. It leverages advanced machine learning models and a holistic synergy engine to detect complex, co-occurring environmental hazards.
This repository contains the modernized architecture of the system, migrated from a legacy Flask application to a high-performance FastAPI backend with a futuristic, responsive frontend.
- Real-time Risk Intelligence: Instant analysis of sensor data (Temperature, Humidity, CO2, PM2.5, etc.).
- Synergistic Risk Detection: Identifies critical combinations of factors (e.g., High Humidity + Poor Ventilation).
- Holistic Health Score: A dynamic 0-100 score reflecting the overall safety of the environment.
- AI Agent Insights: Provides actionable, localized advice (Hinglish support included) for remediation.
- Modern Tech Stack: Built with FastAPI, Pydantic, Tailwind CSS, and Scikit-Learn/XGBoost.
- Framework: FastAPI (Asynchronous, High Performance).
- Validation: Pydantic models ensure strict data integrity for all sensor inputs.
- ML Integration: Secure loading of
veritas_model_bundle.pklwith fallback mechanisms. - Logic:
prepare_input_features: Handles complex feature engineering (lag features, interaction terms).generate_veritas_advice: Rule-based engine for actionable recommendations.
- Modularized configuration separating business logic from application code.
- Contains
PROFESSIONAL_RISK_GUIDEandSYNERGISTIC_RISK_RULES.
- Design: Glassmorphism aesthetic with Neon accents using Tailwind CSS.
- Interactivity: Vanilla JavaScript for lightweight, fast interactions with the API.
- Visualization: SVG-based Health Score gauge and dynamic risk cards.
- Python 3.9+
- pip
-
Clone the repository:
git clone <repository-url> cd veritas-system
-
Install dependencies:
pip install -r requirements.txt
-
Verify Model File: Ensure
veritas_model_bundle.pklis present in the root directory.
Start the server using Uvicorn:
uvicorn main:app --reloadThe application will be available at:
- Dashboard:
http://localhost:8000 - API Docs:
http://localhost:8000/docs
To enable the email alert system, you must configure the following environment variables. You can create a .env file in the project root to store these secrets.
EMAIL_USER: The Gmail address used to send alert emails (e.g.,your.email@gmail.com).EMAIL_PASS: The Google App Password for theEMAIL_USERaccount. This is not your regular password. You must generate it from your Google Account security settings.
Example .env file:
EMAIL_USER="your.email@gmail.com"
EMAIL_PASS="yourgogleappassword"
Analyzes environmental data and returns a comprehensive risk assessment.
Request Body (JSON):
{
"temperature": 25.0,
"humidity": 50.0,
"co2": 800,
"pm2.5": 10.0,
"pm10": 15.0,
"tvoc": 50,
"co": 0.5,
"occupancy_count": 2,
"motion_detected": 1,
"light_intensity": 500
}Response:
primary_risks: List of detected single-source risks.synergistic_risks: List of combined hazard scenarios.holistic_assessment: Overall status text and severity level.health_score: Numeric score (0-100).veritas_advice: List of recommended actions.
- Production: Use a process manager like Gunicorn with Uvicorn workers.
gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app
- Environment: Ensure the server has read access to
veritas_model_bundle.pkl. - Security: Place behind a reverse proxy (Nginx/Apache) with SSL termination.
- Renamed project identity to VERITAS.
- Refactored
app_old.pytomain.pyandconfig.py. - Updated
index.htmlto use modern Tailwind CSS classes. - Preserved all feature engineering logic for model compatibility.