
- Add complete CRUD operations for task management - Implement task filtering by status, priority, and search - Add task statistics endpoint for summary data - Configure SQLite database with Alembic migrations - Set up FastAPI with CORS support and API documentation - Include health check endpoint and base URL information - Add comprehensive README with API usage examples - Structure project with proper separation of concerns
Task Manager API
A comprehensive Task Manager API built with FastAPI and SQLite, providing full CRUD operations for task management with filtering, search, and statistics capabilities.
Features
- ✅ Task Management: Create, read, update, and delete tasks
- 🔍 Advanced Filtering: Filter tasks by status, priority, and search text
- 📊 Statistics: Get task count summaries by status
- 🚀 FastAPI Framework: Modern, fast web framework with automatic API documentation
- 💾 SQLite Database: Lightweight, serverless database with Alembic migrations
- 📝 Comprehensive API Documentation: Auto-generated OpenAPI/Swagger docs
- 🌐 CORS Support: Cross-origin resource sharing enabled
- ⚡ Health Checks: Built-in health monitoring endpoint
Task Properties
Each task includes:
- Title: Task name (required, max 255 characters)
- Description: Optional detailed description
- Status:
pending
,in_progress
, orcompleted
- Priority:
low
,medium
, orhigh
- Due Date: Optional deadline
- Timestamps: Auto-generated creation and update times
API Endpoints
Tasks
GET /tasks/
- List all tasks with optional filteringPOST /tasks/
- Create a new taskGET /tasks/{id}
- Get a specific taskPUT /tasks/{id}
- Update a taskDELETE /tasks/{id}
- Delete a taskGET /tasks/stats/summary
- Get task statistics
System
GET /
- API information and linksGET /health
- Health check endpointGET /docs
- Interactive API documentation (Swagger UI)GET /redoc
- Alternative API documentationGET /openapi.json
- OpenAPI schema
Quick Start
-
Install Dependencies
pip install -r requirements.txt
-
Run Database Migrations
alembic upgrade head
-
Start the Server
uvicorn main:app --reload
-
Access the Application
- API: http://localhost:8000
- Documentation: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
API Usage Examples
Create a Task
curl -X POST "http://localhost:8000/tasks/" \
-H "Content-Type: application/json" \
-d '{
"title": "Complete project documentation",
"description": "Write comprehensive README and API docs",
"priority": "high",
"status": "pending"
}'
Get All Tasks
curl "http://localhost:8000/tasks/"
Filter Tasks
# Get high priority tasks
curl "http://localhost:8000/tasks/?priority=high"
# Get completed tasks
curl "http://localhost:8000/tasks/?status=completed"
# Search tasks
curl "http://localhost:8000/tasks/?search=documentation"
Update a Task
curl -X PUT "http://localhost:8000/tasks/1" \
-H "Content-Type: application/json" \
-d '{
"status": "completed"
}'
Get Task Statistics
curl "http://localhost:8000/tasks/stats/summary"
Database
The application uses SQLite with the following configuration:
- Database Location:
/app/storage/db/db.sqlite
- Migration Tool: Alembic
- Schema Management: Automatic table creation and migrations
Environment Variables
Currently, no environment variables are required. The application uses SQLite with a fixed path for simplicity.
Project Structure
/
├── main.py # FastAPI application entry point
├── requirements.txt # Python dependencies
├── alembic.ini # Alembic configuration
├── alembic/ # Database migrations
│ ├── env.py
│ └── versions/
├── app/
│ ├── api/
│ │ └── tasks.py # Task API routes
│ ├── crud/
│ │ └── task.py # Database operations
│ ├── db/
│ │ ├── base.py # SQLAlchemy base
│ │ └── session.py # Database connection
│ ├── models/
│ │ └── task.py # Database models
│ └── schemas/
│ └── task.py # Pydantic schemas
└── storage/
└── db/ # SQLite database files
Development Commands
# Install dependencies
pip install -r requirements.txt
# Run migrations
alembic upgrade head
# Start development server
uvicorn main:app --reload --host 0.0.0.0 --port 8000
# Run linting
python -m ruff check . --fix
Technologies Used
- FastAPI: Modern Python web framework
- SQLAlchemy: SQL toolkit and ORM
- Alembic: Database migration tool
- Pydantic: Data validation using Python type hints
- SQLite: Lightweight database
- Uvicorn: ASGI server
- Ruff: Fast Python linter
Built with BackendIM - AI-powered backend development assistant.
Description
Languages
Python
95.7%
Mako
4.3%