A lightweight, in-memory CRUD API for managing tasks, built using Python and FastAPI. This project was built step-by-step to demonstrate core backend mechanics, HTTP methods, status codes, and input validation without relying on an external database.
Start the local development server with:
uvicorn main:app --reloadThe server will be available at http://localhost:8000.
| Method | Path | Action | Expected Status Codes |
|---|---|---|---|
| GET | / |
API Information | 200 |
| GET | /health |
Health Check | 200 |
| GET | /tasks |
List all tasks | 200 |
| GET | /tasks/{task_id} |
Get a specific task | 200, 404 |
| POST | /tasks |
Create a new task | 201, 400 |
| PUT | /tasks/{task_id} |
Update an existing task | 200, 400, 404 |
| DELETE | /tasks/{task_id} |
Delete a task | 204, 404 |
- Initialized the FastAPI application.
- Created the root
GET /endpoint returning basic API metadata. - Created the
GET /healthendpoint for server monitoring.
- Established an in-memory Python list (
Task_DB) acting as the database. - Implemented
GET /tasksto return the complete array of tasks. - Implemented
GET /tasks/{task_id}to return a specific task, utilizing a404 Not Foundexception if the ID does not exist.
- Implemented
POST /tasksaccepting a JSON body mapped to a PydanticTaskCreatemodel. - Added validation to ensure the title cannot be empty, triggering a custom
400 Bad Requestglobal exception handler. - Automatically generates an incremented ID and defaults the
donestatus tofalse.
Example POST Request via curl:
curl -i -X POST http://localhost:8000/tasks -H "Content-Type: application/json" -d "{\"title\":\"Test task from terminal\"}"
HTTP/1.1 201 Created
date: Tue, 21 Jul 2026 11:32:22 GMT
server: uvicorn
content-length: 71
content-type: application/json
{"status":"New Task Added Successfully","Task":{"id":2,"title":"Test task from terminal","done":false}}- Implemented
PUT /tasks/{task_id}using aTaskUpdatemodel to allow partial updates oftitleordonefields. Includes400validation for empty titles and404for missing IDs. - Implemented
DELETE /tasks/{task_id}removing the task dictionary from the list using.remove()and returning a204 No Contentstatus. - The Mortality Experiment: Confirmed that because data is stored in memory, restarting the server (via Uvicorn's reload functionality) wipes out all dynamically created tasks and resets to the original hardcoded state.
- Utilized FastAPI's built-in interactive documentation available at
/docs. - Tested the full CRUD cycle visually without manual
curlformatting.
Swagger Documentation Screenshots:


- Initialized the local Git repository.
- Documented the API requirements, behavior, and testing steps in this README.
- Pushed all iterative commits to the remote repository.