Automated Action ab87d3c506 Implement comprehensive cryptocurrency exchange platform
- Built complete CEX platform with FastAPI and Python
- JWT-based authentication system with secure password hashing
- Multi-currency crypto wallet support (BTC, ETH, USDT)
- Fiat account management (USD, EUR, GBP)
- Local transaction signing without external APIs
- Comprehensive transaction handling (send/receive/deposit/withdraw)
- SQLAlchemy models with Alembic migrations
- Security middleware (rate limiting, headers, logging)
- Input validation and sanitization
- Encrypted private key storage with PBKDF2
- Standardized codebase architecture with service layer pattern
- Complete API documentation with health endpoints
- Comprehensive README with setup instructions

Features:
- User registration and authentication
- Crypto wallet creation and management
- Secure transaction signing using local private keys
- Fiat deposit/withdrawal system
- Transaction history and tracking
- Rate limiting and security headers
- Input validation for all endpoints
- Error handling and logging
2025-06-20 23:08:04 +00:00

76 lines
2.0 KiB
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from app.core.config import settings
from app.core.middleware import RateLimitMiddleware, SecurityHeadersMiddleware, LoggingMiddleware
from app.api import auth, wallets, transactions
from app.db.session import engine
from app.db.base import Base
import uvicorn
# Create database tables
Base.metadata.create_all(bind=engine)
app = FastAPI(
title=settings.app_name,
version=settings.app_version,
description="A comprehensive cryptocurrency exchange platform with wallet management, trading, and secure transaction handling.",
openapi_url="/openapi.json"
)
# Security middleware
app.add_middleware(SecurityHeadersMiddleware)
app.add_middleware(RateLimitMiddleware, calls=100, period=60)
app.add_middleware(LoggingMiddleware)
# CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=settings.allowed_origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(auth.router)
app.include_router(wallets.router)
app.include_router(transactions.router)
@app.get("/")
def root():
return {
"title": settings.app_name,
"version": settings.app_version,
"description": "Cryptocurrency Exchange Platform API",
"documentation": "/docs",
"health_check": "/health"
}
@app.get("/health")
def health_check():
return {
"status": "healthy",
"service": settings.app_name,
"version": settings.app_version,
"environment": "development" if settings.debug else "production"
}
@app.exception_handler(Exception)
async def global_exception_handler(request, exc):
return JSONResponse(
status_code=500,
content={"detail": "Internal server error"}
)
if __name__ == "__main__":
uvicorn.run(
"main:app",
host="0.0.0.0",
port=8000,
reload=settings.debug
)