A task management REST API built with FastAPI, managed with uv, and containerized with Docker.
- Python 3.11+
- uv for dependency management
- Docker (optional, for containerized runs)
Install uv if you don't have it:
curl -LsSf https://astral.sh/uv/install.sh | shClone the repo and install dependencies:
git clone <repo-url>
cd intern-coding-prompt
uv syncuv run uvicorn app:app --reloadThe API is available at http://localhost:8000.
Interactive docs (Swagger UI) are at http://localhost:8000/docs.
uv sync --dev
uv run pytestWith coverage:
uv run pytest --cov=api --cov-report=term-missingBuild the image:
docker build -t task-api .Run the container:
docker run -p 8000:8000 task-apiThe API is available at http://localhost:8000.
GET /health
Response 200
{ "status": "healthy" }GET /tasks
Response 200 — array of task objects (empty array if none exist)
[
{
"id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"title": "Buy groceries",
"description": "Milk, eggs, bread",
"completed": false,
"created_at": "2024-01-15T10:30:00.123456"
}
]GET /tasks/{task_id}
Response 200 — task object
Response 404
{ "error": "Task not found" }POST /tasks
Content-Type: application/json
Body
| Field | Type | Required | Description |
|---|---|---|---|
title |
string | yes | Task title |
description |
string | no | Additional detail (defaults to "") |
{ "title": "Buy groceries", "description": "Milk, eggs, bread" }Response 201 — created task object
{
"id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"title": "Buy groceries",
"description": "Milk, eggs, bread",
"completed": false,
"created_at": "2024-01-15T10:30:00.123456"
}Response 400 — missing or invalid body
{ "error": "Title is required" }PUT /tasks/{task_id}
Content-Type: application/json
Body — all fields optional; only supplied fields are updated
| Field | Type | Description |
|---|---|---|
title |
string | New title |
description |
string | New description |
completed |
boolean | Mark complete or incomplete |
{ "completed": true }Response 200 — updated task object (includes updated_at)
{
"id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"title": "Buy groceries",
"description": "Milk, eggs, bread",
"completed": true,
"created_at": "2024-01-15T10:30:00.123456",
"updated_at": "2024-01-15T11:00:00.654321"
}Response 400 — no body provided
Response 404 — task not found
DELETE /tasks/{task_id}
Response 200
{ "message": "Task deleted successfully" }Response 404
{ "error": "Task not found" }| Field | Type | Present |
|---|---|---|
id |
UUID string | always |
title |
string | always |
description |
string | always |
completed |
boolean | always |
created_at |
ISO 8601 timestamp | always |
updated_at |
ISO 8601 timestamp | after first update only |
- Storage is in-memory. All tasks are lost when the process restarts.
- The API has no authentication.