Skip to content

davidharting/fastapi-starter

Repository files navigation

FastAPI starter

A template repository for quickly starting new FastAPI projects with comfortable and productive tooling.

🚀 Use this repository to start your own project

Set up your repository

  • Click the green Use this Template button
  • Fill out the form to create your new repository
  • Clone the repository locally

Rename

Globally search for "fastapi_starter" and "fastapi-starter." Replace these with the name of your own application.

👩‍💻 Set up your development environment

Global dependencies

You will need Python and Poetry to work with this project.

  • Install pyenv to manage Python versions.
  • Install Python. cat .python-version | pyenv install
  • Install pipx.
  • Install Poetry
    • We will use this to manage project dependencies
    • pipx install poetry

Project dependencies

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

🥳 Start developing!

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

Set up VS Code

This project comes with a .vscode folder which will recommend extensions to install and automatically configure. Simply install the recommended extensions when prompted!

✅ Features

Project setup

  • Pyenv for Python version management
  • Poetry for dependency management
  • Typer for project tasks

Code hygiene

  • Ruff for linting
  • Black for code formatting
  • Pyright for type-checking
  • isort for import sorting

Testing

  • Pytest
  • Example API client test

Logging

  • Loguru
  • Middleware to bind a logger per request

FastAPI

  • Multi-file / multi-router setup
  • Health check endpoint
  • Abstraction for consistent background jobs

Config

  • Use Pydant BaseSetting subclass to read and parse environment variables (e.g., LOG_LEVEL)

CI

  • GitHub actions for lint, type-check, format, test

About

A starting point for new FastAPI applications with productive and comfortable tooling

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages