Simple CRUD API for managing tasks, built with FastAPI.
This project demonstrates how I design a small backend service together with automated tests and continuous integration.
It showcases:
- REST API design
- automated testing using pytest
- FastAPI TestClient usage
- CI integration with GitHub Actions
| Tool | Purpose |
|---|---|
| Python 3.x | Programming language |
| FastAPI | Web framework for building APIs |
| pytest | Testing framework |
| FastAPI TestClient (httpx) | API testing client |
| GitHub Actions | Continuous Integration |
The API exposes a minimal task management system.
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Basic healthcheck endpoint |
| GET | /tasks |
Retrieve all tasks |
| POST | /tasks |
Create a new task |
| GET | /tasks/{id} |
Retrieve a task by id |
| PUT | /tasks/{id} |
Update an existing task |
| DELETE | /tasks/{id} |
Delete a task |
Each task contains the following fields:
| Field | Type | Description |
|---|---|---|
id |
integer | Task identifier |
title |
string | Short task title |
description |
string (optional) | Additional details |
done |
boolean | Indicates if the task is completed |
For simplicity this project uses in-memory storage (Python list). This is sufficient to demonstrate API design patterns and automated testing.
fastapi-tasks/
├── app/
│ ├── __init__.py
│ └── main.py # FastAPI application and endpoints
│
├── tests/
│ ├── __init__.py
│ └── test_tasks_api.py # API tests using TestClient
│
├── requirements.txt
├── pytest.ini
│
└── .github/
└── workflows/
└── tests.yml # GitHub Actions workflow
app/ Contains the FastAPI application and API endpoints.
tests/ Automated tests for API endpoints using pytest and FastAPI TestClient.
requirements.txt Project dependencies.
pytest.ini Pytest configuration.
GitHub Actions workflow Continuous Integration pipeline configuration.
git clone https://github.com/KacperBlok1/fastapi-tasks.git
cd fastapi-tasks
python -m venv venv
Activate it:
Windows
venv\Scripts\activate
Mac / Linux
source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload
The API will be available at:
http://127.0.0.1:8000
FastAPI automatically generates interactive API documentation.
http://127.0.0.1:8000/docs
http://127.0.0.1:8000/openapi.json
These tools allow you to test endpoints directly from the browser.
The project includes a small but complete automated test suite.
Covered scenarios:
- API healthcheck
- creating tasks
- retrieving tasks
- updating tasks
- deleting tasks
- verifying
404responses after deletion
Run all tests:
pytest
Tests use FastAPI TestClient, which allows testing the API without running an external server.
This repository includes a GitHub Actions CI pipeline.
Workflow location:
.github/workflows/tests.yml
Triggered on:
- push
- pull_request to the
mainbranch
Pipeline actions:
- Sets up Python environment
- Installs dependencies from
requirements.txt - Runs the pytest test suite
- Ensures the API behaves as expected
You can view the latest runs in the Actions tab of the repository.
Possible improvements for the project:
- add persistent database (PostgreSQL or SQLite)
- add authentication (JWT)
- add pagination for tasks
- integrate API schema validation
- add Docker support
Kacper Blok
Backend / QA Automation Portfolio Project