
Added complete task management functionality including: - CRUD operations for tasks (create, read, update, delete) - Task model with status (pending/in_progress/completed) and priority (low/medium/high) - SQLite database with SQLAlchemy ORM - Alembic migrations for database schema - Pydantic schemas for request/response validation - FastAPI routers with proper error handling - Filtering and pagination support - Health check endpoint - CORS configuration - Comprehensive API documentation - Proper project structure following FastAPI best practices
3.2 KiB
3.2 KiB
Task Manager API
A comprehensive task management API built with FastAPI, SQLAlchemy, and SQLite. This API provides full CRUD operations for managing tasks with status tracking, priority levels, and timestamps.
Features
- ✅ Create, read, update, and delete tasks
- ✅ Task status management (pending, in_progress, completed)
- ✅ Priority levels (low, medium, high)
- ✅ Automatic timestamps (created_at, updated_at)
- ✅ Filtering by status and priority
- ✅ Pagination support
- ✅ FastAPI automatic documentation
- ✅ SQLite database with SQLAlchemy ORM
- ✅ Database migrations with Alembic
- ✅ CORS enabled for cross-origin requests
- ✅ Health check endpoint
API Endpoints
Base URL
- GET
/
- API information and links - GET
/health
- Health check endpoint
Tasks
- POST
/api/v1/tasks/
- Create a new task - GET
/api/v1/tasks/
- Get all tasks (with optional filtering and pagination) - GET
/api/v1/tasks/{task_id}
- Get a specific task by ID - PUT
/api/v1/tasks/{task_id}
- Update a specific task - DELETE
/api/v1/tasks/{task_id}
- Delete a specific task
Query Parameters for GET /api/v1/tasks/
skip
(int): Number of tasks to skip (default: 0)limit
(int): Maximum number of tasks to return (default: 100, max: 1000)status
(string): Filter by status (pending
,in_progress
,completed
)priority
(string): Filter by priority (low
,medium
,high
)
Task Schema
{
"id": 1,
"title": "Example Task",
"description": "This is an example task description",
"status": "pending",
"priority": "medium",
"created_at": "2025-06-20T12:00:00",
"updated_at": "2025-06-20T12:00:00"
}
Status Values
pending
- Task is not yet startedin_progress
- Task is currently being worked oncompleted
- Task has been finished
Priority Values
low
- Low priority taskmedium
- Medium priority task (default)high
- High priority task
Installation and Setup
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the development server:
uvicorn main:app --reload
The API will be available at http://localhost:8000
Documentation
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- OpenAPI JSON: http://localhost:8000/openapi.json
Environment Variables
No environment variables are required for basic operation. The application uses SQLite with a local database file stored in /app/storage/db/db.sqlite
.
Development
The application uses the following structure:
main.py
- FastAPI application entry pointapp/models/
- SQLAlchemy database modelsapp/schemas/
- Pydantic request/response schemasapp/crud/
- Database operationsapp/routers/
- API route handlersapp/db/
- Database configuration and session managementalembic/
- Database migration files
Testing
Run the linter and formatter:
ruff check .
ruff format .
Production Deployment
For production deployment, ensure proper database configuration and consider using PostgreSQL instead of SQLite for better performance and concurrent access.