AI-Powered Property Valuation & Fraud Risk Scoring on a Permissioned Blockchain
ProptiChain is an MVP that integrates machine learning models for property valuation and transaction risk assessment with a permissioned blockchain system for transparent, tamper-proof property registration and ownership management.
- Overview
- Architecture
- Tech Stack
- Project Structure
- Getting Started
- API Reference
- Testing
- How It Works
- Contributing
- License
ProptiChain solves two core problems in real estate:
- Property Valuation — Uses a Random Forest regression model trained on real housing data to predict property prices with confidence intervals.
- Transaction Risk Scoring — Uses a Random Forest classifier to flag potentially risky transactions.
- Blockchain Registry — Stores property records, ownership history, and AI result hashes on a permissioned blockchain for immutability and transparency.
AI predictions are hashed (keccak256) and stored on-chain, ensuring that valuation and risk results cannot be tampered with after submission.
┌──────────────┐ ┌──────────────────┐ ┌───────────────┐ ┌─────────────────┐
│ React UI │────>│ Middleware API │────>│ AI Service │ │ Smart Contract │
│ Port 3000 │ │ (Express.js) │ │ (FastAPI) │ │ (Solidity) │
└──────────────┘ │ Port 3001 │────>│ Port 8000 │ │ Hardhat :8545 │
│ │ └───────────────┘ └─────────────────┘
│ │────────────────────────────────────▲
└──────────────────┘
- React Frontend — User-facing UI for property registration, AI valuation, and marketplace.
- Middleware API — Orchestrates AI predictions and blockchain writes in a single pipeline.
- AI Service — ML models for valuation (regression) and risk scoring (classification).
- Smart Contract — On-chain property registry with RBAC and immutable AI result hashes.
| Layer | Technology |
|---|---|
| AI / ML | Python 3.12, Pandas, NumPy, Scikit-learn, FastAPI |
| Smart Contract | Solidity 0.8.20 |
| Blockchain Dev | Hardhat, Ethers.js v6 |
| Backend API | Node.js, Express.js, Axios |
| Frontend | React 18, React Router DOM 6 |
| Testing | Hardhat + Chai (blockchain), Scikit-learn metrics (AI) |
ProptiChain/
│
├── ai_service/ # AI/ML layer
│ ├── app.py # FastAPI prediction API (port 8000)
│ ├── train_models.py # Model training script
│ ├── preprocess.py # Data preprocessing utilities
│ ├── requirements.txt # Python dependencies
│ └── .gitignore
│
├── smart-contract/ # Blockchain layer
│ ├── contracts/
│ │ └── ProptiChainRegistry.sol
│ ├── scripts/
│ │ └── deploy.js
│ ├── test/
│ │ └── registry.test.js
│ ├── hardhat.config.js
│ └── package.json
│
├── backend/ # Integration middleware (port 3001)
│ ├── server.js # Express API server
│ ├── blockchain/
│ │ └── contract.js # Ethers.js contract helper
│ ├── ai/
│ │ └── aiClient.js # Axios client for AI service
│ ├── controllers/
│ │ ├── propertyController.js
│ │ ├── aiController.js
│ │ └── userController.js
│ ├── routes/
│ │ ├── propertyRoutes.js
│ │ ├── aiRoutes.js
│ │ └── userRoutes.js
│ └── package.json
│
├── frontend/ # React UI (port 3000)
│ ├── public/
│ │ └── index.html
│ ├── src/
│ │ ├── App.js
│ │ ├── App.css
│ │ ├── api.js
│ │ ├── index.js
│ │ └── pages/
│ │ ├── RegisterProperty.js
│ │ ├── AIValuation.js
│ │ └── Marketplace.js
│ └── package.json
│
└── README.md
- Python 3.10–3.12 (for AI service)
- Node.js 18+ (for blockchain, middleware, and frontend)
- npm (comes with Node.js)
You need four terminals to run the full pipeline.
cd ai_service
.\venv\Scripts\Activate.ps1 # Windows PowerShell
pip install -r requirements.txt
python train_models.py # Train models (first time only)
uvicorn app:app --reloadcd smart-contract
npm install
npx hardhat compile
npx hardhat node # Keep this runningcd smart-contract
npx hardhat run scripts/deploy.js --network localhost
cd ../backend
npm install
node server.jscd frontend
npm install
npm startOpen http://localhost:3000 in your browser.
Before using the system, register roles via the middleware API (or use curl/Postman):
# SELLER (account 1)
curl -X POST http://localhost:3001/user/register -H "Content-Type: application/json" \
-d '{"signerIndex":0,"userAddress":"0x70997970C51812dc3A010C7d01b50e0d17dc79C8","role":"SELLER"}'
# BUYER (account 2)
curl -X POST http://localhost:3001/user/register -H "Content-Type: application/json" \
-d '{"signerIndex":0,"userAddress":"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC","role":"BUYER"}'
# AI_ORACLE (account 3)
curl -X POST http://localhost:3001/user/register -H "Content-Type: application/json" \
-d '{"signerIndex":0,"userAddress":"0x90F79bf6EB2c4f870365E785982E1f101E93b906","role":"AI_ORACLE"}'| Method | Endpoint | Description |
|---|---|---|
| POST | /predict |
Get property valuation and risk score |
| Method | Endpoint | Description |
|---|---|---|
| POST | /user/register |
Assign a role (ADMIN only) |
| GET | /user/role/:address |
Check user role |
| POST | /property/register |
Register property (SELLER) |
| POST | /property/list |
List property for sale (owner) |
| POST | /property/buy |
Purchase property (BUYER) |
| GET | /property/all |
List all properties |
| GET | /property/:id |
Get property details |
| POST | /ai/evaluate |
Full pipeline: AI → Hash → Blockchain |
Request:
{
"signerIndex": 3,
"propertyId": 1,
"propertyData": {
"bedrooms": 3,
"bathrooms": 2,
"sqft_living": 1800,
"sqft_lot": 4000,
"floors": 2,
"waterfront": 0,
"view": 1,
"condition": 3,
"sqft_above": 1500,
"sqft_basement": 300,
"age": 10,
"renovated": 1,
"location": "Seattle"
}
}Response:
{
"predicted_price": 332869.17,
"risk_score": 0.57,
"risk_label": "High Risk",
"confidence_interval": [231990, 577950],
"valuationHash": "0xabc...",
"riskHash": "0xdef...",
"blockchain_tx_valuation": "0x123...",
"blockchain_tx_risk": "0x456..."
}cd smart-contract
npx hardhat testRuns 16 automated tests covering:
- Role enforcement (ADMIN, SELLER, BUYER, AI_ORACLE)
- Property registration and validation
- AI valuation and risk hash submission
- Property listing and ownership transfer
Run python train_models.py to see:
- Valuation Model: RMSE, MAE, R² score
- Risk Model: Accuracy, Precision, Recall, F1-score, ROC-AUC
- ADMIN registers users and assigns roles (SELLER, BUYER, AI_ORACLE) via the middleware.
- SELLER registers a property on the blockchain through the React UI.
- AI_ORACLE triggers an AI evaluation — the middleware calls the AI service, receives predictions, hashes the results (keccak256), and submits both hashes to the smart contract in one request.
- SELLER lists the property for sale on the marketplace.
- BUYER purchases the property; ownership is transferred on-chain.
- All actions emit blockchain events for transparency and off-chain monitoring.
| Role | Capabilities |
|---|---|
| ADMIN | Register users, assign roles |
| SELLER | Register properties, list for sale |
| BUYER | Purchase listed properties |
| AI_ORACLE | Submit AI valuation and risk hashes |
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -m 'Add my feature') - Push to the branch (
git push origin feature/my-feature) - Open a Pull Request
This project is for research and educational purposes.
Built by kushwxha