Skip to content

About

REST API with FastAPI, Pydantic v2, repository pattern and pytest

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task API (FastAPI)

A small REST API for managing tasks, built to practise FastAPI, Pydantic validation and clean object-oriented structure.

Features

  • CRUD endpoints: POST /tasks, GET /tasks, GET /tasks/{id}, PATCH /tasks/{id}, DELETE /tasks/{id}
  • Validation with Pydantic v2 (empty titles are rejected with HTTP 422)
  • Filtering by done and priority; open, high-priority tasks are listed first
  • Storage behind an abstract TaskRepository interface, injected with FastAPI Depends, so the in-memory store can be replaced by a database without touching the endpoints
  • Thread-safe in-memory implementation
  • Tests with pytest and FastAPI's TestClient

Run

python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload

Open http://127.0.0.1:8000/docs for the interactive Swagger UI.

Test

pytest -q

Project structure

app/models.py      Pydantic schemas (TaskCreate, TaskUpdate, Task)
app/repository.py  TaskRepository interface + in-memory implementation
app/main.py        FastAPI app and routes
tests/             API tests

Next steps

  • SQLite storage with SQLModel
  • Authentication (OAuth2 password flow with JWT)
  • Docker image

About

REST API with FastAPI, Pydantic v2, repository pattern and pytest

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages