FastAPI Project Scaffolder
A command-line tool to generate FastAPI project scaffolds with various database, message broker, and deployment options.
Read the full article on DEV.
Link to the pyPI package: scaffold-fastapi
Features
- Database Support: PostgreSQL, MongoDB, SQLite
- Message Broker: Redis, RabbitMQ
- Deployment Stacks: Minimal, Full (AWS ECS), Serverless
- Production-Ready: Docker, Terraform, Helm charts
- Dependency Management: Uses
uvfor virtual environments and package installation
Installation
# Install from PyPI
pip install scaffold-fastapi
# Or using uv
uv pip install scaffold-fastapi
# Or using Docker
docker run --rm -it ghcr.io/kenmwaura1/scaffold-fastapi:latest --help
Usage
# Basic usage
scaffold-fastapi my-project --db=postgresql --broker=redis --stack=full
# Interactive mode (will prompt for missing options)
scaffold-fastapi my-project
# Using Docker with volume mount to create project in current directory
docker run --rm -it -v $(pwd):/workspace -w /workspace ghcr.io/kenmwaura1/scaffold-fastapi:latest my-project
Command Options
--db: Database type (postgresql, mongodb, sqlite)--broker: Message broker (redis, rabbitmq)--stack: Deployment stack (minimal, full, serverless)
Project Structure
The generated project will have the following structure:
my-project/
├── app/
│ ├── api/
│ │ └── v1/
│ ├── core/
│ ├── db/
│ ├── models/
│ ├── schemas/
│ └── main.py
├── tasks/
│ ├── celery_app.py
│ └── sample_tasks.py
├── infra/
│ ├── docker/
│ ├── terraform/
│ └── helm/
├── tests/
├── .env
├── .env.example
├── Dockerfile
├── docker-compose.yml
└── requirements.txt
Development
# Clone the repository
git clone https://github.com/KenMwaura1/scaffold-fastapi.git
cd scaffold-fastapi
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black .
isort .
CI/CD
This project uses GitHub Actions for:
- Python Tests: Runs tests on Python code, including formatting, linting, and unit tests
- Docker Compose Testing: Validates and tests the generated Docker Compose files
- Container Publishing: Builds and publishes Docker images to GitHub Container Registry
- PyPI Publishing: Automatically publishes to PyPI when pushing to main or creating a tag
- Dependency Updates: Weekly checks and updates dependencies
Publishing to PyPI
To publish this package to PyPI, you need to:
- Create a PyPI API token (see pypi_instructions.md)
- Add the token to GitHub Secrets as
PYPI_API_TOKEN - Push to main or create a tag starting with
v(e.g.,v0.1.0)
Using the Docker Image
The Docker image is published to GitHub Container Registry and can be used as follows:
# Pull the latest image
docker pull ghcr.io/kenmwaura1/scaffold-fastapi:latest
# Create a new project
docker run --rm -it -v $(pwd):/workspace -w /workspace ghcr.io/kenmwaura1/scaffold-fastapi:latest my-project
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT
Metadata
Release files for scaffold-fastapi 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| scaffold_fastapi-0.1.7.tar.gz | 10.0 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| scaffold_fastapi-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.0 MB
Release files / scaffold_fastapi-0.1.7.tar.gz
| Download URL | scaffold_fastapi-0.1.7.tar.gz |
|---|---|
| Size | 10.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec43ba50f80ad0c015166c628863d8897dbe0a92dca5434055765ab0abfdfd77
|
|
BLAKE2b-256 checksum How to use checksums |
169648a35b54795267f44963fcf651bb582043ff6d07b52c19fa00719a3c5c53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / scaffold_fastapi-0.1.7-py3-none-any.whl
| Download URL | scaffold_fastapi-0.1.7-py3-none-any.whl |
|---|---|
| Size | 20.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
133b85f352f3e90214ea961c4890742d5f8479b1a265abb86daff9e46035b32e
|
|
BLAKE2b-256 checksum How to use checksums |
cd74c521bbf7dc65435ea481933b77bed2860b6afd04fe876c0fa05c7fce0abd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for scaffold-fastapi 0.1.7
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.