
- Set up FastAPI project structure with API versioning - Create database models for users and tasks - Implement SQLAlchemy ORM with SQLite database - Initialize Alembic for database migrations - Create API endpoints for task management (CRUD) - Create API endpoints for user management - Add JWT authentication and authorization - Add health check endpoint - Add comprehensive README.md with API documentation
68 lines
1.4 KiB
Python
68 lines
1.4 KiB
Python
from datetime import datetime
|
|
from enum import Enum
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
|
|
class TaskPriority(str, Enum):
|
|
"""
|
|
Enum for task priority levels
|
|
"""
|
|
LOW = "low"
|
|
MEDIUM = "medium"
|
|
HIGH = "high"
|
|
|
|
class TaskStatus(str, Enum):
|
|
"""
|
|
Enum for task status
|
|
"""
|
|
TODO = "todo"
|
|
IN_PROGRESS = "in_progress"
|
|
DONE = "done"
|
|
|
|
class TaskBase(BaseModel):
|
|
"""
|
|
Base task schema with shared attributes
|
|
"""
|
|
title: str
|
|
description: Optional[str] = None
|
|
status: TaskStatus = TaskStatus.TODO
|
|
priority: TaskPriority = TaskPriority.MEDIUM
|
|
due_date: Optional[datetime] = None
|
|
|
|
class TaskCreate(TaskBase):
|
|
"""
|
|
Schema for task creation
|
|
"""
|
|
pass
|
|
|
|
class TaskUpdate(BaseModel):
|
|
"""
|
|
Schema for task updates
|
|
"""
|
|
title: Optional[str] = None
|
|
description: Optional[str] = None
|
|
status: Optional[TaskStatus] = None
|
|
priority: Optional[TaskPriority] = None
|
|
due_date: Optional[datetime] = None
|
|
is_deleted: Optional[bool] = None
|
|
|
|
class TaskInDBBase(TaskBase):
|
|
"""
|
|
Base schema for tasks in DB with id and timestamps
|
|
"""
|
|
id: int
|
|
user_id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
is_deleted: bool = False
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
class Task(TaskInDBBase):
|
|
"""
|
|
Schema for returning task information
|
|
"""
|
|
pass
|