Skip to main content

Backlooms

Backlooms is a modular Python framework designed for building robust microservices with a strong focus on background workers, dependency injection, and seamless integration with FastAPI and SQLAlchemy.

It provides a structured way to manage your application's lifecycle, configuration, and command-line interface.

Key Features

  • Application Orchestration: A central Application class to wire up configuration, dependency injection, workers, and server adapters.
  • Dependency Injection: Effortless DI powered by dependency-injector, with automatic module wiring and a convenient @inject decorator.
  • Background Workers: A standardized way to define long-lived background tasks with graceful shutdown and lifecycle management.
  • FastAPI Integration: Out-of-the-box support for FastAPI via a dedicated server adapter.
  • Database Layer: Built-on top of SQLAlchemy and SQLModel, providing a clean Repository pattern and migration support (via Alembic).
  • Flexible Auth: Modular authentication system supporting JWT, Bearer tokens, and password-based login.
  • Async CLI: Unified command-line interface based on Typer, with native support for async commands.

Installation

pip install backlooms

Note: Depending on your needs, you might want to install extra dependencies:

pip install "backlooms[db]"       # For database support
pip install "backlooms[fastapi]"  # For FastAPI integration
pip install "backlooms[full]"     # For all features

Quick Start

1. Define Configuration

from backlooms import BaseConfig

class MyConfig(BaseConfig):
    PROJECT_NAME: str = "My Microservice"
    DATABASE_URL: str = "postgresql+asyncpg://user:pass@localhost/db"

2. Set Up Dependency Injection

from backlooms import DIContainer, inject
from dependency_injector import providers
from dependency_injector.wiring import Provide

class MyContainer(DIContainer):
    # Your services and repositories go here
    # config is automatically available as a provider
    pass

@inject
async def my_function(service = Provide[MyContainer.my_service]):
    await service.do_something()

3. Create a Background Worker

from backlooms.workers import BaseWorker
from contextlib import asynccontextmanager

class MyWorker(BaseWorker):
    NAME = "my-worker"
    DESCRIPTION = "Does important background work"

    @asynccontextmanager
    async def lifespan(self):
        print("Worker starting...")
        yield self
        print("Worker stopping...")

4. Run the Application

from backlooms import Application
from backlooms.workers import WorkerRegistry
from backlooms.server.adapters.fastapi import FastAPIServerAdapter
from fastapi import APIRouter

# Setup workers
registry = WorkerRegistry()
registry.add(MyWorker)

# Setup server
router = APIRouter()
adapter = FastAPIServerAdapter(router=router, host="0.0.0.0", port=8000)

app = Application(
    config=MyConfig(),
    container_cls=MyContainer,
    workers=registry,
    server_adapter=adapter
)

if __name__ == "__main__":
    app.run()

CLI Usage

Backlooms automatically generates a CLI for your application.

  • Run a specific worker:

    python main.py run my-worker
    
  • Start server and all workers:

    python main.py start
    
  • Start only the server:

    python main.py start --server-only
    
  • Selective workers:

    python main.py start --without-my-worker
    

Database & Repositories

Backlooms encourages the use of the Repository pattern.

from backlooms.db import BaseRepository
from sqlmodel import SQLModel, Field

class User(SQLModel, table=True):
    id: int = Field(default=None, primary_key=True)
    username: str

class UserRepository(BaseRepository[User, None]):
    model = User

Authentication

The framework provides an IdentityManager to handle multiple authentication providers.

from backlooms.auth import IdentityManager
from backlooms.auth.providers.password import PasswordProvider

# Register providers in your container
identity_manager = IdentityManager(
    auth_service=...,
    user_service=...,
    providers=[PasswordProvider()]
)

Metadata

Release files for backlooms 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for backlooms 0.1.0
File Size Uploaded Provenance
backlooms-0.1.0.tar.gz 64.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for backlooms 0.1.0
File Interpreter ABI Platform
backlooms-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 154.1 kB

Release files / backlooms-0.1.0.tar.gz

Download URL backlooms-0.1.0.tar.gz
Size 64.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b53fb4a182a0471cb366a3e49982f5934a776c54bef7d6485f6172f3bb00ccb6
BLAKE2b-256 checksum
How to use checksums
fe826372934fa8139123fd3a27df55c4cda371e9c4c59857f26d783096984e34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 25, 2026.

Transparency log

Release files / backlooms-0.1.0-py3-none-any.whl

Download URL backlooms-0.1.0-py3-none-any.whl
Size 89.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
436bce4970be86eec21a156b068a9d2fa3fe31e9b28ba94176ac8fdeb1996784
BLAKE2b-256 checksum
How to use checksums
ec47aa8237308c659bb5d9f15fac009f4db48fc03ec79ef7d8ae8d887ccb66fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 25, 2026.

Transparency log

Security for backlooms 0.1.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for backlooms-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 25, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page