Skip to main content

An interactive CLI tool that scaffolds production-ready FastAPI projects with sensible defaults.

Project description

FastAPI Initializer

PyPI version Python License

An interactive CLI tool that scaffolds production-ready FastAPI projects with sensible defaults - so you can skip the boilerplate and start building right away.


โœจ What Does It Do?

Run a single command, answer a few prompts, and get a fully structured FastAPI project with:

  • ๐Ÿ—‚๏ธ Clean project layout - api/, core/, models/, schemas/, services/
  • ๐Ÿ—ƒ๏ธ Database support - SQLite, MySQL, or PostgreSQL
  • ๐Ÿ”ง ORM of your choice - SQLAlchemy or SQLModel
  • ๐Ÿงช Testing setup - pytest / pytest-asyncio with httpx, ready to go
  • ๐Ÿงน Linter config - Black or Ruff
  • ๐Ÿณ Docker ready - optional Dockerfile & docker-compose.yml
  • โš™๏ธ Environment config - pydantic-settings with .env support
  • ๐Ÿ“– Documentation - every folder gets a README explaining its purpose

๐Ÿ“ฆ Installation

Install from PyPI

pip install fastapi-initializer

Or with uv:

uv pip install fastapi-initializer

Install from Source (for development)

# Clone the repository
git clone https://github.com/DasunNethsara-04/fastapi-initializer.git
cd fastapi-initializer

# Create a virtual environment and install dependencies
uv sync

# Run the CLI directly
uv run fastapi-init my-project

๐Ÿš€ Usage

fastapi-init my-project

You'll be guided through interactive prompts:

โฏ FastAPI Initializer
Creating project: my-project

โฏ What kind of database do you want to use?
  > SQLite / MySQL / PostgreSQL / None

โฏ Which ORM do you want to use?
  > SQLAlchemy / SQLModel / None

โฏ What linter do you want to use?
  > Ruff / Black / None

โฏ What testing framework do you like to use?
  > PyTest / pytest-async-io / None

โฏ Do you want to create a Docker file for this project?
  > Yes / No

โœ” FastAPI project 'my-project' created successfully!

Then get started in seconds:

cd my-project
uv sync
uv run uvicorn app.main:app --reload

Open http://127.0.0.1:8000/docs to see the interactive API docs.


Screenshorts

Screenshot 2026-02-27 163615 Screenshot 2026-02-27 163832 Screenshot 2026-02-27 163848 Screenshot 2026-02-27 163910 Screenshot 2026-02-27 164031 Screenshot 2026-02-27 164114

๐Ÿ“ Generated Project Structure

The generated project follows a modular, production-style layout:

my-project/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ”œโ”€โ”€ v1/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ users.py            # User endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py              # Mounts versioned routers
โ”‚   โ”‚   โ””โ”€โ”€ deps.py                  # Shared dependencies (e.g. auth)
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ config.py                # App settings via pydantic-settings
โ”‚   โ”‚   โ””โ”€โ”€ security.py              # OAuth2 / auth utilities
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ””โ”€โ”€ user.py                  # ORM model (SQLAlchemy / SQLModel)
โ”‚   โ”œโ”€โ”€ schemas/
โ”‚   โ”‚   โ””โ”€โ”€ user.py                  # Pydantic request / response models
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ””โ”€โ”€ user_service.py          # Business logic layer
โ”‚   โ”œโ”€โ”€ db/
โ”‚   โ”‚   โ”œโ”€โ”€ base.py                  # ORM Base class
โ”‚   โ”‚   โ””โ”€โ”€ session.py               # Engine & get_session() dependency
โ”‚   โ””โ”€โ”€ main.py                      # FastAPI app entry-point
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_users.py                # Smoke test with httpx
โ”œโ”€โ”€ .env                             # Environment variables
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ Dockerfile                       # (optional)
โ”œโ”€โ”€ docker-compose.yml               # (optional)
โ””โ”€โ”€ README.md                        # Auto-generated project docs

Note: Folders like models/, db/, tests/, and Docker files are only generated when you select the corresponding options.

What Each Folder Does

Folder Purpose
app/api/ HTTP route definitions, versioned (v1/, v2/, โ€ฆ).
app/core/ App-wide settings (Settings class) and security helpers.
app/models/ ORM model classes mapped to database tables.
app/schemas/ Pydantic models for request validation and response serialisation.
app/services/ Business-logic layer โ€” keeps route handlers thin and testable.
app/db/ Database engine, session factory, and get_session() dependency.
tests/ Automated test suite using pytest + httpx.

๐Ÿ› ๏ธ Configuration Options

Prompt Choices What It Generates
Database SQLite, MySQL, PostgreSQL, None app/db/session.py with connection URL and driver dependency
ORM SQLAlchemy, SQLModel, None app/models/ with model classes and app/db/base.py
Linter Ruff, Black, None Adds the linter to pyproject.toml dependencies
Test framework pytest, pytest-asyncio, None tests/ directory with async smoke test
Docker Yes, No Dockerfile, docker-compose.yml, .dockerignore

๐Ÿค Contributing

Contributions are welcome! Here's how to get started:

# 1. Fork and clone
git clone https://github.com/DasunNethsara-04/fastapi-initializer.git
cd fastapi-initializer

# 2. Install dependencies
uv sync

# 3. Make your changes, then test
uv run fastapi-init test-project

# 4. Submit a pull request

๐Ÿ“„ License

This project is licensed under the MIT License.


๐Ÿ™ Acknowledgements

Built with:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_initializer-1.0.1.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_initializer-1.0.1-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_initializer-1.0.1.tar.gz.

File metadata

  • Download URL: fastapi_initializer-1.0.1.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fastapi_initializer-1.0.1.tar.gz
Algorithm Hash digest
SHA256 fd129d6b46d2c99c350bb5810a1ee1f6578cc8dd25a94c5c5b99b5a1e8aa56cf
MD5 260766bba3eb6fb18e4012f10cbb20e3
BLAKE2b-256 de14688570173f4cbb321a5e53b899c2ef893d4353950ac1d59ec8aaa0fc3141

See more details on using hashes here.

File details

Details for the file fastapi_initializer-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: fastapi_initializer-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fastapi_initializer-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d5cc3778d27f27577df294b4629e28271b20a5ea9e8e2680e7c676c12e0769de
MD5 0a716b128b580269e5e45308b6444b8a
BLAKE2b-256 4c8cf79e3b6df857c43d685c5720e23cc426cf8611e5e91881b5f3a0a3680257

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page