Skip to main content

brixta-core

Reusable infrastructure primitives for BRIXTA FastAPI services.

Documented API: 0.1.2Python: >=3.11

Install

python -m pip install "brixta-core==0.1.2"

Verify:

python - <<'PY' import brixta_core print(brixta_core.version) PY

Public API

from brixta_core import ( Base, CoreSettings, RequestIDMiddleware, SecurityHeadersMiddleware, TimestampMixin, UUIDPrimaryKeyMixin, create_database, new_uuid, )

API

Purpose

CoreSettings

BRIXTA configuration from environment variables / .env

create_database()

SQLAlchemy engine + session factory

Base

Shared SQLAlchemy declarative base

UUIDPrimaryKeyMixin

Adds UUID id

TimestampMixin

Adds created_at / updated_at

new_uuid()

New UUID4

RequestIDMiddleware

Adds/preserves X-Request-ID

SecurityHeadersMiddleware

Adds baseline HTTP security headers

Configuration

from brixta_core import CoreSettings settings = CoreSettings()

Supported environment variables:

BRIXTA_ENVIRONMENT=development BRIXTA_DATABASE_URL=sqlite:///./app.db BRIXTA_CACHE_URL=redis://localhost:6379/0 BRIXTA_AUTO_CREATE_TABLES=true

Production example:

BRIXTA_ENVIRONMENT=production BRIXTA_DATABASE_URL=postgresql+psycopg://user:password@db:5432/app BRIXTA_CACHE_URL=redis://valkey:6379/0 BRIXTA_AUTO_CREATE_TABLES=false

Use migrations in production instead of automatic table creation.

Database

from brixta_core import CoreSettings, create_database

settings = CoreSettings() engine, SessionLocal = create_database(settings.database_url)

FastAPI session dependency:

from collections.abc import Iterator from sqlalchemy.orm import Session

def get_session() -> Iterator[Session]: with SessionLocal() as session: yield session

Application models

from brixta_core import Base, TimestampMixin, UUIDPrimaryKeyMixin from sqlalchemy import String from sqlalchemy.orm import Mapped, mapped_column

class Plant(UUIDPrimaryKeyMixin, TimestampMixin, Base): tablename = "plants" name: Mapped[str] = mapped_column(String(200), nullable=False)

The model gets:

id created_at updated_at

For local development:

Base.metadata.create_all(engine)

Request IDs

from fastapi import FastAPI from brixta_core import RequestIDMiddleware

app = FastAPI() app.add_middleware(RequestIDMiddleware)

Responses receive:

X-Request-ID:

Inside a route:

from fastapi import Request

@app.get("/debug") def debug(request: Request): return {"request_id": request.state.request_id}

Security headers

from brixta_core import SecurityHeadersMiddleware

app.add_middleware( SecurityHeadersMiddleware, hsts=False, )

Adds baseline headers including:

X-Content-Type-Options: nosniff X-Frame-Options: DENY Referrer-Policy: no-referrer Permissions-Policy: camera=(), microphone=(), geolocation=()

For HTTPS production only:

app.add_middleware(SecurityHeadersMiddleware, hsts=True)

Minimal service

from contextlib import asynccontextmanager from fastapi import FastAPI

from brixta_core import ( Base, CoreSettings, RequestIDMiddleware, SecurityHeadersMiddleware, create_database, )

settings = CoreSettings() engine, SessionLocal = create_database(settings.database_url)

@asynccontextmanager async def lifespan(app: FastAPI): if settings.auto_create_tables: Base.metadata.create_all(engine) yield engine.dispose()

app = FastAPI(lifespan=lifespan) app.add_middleware(RequestIDMiddleware) app.add_middleware( SecurityHeadersMiddleware, hsts=settings.environment.casefold() == "production", )

What brixta-core does NOT do

It does not provide authentication, login UI, users, roles, CRUD generation, app migrations, cement-domain logic, or frontend components.

LLM IMPLEMENTATION CONTRACT

Copy this into an LLM prompt:

Use brixta-core as an installed dependency. Do not copy its source into the application.

Prefer only these public APIs: Base CoreSettings RequestIDMiddleware SecurityHeadersMiddleware TimestampMixin UUIDPrimaryKeyMixin create_database new_uuid

Rules:

  1. Use CoreSettings for shared BRIXTA infrastructure configuration.
  2. Use create_database() for the SQLAlchemy engine/session factory.
  3. Make application ORM models inherit from brixta_core.Base.
  4. Reuse UUIDPrimaryKeyMixin and TimestampMixin instead of recreating those columns.
  5. Add RequestIDMiddleware to FastAPI services.
  6. Add SecurityHeadersMiddleware; only enable HSTS on HTTPS production deployments.
  7. Do not use Base.metadata.create_all() as the production migration strategy.
  8. Do not invent brixta-core APIs not listed above.
  9. Domain/business logic stays in the consuming application.
  10. When brixta-auth is used, share the same Base/engine/session infrastructure.

Download files

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

Source Distribution

brixta_core-0.1.3.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

brixta_core-0.1.3-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file brixta_core-0.1.3.tar.gz.

File metadata

  • Download URL: brixta_core-0.1.3.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for brixta_core-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5e552c91d0b30519c44b8c1eef2035f5267cf61d2da8f0b46b4b3ff25838b690
MD5 0fbf5d7b58edd245f0b8baa341b80c3f
BLAKE2b-256 0ffb7d79ef10a3a7eac509bd2297c805464026d2bcb47a5530f8b9a7b69b0d66

See more details on using hashes here.

Provenance

The following attestation bundles were made for brixta_core-0.1.3.tar.gz:

Publisher: release.yml on habibieebhy/brixtafoundation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file brixta_core-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: brixta_core-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for brixta_core-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 25987d420a4f2bdc4a7c85915a42fbfaa1dcf199206627d2467dd61b0d784c4d
MD5 5a173ab6b04545364195f6f422c6e947
BLAKE2b-256 7422b2cda092d2ddf642a332a14a9655a20912a69b88ef0cae49fda01fcb2357

See more details on using hashes here.

Provenance

The following attestation bundles were made for brixta_core-0.1.3-py3-none-any.whl:

Publisher: release.yml on habibieebhy/brixtafoundation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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