Skip to content

Latest commit

 

History

History
142 lines (90 loc) · 2.46 KB

File metadata and controls

142 lines (90 loc) · 2.46 KB

FastAPI Project Template

This project uses FastAPI as the web framework, Celery for background tasks, and PostgreSQL as the default database, with Poetry as the dependency manager.


🛠 Local Development Guide

📦 Requirements

  • Python 3.13
  • Poetry (with export plugin)
  • PostgreSQL (or your preferred DB, configured in .env)

🚀 Setup

# Clone the repo and navigate into the project directory
git clone <your-repo-url>
cd fastapi_template

# Install dependencies using Poetry
poetry install

# Activate the virtual environment
poetry shell

# Copy and edit environment variables
cp .env.example .env

Optional IDE

In docs you can find debugger config to run and debug the app vscode-example-launch.json rename it and put in .vscode folder, so it looks like this .vscode/launch.json


🛋 Linting & Code Formatting

Run linters:

make lint

Auto-fix formatting:

make lint-fix

Includes black, isort, flake8, and optionally ruff.


📦 Export requirements.txt

To export all current dependencies to requirements.txt:

make export-req

Uses:

poetry export -f requirements.txt --with dev --without-hashes -o requirements.txt

📃 Database Migrations (Alembic)

Apply latest migrations:

make migrate

Create new migration:

make migration

Rollback last migration:

make migration-downgrade

🧼 Pre-commit Hooks

Install hooks:

pre-commit install

They will run automatically before each commit. You can also run manually:

pre-commit run --all-files

🚜 Gitflow Workflow

Use three main branches:

  • main: production-ready code
  • dev: ongoing development
  • staging: optional pre-production validation

Branch naming:

  • feature/<task_number_or_explanation>

  • fix/<bug_name>

  • hotfix/<critical_issue>

  • Branches are created from main if independent,

  • or from dev/staging if they depend on ongoing work.

For release preparation:

  • Create release/v.<number> branches and merge tasks into it.

Pull Requests:

  • Must target appropriate branch (dev, staging, or main)
  • Include a reviewer
  • Add a link to task in Jira or similar, or a clear description
  • Commits should be modular and descriptive (even small changes deserve commits)