Skip to main content

StaticFlow

The Unified API Gateway Framework for "God Schema" Architectures.

StaticFlow is a lightweight, high-performance Python framework designed to simplify Backend-for-Frontend (BFF) development. It enables a "Universal Gateway" pattern where the frontend communicates via a single, static JSON contract (the "God Schema"), while the gateway handles routing, data extraction, and upstream proxying.


The Problem

In modern microservice or multi-API environments, frontend applications suffer from:

  • Fragmented Requests: Needing to hit multiple diverse endpoints for a single view.
  • Breaking Contracts: Any change in an upstream API requires a frontend update.
  • Auth Complexity: Managing different authentication flows for different services.
  • Observability Gaps: Difficulty tracking a single user action across multiple downstream calls.

The Solution: StaticFlow

StaticFlow provides a unified proxy layer that "plucks" exactly what it needs from a static, massive payload (the God Schema) and forwards it to the correct upstream service. It turns your backend into a clean, predictable API for your frontend team.


Key Features

  • The God Schema Engine: Maintain one single Pydantic-based schema that never changes shape.
  • Smart Extraction: Automatically extract and validate data segments based on the request action.
  • Parallel Fan-out: Trigger multiple upstream requests in parallel (using asyncio.TaskGroup) and merge results into a single response.
  • Resilience: Built-in Exponential Backoff Retries and Circuit Breaking to prevent cascading failures.
  • Flexible Auth: Handle API Keys (Header/Body/Param), OAuth2 Client Credentials, or Passthrough with Bearer normalization.
  • Unified Auditing: Log entire request/response/error cycles as single atomic transactions to MongoDB or In-Memory.
  • Contract Generation: Automatically export your Python schema to TypeScript types for your frontend team.
  • Mocking Mode: Return mock data for specific routes to unblock frontend development.

Architecture

graph TD
    A[Frontend App] -- "1. Single POST (Static God Schema)" --> B[StaticFlow Gateway]
    B -- "2. Extract & Validate" --> C{Routing Engine}
    C -- "Internal Action" --> D[Internal Handler (Auth/Logs/DB)]
    C -- "Proxy Action" --> E[Upstream Service A]
    C -- "Proxy Action" --> F[Upstream Service B]
    B -- "3. Standardized Response" --> A
    B -. "4. Unified Audit Log" .-> G[(Audit Database)]

Quick Start

1. Install

pip install staticfloww

2. Define your Static Schema

from staticfloww import StaticPayload, Section
from typing import Optional

class UserDetails(Section):
    first_name: str
    last_name: str

class MyGodSchema(StaticPayload):
    # Data Sections for specific requests
    UserDetails: Optional[UserDetails] = None

3. Configure the Gateway

from staticfloww import Gateway, APIKeyHandler, MemoryAuditor

# Initialize with In-Memory Auditing
auditor = MemoryAuditor()
app = Gateway(base_url="https://api.your-backend.com", auditor=auditor)

app.add_route(
    action="CREATE_MEMBER",
    path="/api/members/register",
    method="POST",
    extract="UserDetails",
    auth=APIKeyHandler(key="your-secret-key", location="header")
)

4. Use in FastAPI

from fastapi import FastAPI
from my_schema import MyGodSchema

web_app = FastAPI()

@web_app.post("/gateway")
async def handle_request(payload: MyGodSchema):
    return await app.route_request(payload)

Project Structure

staticfloww/
├── core/
│   ├── engine.py      # Orchestrator (TaskGroups & Semaphores)
│   ├── gateway.py     # Main Entry point
│   ├── proxy.py       # Httpx communication
│   ├── routing.py     # Route & Action mapping
│   ├── auth.py        # APIKey, OAuth2, Passthrough
│   └── resilience.py  # Retries & Circuit Breaker
├── middleware/
│   └── auditing.py    # Memory & MongoDB logging
├── schemas/
│   └── base.py        # StaticPayload & Section definitions
└── utils/
    └── ts_gen.py      # TypeScript Generator

Future Roadmap

  • Rate Limiting: Built-in protection to prevent gateway or upstream abuse.
  • Health Dashboard: Real-time status of all upstream services and circuit states.
  • AI Scaffolding Agent: Automatically generate Pydantic schemas from Swagger/OpenAPI docs.

License

MIT License. Created for clean API architectures.

Metadata

Release files for staticfloww 0.1.10

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

Source distribution (sdist)

Source distribution for staticfloww 0.1.10
File Size Uploaded Provenance Actions
staticfloww-0.1.10.tar.gz 21.5 kB Without provenance Details for staticfloww-0.1.10.tar.gz

Built distribution (wheel)

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

Total release size: 40.1 kB

Release files / staticfloww-0.1.10.tar.gz

Download URL staticfloww-0.1.10.tar.gz
Size 21.5 kB
Tags Source
SHA-256 checksum
How to use checksums
82bc1c87c4954045a9f0c525d0133aa5ce206ab4292d847858bcac6c1198ca9c
BLAKE2b-256 checksum
How to use checksums
1a2e0c4cb0676fea74358224ebdb12624451b515478bd60ff2075253776f6f40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / staticfloww-0.1.10-py3-none-any.whl

Download URL staticfloww-0.1.10-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9efa9f6639d75d6e29cf7929b58b1ad8d729bf5fe0f17866ab4268d7ad1c7c06
BLAKE2b-256 checksum
How to use checksums
5661a689995326179e9df3ef35382733ae63e82012a34ba7f58c4bddca48f0bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for staticfloww 0.1.10

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