"Ravi kept his business running. The investor made 8.7% in 60 days. We made a fee. Nobody needed a bank."
Nuvest is two products on one platform:
- An AI-powered portfolio manager for Indian retail investors — tax-aware, Zerodha-connected, and powered by a natural language copilot that actually understands Indian tax law.
- A blockchain-based invoice financing marketplace for SMEs — turning unpaid invoices into instant working capital, settled on-chain without a bank in the loop.
- What It Does
- Architecture
- Tech Stack
- Repo Structure
- Local Setup
- MetaMask Configuration
- Demo Walkthrough
- API Reference
- Smart Contract Notes
- Yield Numbers
Indian retail investors connect their Zerodha demat account via Kite Connect and get:
- Live holdings across NSE/BSE with real-time price updates
- LTCG/STCG tax breakdown for the current financial year
- 80C optimisation alerts — ELSS, PPF, and NPS gaps flagged before March 31
- An AI copilot (Groq
llama3-70b) that answers natural language queries with full Indian tax context - FY-end rebalancing alerts when equity is overweight or 80C is underfilled
SMEs unlock working capital from unpaid invoices without waiting 30–90 days for buyers to pay:
- SME uploads invoice → AI scores it (XGBoost + SHAP explanation)
- An ERC-721 token is minted on-chain representing the invoice
- An investor funds the advance directly via smart contract — SME gets cash instantly
- Buyer pays at the due date → escrow automatically releases the payout to the investor
- Platform earns a 1% fee per invoice; neither side needs a bank
┌──────────────────────────────────────────────────────────────────┐
│ Frontend (React + Vite) │
│ ┌──────────────────┐ ┌──────────────────┐ ┌───────────────┐ │
│ │PortfolioDashboard│ │ SMEDashboard │ │ Investor │ │
│ │Live holdings │ │ Upload invoice │ │ Marketplace │ │
│ │AI copilot chat │ │ Score + mint │ │ Fund + settle│ │
│ └────────┬─────────┘ └────────┬─────────┘ └──────┬────────┘ │
└───────────┼─────────────────────┼───────────────────┼───────────┘
│ REST │ REST │ ethers.js
▼ ▼ ▼
┌──────────────────────┐ ┌───────────────────────────────────┐
│ FastAPI Backend │ │ Smart Contracts (Solidity 0.8) │
│ /portfolio/summary │ │ InvoiceToken.sol (ERC-721) │
│ /portfolio/chat │ │ InvoiceEscrow.sol (escrow logic) │
│ /invoice/score │ │ Hardhat local / Polygon Amoy │
│ /kite/* │ └───────────────────────────────────┘
└──────────────────────┘
│ │
▼ ▼
Kite Connect Groq API
(live holdings) (llama3-70b)
| Layer | Technology |
|---|---|
| Smart contracts | Solidity 0.8.24, Hardhat, ethers.js v6 |
| Chain | Hardhat local (dev) / Polygon Amoy testnet |
| AI scoring | Python, XGBoost, SHAP, FastAPI |
| AI chat | Groq API — llama3-70b-8192, India tax system prompt |
| Portfolio data | Zerodha Kite Connect (live) with 60s TTL cache + mock fallback |
| Frontend | React 18, Vite, Recharts |
| Wallet | MetaMask, ethers.js BrowserProvider |
nuvest/
├── contracts/
│ ├── InvoiceToken.sol # ERC-721: one token per invoice
│ └── InvoiceEscrow.sol # Escrow + settlement + 1% fee
├── scripts/
│ └── deploy.js # Hardhat deploy → writes ABIs to frontend
├── backend/
│ ├── app.py # FastAPI routes
│ ├── model.py # XGBoost scoring model
│ ├── scorer.py # Feature engineering
│ ├── portfolio.py # Kite Connect wrapper + caching
│ ├── ai_chat.py # Groq chat handler
│ └── requirements.txt
├── frontend/
│ └── src/
│ ├── pages/
│ │ ├── PortfolioDashboard.jsx
│ │ ├── SMEDashboard.jsx
│ │ └── InvestorMarketplace.jsx
│ └── utils/
│ ├── contract.js # ethers.js contract calls
│ ├── api.js # Backend API calls
│ └── abis/ # Auto-generated by deploy.js
├── deployments/
│ └── localhost.json
└── hardhat.config.js
- Node.js ≥ 18
- Python ≥ 3.10
- MetaMask browser extension
git clone https://github.com/vig-05/Tokenized-Invoice-Financing-Platform
cd Tokenized-Invoice-Financing-Platform
# Hardhat + contract tooling
npm install
# Backend
cd backend && pip install -r requirements.txt && cd ..
# Frontend
cd frontend && npm install && cd ..Create a .env file in the project root:
# Groq — free tier at console.groq.com
GROQ_API_KEY=your_groq_key
# Zerodha Kite Connect (optional — mock data works without it)
KITE_API_KEY=
KITE_API_SECRET=
KITE_ACCESS_TOKEN=
# Filled automatically by deploy.js
VITE_TOKEN_CONTRACT_ADDRESS=
VITE_ESCROW_CONTRACT_ADDRESS=
# Backend
VITE_API_BASE=http://localhost:8000# Terminal 1
npx hardhat nodeStarts a JSON-RPC server at http://127.0.0.1:8545 with 20 accounts pre-funded with 10,000 ETH each.
# Terminal 2
npx hardhat run scripts/deploy.js --network localhostCompiles, deploys to localhost, and writes ABIs into frontend/src/utils/abis/ automatically.
cd backend
python -m uvicorn app:app --reload --port 8000cd frontend
npm run devOpen http://localhost:5173.
Add the local network (the app will prompt you automatically on first connect, or add it manually):
| Field | Value |
|---|---|
| Network Name | Hardhat Local |
| RPC URL | http://127.0.0.1:8545 |
| Chain ID | 31337 |
| Currency Symbol | ETH |
Import test accounts — these are Hardhat's deterministic keys. Never use them on mainnet.
| Role | Address | Private Key |
|---|---|---|
| Deployer / SME | 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 |
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 |
| Investor | 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 |
0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d |
| Buyer (optional) | 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC |
0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a |
0:00 – 0:30 — Portfolio
- Open
/portfolio→ holdings load from mock data (or live via Kite Connect) - Ask the copilot: "How much ELSS can I still add for 80C?"
- AI responds with an India-specific tax answer
- FY-end rebalancing alert is shown
0:30 – 1:30 — SME side (Ravi's wallet — Account #0)
- Open
/sme→ connect MetaMask (auto-switches to Hardhat Local) - Enter: Buyer = "Reliance Retail", Amount = ₹10,00,000, Due = 60 days
- Click Score Invoice → score: 91/100, SHAP: "Reliance tier-3 buyer (+45 pts)"
- Click List Invoice → MetaMask signs → token minted on-chain
1:30 – 2:30 — Investor funds (switch to Account #1)
- Open
/invest→ invoice appears in the marketplace - Click Fund Invoice → MetaMask confirms
- SME wallet receives ₹9,20,000 advance instantly
2:30 – 3:00 — Settlement
- Click Simulate Buyer Payment
- Smart contract releases ₹9,90,000 to the investor (face value minus 1% fee)
3:00 – 3:30 — Close
"Ravi kept his business running. The investor made 8.7% in 60 days. We made a fee. Nobody needed a bank."
| Method | Route | Description |
|---|---|---|
GET |
/health |
Liveness check |
POST |
/invoice/score |
Score invoice — XGBoost + SHAP |
GET |
/portfolio/summary |
Holdings summary, allocation, tax figures |
GET |
/portfolio/holdings |
Raw enriched holdings list |
POST |
/portfolio/chat |
AI copilot (Groq llama3-70b) |
POST |
/invoice/settlement |
Post-settlement AI redeployment advice |
GET |
/kite/login-url |
Zerodha Kite OAuth redirect URL |
GET |
/kite/callback |
Exchange request_token for access_token |
Score invoice — request
{
"buyer": "Reliance Retail Ltd",
"sme_name": "Sri Lakshmi Textiles",
"invoice_amount": 1000000,
"due_days": 60,
"sme_history_count": 6,
"sme_default_rate": 0.0
}Score invoice — response
{
"score": 91,
"verdict": "LOW_RISK",
"advance_rate": 0.92,
"advance_amount": 920000,
"shap_values": {
"buyer_tier": 25,
"sme_history": 18,
"due_days": -8,
"amount_ratio": -4
}
}InvoiceToken (ERC-721) stores invoice metadata on-chain:
struct Invoice {
uint256 invoiceAmount;
uint256 advanceAmount;
uint256 dueDate;
address smeWallet;
address investorWallet;
bytes32 invoiceHash;
uint8 riskScore;
InvoiceStatus status; // LISTED → FUNDED → SETTLED | DEFAULTED
}InvoiceEscrow key functions:
| Function | Caller | Description |
|---|---|---|
listInvoice(...) |
SME | Mints token; rejects if paymentDest != address(this) |
fundInvoice(id) |
Investor | Sends advance to SME instantly |
simulateBuyerPayment(id) |
Anyone post-due | Settles invoice; pays investor minus 1% fee |
markDefault(id) |
Owner | Marks an overdue invoice as defaulted |
withdrawFee() |
Owner | Collects accumulated platform fees |
Production path for
simulateBuyerPayment: Replace with a Chainlink Automation job that monitors an off-chain payment webhook and co-signs on-chain settlement after bank transfer confirmation.
| Metric | Value |
|---|---|
| Sample invoice return | 8.7% over 60 days |
| Annualised platform range | 12–18% (blended across 30–90 day tenors) |
The 12–18% is a blended annualised yield across all invoices over a year. A single invoice returns more when annualised, but capital isn't deployed every day.
Nuvest gives India's 80 million retail investors an AI copilot that actually understands Indian taxes — and turns 63 million SMEs' unpaid invoices into a new yield asset class, settled on-chain without banks.