Overview#
The Task Management API is a comprehensive backend service that allows users to create, manage, and organize tasks. Built with FastAPI, it showcases modern Python async programming, database design, and API best practices.
Technologies Used#
- Python 3.11+ - Core language with type hints
- FastAPI - Modern, fast web framework for building APIs
- PostgreSQL - Relational database with SQLAlchemy ORM
- Pydantic - Data validation using Python type annotations
- JWT Authentication - Secure token-based authentication
- Docker - Containerization for deployment
- Pytest - Comprehensive test suite
Features#
- ✅ CRUD Operations - Full Create, Read, Update, Delete functionality
- 🔐 JWT Authentication - Secure user registration and login
- 📊 Advanced Filtering - Search, sort, and paginate tasks
- 🏷️ Categories & Tags - Organize tasks with custom metadata
- 👥 User Isolation - Each user has their own task space
- 📝 Input Validation - Comprehensive data validation with Pydantic
- 🔄 Async Operations - Non-blocking database queries
- 📖 Auto-generated Docs - Swagger UI and ReDoc documentation
- 🐳 Docker Ready - Containerized with docker-compose
Architecture#
task-api/
├── app/
│ ├── api/ # Route handlers
│ ├── core/ # Config, security, dependencies
│ ├── db/ # Database session, models
│ ├── schemas/ # Pydantic models
│ └── services/ # Business logic
├── tests/ # Test suite
├── alembic/ # Database migrations
├── Dockerfile
├── docker-compose.yml
└── requirements.txtAPI Endpoints#
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/auth/register | Register new user |
| POST | /api/v1/auth/login | Login and get JWT token |
| GET | /api/v1/tasks | List all tasks (paginated) |
| POST | /api/v1/tasks | Create new task |
| GET | /api/v1/tasks/{id} | Get task by ID |
| PUT | /api/v1/tasks/{id} | Update task |
| DELETE | /api/v1/tasks/{id} | Delete task |
| GET | /api/v1/tasks/search | Search tasks |
Getting Started#
Prerequisites#
- Python 3.11+
- PostgreSQL 14+
- Docker & Docker Compose (optional)
Local Setup#
# Clone the repository
git clone https://github.com/jahruhn/task-api.git
cd task-api
# Create virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Set up environment variables
cp .env.example .env
# Edit .env with your database credentials
# Run database migrations
alembic upgrade head
# Start the development server
uvicorn app.main:app --reloadUsing Docker#
# Start all services
docker-compose up -d
# API will be available at http://localhost:8000
# API Docs at http://localhost:8000/docsTesting#
# Run the test suite
pytest
# With coverage
pytest --cov=app --cov-report=htmlChallenges & Learnings#
Database Connection Pooling: Initially faced performance issues with database connections under load. Implemented connection pooling with SQLAlchemy’s QueuePool, which improved response times by 40%.
Async vs Sync: Learned when to use async database operations vs synchronous ones. Not all operations benefit from async, and understanding the tradeoffs was crucial.
Authentication Security: Implemented password hashing with bcrypt, JWT token expiration, and refresh token rotation to ensure security best practices.
Future Enhancements#
- WebSocket support for real-time updates
- Task sharing between users
- File attachments to tasks
- GraphQL API endpoint
- Rate limiting and API keys
- Export to CSV/PDF
Links#
- Source Code: GitHub Repository
- API Documentation: Live Swagger UI
- Postman Collection: API Tests
💡 Note: This is a sample project page. Replace with your actual project details and update the links above.

