A template repository for quickly starting new FastAPI projects with comfortable and productive tooling.
- Click the green Use this Template button
- Fill out the form to create your new repository
- Clone the repository locally
Globally search for "fastapi_starter" and "fastapi-starter." Replace these with the name of your own application.
You will need Python and Poetry to work with this project.
- Install
pyenv
to manage Python versions.brew install pyenv
- Or, follow these steps.
- Install Python.
cat .python-version | pyenv install
- Install pipx.
- We will use this to install Poetry
brew install pipx
, or follow these instructions
- Install Poetry
- We will use this to manage project dependencies
pipx install poetry
Now you are ready to install the dependencies for this project. From the root directory:
poetry install
The first time you do this, it may take a long time. Poetry may do some initial work to resolve dependencies and cache information from pypi.
After install dependencies, you can run commands against the virtual environment with:
poetry run [your command]
Or, activate the environment in your shell with
poetry shell
Activate the virtual environment.
poetry shell
Now, see what commands are availabile to you.
python tasks.py --help
To start the dev server:
python tasks.py dev
This project comes with a .vscode
folder which will recommend extensions to install and automatically configure. Simply install the recommended extensions when prompted!
- Pyenv for Python version management
- Poetry for dependency management
- Typer for project tasks
- Ruff for linting
- Black for code formatting
- Pyright for type-checking
- isort for import sorting
- Pytest
- Example API client test
- Loguru
- Middleware to bind a logger per request
- Multi-file / multi-router setup
- Health check endpoint
- Abstraction for consistent background jobs
- Use Pydant
BaseSetting
subclass to read and parse environment variables (e.g., LOG_LEVEL)
- GitHub actions for lint, type-check, format, test