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
.envfor environment variables. - Main Application Setup: Generates a
main.pytailored to your database threading choice. - Utility Scripts: Adds a
manage.pyfor project management tasks. - Documentation: Includes a basic
README.mdandrequirements.txtin 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
Ensure you have Python 3.8+ installed.
- 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-createglobally using pip:
pip install fastapi-create
Usage
To create a new FastAPI project, run:
fastapi-create my_project
What Happens Next?
- Project Name Validation: Ensures your project name is valid (e.g., no special characters).
- Database Setup: Prompts you to choose a database dependency (e.g., SQLAlchemy, asyncpg) and provide a database URL.
- Alembic Configuration: Asks for a folder name for Alembic migrations (defaults to alembic if unspecified).
- Project Generation: Sets up the project structure, installs dependencies, and configures all necessary files.
Examples:
- Generates the project in the current working directory.
fastapi-create .
Should the database connection be async or sync? [async/sync] (async): async
Which database engine would you like to use? [postgresql/mysql/sqlite/mariadb] (postgresql): sqlite
Enter the path to the SQLite database file: :memory:
Enter the name of the Alembic folder (alembic): migrations
- Generates the project in a directory called test-project relative to the current working directory.
fastapi-create test-project
Should the database connection be async or sync? [async/sync] (async): async
Which database engine would you like to use? [postgresql/mysql/sqlite/mariadb] (postgresql): sqlite
Enter the path to the SQLite database file: :memory:
Enter the name of the Alembic folder (alembic): migrations
- Calling
fastapi-create [PATH]without the[PATH]prompts the user for a project name.
fastapi-create
Enter the project name: test-project
Should the database connection be async or sync? [async/sync] (async): async
Which database engine would you like to use? [postgresql/mysql/sqlite/mariadb] (postgresql): sqlite
Enter the path to the SQLite database file: :memory:
Enter the name of the Alembic folder (alembic): 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
│ ├── 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.
Release files for fastapi-create 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastapi_create-0.1.1.tar.gz | 15.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_create-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.5 kB
Release files / fastapi_create-0.1.1.tar.gz
| Download URL | fastapi_create-0.1.1.tar.gz |
|---|---|
| Size | 15.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d09c54e69243e8d11f60b63169f1be270e875edcfaacc780dc6b2b5b3736230
|
|
BLAKE2b-256 checksum How to use checksums |
3adb1586345c73899fa7ffc57e0270035ac72ad6514ece06e0acb73a6211eea6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.5
|
Release files / fastapi_create-0.1.1-py3-none-any.whl
| Download URL | fastapi_create-0.1.1-py3-none-any.whl |
|---|---|
| Size | 19.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ffc5212ba446724bad427ad910031ab2a1c1908e18b03e6ffe0f23dc2f57a8d2
|
|
BLAKE2b-256 checksum How to use checksums |
41de40b1e2013d20587c0242bd272a3c4d7ffbf8fd30649b476f86b9fff24f0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.5
|