Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Pune EstateLens β€” AI-Powered Property Price Predictor

🌐 Live Demo: ai-powered-property-price-predictor.vercel.app β†—
βš™οΈ API: estatelens-backend.onrender.com/docs β†—


πŸ“‹ What is Pune EstateLens?

Pune EstateLens is a production-grade, full-stack AI web application that delivers real-time residential property price predictions across Pune's two fastest-growing real estate corridors. The system combines an XGBoost machine learning model with a modern React frontend, a FastAPI REST backend, and MongoDB Atlas for persistent prediction analytics.

Built as a complete end-to-end ML product β€” from data generation and model training to cloud deployment with a premium UI.


🏘️ Covered Corridors

Corridor Direction Key Localities
Dehu Road β†’ Solapur Road West β†’ Southeast Dehu Road, Kiwale, Ravet, Hadapsar, Manjri, Loni Kalbhor, Uruli Kanchan
Kolhapur Road β†’ Nashik Road South β†’ North Katraj, Khed Shivapur, Bhosari, Chakan, Moshi, Alandi

These two corridors represent Pune's highest infrastructure investment zones (metro, IT parks, ring roads), making them ideal for property price modeling.


✨ Features

🏠 1. AI Valuation Engine (Valuation Page)

The core feature. Enter property specifications and receive an instant AI-generated valuation.

Inputs accepted:

  • Growth corridor (Dehu-Solapur vs Kolhapur-Nashik)
  • Locality (dynamically populated based on corridor)
  • BHK configuration (1–4 BHK)
  • Total area in sq.ft. (300–3500)
  • Number of bathrooms (1–4)
  • Floor level (0–30)
  • Amenities: Parking, Gym, Swimming Pool, Garden, Security, Clubhouse

Output delivered:

  • πŸ’° Predicted price in β‚Ή Lakhs (e.g., β‚Ή72.5L)
  • πŸ“ Price per sq.ft. (e.g., β‚Ή7,631/sqft)
  • 🎯 Confidence band (Β±8% range: e.g., β‚Ή66.7L – β‚Ή78.3L)
  • πŸ“Š Market comparison charts (BHK trends, locality benchmarks, amenity impact)

πŸ—ΊοΈ 2. Interactive Map View (Map Page)

  • Leaflet.js powered dark-mode map with CartoDB DarkMatter tiles
  • Toggle between both corridors with visual route overlays
  • Custom glowing markers for each locality
  • Click markers to see locality-level price statistics

πŸ”„ 3. Corridor Comparison (Compare Page)

  • Configure two properties independently, each with their own corridor and locality
  • Side-by-side valuation results with price, per-sqft rate, and confidence bands
  • Comparison Dashboard appears after both predictions:
    • Summary banner with price difference (β‚ΉL and %), rate comparison
    • Bar chart comparing predicted prices
    • Radar chart comparing feature profiles (BHK, area, floor, amenities)
    • Confidence band overlap visualization
    • Full factor breakdown table with impact explanations
    • "Why the price difference?" dynamic explanation section

πŸ“œ 4. Prediction History (History Page β€” MongoDB)

  • All predictions are automatically logged to MongoDB Atlas
  • Scatter chart showing Price vs. Area correlation colored by corridor
  • Side-by-side corridor comparison cards with average predicted price, count, min/max
  • Full sortable prediction table with timestamp, locality, BHK, floor, amenities, price

πŸ” 5. Model Administration (Data & Model Page)

  • Upload a new .csv dataset to retrain the XGBoost model live
  • Safe Fallback system: staging environment used before live swap β€” if training fails, previous model stays live (zero downtime)
  • Post-retraining metrics (RΒ², RMSE) displayed instantly
  • Required CSV schema documented in the UI

🎨 6. Premium Prop-Tech UI/UX

  • Immersive 100vh scrolling hero landing page
  • Professionally designed Charcoal and Amber dark mode aesthetic
  • Seamless glassmorphism interface components with interactive hover states
  • Built-in "Market Aesthetics" luxury architectural gallery

🧠 Machine Learning System (Deep Dive)

Dataset

The model is trained on a synthetic dataset of 2,000+ Pune residential property records generated using realistic pricing distributions based on Pune's actual real estate market dynamics (corridor premiums, locality tiers, amenity multipliers, floor pricing).

