Automated Action 9947e2629c Add comprehensive user profile management system
Features:
- Extended User model with profile fields (first_name, last_name, phone, bio, preferred_language, timezone)
- Complete profile endpoints for viewing and updating user information
- Password update functionality with current password verification
- Email update functionality with duplicate email checking
- Account deletion endpoint
- Database migration for new profile fields
- Enhanced logging and error handling for all profile operations
- Updated API documentation with profile endpoints

Profile fields include:
- Personal information (name, phone, bio)
- Preferences (language, timezone)
- Account management (password, email updates)
- Timestamps (created_at, updated_at)
2025-06-24 19:40:23 +00:00

89 lines
2.6 KiB
Python

from pathlib import Path
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from contextlib import asynccontextmanager
import logging
from app.db.session import engine
from app.db.base import Base
from app.routes import auth, videos, transcription, translation, voice_cloning, video_processing, profile
# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
@asynccontextmanager
async def lifespan(app: FastAPI):
try:
# Create database tables
logger.info("Starting application initialization...")
storage_dir = Path("/app/storage/db")
storage_dir.mkdir(parents=True, exist_ok=True)
logger.info(f"Created storage directory: {storage_dir}")
Base.metadata.create_all(bind=engine)
logger.info("Database tables created successfully")
yield
except Exception as e:
logger.error(f"Error during application startup: {e}")
raise
app = FastAPI(
title="AI Video Dubbing API",
description="Backend API for AI-powered video dubbing with voice cloning and translation",
version="1.0.0",
lifespan=lifespan
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
allow_headers=["*"],
expose_headers=["*"]
)
# Include routers
app.include_router(auth.router, prefix="/auth", tags=["Authentication"])
app.include_router(profile.router, prefix="/profile", tags=["Profile"])
app.include_router(videos.router, prefix="/videos", tags=["Videos"])
app.include_router(transcription.router, prefix="/transcription", tags=["Transcription"])
app.include_router(translation.router, prefix="/translation", tags=["Translation"])
app.include_router(voice_cloning.router, prefix="/voice", tags=["Voice Cloning"])
app.include_router(video_processing.router, prefix="/process", tags=["Video Processing"])
@app.get("/")
async def root():
return {
"title": "AI Video Dubbing API",
"documentation": "/docs",
"health": "/health"
}
@app.get("/health")
async def health_check():
return {
"status": "healthy",
"service": "AI Video Dubbing API",
"database": "connected"
}
@app.get("/test")
async def test_endpoint():
logger.info("Test endpoint called")
return {
"message": "API is working correctly",
"timestamp": "2024-01-01T00:00:00Z",
"status": "success"
}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)