This is a Task Management API built with FastAPI, SQLModel, and SQLite. It demonstrates RESTful API design, data validation, database operations, and clean code practices.
- Create, Read, Update, Delete tasks
- Filter by status and priority
- Pagination and validation
- Bulk operations (create, update, delete)
- Auto-generated Swagger docs
- Dockerized for easy deployment
- Database migrations with Alembic
- FastAPI (web framework)
- SQLModel (ORM, built on SQLAlchemy)
- Pydantic (data validation)
- SQLite (database)
- Alembic (migrations)
- Docker (containerization)
├── app/
│ ├── main.py # FastAPI app entrypoint
│ ├── routes.py # API endpoints
│ ├── models.py # SQLModel models
│ ├── schemas.py # Pydantic schemas
│ ├── database.py # DB connection/session
│ └── utils.py # Validation utilities
├── alembic/ # DB migrations
├── alembic.ini # Alembic config
├── requirements.txt # Python dependencies
├── Dockerfile # Docker config
├── docker-compose.yml # Docker Compose config
├── .env # Environment variables
├── task.db # SQLite database
└── README.md # Project documentation
git clone <repo>
cd task_management_api
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Create a .env
file in the root directory:
DATABASE_URL=sqlite:///./task.db
alembic upgrade head
python -m app.main
docker-compose up --build
- Interactive docs: http://localhost:8000/docs
- Alternative docs: http://localhost:8000/redoc
# Create a task
curl -X POST "http://localhost:8000/tasks" \
-H "Content-Type: application/json" \
-d '{"title": "Sample Task", "priority": "high"}'
# List tasks
curl "http://localhost:8000/tasks?skip=0&limit=10"
# Get a task by ID
curl "http://localhost:8000/tasks/1"
# Update a task
curl -X PUT "http://localhost:8000/tasks/1" \
-H "Content-Type: application/json" \
-d '{"status": "completed"}'
# Delete a task
curl -X DELETE "http://localhost:8000/tasks/1"
GET /
- API infoGET /health
- Health checkPOST /tasks
- Create taskGET /tasks
- List tasks (with pagination)GET /tasks/{task_id}
- Get task by IDPUT /tasks/{task_id}
- Update taskDELETE /tasks/{task_id}
- Delete taskGET /tasks/status/{status}
- Filter by statusGET /tasks/priority/{priority}
- Filter by priorityPOST /tasks/bulk
- Bulk createPUT /tasks/bulk/update
- Bulk updateDELETE /tasks/bulk/delete
- Bulk delete
- Title: Cannot be empty/whitespace, trimmed
- Due date: Must be in the future (if provided)
- HTTP status codes: 201 (created), 200 (success), 404 (not found), 422 (validation error), 400 (client error)
- Install dependencies and run the app as above
- Access http://localhost:8000/docs for interactive testing
- Use
curl
or Postman for manual API testing
- Uses environment variables for DB config
- Alembic for migrations
- Docker for reproducibility
- Clean separation of models, schemas, routes, and DB logic
For questions, see the resources above or contact the project maintainer.
git clone <repo>
cd task_management_api
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python -m app.main