Skip to content

stevenfu2006/InternCodingPrompt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task Management API

A task management REST API built with FastAPI, managed with uv, and containerized with Docker.

Requirements

  • Python 3.11+
  • uv for dependency management
  • Docker (optional, for containerized runs)

Setup

Install uv if you don't have it:

curl -LsSf https://astral.sh/uv/install.sh | sh

Clone the repo and install dependencies:

git clone <repo-url>
cd intern-coding-prompt
uv sync

Running locally

uv run uvicorn app:app --reload

The API is available at http://localhost:8000.
Interactive docs (Swagger UI) are at http://localhost:8000/docs.


Running the tests

uv sync --dev
uv run pytest

With coverage:

uv run pytest --cov=api --cov-report=term-missing

Docker

Build the image:

docker build -t task-api .

Run the container:

docker run -p 8000:8000 task-api

The API is available at http://localhost:8000.


API endpoints

Health check

GET /health

Response 200

{ "status": "healthy" }

List all tasks

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 a task

GET /tasks/{task_id}

Response 200 — task object
Response 404

{ "error": "Task not found" }

Create a task

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" }

Update a task

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 a task

DELETE /tasks/{task_id}

Response 200

{ "message": "Task deleted successfully" }

Response 404

{ "error": "Task not found" }

Task object reference

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

Notes

  • Storage is in-memory. All tasks are lost when the process restarts.
  • The API has no authentication.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 95.0%
  • Dockerfile 5.0%