Skip to main content

TaipanStack - Modular, secure, and scalable Python stack for robust development

Project description

๐Ÿ TaipanStack

The Modern Python Foundation

Launch secure, high-performance Python applications in seconds.

CI Python Coverage Code Style Type Checked License Security SBOM SLSA PyPI


Features โ€ข Quick Start โ€ข Architecture โ€ข DevSecOps โ€ข API โ€ข Contributing


โœจ Why TaipanStack?

"Write less, build better."

TaipanStack is a battle-tested foundation for production-grade Python projects that combines security, performance, and developer experience into a single, cohesive toolkit.

๐Ÿ›ก๏ธ Security First

  • Path traversal protection
  • Command injection guards
  • Input sanitizers & validators
  • Secret detection integration
  • SBOM + SLSA supply-chain attestation

โšก High Performance

  • uvloop async event loop
  • orjson fast JSON serialization
  • Pydantic v2 validation
  • Performance benchmarks with regression detection

๐ŸŽฏ Rust-Style Error Handling

  • Ok/Err Result types
  • Explicit error propagation
  • Pattern matching support
  • No silent failures

๐Ÿ”ง Developer Experience

  • Pre-configured quality tools
  • 100% code coverage (1164 tests)
  • Architecture enforcement
  • Hardened Docker template

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.11+ (supports 3.11, 3.12, 3.13, 3.14)
  • Poetry (install guide)

Installation

From PyPI

pip install taipanstack

From Source

# Clone the repository
git clone https://github.com/gabrielima7/TaipanStack.git
cd TaipanStack

# Install dependencies
poetry install --with dev

# Run quality checks
make all

Verify Installation

# Run tests with 100% coverage (1164 tests)
make test

# Check architecture contracts
make lint-imports

# Run security scans
make security

# Run property-based fuzzing
make property-test

# Run performance benchmarks
make benchmark

๐Ÿ“ Architecture

TaipanStack follows a clean, layered architecture with strict dependency rules enforced by Import Linter.

                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚             Application             โ”‚
                    โ”‚          (src/app/main.py)          โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                      โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ–ผ                           โ–ผ                           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚    Security     โ”‚       โ”‚     Config      โ”‚       โ”‚     Utils       โ”‚
โ”‚ guards, saniti- โ”‚       โ”‚    models,      โ”‚       โ”‚  logging, retry โ”‚
โ”‚ zers, validatorsโ”‚       โ”‚   generators    โ”‚       โ”‚ metrics, fs     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                         โ”‚                         โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                   โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚              Core                   โ”‚
                    โ”‚    Result types, base patterns      โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Project Structure

TaipanStack/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ app/              # Application entry point
โ”‚   โ””โ”€โ”€ taipanstack/
โ”‚       โ”œโ”€โ”€ core/         # ๐ŸŽฏ Result types, functional patterns
โ”‚       โ”œโ”€โ”€ config/       # โš™๏ธ Configuration models & generators
โ”‚       โ”œโ”€โ”€ security/     # ๐Ÿ›ก๏ธ Guards, sanitizers, validators
โ”‚       โ””โ”€โ”€ utils/        # ๐Ÿ”ง Logging, metrics, retry, filesystem
โ”œโ”€โ”€ tests/                # โœ… 1164 tests, 100% coverage
โ”œโ”€โ”€ .semgrep/             # ๐Ÿ” Custom SAST rules
โ”œโ”€โ”€ .github/              # ๐Ÿ”„ CI/CD + SBOM/SLSA workflows
โ”œโ”€โ”€ Dockerfile            # ๐Ÿณ Hardened multi-stage container
โ””โ”€โ”€ pyproject.toml        # ๐Ÿ“‹ Modern dependency management

๐Ÿ” DevSecOps

TaipanStack integrates security and quality at every level:

Category Tools Purpose
SAST Bandit, Semgrep + custom rules Static Application Security Testing
SCA Safety, pip-audit Dependency vulnerability scanning
SBOM Syft (CycloneDX) Software Bill of Materials
SLSA Cosign (Sigstore) Artifact signing & attestation
Types Mypy (strict) Compile-time type checking
Lint Ruff Lightning-fast linting & formatting
Arch Import Linter Dependency rule enforcement
Test Pytest, Hypothesis, mutmut Property-based & mutation testing
Perf pytest-benchmark Performance regression detection
Containers Docker (Alpine, rootless) Hardened-by-default images

CI Pipeline

# Runs on every push/PR
โœ“ Test Matrix     โ†’ Python 3.11-3.14 ร— (Ubuntu, macOS, Windows)
โœ“ Linux Distros   โ†’ Ubuntu, Debian, Fedora, openSUSE, Arch, Alpine
โœ“ Code Quality    โ†’ Ruff check & format
โœ“ Type Check      โ†’ Mypy strict mode
โœ“ Security        โ†’ Bandit + Semgrep (custom rules)
โœ“ Architecture    โ†’ Import Linter contracts
โœ“ Benchmarks      โ†’ Performance regression (>5% = fail)
โœ“ SBOM + SLSA     โ†’ Supply-chain attestation on release

๐Ÿ“š API Highlights

Result Types (Rust-Style Error Handling)

from taipanstack.core.result import Result, Ok, Err, safe

@safe
def divide(a: int, b: int) -> float:
    return a / b

# Explicit error handling with pattern matching
match divide(10, 0):
    case Ok(value):
        print(f"Result: {value}")
    case Err(error):
        print(f"Error: {error}")

Security Guards

from taipanstack.security.guards import guard_path_traversal, guard_command_injection

# Prevent path traversal attacks
safe_path = guard_path_traversal(user_input, base_dir="/app/data")

# Prevent command injection
safe_cmd = guard_command_injection(
    ["git", "clone", repo_url],
    allowed_commands=["git"]
)

Retry with Exponential Backoff

from taipanstack.utils.retry import retry

@retry(max_attempts=3, on=(ConnectionError, TimeoutError))
async def fetch_data(url: str) -> dict:
    return await http_client.get(url)

Circuit Breaker

from taipanstack.utils.circuit_breaker import circuit_breaker

@circuit_breaker(failure_threshold=5, timeout=30)
def call_external_service() -> Response:
    return service.call()

๐Ÿ”— Combining Result + Circuit Breaker

from taipanstack.core.result import safe, Ok, Err
from taipanstack.utils.circuit_breaker import CircuitBreaker

breaker = CircuitBreaker(failure_threshold=3, timeout=60, name="payments")

@breaker
@safe
def charge_customer(customer_id: str, amount: float) -> dict:
    return payment_gateway.charge(customer_id, amount)

# Both circuit protection AND explicit error handling
result = charge_customer("cust_123", 49.99)
match result:
    case Ok(receipt):
        print(f"Payment successful: {receipt}")
    case Err(error):
        print(f"Payment failed safely: {error}")

๐Ÿ”— Combining Result + Retry with Monitoring

from taipanstack.core.result import safe, unwrap_or
from taipanstack.utils.retry import retry

@retry(
    max_attempts=3,
    on=(ConnectionError, TimeoutError),
    on_retry=lambda attempt, max_a, exc, delay: print(
        f"โš ๏ธ  Attempt {attempt}/{max_a} failed, retrying in {delay:.1f}s..."
    ),
)
@safe
def fetch_user_profile(user_id: str) -> dict:
    return api_client.get(f"/users/{user_id}")

# Retry handles transient failures, Result handles business errors
profile = unwrap_or(fetch_user_profile("usr_456"), {"name": "Unknown"})

๐Ÿ”— Adaptive Resilience Pipeline

from taipanstack.core.result import Result, Ok, Err
from taipanstack.resilience.adaptive import ResilienceOrchestrator, AdaptiveCircuitBreaker
from taipanstack.resilience.retry import RetryConfig

