Skip to content

Latest commit

Β 

History

History
49 lines (38 loc) Β· 2.41 KB

README.md

File metadata and controls

49 lines (38 loc) Β· 2.41 KB

Production Disruption Early Warning System - Backend API

This is the backend server for the AI-Enabled Production Disruption Early Warning System. It simulates real-time manufacturing telemetry, runs an Isolation Forest model to detect anomalies on the fly, and provides a GenAI Decision Support layer for factory operators.

πŸš€ Setup & Execution

1. Install Dependencies

pip install fastapi uvicorn scikit-learn numpy pandas httpx

2. Run the Backend Server

uvicorn main:app --reload
  • Server URL: http://127.0.0.1:8000
  • Interactive API Docs: http://127.0.0.1:8000/docs

⚑ API Endpoints Reference

Core Telemetry & Status

Endpoint Method Description
/api/status GET Returns current system state ("NORMAL" / "DISRUPTED") & latest telemetry.
/api/telemetry/history GET Returns the last 20 telemetry records (chronological order for line charts).
/api/alerts GET Returns the 10 most recent disruption alerts.
/api/telemetry POST Manually pushes telemetry to evaluate against Isolation Forest.

Demo Simulation & Scenarios

Endpoint Method Description
/api/inject-failure POST Forces live simulator into generating disruption data.
/api/reset-demo POST Clears all alerts and restores simulator to normal operation.
/api/scenarios GET Returns the 5 predefined factory disruption scenarios.
/api/scenarios/{name}/activate POST Instantly loads and activates one of the 5 scenarios into the database (normal_operation, high_processing_delay, high_error_rate, low_throughput, combined_disruption).

GenAI Decision Support & Chat Assistant

Endpoint Method Description
/api/ai/decision-support GET Returns the structured 5-part AI intelligence (what_happened, possible_causes, prediction, risk_score, action_required with dynamic role filtering).
/api/ai/decision-support/scenario/{name} POST Returns 5-part decision intelligence for any specific scenario.
/api/ai/chat POST Conversational assistant endpoint for chat widgets (e.g. {"query": "What should maintenance do?"}).

πŸ”’ CORS

CORS is enabled for all origins (*), so any frontend application running on localhost:3000, localhost:5173, etc., can communicate freely with this API.