
- Set up project structure and dependencies - Create database models and schemas for tasks - Implement CRUD operations for tasks - Add API endpoints for task management - Create Alembic migrations for the database - Add health check endpoint - Implement error handling - Add documentation in README.md
Task Management API
A simple task management API built with FastAPI and SQLite.
Features
- Create, read, update, and delete tasks
- Filter tasks by status
- Mark tasks as completed
- Set task priorities
- Health check endpoint
Tech Stack
- FastAPI: Modern, fast web framework for building APIs
- SQLAlchemy: SQL toolkit and ORM
- Alembic: Database migration tool
- SQLite: Lightweight, file-based database
- Pydantic: Data validation and settings management
- Uvicorn: ASGI server for FastAPI
Setup and Installation
Prerequisites
- Python 3.9+
Installation
- Clone the repository:
git clone <repository-url>
cd <repository-directory>
- Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
Running the Application
Start the application with Uvicorn:
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
The API will be available at http://localhost:8000.
API Documentation
Once the application is running, you can access:
- Interactive API documentation: http://localhost:8000/docs
- Alternative API documentation: http://localhost:8000/redoc
API Endpoints
Health Check
GET /api/v1/health
: Check API and database health
Tasks
GET /api/v1/tasks
: Get all tasksPOST /api/v1/tasks
: Create a new taskGET /api/v1/tasks/{id}
: Get a specific taskPUT /api/v1/tasks/{id}
: Update a taskDELETE /api/v1/tasks/{id}
: Delete (soft delete) a task
Task Structure
A task has the following structure:
{
"id": 1,
"title": "Sample Task",
"description": "This is a sample task",
"status": "todo",
"priority": "medium",
"due_date": "2023-12-31T23:59:59",
"created_at": "2023-09-27T10:00:00",
"updated_at": "2023-09-27T10:00:00"
}
status
can be: "todo", "in_progress", or "done"priority
can be: "low", "medium", or "high"
Description
Languages
Python
97.6%
Mako
2.4%