Skip to content

umaima06/PrediChain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

42 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ—๏ธ PrediChain: AI-Powered Materials Demand Forecasting for Civic Infrastructure

โš™๏ธ Project Overview

PrediChain is an AI-driven forecasting and procurement optimization system designed for civic infrastructure projects โ€” helping organizations predict future material demand with high accuracy.

By leveraging machine learning, PrediChain enables smart supply chain planning, timely procurement, and optimized inventory levels for key construction materials like cement, steel, sand, and bricks.


๐Ÿš€ Problem Statement

In civic infrastructure, procurement inefficiencies often lead to:

  • Overstocking (wasted capital and storage costs)
  • Stockouts (delayed projects and cost overruns)
  • Poor visibility into upcoming demand

Traditional planning relies on manual estimates that ignore seasonality, lead times, and external factors.
PrediChain solves this by forecasting future material demand using machine learning โ€” transforming how supply chains in public infrastructure are managed.


๐ŸŽฏ Objective

To build a predictive system that:

  • Accurately forecasts monthly demand for key construction materials.
  • Incorporates project, regional, and seasonal variables.
  • Recommends optimal order quantities, safety stock, and reorder points.
  • Supports data-driven procurement and inventory decisions.

๐Ÿ—๏ธ Domain Focus

Civic Infrastructure Construction

PrediChain focuses on public infrastructure such as roads, bridges, and municipal buildings โ€” where timely material availability is crucial.
The system forecasts demand for:

  • ๐Ÿงฑ Cement
  • ๐Ÿ”ฉ Reinforcing Steel (Rebar)
  • ๐Ÿชจ Sand & Aggregates
  • ๐Ÿงฑ Bricks
  • ๐Ÿงฐ PVC Pipes, Electrical Wiring, Paint, Tiles

๐Ÿ“Š Data Sources

PrediChain utilizes (or simulates) data such as:

Data Type Example Fields
Historical usage month, material, quantity_used
Project data project_id, region, project_type, start_date, end_date
Procurement lead_time, order_date, delivery_date
External rainfall_mm, commodity_price_index, permits_issued, holiday_flag

If real datasets are unavailable, a synthetic dataset can be generated to simulate realistic construction material consumption trends.


๐Ÿง  Machine Learning Approach

1. Data Preprocessing

  • Time-based aggregation (monthly per material)
  • Handling missing values and outliers
  • Feature generation (lags, rolling averages, seasonality, project pipeline)

2. Modeling Techniques

  • Baseline Models: Moving Average, Exponential Smoothing
  • Forecasting Models: Prophet, ARIMA/SARIMA
  • Machine Learning Models: XGBoost, Random Forest for multivariate regression
  • Hybrid Ensemble: Prophet + XGBoost for accuracy and interpretability
  • Intermittent Demand: Crostonโ€™s method for rarely used materials

3. Evaluation Metrics

  • MAE (Mean Absolute Error)
  • RMSE (Root Mean Square Error)
  • sMAPE (Symmetric Mean Absolute Percentage Error)
  • Cost-based metrics (holding & stockout cost impact simulation)

๐Ÿงพ Procurement Optimization Layer

Using predicted demand, PrediChain computes key operational insights:

Formula Purpose
Safety Stock = z * ฯƒ * sqrt(LeadTime) Ensures buffer stock
Reorder Point = DemandDuringLeadTime + SafetyStock Optimal reorder trigger
EOQ = sqrt((2 * D * OrderingCost) / HoldingCost) Minimizes total cost

These formulas guide when and how much to order for each material, directly reducing waste and delays.


๐Ÿ’ป System Architecture

        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚ Historical Data (CSV)โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚ Data Preprocessing   โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
      โ”‚ ML Model (Prophet/XGB) โ”‚
      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚ Forecast Output & Procurement   โ”‚
  โ”‚ Recommendations (ROP, EOQ)      โ”‚
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚ Interactive Dashboard (UI)  โ”‚
     โ”‚ Streamlit / React + Charts  โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ˆ Key Features

โœ… Real-time demand forecasting per material
โœ… Seasonality & weather-aware predictions
โœ… Procurement decision engine (ROP, EOQ)
โœ… Cost & risk simulation (stockout vs overstock)
โœ… Explainable forecasts (feature importance via SHAP)
โœ… Visual dashboard for planning & what-if analysis


๐Ÿงฉ Tech Stack

Component Technology
Backend / ML Python (Pandas, Scikit-learn, Prophet, XGBoost)
Data Storage CSV / Firebase / SQLite
Visualization Matplotlib, Plotly, Seaborn
Dashboard / Frontend Streamlit or React.js
Deployment Replit / Render / Streamlit Cloud

๐Ÿ“‚ Project Structure

๐Ÿ“ฆ PrediChain

โ”œโ”€โ”€ ๐Ÿ“ backend

โ”‚   โ”œโ”€โ”€ ๐Ÿ“ __pycache__
        โ””โ”€โ”€ ๐Ÿ“„ app.cpython-313.pyc

