
- Set up project structure and dependencies - Create task model and schema - Implement Alembic migrations - Add CRUD API endpoints for task management - Add health endpoint with database connectivity check - Add comprehensive error handling - Add tests for API endpoints - Update README with API documentation
Task Manager API
A RESTful API for managing tasks built with FastAPI and SQLite.
Features
- CRUD operations for tasks
- Filtering by task status, priority, and title search
- Health check endpoint with database connectivity check
- Comprehensive error handling
- Database migrations with Alembic
- Complete test suite
Technical Stack
- Python 3.9+
- FastAPI - High-performance web framework
- SQLite - Database
- SQLAlchemy - ORM
- Alembic - Database migrations
- Pydantic - Data validation
- Pytest - Testing
Setup and Installation
Prerequisites
- Python 3.9 or higher
Installation
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables (optional):
# Enable debug mode
export DEBUG=True
Database Setup
The database will be automatically created at /app/storage/db/db.sqlite
when the application starts. To apply migrations:
alembic upgrade head
Running the API
# Development mode with auto-reload
uvicorn main:app --reload
# Production mode
uvicorn main:app --host 0.0.0.0 --port 8000
API Documentation
The API documentation is available at /docs
or /redoc
when the server is running.
Endpoints
Health Check
GET /health
Returns the health status of the API, including database connectivity.
Tasks
Method | Endpoint | Description |
---|---|---|
GET | /api/v1/tasks |
List all tasks with optional filtering |
POST | /api/v1/tasks |
Create a new task |
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 |
Filtering Tasks
The GET /api/v1/tasks
endpoint supports the following query parameters:
completed
- Filter by completion status (true/false)priority
- Filter by priority level (1-3)search
- Search by task titleskip
- Number of items to skip (pagination)limit
- Maximum number of items to return (pagination)
Task Object Structure
{
"id": 1,
"title": "Task Title",
"description": "Task description",
"completed": false,
"priority": 2,
"due_date": "2023-09-30T00:00:00",
"created_at": "2023-09-01T12:00:00",
"updated_at": "2023-09-01T12:00:00"
}
Testing
Run the test suite with:
pytest
Development
Running Linting
ruff check .
ruff check --fix .
Description
Languages
Python
97.8%
Mako
2.2%