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

50 lines
1.3 KiB
Python

from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime
class CarbonProjectBase(BaseModel):
title: str
description: str
location: str
project_type: str
methodology: str
total_credits_available: int
price_per_credit: float
start_date: datetime
end_date: datetime
class CarbonProjectCreate(CarbonProjectBase):
pass
class CarbonProjectUpdate(BaseModel):
title: Optional[str] = None
description: Optional[str] = None
location: Optional[str] = None
project_type: Optional[str] = None
methodology: Optional[str] = None
total_credits_available: Optional[int] = None
price_per_credit: Optional[float] = None
start_date: Optional[datetime] = None
end_date: Optional[datetime] = None
verification_document_url: Optional[str] = None
class CarbonProjectResponse(CarbonProjectBase):
id: int
credits_sold: int
verification_status: str
verification_document_url: Optional[str] = None
is_active: bool
contract_address: Optional[str] = None
token_id: Optional[str] = None
created_at: datetime
updated_at: datetime
developer_id: int
class Config:
from_attributes = True
class CarbonProjectListResponse(BaseModel):
projects: List[CarbonProjectResponse]
total: int
page: int
page_size: int