Automated Action e122f16dea Build complete blockchain-enabled carbon offset trading platform
Features implemented:
- User authentication with JWT tokens and role-based access (developer/buyer)
- Blockchain wallet linking and management with Ethereum integration
- Carbon project creation and management for developers
- Marketplace for browsing and purchasing carbon offsets
- Transaction tracking with blockchain integration
- Database models for users, projects, offsets, and transactions
- Comprehensive API with authentication, wallet, project, and trading endpoints
- Health check endpoint and platform information
- SQLite database with Alembic migrations
- Full API documentation with OpenAPI/Swagger

Technical stack:
- FastAPI with Python
- SQLAlchemy ORM with SQLite
- Web3.py for blockchain integration
- JWT authentication with bcrypt
- CORS enabled for frontend integration
- Comprehensive error handling and validation

Environment variables required:
- SECRET_KEY (JWT secret)
- BLOCKCHAIN_RPC_URL (optional, defaults to localhost)
2025-06-20 13:45:14 +00:00

44 lines
1.7 KiB
Python

from sqlalchemy import Column, Integer, String, DateTime, Boolean, Text, Float, ForeignKey
from sqlalchemy.orm import relationship
from datetime import datetime
from app.db.base import Base
class CarbonProject(Base):
__tablename__ = "carbon_projects"
id = Column(Integer, primary_key=True, index=True)
title = Column(String, nullable=False)
description = Column(Text, nullable=False)
location = Column(String, nullable=False)
project_type = Column(String, nullable=False) # "forestry", "renewable_energy", "waste_management", etc.
methodology = Column(String, nullable=False) # Certification methodology used
# Carbon offset details
total_credits_available = Column(Integer, nullable=False)
credits_sold = Column(Integer, default=0)
price_per_credit = Column(Float, nullable=False) # Price in USD
# Project timeline
start_date = Column(DateTime, nullable=False)
end_date = Column(DateTime, nullable=False)
# Verification and status
verification_status = Column(String, default="pending") # "pending", "verified", "rejected"
verification_document_url = Column(String, nullable=True)
is_active = Column(Boolean, default=True)
# Blockchain information
contract_address = Column(String, nullable=True)
token_id = Column(String, nullable=True)
# Timestamps
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
# Foreign keys
developer_id = Column(Integer, ForeignKey("users.id"), nullable=False)
# Relationships
developer = relationship("User", back_populates="projects")
offsets = relationship("CarbonOffset", back_populates="project")