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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| app_platform-0.9.0.tar.gz | 79.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| app_platform-0.9.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 177.0 kB
Release files / app_platform-0.9.0.tar.gz
| Download URL | app_platform-0.9.0.tar.gz |
|---|---|
| Size | 79.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2657f1c03b531f151238800fcf05f5e9dd02037c4980451e3bf6d1c86c88c665
|
|
BLAKE2b-256 checksum How to use checksums |
2680323c8f1982d969174d8e0cc041d4a743c42025b3f0cd7f2fa2b796af3ca5
|
| 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.0-py3-none-any.whl
| Download URL | app_platform-0.9.0-py3-none-any.whl |
|---|---|
| Size | 97.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3916f3e6253fb446d7bcbf4606dc43ab236246ba5dd8b4cb436fcb30364357c5
|
|
BLAKE2b-256 checksum How to use checksums |
63545d7acd6a3d4afadaa9a7973a44b5780e25b4b132f193b31730384ea34b80
|
| 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.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.
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.