Field Type Description
corridor categorical dehu_solapur or kolhapur_nashik
locality categorical One of 13 localities
bhk integer Bedroom count (1–4)
sqft integer Total carpet area (300–3500)
bathrooms integer Bathroom count (1–4)
floor integer Floor level (0–30)
parking binary 0 or 1
gym binary 0 or 1
swimming_pool binary 0 or 1
garden binary 0 or 1
security binary 0 or 1
clubhouse binary 0 or 1
amenities_score integer Sum of all amenity flags (derived)
price_lakhs float Target variable

Preprocessing Pipeline

Built using scikit-learn's Pipeline + ColumnTransformer:

Raw Input (13 features)
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         ColumnTransformer            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  OneHotEncoder   β”‚  β”‚ Standard β”‚  β”‚
β”‚  β”‚ (corridor,       β”‚  β”‚ Scaler   β”‚  β”‚
β”‚  β”‚  locality)       β”‚  β”‚(numeric  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚ features)β”‚  β”‚
β”‚                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         XGBRegressor                 β”‚
β”‚  n_estimators=500, max_depth=7       β”‚
β”‚  learning_rate=0.05, subsample=0.8   β”‚
β”‚  colsample_bytree=0.8                β”‚
β”‚  reg_alpha=0.1, reg_lambda=1.0       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
    prediction (β‚Ή Lakhs)

Model Performance

Metric Train Test
RΒ² Score ~0.97 ~0.91
RMSE ~5.2L ~8.4L
MAE ~3.8L ~6.1L
5-Fold CV RΒ² 0.91 Β± 0.02 β€”

Why XGBoost?

Property Benefit
Handles mixed feature types Both categorical (locality, corridor) and numeric (sqft, floor) natively
Non-linear relationships Floor-price interactions, locality premiums, amenity stacking effects
Robust to outliers Real estate data inherently has premium outliers
Feature importance Can explain which features drive the price most
Fast inference Sub-millisecond predictions suitable for real-time API responses

Confidence Band

The system reports a Β±8% confidence interval around every prediction. This is the empirically observed MAPE (Mean Absolute Percentage Error) of the model on the test set, providing users with realistic uncertainty bounds rather than false precision.


πŸ› οΈ Tech Stack

Layer Technology Version Purpose
Frontend Framework React 19 Component-based SPA
Build Tool Vite 8 Dev server + production bundler
Styling Tailwind CSS 3 Utility-first design system
Charts Recharts 3 Interactive data visualization
Maps React Leaflet 5 Corridor map with markers
Icons Lucide React 1.8 Consistent icon system
Routing React Router 7 SPA client-side routing
Backend FastAPI 0.115 Async REST API
ML Model XGBoost 2+ Gradient boosted regression
ML Pipeline Scikit-learn 1.8 Preprocessing + pipeline
Database MongoDB Atlas β€” Prediction log persistence
DB Driver PyMongo 4.16 MongoDB Python driver
Data Pandas + NumPy β€” Data manipulation
Deployment Render + Vercel β€” Cloud hosting

πŸ“‘ REST API Reference

Base URL (production): https://estatelens-backend.onrender.com

Method Endpoint Auth Description
GET /api/health None Server health + MongoDB status
GET /api/meta None Available corridors and localities
POST /api/predict None Get AI price prediction
POST /api/compare None Compare same property across corridors
GET /api/stats None Market statistics (avg price per locality, BHK)
GET /api/amenity-impact None Price premium per amenity type
GET /api/history None Last 50 predictions from MongoDB
GET /api/history/corridor-stats None Corridor aggregation from history
POST /api/retrain None Upload CSV to retrain model

Sample Predict Request

POST /api/predict
{
  "corridor": "dehu_solapur",
  "locality": "Hadapsar",
  "bhk": 2,
  "sqft": 950,
  "bathrooms": 2,
  "floor": 5,
  "parking": 1,
  "gym": 1,
  "swimming_pool": 0,
  "garden": 0,
  "security": 1,
  "clubhouse": 0
}

Sample Predict Response

{
  "predicted_price_lakhs": 72.5,
  "price_per_sqft": 7631.0,
  "corridor": "dehu_solapur",
  "locality": "Hadapsar",
  "confidence_band": { "low": 66.7, "high": 78.3 },
  "input_summary": {
    "bhk": 2,
    "sqft": 950,
    "bathrooms": 2,
    "floor": 5,
    "amenities_score": 3
  }
}

πŸ—‚οΈ Project Structure

