Skip to content

Add Category model and relate it to Tasks #7

Description

@Navashub

Description

Tasks should be organizable by category (e.g. "Work", "Personal", "Learning"). Build the Category model, its CRUD, and link it to Task.

What to do

  • Create a Category SQLAlchemy model in models.py: id, name (unique, not null)
  • Add a category_id foreign key to the Task model (nullable — tasks don't have to have a category)
  • Add a relationship from Task to Category
  • Create Pydantic schemas: CategoryCreate, CategoryResponse
  • Create routers/categories.py with full CRUD: POST, GET /, GET /{id}, DELETE /{id}
  • Register the router in main.py
  • Include category (nested) in TaskResponse

Acceptance Criteria

  • POST /categories/ creates a category
  • GET /categories/ lists all categories
  • POST /tasks/ accepts an optional category_id
  • GET /tasks/ includes the category object nested inside each task response

Difficulty

🟡 Intermediate

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendPython / FastAPI workintermediateRequires some FastAPI experience

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions