FastAPI project structure

FastAPI project structure

Explorer

  • .venv…, not committed
  • .git…
  • .gitignore
  • .python-version
  • .editorconfig
  • pyproject.toml
  • uv.lock
  • README.md
  • app
  • __init__.py
  • main.py
  • __pycache__…, not committed
  • alembicnew
  • env.pynew
  • script.py.makonew
  • READMEnew
  • alembic.ininew
  • testsnew
  • conftest.pynew
  • .pytest_cache…new, not committed
  • .ruff_cache…new, not committed
  • .mypy_cache…new, not committed
  • .coveragenew, not committed
  • htmlcov…new, not committed
  • .envnew, not committed
  • .env.examplenew
  • compose.yamlnew
  • Makefilenew
  • .pre-commit-config.yamlnew
  • .vscodenew
  • settings.jsonnew
  • extensions.jsonnew
  • launch.jsonnew
  • .devcontainernew
  • devcontainer.jsonnew
  • AGENTS.mdnew
  • CLAUDE.mdnew
  1. # Create the project with the official generator (needs uv)

    uvx fastapi-new orders-api
  2. # Start the dev server with auto reload

    cd orders-api && uv run fastapi dev
  3. # Add the data layer and settings when you need them

    uv add sqlalchemy alembic "psycopg[binary]" pydantic-settings
  4. # Add auth, jobs and logging

    uv add pyjwt "pwdlib[argon2]" "celery[redis]" structlog
  5. # Add test, lint and type tools as dev dependencies

    uv add --dev pytest pytest-cov factory-boy "testcontainers[postgres]" ruff mypy pre-commit
  6. # Install the Git hooks once per clone

    uv run pre-commit install
  7. # Add production observability and limits

    uv add sentry-sdk slowapi opentelemetry-sdk opentelemetry-exporter-otlp opentelemetry-instrumentation-fastapi opentelemetry-instrumentation-sqlalchemy
  8. # Create the migrations folder

    uv run alembic init alembic