A professional task management system built with FastAPI, SQLAlchemy, and Docker. This system allows multiple users to manage their tasks with full CRUD operations and status tracking.
- π₯ Multi-user Support: Each user can manage their own tasks
- π Task Management: Create, read, update, and delete tasks
- π Status Tracking: Track task progress (TODO, IN_PROGRESS, DONE)
- π RESTful API: Clean REST API design with proper HTTP status codes
- π‘οΈ Data Validation: Comprehensive input validation using Pydantic
- ποΈ Database Management: SQLAlchemy ORM with SQLite database
- π§ͺ Testing: Full test suite with pytest
- π³ Containerization: Docker and Docker Compose support
- π API Documentation: Auto-generated OpenAPI/Swagger documentation
- Backend Framework: FastAPI 0.104+
- Database: SQLite with SQLAlchemy ORM
- Validation: Pydantic v2
- Testing: pytest, httpx
- Containerization: Docker & Docker Compose
- Database Migrations: Alembic
- Code Quality: Black, isort, flake8, mypy
task-management-system/
βββ app/
β βββ api/v1/ # API endpoints
β βββ core/ # Core configuration
β βββ crud/ # CRUD operations
β βββ models/ # SQLAlchemy models
β βββ schemas/ # Pydantic schemas
β βββ utils/ # Utility functions
β βββ main.py # FastAPI application
βββ tests/ # Test suite
βββ alembic/ # Database migrations
βββ requirements.txt # Python dependencies
βββ Dockerfile # Docker configuration
βββ docker-compose.yml # Docker Compose configuration
βββ README.md # Project documentation
- Python 3.11+
- Docker (optional)
- Git
-
Clone the repository
git clone <repository-url> cd task-management-system
-
Create virtual environment
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
uv pip install -r requirements.txt
-
Set up environment variables
cp .env.example .env # Edit .env file with your configuration -
Initialize database
alembic upgrade head
-
Run the application
uvicorn app.main:app --reload
-
Access the API documentation
- π§ Swagger UI: http://localhost:8000/api/v1/docs
- π ReDoc: http://localhost:8000/api/v1/redoc
-
Build and run with Docker Compose
# Production mode docker-compose up --build # Development mode with hot reload docker-compose --profile dev up --build
-
Access the application
- π Production: http://localhost:8000
- π οΈ Development: http://localhost:8001
POST /api/v1/users/- Create a new userGET /api/v1/users/- Get all usersGET /api/v1/users/{user_id}- Get user by IDGET /api/v1/users/{user_id}/with-tasks- Get user with tasksPUT /api/v1/users/{user_id}- Update userDELETE /api/v1/users/{user_id}- Delete user
POST /api/v1/users/{user_id}/tasks/- Create task for userGET /api/v1/users/{user_id}/tasks/- Get user's tasksGET /api/v1/tasks/{task_id}- Get task by IDPUT /api/v1/tasks/{task_id}- Update taskPATCH /api/v1/tasks/{task_id}/status- Update task statusDELETE /api/v1/tasks/{task_id}- Delete taskGET /api/v1/users/{user_id}/tasks/stats- Get task statistics
GET /health- Application health status
# Run all tests
pytest
# Run with coverage
pytest --cov=app
# Run specific test file
pytest tests/test_users.py
# Run tests in verbose mode
pytest -v# Format code
black app/ tests/
# Sort imports
isort app/ tests/
# Lint code
flake8 app/ tests/
# Type checking
mypy app/# Create new migration
alembic revision --autogenerate -m "Description of changes"
# Apply migrations
alembic upgrade head
# Rollback migration
alembic downgrade -1| Variable | Description | Default |
|---|---|---|
APP_NAME |
Application name | Task Management System |
APP_VERSION |
Application version | 1.0.0 |
DEBUG |
Debug mode | True |
ENVIRONMENT |
Environment (dev/prod) | development |
DATABASE_URL |
Database connection URL | sqlite:///./task_management.db |
API_V1_STR |
API version prefix | /api/v1 |
HOST |
Server host | 0.0.0.0 |
PORT |
Server port | 8000 |
curl -X POST "http://localhost:8000/api/v1/users/" \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "john.doe@example.com"
}'curl -X POST "http://localhost:8000/api/v1/users/1/tasks/" \
-H "Content-Type: application/json" \
-d '{
"title": "Complete project documentation",
"description": "Write comprehensive API documentation"
}'curl -X PATCH "http://localhost:8000/api/v1/tasks/1/status" \
-H "Content-Type: application/json" \
-d '{
"status": "IN_PROGRESS"
}'This project implements several software engineering best practices:
- π§© Clean Architecture: Separation of concerns with distinct layers
- ποΈ Repository Pattern: CRUD operations abstracted from business logic
- π§° Dependency Injection: Database sessions and services injected via FastAPI
- π Factory Pattern: CRUD factory functions for consistent instantiation
- π¨ Exception Handling: Custom exceptions with proper HTTP status codes
- π‘οΈ Data Validation: Pydantic schemas for request/response validation
- π§ͺ Testing Strategy: Comprehensive unit and integration tests
- π Connection Pooling: SQLAlchemy connection pooling for database efficiency
- β‘ Query Optimization: Proper indexing and relationship loading
- π Pagination: Built-in pagination for large result sets
- ποΈ Caching Headers: Appropriate HTTP headers for caching strategies
- π³ Container Optimization: Multi-stage Docker builds for smaller images
- π‘οΈ Input Validation: Comprehensive data validation with Pydantic
- π SQL Injection Prevention: SQLAlchemy ORM prevents SQL injection
- π CORS Configuration: Configurable Cross-Origin Resource Sharing
- π€ Non-root Container: Docker container runs as non-root user
- β€οΈ Health Checks: Container health monitoring
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Project Link: https://github.com/EeshaaKhan/FastAPI-task-management-system.git