This is a small FastAPI backend for a task tracker app.
It exposes a simple JSON API for creating, reading, updating, and deleting tasks, then persists that data to a local JSON file.
Current structure is split into:
app/api: FastAPI route definitionsapp/db: repository and storage layersapp/models: Pydantic request/response modelsapp/core: app configuration and logging
- Python 3.12+
- FastAPI
- Uvicorn
- Pytest
- Python 3.12+
- Poetry
poetry installpoetry run uvicorn app.main:create_app --factory --reloadOR
fastapi devThen open:
- API:
http://127.0.0.1:8000 - Swagger UI:
http://127.0.0.1:8000/docs - ReDoc:
http://127.0.0.1:8000/redoc
By default, task data is stored at data/tasks.json.
You can override this with an environment variable:
DATA_FILE_PATH=/absolute/path/tasks.jsonRoutes:
GET /api/v1/tasks/healthGET /api/v1/tasks/GET /api/v1/tasks/{task_id}POST /api/v1/tasks/PATCH /api/v1/tasks/{task_id}DELETE /api/v1/tasks/DELETE /api/v1/tasks/{task_id}
Each task looks like this:
{
"id": 1,
"title": "Write README",
"description": "Explain full app behavior",
"priority": "UNSET",
"completed": false,
"due_date": null,
"completed_at": null,
"created_at": "2026-03-31T12:00:00Z",
"updated_at": "2026-03-31T12:00:00Z"
}GET /api/v1/tasks/ returns a paginated list:
{
"total": 0,
"count": 0,
"limit": 50,
"offset": 0,
"tasks": []
}List query params:
completed: filter by completion statuspriority:URGENT,HIGH,MEDIUM,LOW, orUNSETdue_before/due_after: filter by due dateq: case-insensitive title and description searchsort_by:created_at,updated_at,due_date,priority, ortitleorder:ascordesclimit: page size, from1to100, default50offset: starting index, default0
Notes:
descriptionis optionalprioritydefaults toUNSETcompleteddefaults tofalseGET /tasksdefaults to newest-created tasks first- missing tasks return
404 - storage failures return
500
Create a task:
curl -X POST http://127.0.0.1:8000/api/v1/tasks/ \
-H "Content-Type: application/json" \
-d '{"title":"Write README","description":"Trim the docs down"}'List tasks:
curl http://127.0.0.1:8000/api/v1/tasks/Filter, sort, and paginate tasks:
curl 'http://127.0.0.1:8000/api/v1/tasks/?completed=false&sort_by=priority&limit=10&offset=0'Update a task:
curl -X PATCH http://127.0.0.1:8000/api/v1/tasks/1 \
-H "Content-Type: application/json" \
-d '{"title":"Write a shorter README"}'Delete a task:
curl -X DELETE http://127.0.0.1:8000/api/v1/tasks/1Delete all tasks:
curl -X DELETE http://127.0.0.1:8000/api/v1/tasks/poetry run pytest -qThe test suite covers CRUD flows, list filtering/search/sorting/pagination, error handling, and JSON persistence behavior.