How parthita/powergrid_ml_sih works
Project Type and Purpose
• This is a full-stack web application.
• Purpose: Provide predictive insights (cost & timeline overruns) for power grid construction projects via an interactive dashboard.
File Structure
• Top-level folders:
• backend/ (FastAPI service, ML pipeline, model artifacts)
• frontend/ (React SPA)
• test_csvs/ (sample input CSVs)
• backend contains:
• api.py (FastAPI routes)
• schema.py (Pydantic request/response models)
• feature_engineering.py (data transformation pipeline)
• train_overrun.py & predict.py (model training & inference logic)
• best_models.pkl (serialized XGBoost models)
• requirements.txt & Procfile (deployment config)
• frontend contains:
• src/index.html, main.jsx, App.jsx (entrypoint & React components)
• vite.config.js, package.json (build tooling)
• No dedicated database—state is stateless, input is provided at request time, model lives in file system.
README for Additional Insights
• Architecture: two-tier decoupled design (Frontend SPA + Backend API).
• ML stack: Pandas, Scikit-learn, XGBoost, Joblib.
• Deployment: Railway (backend) & Vercel (frontend).
• Data flow: user uploads CSV → backend feature-engineering → XGBoost inference → JSON response → frontend visualization.
Main Components
a. Frontend SPA
• React App (App.jsx)
• Visualization library (Recharts)
• Deployed on Vercel
b. Backend API
• FastAPI service (api.py)
• Pydantic schemas (schema.py)
• Feature engineering module (feature_engineering.py)
• Model inference module (predict.py)
• Trained model artifacts (best_models.pkl)
• Deployed on Railway
c. External Services
• Vercel hosting (frontend)
• Railway hosting (backend)
d. Data Input
• CSV file (user-provided or test_csvs)
• HTTP POST request payload
e. Output
• JSON payload with CostOverrunPct & TimelineOverrunPct
• Dashboard charts/graphs
Relationships & Data Flow
1. User browser loads React SPA from Vercel
2. User selects or uploads a CSV of project data
3. SPA sends HTTP POST /predict (or similar) to FastAPI endpoint on Railway
4. FastAPI endpoint:
• Validates payload via Pydantic models
• Invokes feature_engineering pipeline
• Loads XGBoost models (best_models.pkl)
• Runs predictions
• Returns JSON with predictions
5. SPA receives JSON and renders interactive charts
Architectural Patterns & Principles
• Separation of concerns: UI logic vs. ML & API logic
• Stateless services: no database or session state
• Modular ML pipeline: clear separation between feature engineering, training, and inference
• Single responsibility: each module (schema, feature_engineering, predict) has a clear role
Diagramming Conventions
• Blue for frontend components
• Green for backend/API components
• Yellow for ML pipeline parts
• Gray for external services
• Endpoints (e.g., POST /predict) and data formats (CSV, JSON)
Essential Elements to Capture
• Client browser (User)
• React SPA (Static host on Vercel)
• FastAPI service (Deployed on Railway)
• Feature engineering & ML model modules
• Model artifact file (best_models.pkl)