FastAPI Builder with Tortoise ORM support
Project description
fast-backend-builder
fast-backend-builder is a project generator and manager for FastAPI with Tortoise ORM & Aerich.
๐ก FastAPI Backend Builder โ A lightweight library to help you quickly scaffold and build FastAPI projects.
๐ Overview
fast-backend-builder is designed for rapid web application development with FastAPI.
It comes bundled with tools and integrations to help developers create well-structured, maintainable, and production-ready FastAPI applications in no time.
The goal is to provide a one-stop solution to accelerate prototyping and simplify production deployment.
๐ Source Code: GitHub Repository
โจ Features
- ๐ CRUD Base with GraphQL (Strawberry) โ Auto-generate and manage CRUD endpoints with GraphQL support
- ๐ Authentication with JWT โ Built-in secure authentication and token management
- โก Redis Integration โ Caching, sessions, and queue support with Redis
- ๐ File Storage with MinIO โ Easy file upload and attachment handling
- ๐ ESB Integrations โ Simplified enterprise service bus support
- ๐ฌ BullMQ Integration โ Notifications and queue management out of the box
๐ Quick Start
Create FastAPI App for more visit https://fastapi.tiangolo.com/
โ๏ธ Installation
pip install fast-backend-builder
๐ Setting Up a Custom User Model in FastAPI with Tortoise ORM + FastAPI-Builder
This guide explains how to create a package module for your User model, extend it from AbstractUser, configure it in Tortoise ORM, and generate GraphQL + migrations.
๐ Project Structure
myapp
โโโ mymodel_package
โ โโโ __init__.py
โ โโโ models
โ โโโ user.py
โโโ config
โ โโโ __init__.py
โ โโโ tortoise.py
โโโ main.py
โโโ ...
๐ค 1. Create Your Custom User Model
Inside mymodel_package/models/user.py:
from fast_backend_builder.models.base_models import AbstractUser
class User(AbstractUser):
"""Custom application user model extending AbstractUser."""
pass
โ๏ธ 2. Set Your User Model in main.py (your main FastAPI file)
At the top of your main.py (before any model imports):
from fast_backend_builder.utils.config import set_user_model
from mymodel_package.models.user import User
# Register the User model so fast_backend_builder can resolve it
set_user_model(User, "models.User")
๐๏ธ 3. Create Tortoise ORM Config
Inside config/tortoise.py:
from decouple import config
db_url = f"postgres://{config('DB_USER')}:{config('DB_PASSWORD')}@{config('DB_HOST')}:{config('DB_PORT')}/{config('DB_NAME')}"
TORTOISE_ORM = {
"connections": {"default": db_url},
"apps": {
"models": {
"models": [
"fast_backend_builder.models", # built-in models
"mymodel_package.models", # your custom models
"aerich.models", # migration tracking
],
"default_connection": "default",
},
},
"use_tz": True, # Enable timezone-aware datetimes
"timezone": "Africa/Dar_es_Salaam", # Set to EAT (Dar es Salaam)
}
๐ง 4. Generate CRUD APIs via GraphQL
Run the following to scaffold GraphQL CRUD APIs:
# For your custom User model
graphql gen:crud-api user_management --module-package=mymodel_package.models --model User
# For fast_backend_builder built-in models
graphql gen:crud-api user_management --module-package=fast_backend_builder.models --model Group,Permission,Headship
graphql gen:crud-api workflow --module-package=fast_backend_builder.models --model Workflow,WorkflowStep,Transition,Evaluation
For your Models
#
graphql gen:crud-api <module-name> --model Model1,Model2,Model3
# generating graphql schemas with attachments
graphql gen:crud-api <module-name> --model ModelName --with-attachment
๐ฆ 5. Initialize Aerich (DB migrations)
# Initialize Aerich with your Tortoise ORM config
aerich init -t config.tortoise.TORTOISE_ORM
# Create initial migration & database tables
aerich init-db
๐ Documentation
Coming soon...
๐ค Contributing
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
๐ License
This project is licensed under the Other/Proprietary License.
Thanks
Thanks for all the contributors that made this library possible, also a special mention to Japhary Juma, Shija Ntula and Juma Nassoro.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fast_backend_builder-0.1.3.2.tar.gz.
File metadata
- Download URL: fast_backend_builder-0.1.3.2.tar.gz
- Upload date:
- Size: 69.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53f8f876fdc5fa62664ceb2cd29fb6b2ea453933cb4679b86eac5f6b61aaea3d
|
|
| MD5 |
4ccfc04613784b62c5c5cb5fc582a09c
|
|
| BLAKE2b-256 |
4592be21a87f1f095b878cef92e85a9ec85ee4e58e10c24803d9c20c52038c66
|
File details
Details for the file fast_backend_builder-0.1.3.2-py3-none-any.whl.
File metadata
- Download URL: fast_backend_builder-0.1.3.2-py3-none-any.whl
- Upload date:
- Size: 89.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85ba996ad4952546237417ffa32ea253af24c82ce5b0397098a8b89f274b60a0
|
|
| MD5 |
147882a4b67859ea2c6f8b494a98fe7d
|
|
| BLAKE2b-256 |
ed0069c7738bed1a619d9431b729e25d9ca07b9b9b153ae5bcf61834c5567342
|