Automated Action f19a6fea04 Build complete Personal Task Management API with FastAPI
- Implemented user authentication with JWT tokens
- Created comprehensive task management with CRUD operations
- Added category system for task organization
- Set up SQLite database with SQLAlchemy ORM
- Configured Alembic for database migrations
- Added API documentation with OpenAPI/Swagger
- Implemented proper authorization and user scoping
- Created health check and root endpoints
- Updated README with complete documentation
2025-06-21 16:16:40 +00:00
2025-06-21 16:10:55 +00:00

Personal Task Management API

A comprehensive FastAPI-based REST API for managing personal tasks, categories, and user authentication. Built with Python, FastAPI, SQLAlchemy, and SQLite.

Features

  • User Authentication: JWT-based authentication with registration and login
  • Task Management: Full CRUD operations for tasks with status and priority tracking
  • Category Management: Organize tasks with custom categories
  • User Authorization: All operations are user-scoped and protected
  • Database Migrations: Alembic for database schema management
  • API Documentation: Auto-generated OpenAPI/Swagger documentation

Quick Start

Prerequisites

  • Python 3.8+
  • pip

Installation

  1. Install dependencies:
pip install -r requirements.txt
  1. Run database migrations:
alembic upgrade head
  1. Start the application:
uvicorn main:app --reload

The API will be available at http://localhost:8000

API Documentation

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc
  • OpenAPI JSON: http://localhost:8000/openapi.json

API Endpoints

Authentication

  • POST /auth/register - Register a new user
  • POST /auth/login - Login with email and password
  • GET /auth/me - Get current user information

Tasks

  • GET /tasks/ - List all tasks (with filtering options)
  • POST /tasks/ - Create a new task
  • GET /tasks/{task_id} - Get a specific task
  • PUT /tasks/{task_id} - Update a task
  • DELETE /tasks/{task_id} - Delete a task

Categories

  • GET /categories/ - List all categories
  • POST /categories/ - Create a new category
  • GET /categories/{category_id} - Get a specific category
  • PUT /categories/{category_id} - Update a category
  • DELETE /categories/{category_id} - Delete a category

System

  • GET / - API information and links
  • GET /health - Health check endpoint

Data Models

Task

  • id: Unique identifier
  • title: Task title (required)
  • description: Optional task description
  • status: pending, in_progress, completed, cancelled
  • priority: low, medium, high, urgent
  • due_date: Optional due date
  • category_id: Optional category association
  • completed_at: Timestamp when task was completed
  • created_at/updated_at: Timestamps

Category

  • id: Unique identifier
  • name: Category name (required)
  • description: Optional description
  • color: Optional color code
  • created_at/updated_at: Timestamps

User

  • id: Unique identifier
  • email: User email (unique, required)
  • full_name: Optional full name
  • is_active: Account status
  • created_at/updated_at: Timestamps

Environment Variables

Set the following environment variables for production:

  • SECRET_KEY: JWT secret key for token signing (required for production)

Example:

export SECRET_KEY="your-super-secret-key-here"

Database

The application uses SQLite by default with the database file stored at /app/storage/db/db.sqlite. The database is automatically created when the application starts.

Authentication

The API uses JWT bearer tokens for authentication. To access protected endpoints:

  1. Register a new user or login with existing credentials
  2. Include the access token in the Authorization header: Authorization: Bearer <token>

Development

Code Quality

The project uses Ruff for linting and code formatting:

ruff check .
ruff format .

Database Migrations

Create new migrations after model changes:

alembic revision --autogenerate -m "Description of changes"
alembic upgrade head

Architecture

  • FastAPI: Modern, fast web framework for building APIs
  • SQLAlchemy: ORM for database operations
  • Alembic: Database migration tool
  • Pydantic: Data validation using Python type annotations
  • JWT: JSON Web Tokens for authentication
  • SQLite: Lightweight database for development and small deployments

The application follows a clean architecture pattern with separate layers for:

  • API routes (app/api/)
  • Database models (app/models/)
  • Data schemas (app/schemas/)
  • Core utilities (app/core/)
  • Database configuration (app/db/)
Description
Project: Personal Task Management API
Readme 87 KiB
Languages
Python 99.6%
Mako 0.4%