Flask project structure

Flask project structure

Explorer

  • .venv…, not committed
  • .git…
  • .gitignore
  • .python-version
  • pyproject.toml
  • uv.lock
  • README.md
  • flaskr
  • __pycache__…, not committed
  • __init__.py
  • db.py
  • schema.sql
  • auth.py
  • blog.py
  • config.pynew
  • extensions.pynew
  • forms.pynew
  • errors.pynew
  • cli.pynew
  • tasks.pynew
  • instance, not committed
  • flaskr.sqlite, not committed
  • config.pynew, not committed
  • testsnew
  • conftest.pynew
  • data.sqlnew
  • factories.pynew
  • test_factory.pynew
  • test_db.pynew
  • test_auth.pynew
  • test_blog.pynew
  • test_services.pynew
  • test_models.pynew
  • test_cli.pynew
  • test_api.pynew
  • MANIFEST.innew
  • migrationsnew
  • alembic.ininew
  • env.pynew
  • script.py.makonew
  • READMEnew
  • .flaskenvnew
  • .envnew, not committed
  • .env.examplenew
  • compose.yamlnew
  • make_celery.pynew
  • .vscodenew
  • settings.jsonnew
  • launch.jsonnew
  • .editorconfignew
  • .pre-commit-config.yamlnew
  • Makefilenew
  • htmlcov…new, not committed
  1. # Flask has no generator: create the folder and project file with uv

    uv init --bare flask-tutorial && cd flask-tutorial && git init && uv python pin 3.14
  2. # Add Flask and create the package folders from the tutorial

    uv add flask && mkdir -p flaskr/templates flaskr/static tests
  3. # Create the tutorial database and run the dev server

    uv run flask --app flaskr init-db && uv run flask --app flaskr run --debug
  4. # Add the database layer, forms and the API when the app grows

    uv add flask-sqlalchemy flask-migrate "psycopg[binary]" flask-wtf flask-smorest python-dotenv
  5. # Create the migrations folder and the first migration

    uv run flask db init && uv run flask db migrate -m "initial" && uv run flask db upgrade
  6. # Add test and lint tools

    uv add --dev pytest pytest-cov factory-boy ruff mypy pre-commit
  7. # Add the production server and protection

    uv add gunicorn flask-limiter redis sentry-sdk