A small REST API that models a helpdesk ticket workflow.
Demonstrates CRUD operations, validation, search filtering, and partial updates (PATCH) backed by a SQLite database.
- FastAPI
- SQLModel (SQLAlchemy + Pydantic)
- SQLite
- Docker
- Create tickets (POST)
- List tickets (GET)
- Get ticket by ID (GET)
- Search tickets via query parameters (GET)
- Update tickets partially (PATCH)
- Delete tickets (DELETE)
- Enum-restricted status:
open | in_progress | closed - Priority validation: 1–5
python -m venv .venvYou only need to do this if you are NOT using the provided run script.
Windows (Command Prompt):
.venv\Scripts\activatemacOS / Linux:
source .venv/bin/activatepip install -r requirements.txtuvicorn main:app --reloadrun_api.cmdOpen:
- API docs: http://127.0.0.1:8000/docs
- Root: http://127.0.0.1:8000/
Build the image:
docker build -t helpdesk-api .Run the container:
docker run --rm -p 8000:8000 helpdesk-apiRun the demo script (creates tickets, patches, searches, deletes):
python demo_client.pyrun_demo.cmdPOST /tickets/
Body:
{
"title": "Printer not working",
"description": "Office printer keeps jamming",
"priority": 3
}Response (example):
{
"id": 1,
"title": "Printer not working",
"description": "Office printer keeps jamming",
"priority": 3,
"status": "open"
}GET /tickets/?offset=0&limit=100
GET /tickets/{ticket_id}
GET /tickets/search?priority=5&status=open
PATCH /tickets/{ticket_id}
Body (example):
{
"status": "in_progress"
}DELETE /tickets/{ticket_id}
- The SQLite database file (
database.db) is intentionally not committed. - Database tables are created automatically on application startup.
- The API is stateless and follows REST conventions.