Skip to main content

A CLI tool to scaffold FastAPI projects with database and migration support

Project description

fastapi-create

A command-line tool to quickly scaffold a FastAPI project with pre-configured database support, migrations, and essential setup files.

Features

  • Project Structure Creation: Generates a clean, organized FastAPI project layout.
  • Database Configuration: Supports both synchronous (e.g., SQLAlchemy) and asynchronous (e.g., asyncpg) database setups.
  • Alembic Integration: Sets up Alembic for database migrations with a customizable folder name.
  • Dependency Management: Automatically installs required dependencies based on your database choice.
  • Configuration Files: Creates core configuration files and a .env for environment variables.
  • Main Application Setup: Generates a main.py tailored to your database threading choice.
  • Utility Scripts: Adds a manage.py for project management tasks.
  • Documentation: Includes a basic README.md and requirements.txt in the generated project.

Planned Features (Coming Soon):

  • Support for additional database engines (e.g., MongoDB).
  • Pre-built API route templates.
  • Testing framework integration (e.g., pytest).

Installation

  • Create a new virtual environment:
python -m venv venv
  • Activate the virtual environment:

  • Windows: venv\Scripts\activate

  • macOS/Linux: source venv/bin/activate

  • Upgrade pip

python -m pip install --upgrade pip
  • Install fastapi-create globally using pip:
pip install fastapi-create

Ensure you have Python 3.8+ installed.

Usage

To create a new FastAPI project, run:

fastapi-create my_project

What Happens Next?

  1. Project Name Validation: Ensures your project name is valid (e.g., no special characters).
  2. Database Setup: Prompts you to choose a database dependency (e.g., SQLAlchemy, asyncpg) and provide a database URL.
  3. Alembic Configuration: Asks for a folder name for Alembic migrations (defaults to alembic if unspecified).
  4. Project Generation: Sets up the project structure, installs dependencies, and configures all necessary files.

Example:

fastapi-create create my_project
# Follow prompts:
# - Database dependency: SQLAlchemy
# - Database URL: sqlite:///my_project.db
# - Alembic folder name: migrations

Generated Project Structure

After running the command, your project will look like this:

my_project/
├── app/
│   ├── core/
│   │   ├── config.py      # Core configuration (e.g., environment variables)
│   │   └── __init__.py
│   ├── db/
│   │   ├── config.py      # Database connection setup
│   │   ├── init_db.py     # Database initialization
│   │   ├── models.py      # Database models
│   │   └── __init__.py
│   ├── routes/            # API routes (to be expanded)
│   │   └── __init__.py
│   ├── schemas/           # Pydantic schemas (to be expanded)
│   │   └── __init__.py
│   ├── lifespans.py       # Application lifespan events
│   ├── main.py            # FastAPI app entry point
│   └── __init__.py
├── migrations/            # Alembic migrations folder (name customizable)
├── .env                   # Environment variables (e.g., DATABASE_URL)
├── manage.py             # Management script
├── README.md             # Project-specific README
└── requirements.txt      # Project dependencies

Configuration

Edit the .env file in your generated project to customize settings, such as:

DATABASE_URL=sqlite:///my_project.db

Contributing

We’d love for the FastAPI community to help improve fastapi-create! Check out CONTRIBUTING.md for guidelines on how to get involved.

License

This project is licensed under the MIT License. See LICENSE for details.

Acknowledgments

  • FastAPI - The amazing web framework powering this tool.
  • Alembic - For database migration support.
  • Typer - For building the CLI interface.

Contact

Questions or feedback? Reach out via email or GitHub - OluwaFavour.

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_create-0.1.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

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

fastapi_create-0.1.0-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_create-0.1.0.tar.gz.

File metadata

  • Download URL: fastapi_create-0.1.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for fastapi_create-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cc1bbed49cb317ddeddea350d46beae75d397cc62e3a5b50bb971f2cde850a83
MD5 bfbe9f85f889cc45056e9e686bc892f1
BLAKE2b-256 8989c237d3dc67cfcc427d002f3dfaf764fee378667a98f66278c69714b78e34

See more details on using hashes here.

File details

Details for the file fastapi_create-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fastapi_create-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for fastapi_create-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 161d57d6efbcfdc81bce15fee21421f42046a99a947c0fcdbc06ed36fe9fb3da
MD5 eeeca8bdba936181e8b8018d9f8460ff
BLAKE2b-256 098a5f9d81c2316cd5f34b31e1db4b63bc853d62ee28a021e91230fce0d9f04f

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