Three-Phase DCRM Flask API - Quick Start Guide
π Quick Start (3 Steps)
Step 1: Start the Flask API
python dcrm_flask_api.py
Expected output:
* Running on http://0.0.0.0:5000
* Restarting with stat
* Debugger is active!
Step 2: Open the Test Frontend
Double-click: test_three_phase_frontend.html
OR open in browser: file:///c:/codes/dcrm/pranit/csv_kpi/combined/test_three_phase_frontend.html
Step 3: Upload and Test
- Enter Breaker ID (default:
6926e63d4614721a79b7b24e) - Enter Operator Name (default:
Test Engineer) - Upload 3 CSV files:
- π΄ Red Phase (R):
df3_final (1).csv - π‘ Yellow Phase (Y):
df3_final (1).csv - π΅ Blue Phase (B):
df3_final (1).csv
- π΄ Red Phase (R):
- Click "Upload & Analyze All Phases"
- Wait 90-180 seconds for processing
- View results!
π Alternative: Command Line Test
# Terminal 1: Start API
python dcrm_flask_api.py
# Terminal 2: Run automated test
python test_three_phase_flask.py
π― What You'll See
Overall Results:
- Overall Health Score (average of 3 phases)
- Breaker ID
- Operator Name
- Creation Timestamp
Per-Phase Results:
- Red Phase (R): Health Score, CBHI, Findings
- Yellow Phase (Y): Health Score, CBHI, Findings
- Blue Phase (B): Health Score, CBHI, Findings
Complete JSON:
- Full three-phase analysis
- Enhanced waveform with coil currents
- AI recommendations with performanceGains & riskMitigation
- All fields matching
sample.jsonstructure
π API Endpoints
Three-Phase Analysis
POST /api/circuit-breakers/{breaker_id}/tests/upload-three-phase
Request:
fileR: CSV file for Red phasefileY: CSV file for Yellow phasefileB: CSV file for Blue phaseoperator: (optional) Operator name
Response: Combined three-phase JSON
Health Check
GET /api/health
π§ Configuration
Change Port
Edit dcrm_flask_api.py line ~400:
app.run(host="0.0.0.0", port=5000, debug=True)
Change API URL in Frontend
Edit test_three_phase_frontend.html line ~300:
const API_URL = 'http://localhost:5000';
β Features Implemented
β Flask-based API (instead of FastAPI) β Three-phase processing (fileR, fileY, fileB) β Enhanced waveform (includes close_coil, trip_coil_1, trip_coil_2) β Updated AI recommendations (performanceGains, riskMitigation) β Combined JSON structure matching sample.json β Beautiful HTML frontend with 3-file upload β Automated test script β Complete documentation
π You're All Set!
Everything is ready to use. Just start the API and open the HTML frontend!