FLASK_APP / docs /QUICKSTART.md
pranit144's picture
Upload 97 files
e38de99 verified
# Three-Phase DCRM Flask API - Quick Start Guide
## πŸš€ Quick Start (3 Steps)
### Step 1: Start the Flask API
```bash
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
1. Enter Breaker ID (default: `6926e63d4614721a79b7b24e`)
2. Enter Operator Name (default: `Test Engineer`)
3. 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`
4. Click "Upload & Analyze All Phases"
5. Wait 90-180 seconds for processing
6. View results!
---
## πŸ“ Alternative: Command Line Test
```bash
# 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.json` structure
---
## πŸ“Š API Endpoints
### Three-Phase Analysis
```
POST /api/circuit-breakers/{breaker_id}/tests/upload-three-phase
```
**Request:**
- `fileR`: CSV file for Red phase
- `fileY`: CSV file for Yellow phase
- `fileB`: CSV file for Blue phase
- `operator`: (optional) Operator name
**Response:** Combined three-phase JSON
### Health Check
```
GET /api/health
```
---
## πŸ”§ Configuration
### Change Port
Edit `dcrm_flask_api.py` line ~400:
```python
app.run(host="0.0.0.0", port=5000, debug=True)
```
### Change API URL in Frontend
Edit `test_three_phase_frontend.html` line ~300:
```javascript
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!