Skip to main content

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

# generating graphql schemas with transitions

graphql gen:crud-api <module-name> --model ModelName --with-transition

๐Ÿ“ฆ 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast_backend_builder-0.1.3.35.tar.gz (71.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fast_backend_builder-0.1.3.35-py3-none-any.whl (91.2 kB view details)

Uploaded Python 3

File details

Details for the file fast_backend_builder-0.1.3.35.tar.gz.

File metadata

  • Download URL: fast_backend_builder-0.1.3.35.tar.gz
  • Upload date:
  • Size: 71.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for fast_backend_builder-0.1.3.35.tar.gz
Algorithm Hash digest
SHA256 9745e3788a78bdd993348fe7d8f76e0bfdfd3bc88a01dadb0280006ad99f4c14
MD5 6a7558bd19c9128dec5261eec92c1d12
BLAKE2b-256 98b9097796abf94808b8f7f8f0323b655c2dd0dfbaefe1e52dd8c6898b546cb8

See more details on using hashes here.

File details

Details for the file fast_backend_builder-0.1.3.35-py3-none-any.whl.

File metadata

File hashes

Hashes for fast_backend_builder-0.1.3.35-py3-none-any.whl
Algorithm Hash digest
SHA256 5fcc792a8ab4a1917aa1e275414f2e98c5b4aabe341786e9e1d0bfe4225cd019
MD5 797fc92fb147f316e5d3d7496232a640
BLAKE2b-256 5e179ea84112d43cf8d0da23291375a9ea1a70dae1b9b68f42312db7ab96256c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page