Skip to main content

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 fastapi-initializer as a global CLI tool — no virtual environment needed. Just install once and use the fastapi-init command from anywhere, just like uv, pip, or ruff.

Using pipx:

pipx install fastapi-initializer

Or using uv:

uv tool install fastapi-initializer

Alternative: Install with pip

If you prefer a traditional install inside a virtual environment:

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:

Metadata

Release files for fastapi-initializer 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastapi-initializer 1.0.2
File Size Uploaded Provenance Actions
fastapi_initializer-1.0.2.tar.gz 16.0 kB Without provenance Details for fastapi_initializer-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-initializer 1.0.2
File Interpreter ABI Platform Actions
fastapi_initializer-1.0.2-py3-none-any.whl Python 3 none any Details for fastapi_initializer-1.0.2-py3-none-any.whl

Total release size: 40.9 kB

Release files / fastapi_initializer-1.0.2.tar.gz

Download URL fastapi_initializer-1.0.2.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
332ebccf24de51aa079682d32166aac7646f7a7e41243e4a1be817fa60ae7d0c
BLAKE2b-256 checksum
How to use checksums
4398901c35a5e327c85c55f5d4a9dc5d7dda439e6ed720a1504442bf57af2aac
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / fastapi_initializer-1.0.2-py3-none-any.whl

Download URL fastapi_initializer-1.0.2-py3-none-any.whl
Size 24.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42381d32244cf3a30a3bc5874fb29b08f6653cf9c474859cbeb939af45cbe033
BLAKE2b-256 checksum
How to use checksums
71a0f23733efe24308abadf2a752d0b38cb04ad6e548b469232d1c97e6cbcba7
Upload date
Uploaded using Trusted Publishing?
What is 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}

Security for fastapi-initializer 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page