AI-Powered-Property-Price-Predictor/
β”‚
β”œβ”€β”€ backend/                          # FastAPI Python backend
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”œβ”€β”€ generate_dataset.py       # Synthetic data generator
β”‚   β”‚   └── pune_properties.csv       # 2000+ row training dataset
β”‚   β”œβ”€β”€ model/
β”‚   β”‚   β”œβ”€β”€ train_model.py            # XGBoost training pipeline
β”‚   β”‚   β”œβ”€β”€ xgb_pipeline.joblib       # Serialized trained model (2.1 MB)
β”‚   β”‚   β”œβ”€β”€ model_meta.json           # Corridors & localities metadata
β”‚   β”‚   └── metrics.json              # Training & evaluation metrics
β”‚   β”œβ”€β”€ database.py                   # MongoDB connection module (graceful degradation)
β”‚   β”œβ”€β”€ main.py                       # FastAPI app with all endpoints
β”‚   β”œβ”€β”€ requirements.txt              # All Python dependencies
β”‚   └── .env                          # Local env vars (gitignored β€” never committed)
β”‚
β”œβ”€β”€ frontend/                         # React + Vite frontend
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   └── favicon.svg
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.jsx            # App header with branding
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.jsx            # Footer with GitHub CTA
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx         # Market charts component
β”‚   β”‚   β”‚   β”œβ”€β”€ PredictionForm.jsx    # Property input form
β”‚   β”‚   β”‚   └── PredictionResult.jsx  # Result display card
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ PredictPage.jsx       # Main valuation page
β”‚   β”‚   β”‚   β”œβ”€β”€ MapPage.jsx           # Interactive map with corridors
β”‚   β”‚   β”‚   β”œβ”€β”€ ComparePage.jsx       # Corridor comparison with visualizations
β”‚   β”‚   β”‚   β”œβ”€β”€ HistoryPage.jsx       # MongoDB prediction history
β”‚   β”‚   β”‚   └── AdminPage.jsx         # Model retraining dashboard
β”‚   β”‚   β”œβ”€β”€ api.js                    # Centralized API service layer
β”‚   β”‚   β”œβ”€β”€ App.jsx                   # Root with routing & navigation
β”‚   β”‚   β”œβ”€β”€ index.css                 # Design system (Tailwind + custom tokens)
β”‚   β”‚   └── main.jsx                  # Entry point
β”‚   β”œβ”€β”€ vercel.json                   # SPA routing rewrites for Vercel
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
β”‚
β”œβ”€β”€ sample_data.csv                   # CSV template for model retraining
β”œβ”€β”€ .gitignore
└── README.md

πŸš€ Local Development Setup

Prerequisites

  • Python 3.9+
  • Node.js 18+
  • MongoDB Atlas account (free M0 cluster)

1. Clone

git clone https://github.com/ranvirdeshmukh2004/AI-Powered-Property-Price-Predictor.git
cd AI-Powered-Property-Price-Predictor

2. Backend

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

# Configure MongoDB (edit this file with your Atlas URI)
# backend/.env β†’ MONGODB_URI=mongodb+srv://user:pass@cluster.mongodb.net/?appName=Cluster0

# Start API server
cd backend
python3 -m uvicorn main:app --reload --port 8000

Backend runs at: http://localhost:8000 | Swagger UI: http://localhost:8000/docs

3. Frontend

cd frontend
npm install
npm run dev

Frontend runs at: http://localhost:5173 (or next available port)


🌐 Cloud Deployment

Backend β†’ Render

Field Value
Root Directory backend
Build Command pip install -r requirements.txt
Start Command uvicorn main:app --host 0.0.0.0 --port $PORT
Environment Var MONGODB_URI = your Atlas URI

Frontend β†’ Vercel

Field Value
Root Directory frontend
Framework Vite (auto-detected)
Build Command npm run build
Output Directory dist
Environment Var VITE_API_BASE_URL = https://your-render-url.onrender.com/api

πŸ”’ Security & Design Decisions

Decision Rationale
.env is gitignored MongoDB credentials never enter version control
MongoDB write is fire-and-forget A DB failure never blocks or delays the prediction response
Safe fallback retraining Staging environment used before live swap β€” guarantees zero downtime
CORS allow_origins=["*"] Permissive for demo; should be locked to Vercel domain in production
XGBoost serialized with joblib Committed to repo so Render doesn't need to retrain on every deploy

Pune EstateLens β€” Production-Grade AI Property Intelligence
Live App β†— β€’ API Docs β†— β€’ Source Code β†—

Releases

Packages

Contributors

Languages