โ”‚   โ”œโ”€โ”€ ๐Ÿค– ml
        โ”‚   โ”œโ”€โ”€ ๐Ÿ“ __pycache__/
        โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ __init__.py
        โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ forecast.py           # Forecasting logic (Prophet, etc.)
        โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ recommendation.py     # Material recommendation logic
        โ”‚   โ””โ”€โ”€ ๐Ÿ“„ utils.py              # Helper functions (data cleaning, validation)

โ”‚  โ”œโ”€โ”€ ๐Ÿ“ data
        โ”‚   โ”œโ”€โ”€ ๐Ÿ“ uploads               # User-uploaded datasets
        โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ generate_sample_data.py
        โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“„ realistic_project_data.csv
        โ”‚   โ”œโ”€โ”€ ๐Ÿ“ forecasts             # Generated forecast outputs
        โ”‚        โ””โ”€โ”€ ๐Ÿ“„ cement_forecast.csv

โ”‚  โ”œโ”€โ”€ โš™๏ธ app.py                    # FastAPI app entry point
โ”‚  โ”œโ”€โ”€ โš™๏ธ .env
โ”‚  โ”œโ”€โ”€ ๐Ÿ“„ requirements.txt          # Dependency list
โ”‚  โ”œโ”€โ”€ ๐Ÿ“„ generate_sample_data.py   # Script to generate sample/synthetic data
โ”‚  โ”œโ”€โ”€ ๐Ÿง  venv                      # Virtual environment
โ”‚  โ”‚   โ”œโ”€โ”€ ๐Ÿ“ Include/
โ”‚  โ”‚   โ”œโ”€โ”€ ๐Ÿ“ Lib/
โ”‚  โ”‚   โ”œโ”€โ”€ ๐Ÿ“ Scripts/
โ”‚  โ”‚   โ”œโ”€โ”€ ๐Ÿ“ share/
โ”‚  โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ .gitignore
โ”‚  โ”‚   โ””โ”€โ”€ ๐Ÿ“„ pyvenv.cfg
โ”‚  โ””โ”€โ”€ ๐Ÿ“„ .gitignore

๐Ÿ“ฆ PrediChain Frontend folder structure

โ”œโ”€โ”€ ๐Ÿ“ frontend
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ predichain-frontend
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ public
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ index.html
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ manifest.json
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“„ robots.txt
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ src
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ components
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ axiosConfig.js
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ BenefitCard.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Chatbot.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ ComparisonChart.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ FeatureCard.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Footer.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Hero.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ HistoricalVsForecastChart.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Layout.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ LiquidEther.js
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ LiquidEther.css
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ MapPreview.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Mapsection.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ MaterialForecastChart.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ MaterialTable.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ MetricCard.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Navbar.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ RecommendationPanel.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Sidebar.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ ThemeToggle.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“„ Topbar.jsx
โ”‚   โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ pages
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Auth.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ CSVUpload.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Dashbaord.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ FullMap.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ Home.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“„ ProjectManagement.jsx
โ”‚   โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ Services
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ dashboardService.js
โ”‚   โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ utils
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ api.js
โ”‚   โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ App.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ index.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ firebase.js
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“„ index.css
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ โš™๏ธ .env
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ .gitignore
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ firebaseConfig.js
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ package-lock.json
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ package.json
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ postcss.config.js
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ README.md
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ tailwind.config.js
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ postcss.config.js
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ tailwind.config.js
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ package.json
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ package-lock.json

---

## ๐Ÿ“‰ Sample Output
Month Material Forecast (Tons) Safety Stock Reorder Point Suggested Order
Nov 2025 Cement 420 40 460 480
Dec 2025 Steel 280 30 310 300

๐ŸŒ Impact

  • โฑ๏ธ Reduced procurement delays by up to 30%
  • ๐Ÿ’ฐ Lowered inventory holding cost through precise ordering
  • ๐ŸŒฑ Sustainability: minimized wastage of raw materials
  • ๐Ÿงฎ Data-driven governance: supports transparent planning in civic projects

๐Ÿงฉ Future Enhancements

  • Integration with live procurement ERP systems
  • Incorporate satellite data or real-time weather feeds
  • Apply Reinforcement Learning for adaptive ordering policies
  • Multi-tier forecasting (material โ†’ project โ†’ regional โ†’ national level)
  • Predict supply risk based on vendor reliability

๐Ÿง‘โ€๐Ÿ’ป Team PrediChain

  • Domain: Civic Infrastructure
  • Focus: Data-driven demand forecasting & inventory optimization
  • Goal: Build a sustainable and intelligent materials supply chain ecosystem.

โšก How to Run (Local)

# Clone the repository
git clone https://github.com/yourusername/PrediChain.git
cd PrediChain

#Run backend
# Install dependencies
pip install -r requirements.txt

# Run the notebook or dashboard
streamlit run app.py

#Run frontend
# Go to frontend folder
cd frontend/predichain-frontend

# Install dependencies
npm install

# Run React app
npm start

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •