Skip to content

🧪 Proof of Concept for a RESTful API made with Python 3 and FastAPI

License

Notifications You must be signed in to change notification settings

nanotaboada/python-samples-fastapi-restful

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

🧪 RESTful API with Python 3 and FastAPI

Status

Python CI Python CD Quality Gate Status Codacy Badge codecov CodeFactor Code style: black

About

Proof of Concept for a RESTful API made with Python 3 and FastAPI.

Structure

Simplified, conceptual project structure and main application flow

Figure: Simplified, conceptual project structure and main application flow. Not all dependencies are shown.

Python Version Management

This project uses .python-version to specify the required Python version. If you use pyenv, asdf, or mise, the correct Python version will be automatically activated when you enter the project directory.

Alternatively, ensure you have Python 3.13.3 (or the version specified in .python-version) installed.

Install

pip install -r requirements.txt
pip install -r requirements-lint.txt
pip install -r requirements-test.txt

Start

uvicorn main:app --reload --port 9000

Docs

http://localhost:9000/docs

API Documentation

Container

Docker Compose

This setup uses Docker Compose to build and run the app and manage a persistent SQLite database stored in a Docker volume.

Build the image

docker compose build

Start the app

docker compose up

On first run, the container copies a pre-seeded SQLite database into a persistent volume On subsequent runs, that volume is reused and the data is preserved

Stop the app

docker compose down

Optional: database reset

docker compose down -v

This removes the volume and will reinitialize the database from the built-in seed file the next time you up.

Releases

This project uses famous football coaches as release names ♟️

Create a Release

Releases are created by pushing version tags in the format v{MAJOR}.{MINOR}.{PATCH}-{COACH}:

# Example: Creating the first release (Ancelotti)
git tag -a v1.0.0-ancelotti -m "Release 1.0.0 - Ancelotti"
git push origin v1.0.0-ancelotti

The CD pipeline will automatically:

  • Run tests and generate coverage reports
  • Build and push Docker images with multiple tags
  • Generate a changelog from git commits
  • Create a GitHub Release with auto-generated notes

Pull Docker Images

Official releases are published to GitHub Container Registry (GHCR):

# By semantic version (recommended)
docker pull ghcr.io/nanotaboada/python-samples-fastapi-restful:1.0.0

# By coach name
docker pull ghcr.io/nanotaboada/python-samples-fastapi-restful:ancelotti

# Latest
docker pull ghcr.io/nanotaboada/python-samples-fastapi-restful:latest

Coach Names (A-Z)

Letter Coach Tag Name Letter Coach Tag Name
A Ancelotti ancelotti N Nagelsmann nagelsmann
B Bielsa bielsa O Ottmar ottmar
C Capello capello P Pochettino pochettino
D Del Bosque delbosque Q Queiroz queiroz
E Eriksson eriksson R Ranieri ranieri
F Ferguson ferguson S Simeone simeone
G Guardiola guardiola T Tuchel tuchel
H Heynckes heynckes U Unai unai
I Inzaghi inzaghi V Van Gaal vangaal
J Klopp klopp W Wenger wenger
K Kovač kovac X Xavi xavi
L Löw low Y Yozhef yozhef
M Mourinho mourinho Z Zeman zeman

See CHANGELOG.md for full release history.

Credits

The solution has been coded using Visual Studio Code with the official Python extension.

Terms

All trademarks, registered trademarks, service marks, product names, company names, or logos mentioned on this repository are the property of their respective owners. All usage of such terms herein is for identification purposes only and constitutes neither an endorsement nor a recommendation of those items. Furthermore, the use of such terms is intended to be for educational and informational purposes only.