
- Setup FastAPI project structure with main.py and requirements.txt - Implement SQLAlchemy ORM with SQLite database - Create Item model with CRUD operations - Implement health endpoint for monitoring - Setup Alembic for database migrations - Add comprehensive documentation in README.md - Configure Ruff for code linting
46 lines
905 B
Python
46 lines
905 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
# Shared properties
|
|
class ItemBase(BaseModel):
|
|
title: Optional[str] = None
|
|
description: Optional[str] = None
|
|
is_active: Optional[bool] = True
|
|
|
|
|
|
# Properties to receive on item creation
|
|
class ItemCreate(ItemBase):
|
|
title: str = Field(..., min_length=1, max_length=100)
|
|
description: str = Field(..., min_length=1)
|
|
|
|
|
|
# Properties to receive on item update
|
|
class ItemUpdate(ItemBase):
|
|
pass
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class ItemInDBBase(ItemBase):
|
|
id: int
|
|
title: str
|
|
description: str
|
|
is_active: bool
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Item(ItemInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties stored in DB
|
|
class ItemInDB(ItemInDBBase):
|
|
pass
|