
Create a full-featured task management API with the following components: - RESTful CRUD operations for tasks - Task status and priority management - SQLite database with SQLAlchemy ORM - Alembic migrations - Health check endpoint - Comprehensive API documentation
3.0 KiB
3.0 KiB
Task Manager API
A RESTful API for managing tasks built with FastAPI and SQLite.
Features
- Create, read, update, and delete tasks
- Filter tasks by status and title
- Task prioritization
- Due date management
- Health check endpoint for monitoring
- Comprehensive API documentation
Tech Stack
- FastAPI: Modern, fast web framework for building APIs
- SQLAlchemy: SQL toolkit and Object-Relational Mapping
- Alembic: Database migration tool
- SQLite: Lightweight, file-based database
- Pydantic: Data validation and settings management
- Uvicorn: ASGI server
Project Structure
taskmanagerapi/
├── alembic.ini # Alembic configuration
├── main.py # Application entry point
├── README.md # Project documentation
├── requirements.txt # Project dependencies
├── app/ # Application package
│ ├── api/ # API endpoints
│ │ └── api_v1/ # API version 1
│ │ ├── api.py # API router
│ │ └── endpoints/# API endpoint modules
│ ├── core/ # Core application code
│ │ └── config.py # Configuration settings
│ ├── crud/ # CRUD operations
│ ├── db/ # Database setup
│ ├── models/ # SQLAlchemy models
│ └── schemas/ # Pydantic schemas
└── migrations/ # Database migrations
├── env.py # Alembic environment
├── script.py.mako # Migration script template
└── versions/ # Migration versions
Getting Started
Prerequisites
- Python 3.8+
Installation
-
Clone the repository:
git clone https://github.com/yourusername/taskmanagerapi.git cd taskmanagerapi
-
Install dependencies:
pip install -r requirements.txt
-
Run the application:
uvicorn main:app --reload
-
Access the API at
http://localhost:8000
-
Access the API documentation at
http://localhost:8000/docs
orhttp://localhost:8000/redoc
API Endpoints
Health Check
GET /api/v1/health
: Check the health of the application
Tasks
GET /api/v1/tasks
: List all tasksPOST /api/v1/tasks
: Create a new taskGET /api/v1/tasks/{id}
: Get a specific taskPUT /api/v1/tasks/{id}
: Update a specific taskDELETE /api/v1/tasks/{id}
: Delete a specific task
Task Model
{
"id": 1,
"title": "Complete project",
"description": "Finish the project by the deadline",
"status": "todo",
"priority": "high",
"due_date": "2023-12-31T23:59:59",
"created_at": "2023-09-01T12:00:00",
"updated_at": "2023-09-01T12:00:00"
}
Filtering Tasks
- By status:
GET /api/v1/tasks?status=todo
- By title:
GET /api/v1/tasks?title=project
- Pagination:
GET /api/v1/tasks?skip=0&limit=10
License
This project is licensed under the MIT License.