
This commit implements a simple movie database backend inspired by IMDb. It includes: - API endpoints for movies, actors, directors and genres - SQLAlchemy models with relationships - Alembic migrations - Pydantic schemas for request/response validation - Search and filtering functionality - Health check endpoint - Complete documentation
58 lines
1.1 KiB
Python
58 lines
1.1 KiB
Python
from typing import List, Optional
|
|
from datetime import date
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class GenreBase(BaseModel):
|
|
name: str
|
|
|
|
|
|
# Properties to receive on genre creation
|
|
class GenreCreate(GenreBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive on genre update
|
|
class GenreUpdate(GenreBase):
|
|
name: Optional[str] = None
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class GenreInDBBase(GenreBase):
|
|
id: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Genre(GenreInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties properties stored in DB
|
|
class GenreInDB(GenreInDBBase):
|
|
pass
|
|
|
|
|
|
# We need a simplified movie class to avoid circular import issues
|
|
class MovieSummary(BaseModel):
|
|
id: int
|
|
title: str
|
|
release_date: Optional[date] = None
|
|
poster_path: Optional[str] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties for genre with details
|
|
class GenreDetails(Genre):
|
|
movies: List[MovieSummary] = []
|
|
|
|
|
|
# Properties for list
|
|
class GenreList(BaseModel):
|
|
data: List[Genre]
|
|
total: int |