A simple FastAPI-powered RESTful API for managing tasks.
Currently, tasks are stored in a local SQLite database, making this ideal for demos, learning, or as a starter template for production APIs.
- Python ≥ 3.13
- FastAPI — API framework
- Pydantic — request/response validation
- Uvicorn — ASGI server
- pytest — testing framework
task-management-api/
├── src/
│ ├── main.py # Application entry point
│ ├── api/
│ │ └── endpoints/
│ │ └── task.py # Task endpoints (CRUD)
│ ├── models/
│ │ └── task.py # Task domain model & in-memory storage
│ ├── schemas/
│ │ └── task.py # Pydantic schemas for validation
│ ├── core/
│ │ └── database.py # database connection and session management
│ └── services/
│ └── task_services.py # Business logic for tasks
├── tests/ # Unit & integration tests
├── .gitignore
├── .python-version
├── README.md
├── pyproject.toml # Project metadata & dependencies
└── uv.lock # Lock file for dependencies
-
Clone the repository:
git clone https://github.com/Prince-Letsyo/task-management-api.git cd task-management-api
-
Install dependencies:
pip install .
(or use
pip install -r requirements.txt
if you generate one) -
Run the server:
uvicorn src.main:app --reload
-
Access the app:
- Swagger UI: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
Method | Endpoint | Description | Body Parameters |
---|---|---|---|
GET | /tasks |
Get all tasks | — |
GET | /tasks/{id} |
Get a task by ID | — |
POST | /tasks |
Create a new task | title (str), description (str, optional), due_date (date) |
PUT | /tasks/{id} |
Update a task completely | same as POST |
PATCH | /tasks/{id} |
Partial update of a task | any subset of fields |
DELETE | /tasks/{id} |
Delete a task | — |
Create a task
curl -X POST "http://127.0.0.1:8000/tasks" -H "Content-Type: application/json" -d '{"title":"Write docs","description":"Complete README","due_date":"2025-09-30"}'
Update task (PATCH)
curl -X PATCH "http://127.0.0.1:8000/tasks/1" -H "Content-Type: application/json" -d '{"title":"Write detailed docs"}'
Delete task
curl -X DELETE "http://127.0.0.1:8000/tasks/1"
Task object
{
"id": 1,
"title": "Write docs",
"description": "Complete README",
"due_date": "2025-09-30"
}
Error (task not found)
{
"detail": "Task with id 42 not found"
}
Run all tests with:
pytest
(Tests cover services, schemas, and endpoints via FastAPI’s TestClient
.)
- Add persistent storage (SQLite / PostgreSQL)
- Improve error handling & validation (e.g., ensure due date is future)
- Authentication & authorization (user accounts, JWT, etc.)
- Pagination & filtering for large task lists
- Dockerize for deployment
- CI/CD pipeline (GitHub Actions)
- Expand test coverage
- Fork the repo
- Create a feature branch (
git checkout -b feature-name
) - Commit changes (
git commit -m "Added feature"
) - Push to branch (
git push origin feature-name
) - Open a Pull Request
This project is licensed under the MIT License.