- Project Overview
- Tech Stack
- Project Structure
- Prerequisites
- Environment Variables
- Installation
- Running the Services
- API Reference
- Frontend Pages & Components
- ML Verification Module
- Blockchain Module
- Useful Dev Commands
- License
CarbonCred is a full-stack platform for the Indian Carbon Credit Trading Scheme (CCTS). It lets green projects submit and earn verified carbon credits, organizations buy credits for compliance, and auditors verify projects using an AI-powered pipeline β all backed by Ethereum smart contracts.
| Layer | Technology |
|---|---|
| Backend | Django 4.2, Django REST Framework, SimpleJWT |
| Database | PostgreSQL 16 |
| Frontend | React 19, Vite 7, Tailwind CSS 4, Bootstrap 5 |
| Blockchain | Ethereum (Sepolia Testnet), Hardhat, web3.py |
| ML / AI | TensorFlow 2.13, UNet (vegetation), ResNet50 (solar) |
| API Docs | Swagger UI / ReDoc (drf-yasg) |
| Containerisation | Docker, Docker Compose |
carboncred/
βββ accounts/ # User auth, registration, JWT, profiles
βββ analytics/ # Platform-wide & user analytics APIs
βββ backend/ # Django project settings, URLs, WSGI/ASGI
β βββ settings.py
β βββ urls.py
β βββ wsgi.py
βββ blockchain/ # Ethereum smart contracts & deploy scripts
β βββ contracts/
β β βββ CarbonCredToken.sol
β β βββ IndianCarbonCredit.sol
β βββ scripts/
β βββ hardhat.config.js
βββ credits/ # Credit wallet, issuance, balance tracking
βββ marketplace/ # Buy/sell listings and credit trading
βββ ml-verification/ # AI verification pipeline
β βββ src/
β β βββ models/ # UNet + ResNet50 model definitions
β β βββ train.py
β β βββ verify.py
β βββ requirements.txt
βββ projects/ # Project submission and management
βββ transactions/ # Transaction history records
βββ frontend/ # React + Vite application
β βββ src/
β β βββ components/ # All UI pages and components
β β βββ hooks/
β β βββ App.jsx
β βββ package.json
βββ media/ # Uploaded project images
βββ docker-compose.yml
βββ manage.py
βββ requirements.txt
βββ .env.example
| Tool | Version |
|---|---|
| Python | 3.9+ |
| Node.js | 16.x+ |
| npm | 8.x+ |
| PostgreSQL | 13+ (or use Docker) |
| Docker & Docker Compose | Latest v2+ (optional, for full stack) |
| MetaMask | Browser extension (for blockchain features) |
Copy .env.example to .env and fill in your values:
cp .env.example .env| Variable | Description | Example |
|---|---|---|
POSTGRES_USER |
PostgreSQL username | postgres |
POSTGRES_PASSWORD |
PostgreSQL password | yourpassword |
POSTGRES_DB |
Database name | carboncred |
POSTGRES_HOST |
DB host | 127.0.0.1 |
POSTGRES_PORT |
DB port | 5432 |
SECRET_KEY |
Django secret key | your-secret-key |
DEBUG |
Debug mode | True |
ALLOWED_HOSTS |
Comma-separated hosts | localhost,127.0.0.1 |
ALCHEMY_URL |
Alchemy RPC endpoint (Sepolia) | https://eth-sepolia.g.alchemy.com/v2/KEY |
BLOCKCHAIN_PRIVATE_KEY |
Deployer wallet private key | 0x... |
CONTRACT_ADDRESS |
Deployed contract address | 0x... |
BLOCKCHAIN_CHAIN_ID |
Sepolia chain ID | 11155111 |
REACT_APP_API_URL |
Backend base URL for frontend | http://127.0.0.1:8000 |
REACT_APP_CONTRACT_ADDRESS |
Contract address for frontend | 0x... |
β οΈ Never commit real private keys or secrets. Keep.envin.gitignore.
git clone https://github.com/Prathameshjain/carboncred.git
cd carboncred# Create & activate virtual environment
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install Python dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env with your database credentials and keys
# Apply database migrations
python manage.py migrate
# (Optional) Create a Django admin superuser
python manage.py createsuperusercd frontend
# Install Node dependencies
npm installcd ml-verification
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtcd blockchain
npm install
# Compile contracts
npx hardhat compile
# Deploy to Sepolia (ensure ALCHEMY_URL and BLOCKCHAIN_PRIVATE_KEY are set in .env)
npx hardhat run scripts/deploy.js --network sepoliaThe docker-compose.yml spins up 5 services in a single command:
| Service | Container | Port |
|---|---|---|
| PostgreSQL 16 | carboncred-postgres |
internal |
| pgAdmin 4 | carboncred-pgadmin |
5050 |
| ML Verification (TensorFlow/Flask) | carboncred-ml |
internal 5001 |
| Django Backend (Gunicorn) | carboncred-backend |
8000 |
| React Frontend (Nginx) | carboncred-frontend |
80 |
cp .env.docker .env
# Optionally edit .env with your real blockchain keys
β οΈ .env.dockercontains pre-configured defaults for Docker networking (e.g.,POSTGRES_HOST=db). Do not use.env.examplefor Docker β the host values differ.
# Build images and start all 5 services in detached mode
docker compose up --build -dβ± First build takes ~10β15 minutes β TensorFlow + ML model checkpoints (~660 MB each) are baked into the ML image. Subsequent builds are fast thanks to Docker layer caching.
| Service | URL | Credentials |
|---|---|---|
| π Frontend (React) | http://localhost | β |
| βοΈ Django API | http://localhost:8000/api/ | JWT token |
| π§ Django Admin | http://localhost/admin/ | superuser |
| π Swagger Docs | http://localhost:8000/swagger/ | β |
| π pgAdmin | http://localhost:5050 | nesar@carboncred.com / nesar |
# Create Django superuser
docker compose exec backend python manage.py createsuperuser
# Run / re-run migrations manually
docker compose exec backend python manage.py migrate
# View live logs for all services
docker compose logs -f
# View logs for a specific service
docker compose logs -f backend
docker compose logs -f ml-service
# Stop all services (keeps data volumes)
docker compose down
# Stop and delete all data volumes (fresh start)
docker compose down -v- Open http://localhost:5050 β login with
nesar@carboncred.com/nesar - Click Add New Server
- Fill in:
- Name:
CarbonCred DB - Host:
db - Port:
5432 - Database:
carboncred - Username:
postgres - Password:
Postgre123
- Name:
| Service | Command | URL |
|---|---|---|
| Backend (Django) | python manage.py runserver |
http://127.0.0.1:8000 |
| Frontend (Vite) | cd frontend && npm run dev |
http://localhost:5173 |
| Swagger Docs | (backend must be running) | http://127.0.0.1:8000/swagger/ |
| ReDoc | (backend must be running) | http://127.0.0.1:8000/redoc/ |
| Django Admin | (backend must be running) | http://127.0.0.1:8000/admin/ |
| PostgreSQL | docker compose up db -d |
localhost:5432 |
Both the backend and frontend dev servers support hot reload β changes take effect without restarting.
| Service | URL |
|---|---|
| π React Frontend (via Nginx) | http://localhost |
| βοΈ Django API | http://localhost:8000/api/ |
| π§ Django Admin | http://localhost/admin/ |
| π Swagger / ReDoc | http://localhost:8000/swagger/ |
| π pgAdmin | http://localhost:5050 |
The Nginx container reverse-proxies
/api/,/admin/, and/media/to the Django backend on port 8000.
All endpoints are prefixed with /api/. Full interactive docs available at /swagger/ when DEBUG=True.
| Endpoint | Method | Description |
|---|---|---|
/api/accounts/register/ |
POST | Register a new user |
/api/accounts/login/ |
POST | Obtain JWT access & refresh tokens |
/api/accounts/refresh/ |
POST | Refresh access token |
/api/accounts/profile/ |
GET / PATCH | Get or update user profile |
| Endpoint | Method | Description |
|---|---|---|
/api/projects/ |
GET / POST | List or submit a new project |
/api/projects/<id>/ |
GET / PATCH | Get or update project details |
/api/projects/<id>/verify/ |
POST | Trigger ML verification on a project |
| Endpoint | Method | Description |
|---|---|---|
/api/credits/wallet/ |
GET | Get current user's credit balance |
/api/credits/issue/ |
POST | Issue credits to a project (admin) |
| Endpoint | Method | Description |
|---|---|---|
/api/marketplace/listings/ |
GET / POST | View or create credit listings |
/api/marketplace/listings/<id>/buy/ |
POST | Purchase a listing |
| Endpoint | Method | Description |
|---|---|---|
/api/transactions/ |
GET | View transaction history for current user |
| Endpoint | Method | Description |
|---|---|---|
/api/analytics/platform/ |
GET | Platform-wide stats |
/api/analytics/user/ |
GET | Per-user analytics |
The frontend lives in frontend/src/components/. Key pages:
| Component | Route | Description |
|---|---|---|
Home.jsx |
/ |
Landing page |
Registration.jsx |
/register |
User sign-up |
Login.jsx |
/login |
JWT login |
Dashboard.jsx |
/dashboard |
Main user dashboard |
AddProject.jsx |
/projects/add |
Submit a new carbon project |
ViewProjects.jsx |
/projects |
Browse existing projects |
Marketplace.jsx |
/marketplace |
Buy/sell credit listings |
Mycredits.jsx |
/credits |
Credit wallet & history |
PurchaseHistory.jsx |
/history |
Transaction history |
VerificationReport.jsx |
/verification |
ML verification results |
UserAnalytics.jsx |
/analytics/user |
User-level charts |
PlatformAnalytics.jsx |
/analytics/platform |
Platform-wide charts |
Profile.jsx |
/profile |
User profile management |
cd frontend
npm run dev # Start dev server β http://localhost:5173
npm run build # Production build β dist/
npm run preview # Preview production build locally
npm run lint # Run ESLintLocated in ml-verification/. Runs as a standalone Python service integrated into the Django backend via projects/verification_service.py.
The platform supports 6 project classification types. Each maps to a distinct verification strategy:
| Classification | ML Type | Verification Approach | Key Inputs |
|---|---|---|---|
VEGETATION |
vegetation |
UNet image segmentation on NDVI satellite imagery | Satellite images, area (ha), claimed improvement % |
PLANTATION |
vegetation |
Same as VEGETATION β UNet + NDVI pipeline | Tree count, avg DBH (mm), avg height (cm), species factor |
SOLAR |
solar |
ResNet50 classification on RGB satellite imagery | Satellite images, energy generated (kWh), grid emission factor, efficiency % |
METHANE |
methane |
Numeric-only formula (no image ML) | Biogas volume (mΒ³/year), methane fraction %, plant capacity (kW) |
COOKSTOVE |
cookstove |
Numeric-only formula (no image ML) | Stove count, wood saved (kg/stove/year), FNRB factor, emission factor, efficiency % |
WIND |
wind |
Numeric-only formula (no image ML) | Wind energy generated (kWh), grid emission factor, turbine efficiency %, turbine count |
VEGETATIONandPLANTATIONshare the same ML pipeline.METHANE,COOKSTOVE, andWINDare numeric-only β they do not use image models; credits are calculated from domain-specific formulas.
| Model | Task | Input | Output |
|---|---|---|---|
| UNet | Vegetation/plantation segmentation | NDVI images (256Γ256) | Binary vegetation mask |
| ResNet50 | Solar site classification | RGB satellite images (256Γ256) | no_site / construction / active |
Model checkpoints are stored in ml-verification/src/models/checkpoints/:
vegetation_unet_best.kerassolar_resnet_best.keras
cd ml-verification
source venv/bin/activate
# Train models
python src/train.py --task vegetation
python src/train.py --task solar
# Run verification on a project
python src/verify.py --project veg_001 # vegetation / plantation
python src/verify.py --project solar_001 # solar| Domain | Key Metrics |
|---|---|
| Vegetation / Plantation | IoU ~0.73, Dice ~0.83, Temporal Consistency ~0.98 |
| Solar | Solar probability score, estimated panel area (mΒ²), avoided COβ (tCOβ/year) |
| Methane | COβ equivalent tonnes/year from biogas formula |
| Cookstove | Credits from wood-saved formula (FNRB-adjusted) |
| Wind | Avoided COβ from wind energy Γ grid emission factor |
- Project submitted β classification stored in Django
Projectmodel /api/projects/<id>/verify/triggered βProjectVerificationService.verify_project()called- For image domains (vegetation, solar): images processed β ML inference runs
- For numeric domains (methane, cookstove, wind): formula-based calculation only
- Result saved as JSON report in
media/reports/<report_id>.json - Django model updated with
final_decision,confidence_score,estimated_co2_tco2_year, and domain-specific fields
Located in blockchain/. Uses Hardhat + web3.py.
| Contract | Description |
|---|---|
IndianCarbonCredit.sol |
Main CCTS contract |
CarbonCredToken.sol |
ERC-20 carbon credit token |
- Testnet: Ethereum Sepolia (
chainId: 11155111) - RPC: Alchemy (
ALCHEMY_URLin.env)
cd blockchain
npm install
# Compile
npx hardhat compile
# Deploy to Sepolia
npx hardhat run scripts/deploy.js --network sepoliaAfter deploying, copy the output contract address into .env as CONTRACT_ADDRESS and REACT_APP_CONTRACT_ADDRESS.
source .venv/bin/activate
python manage.py runserver # Start dev server
python manage.py migrate # Apply migrations
python manage.py makemigrations # Generate new migrations
python manage.py createsuperuser # Create admin user
python manage.py shell # Open Django shell# Build and start all 5 services
docker compose up --build -d
# Start only the DB (useful for local dev)
docker compose up db -d
# Rebuild a single service after code changes
docker compose up --build backend -d
# Stop all services (data volumes preserved)
docker compose down
# Stop and delete all volumes (fresh start)
docker compose down -v
# Follow logs
docker compose logs -f # All services
docker compose logs -f backend # Backend only
docker compose logs -f ml-service # ML service only
docker compose logs -f frontend # Nginx/frontend only
# Run Django management commands inside the container
docker compose exec backend python manage.py migrate
docker compose exec backend python manage.py createsuperuser
docker compose exec backend python manage.py shell
# Restart a single service without full rebuild
docker compose restart backendcd frontend
npm install # Install / update packages
npm run dev # Dev server
npm run build # Production build
npm run lint # Lint checkThis project is licensed under the MIT License β see LICENSE for details.
Built with β€οΈ for a greener India π±
Β© 2025β2026 Nesar Wagannawar , Prathamesh Jain , Aaditya Cholle , Suhani Shah