A command-line tool to generate FastAPI project scaffolds with various database, message broker, and deployment options.
Link to the pyPI package: scaffold-fastapi
- 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
uv
for virtual environments and package 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
# 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
--db
: Database type (postgresql, mongodb, sqlite)--broker
: Message broker (redis, rabbitmq)--stack
: Deployment stack (minimal, full, serverless)
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
# 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 .
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
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
)
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
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
MIT