Skip to main content

app-platform

Generic web app infrastructure for PostgreSQL pooling, structured logging, auth, middleware, and gateway proxying.

Installation

pip install "app-platform[all]"
pip install "app-platform[fastapi]"
pip install "app-platform[fastapi,auth-google]"
pip install "app-platform[fastapi,gateway]"

import app_platform eagerly re-exports db, logging, and middleware, and middleware is FastAPI-side, so the fastapi extra is the minimum supported install. A bare pip install app-platform installs the package without those runtime dependencies and is not a supported configuration.

Included subpackages

Subpackage Provides
db PostgreSQL connection pooling, pooled session helpers, migrations, and database exception utilities
logging Structured file and JSONL logging, context helpers, logger access, and decorators for timing/error instrumentation
middleware FastAPI middleware configuration for rate limiting, sessions, CORS, and validation/error handling
auth Pluggable auth service base with in-memory and PostgreSQL-backed user/session stores
gateway FastAPI router factory for proxying chat and tool approval requests to an upstream gateway

Quick usage

Database

import os

from app_platform.db import PoolManager, get_db_session

os.environ["DATABASE_URL"] = "postgresql://postgres:postgres@localhost:5432/app"

pool_manager = PoolManager(min_connections=2, max_connections=10)
pool_manager.get_pool()

with get_db_session() as conn:
    with conn.cursor() as cursor:
        cursor.execute("SELECT 1 AS ok")
        print(cursor.fetchone())

pool_manager.close()

Logging

from app_platform.logging import (
    LoggingManager,
    configure_logging,
    log_errors,
    log_operation,
    log_timing,
)

logging_manager: LoggingManager = configure_logging(app_name="orders", log_dir="./logs")
logger = logging_manager.get_logger("service")

@log_errors()
@log_timing(threshold_s=0.25)
@log_operation("create_order")
def create_order(order_id: str) -> None:
    logger.info("creating order %s", order_id)


create_order("ord_123")

Auth

from app_platform.auth import AuthServiceBase, InMemorySessionStore, InMemoryUserStore

users = {}
sessions = {}

auth = AuthServiceBase(
    session_store=InMemorySessionStore(users_dict=users, sessions_dict=sessions),
    user_store=InMemoryUserStore(users_dict=users),
)

session_id = auth.create_user_session(
    {
        "google_user_id": "user-123",
        "email": "user@example.com",
        "name": "Example User",
    }
)

print(auth.get_user_by_session(session_id))

Gateway

from fastapi import FastAPI

from app_platform.gateway import GatewayConfig, create_gateway_router

app = FastAPI()


def get_current_user():
    return {"user_id": "user-123", "email": "user@example.com"}


gateway_router = create_gateway_router(
    GatewayConfig(
        gateway_url="https://gateway.example.com",
        api_key="gateway-api-key",
        channel="web",
    ),
    get_current_user=get_current_user,
)

app.include_router(gateway_router, prefix="/gateway")

Requirements

Python 3.11+

License

MIT

Metadata

Release files for app-platform 0.9.1

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

Source distribution (sdist)

Source distribution for app-platform 0.9.1
File Size Uploaded Provenance
app_platform-0.9.1.tar.gz 79.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for app-platform 0.9.1
File Interpreter ABI Platform
app_platform-0.9.1-py3-none-any.whl Python 3 none any Details

Total release size: 177.0 kB

Release files / app_platform-0.9.1.tar.gz

Download URL app_platform-0.9.1.tar.gz
Size 79.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c04ddc41e546be4758a52e58bb3ce0f75fe4a44226dcb52ae62c5ae43ee388e3
BLAKE2b-256 checksum
How to use checksums
b7c8fb1e91cc6b8cca5621294d0be0f8651f8db0bc7112374c711c9afc43a83a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / app_platform-0.9.1-py3-none-any.whl

Download URL app_platform-0.9.1-py3-none-any.whl
Size 97.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
beb631f9d50d90f00f0baa34547af1fff3de5c671433692be90bdf38df58147f
BLAKE2b-256 checksum
How to use checksums
894b726f1f09a6de1d888a87e3861e2e5c5ed4f94e622bcabb64dd2356a455a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Security for app-platform 0.9.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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