
- Directly import tasks endpoints in main.py for more explicit routing - Create API v1 router in main.py instead of using a separate module - Simplify routing structure to ensure endpoints are accessible
Task Manager API
A RESTful API for managing tasks, built with FastAPI and SQLite.
Features
- Create, read, update, and delete tasks
- Filter tasks by title, priority, and completion status
- Pagination support
- Health check endpoint
- SQLite database with SQLAlchemy ORM
- Alembic for database migrations
- Comprehensive API documentation with Swagger UI
Getting Started
Prerequisites
- Python 3.8+
- pip
Installation
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the application:
uvicorn main:app --reload
API Endpoints
The API will be available at http://localhost:8000
- API Documentation:
http://localhost:8000/docs
orhttp://localhost:8000/redoc
- OpenAPI Schema:
http://localhost:8000/openapi.json
- Health Check:
http://localhost:8000/health
Tasks Endpoints
GET /api/v1/tasks
: List all tasks (with optional filtering)POST /api/v1/tasks
: Create a new taskGET /api/v1/tasks/{task_id}
: Get a specific taskPUT /api/v1/tasks/{task_id}
: Update a taskDELETE /api/v1/tasks/{task_id}
: Delete a task
Query Parameters for Filtering Tasks
skip
: Number of tasks to skip (pagination)limit
: Maximum number of tasks to return (pagination)title
: Filter by title (partial match)priority
: Filter by priority (1=Low, 2=Medium, 3=High)completed
: Filter by completion status (true/false)
Task Data Model
id
: Unique identifiertitle
: Task title (required)description
: Task description (optional)completed
: Completion status (default: false)priority
: Priority level (1=Low, 2=Medium, 3=High, default: 1)due_date
: Due date (optional)created_at
: Creation timestampupdated_at
: Last update timestamp
Development
Project Structure
.
├── alembic.ini # Alembic configuration file
├── main.py # FastAPI application entry point
├── README.md # Project documentation
├── requirements.txt # Project dependencies
├── app/ # Application package
│ ├── api/ # API endpoints
│ │ └── v1/ # API version 1
│ │ └── endpoints/ # API endpoints modules
│ ├── core/ # Core application modules
│ ├── crud/ # CRUD operations
│ ├── db/ # Database setup and session
│ ├── models/ # SQLAlchemy models
│ └── schemas/ # Pydantic schemas
└── migrations/ # Alembic migrations
└── versions/ # Migration versions
Database Migrations
To create a new migration after model changes:
alembic revision --autogenerate -m "description"
To apply migrations:
alembic upgrade head
License
This project is licensed under the MIT License.
Description
Languages
Python
97%
Mako
3%