fastapi-scaffold is a CLI tool that generates a scalable FastAPI project template with advanced features including authentication, machine learning endpoints, background tasks, caching, rate limiting, and more.
Install the CLI tool via pip:
pip install fastapi-scaffold
To create a new project, run:
fastapi-scaffold create my_project
This command generates a new project with optional features:
--ml
β Includes machine learning endpoints and model setup.--db
β Adds database configuration and ORM setup.--auth
β Includes authentication endpoints.--docker
β Generates Dockerfile and docker-compose.yml for container support.
Example:
fastapi-scaffold create my_project --ml --db --auth --docker
After generating your project, navigate into the project directory and install dependencies:
fastapi-scaffold install
Alternatively, run:
pip install -r requirements.txt
To delete a project directory, use:
fastapi-scaffold delete my_project
A generated project will have the following structure:
my_project/
βββ app/
β βββ api/
β β βββ __init__.py
β β βββ users.py
β β βββ items.py
β β βββ admin.py
β β βββ ml.py
β β βββ health.py
β βββ schemas/
β β βββ __init__.py
β β βββ user.py
β β βββ item.py
β β βββ ml.py
β β βββ stats.py
β βββ models/
β β βββ __init__.py
β β βββ user.py
β β βββ item.py
β β βββ ml_model.pkl
β βββ crud/
β β βββ __init__.py
β β βββ user.py
β β βββ item.py
β β βββ stats.py
β βββ services/
β β βββ __init__.py
β β βββ auth.py
β β βββ tasks.py
β β βββ ml.py
β βββ utils/
β β βββ __init__.py
β β βββ dependencies.py
β β βββ cache.py
β β βββ rate_limit.py
β βββ middleware.py
β βββ database.py
β βββ auth.py
β βββ logger.py
β βββ config.py
β βββ main.py
βββ tests/
β βββ test_main.py
β βββ test_users.py
βββ .env
βββ requirements.txt
βββ Dockerfile
βββ docker-compose.yml
βββ README.md
- Navigate to the project directory:
cd my_project
- Install dependencies:
pip install -r requirements.txt
- Start the FastAPI server:
uvicorn app.main:app --reload
The API will be available at http://127.0.0.1:8000.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.