# Compose an intelligent pipeline: Bulkhead -> Breaker -> Retry -> Timeout -> Fallback
orch = (
    ResilienceOrchestrator("billing_api")
    .with_bulkhead(max_concurrent=10, max_queue=50) # Prevent resource exhaustion
    .with_circuit_breaker(AdaptiveCircuitBreaker("billing", target_error_rate=0.1)) # Auto-tunes thresholds
    .with_retry(RetryConfig(max_attempts=3, initial_delay=0.1))
    .with_timeout(5.0)
    .with_fallback({"status": "unavailable"})
)

async def process_billing() -> Result[dict, Exception]:
    # The orchestrator handles all concurrency, retry, circuit breaking, and fallbacks
    return await orch.execute(stripe_gateway.charge)

Intelligent Caching

from taipanstack.utils.cache import cached
from taipanstack.core.result import Result

@cached(ttl=60)
async def get_user_data(user_id: int) -> Result[dict, Exception]:
    return await db.fetch(user_id) # Only Ok() results are cached

Fallbacks & Timeouts

from taipanstack.utils.resilience import fallback, timeout
from taipanstack.core.result import Result

@fallback(fallback_value={"status": "offline"}, exceptions=(TimeoutError,))
@timeout(seconds=5.0)
async def fetch_remote_status() -> Result[dict, Exception]:
    return await api.get_status()

๐Ÿณ Docker

# Build hardened image
docker build -t taipanstack:latest .

# Run (rootless, read-only)
docker run --rm --read-only taipanstack:latest

Security features: multi-stage build, Alpine base (<50MB), non-root appuser (UID 1000), healthcheck, no shell in runtime.


๐Ÿ› ๏ธ Tech Stack

Runtime Quality DevSecOps
  • Pydantic v2
  • Orjson
  • Uvloop
  • Structlog
  • Result
  • Ruff
  • Mypy
  • Bandit
  • Pytest + Hypothesis
  • mutmut
  • pytest-benchmark
  • GitHub Actions
  • Syft + Cosign (SBOM/SLSA)
  • Dependabot
  • Pre-commit
  • Poetry
  • Docker (Alpine, rootless)

๐Ÿค Contributing

Contributions are welcome! Please check our Contributing Guide for details on:

  • ๐Ÿ› Bug reports
  • โœจ Feature requests
  • ๐Ÿ“ Documentation improvements
  • ๐Ÿ”ง Pull requests

๐Ÿ“ License

This project is open-sourced under the MIT License.


Made with โค๏ธ for the Python community

โฌ† Back to Top

Project details


Download files

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

Source Distribution

taipanstack-0.4.0.tar.gz (81.4 kB view details)

Uploaded Source

Built Distribution

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

taipanstack-0.4.0-py3-none-any.whl (100.0 kB view details)

Uploaded Python 3

File details

Details for the file taipanstack-0.4.0.tar.gz.

File metadata

  • Download URL: taipanstack-0.4.0.tar.gz
  • Upload date:
  • Size: 81.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for taipanstack-0.4.0.tar.gz
Algorithm Hash digest
SHA256 2486881bd506d43ffa23b18eaf63dc028dfd1bd54ca2a577f0b84f8e874f6fd9
MD5 8da8d9e54c4c609d8174d8ebf8897b2a
BLAKE2b-256 67c74749f19389da66ba6210050e56025f4a0b0219428fc962990777f92bc797

See more details on using hashes here.

Provenance

The following attestation bundles were made for taipanstack-0.4.0.tar.gz:

Publisher: publish.yml on gabrielima7/TaipanStack

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

File details

Details for the file taipanstack-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: taipanstack-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 100.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for taipanstack-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d48688bdfc971f5e8986eaf03f1c3b6cb79b3f36d8615839657b48047289af55
MD5 af4a09ec81aa57c767895cca04d11d57
BLAKE2b-256 b131c389f84b532767a5db8f7de1d6211bd5159365038c0162f3b0253e361765

See more details on using hashes here.

Provenance

The following attestation bundles were made for taipanstack-0.4.0-py3-none-any.whl:

Publisher: publish.yml on gabrielima7/TaipanStack

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 Pingdom Monitoring Sentry Error logging StatusPage Status page