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:
- Use CoreSettings for shared BRIXTA infrastructure configuration.
- Use create_database() for the SQLAlchemy engine/session factory.
- Make application ORM models inherit from brixta_core.Base.
- Reuse UUIDPrimaryKeyMixin and TimestampMixin instead of recreating those columns.
- Add RequestIDMiddleware to FastAPI services.
- Add SecurityHeadersMiddleware; only enable HSTS on HTTPS production deployments.
- Do not use Base.metadata.create_all() as the production migration strategy.
- Do not invent brixta-core APIs not listed above.
- Domain/business logic stays in the consuming application.
- 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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e552c91d0b30519c44b8c1eef2035f5267cf61d2da8f0b46b4b3ff25838b690
|
|
| MD5 |
0fbf5d7b58edd245f0b8baa341b80c3f
|
|
| BLAKE2b-256 |
0ffb7d79ef10a3a7eac509bd2297c805464026d2bcb47a5530f8b9a7b69b0d66
|
Provenance
The following attestation bundles were made for brixta_core-0.1.3.tar.gz:
Publisher:
release.yml on habibieebhy/brixtafoundation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
brixta_core-0.1.3.tar.gz -
Subject digest:
5e552c91d0b30519c44b8c1eef2035f5267cf61d2da8f0b46b4b3ff25838b690 - Sigstore transparency entry: 2396695910
- Sigstore integration time:
-
Permalink:
habibieebhy/brixtafoundation@5f95555f83d68af33fbe03eaf24b4e721ceb4e83 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/habibieebhy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5f95555f83d68af33fbe03eaf24b4e721ceb4e83 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25987d420a4f2bdc4a7c85915a42fbfaa1dcf199206627d2467dd61b0d784c4d
|
|
| MD5 |
5a173ab6b04545364195f6f422c6e947
|
|
| BLAKE2b-256 |
7422b2cda092d2ddf642a332a14a9655a20912a69b88ef0cae49fda01fcb2357
|
Provenance
The following attestation bundles were made for brixta_core-0.1.3-py3-none-any.whl:
Publisher:
release.yml on habibieebhy/brixtafoundation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
brixta_core-0.1.3-py3-none-any.whl -
Subject digest:
25987d420a4f2bdc4a7c85915a42fbfaa1dcf199206627d2467dd61b0d784c4d - Sigstore transparency entry: 2396695953
- Sigstore integration time:
-
Permalink:
habibieebhy/brixtafoundation@5f95555f83d68af33fbe03eaf24b4e721ceb4e83 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/habibieebhy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5f95555f83d68af33fbe03eaf24b4e721ceb4e83 -
Trigger Event:
push
-
Statement type: