Skip to main content

Composable toolkit for clean, testable, and maintainable Python applications

Project description

ForgingBlocks

Composable abstractions and interfaces for writing clean, testable, and maintainable Python code.

Python Poetry Type checked: mypy Code style: ruff Security: bandit CI


Overview

Not a framework — a toolkit of composable contracts and abstractions.

ForgingBlocks helps you create codebases that are:

  • Clean — with clear boundaries and intent
  • Testable — by design, through explicit interfaces
  • Maintainable — by isolating concerns and dependencies

It doesn’t dictate your architecture. Instead, it provides foundations and reusable abstractions for forging your own blocks.

Isolate external concerns from your core logic you will achieve systems that are adaptable and resilient. If you forge your own block you will achieve software with intent and clarity If you use blocks you will achieve consistency and reusability. ForgingBlocks helps you build systems that last.

You can use it to:

  • Learn and apply architecture and design principles
  • Build decoupled applications that scale safely
  • Model systems with type safety and explicit intent
  • Experiment with Clean, Hexagonal, DDD, or Message-Driven styles

Core Concepts

Foundations, not frameworks — ForgingBlocks provides the language for clean architecture.

This toolkit defines layer-agnostic foundations that compose into any design:

  • Result, Ok, Err → explicit success/failure handling
  • Port, InboundPort, OutboundPort → communication boundaries
  • Entity, ValueObject, AggregateRoot → domain modeling
  • Repository, UnitOfWork → persistence contracts
  • Event, MessageBus, CommandHandler → messaging and orchestration

Installation

poetry add forging-blocks
# or
pip install forging-blocks
# or
uv add forging-blocks

Requires Python 3.14+


Quick Example

from forging_blocks.foundation import Result, Ok, Err

def divide(a: int, b: int) -> Result[int, str]:
    if b == 0:
        return Err("division by zero")
    return Ok(a // b)

result = divide(10, 2)
if result.is_ok:
    print(result.value)  # → 5

Learn More


[DEV] Development

Prerequisites

  • Python 3.14+
  • Poetry for dependency management

Setup

# Clone the repository
git clone https://github.com/forging-blocks-org/forging-blocks.git
cd forging-blocks

# Install dependencies
poetry install

# Run tests
poetry run poe test

# Run full CI suite
poetry run poe ci:check

Available Commands

# Testing - Primary Commands
poetry run poe test              # Run ALL tests (recommended)
poetry run poe test:unit         # Run unit tests only (fast feedback)
poetry run poe test:integration  # Run integration tests only
poetry run poe test:e2e          # Run end-to-end tests only

# Testing - Alternative Commands
poetry run poe test:debug        # Run tests with verbose output

# Code quality
poetry run poe lint              # Check code style
poetry run poe lint:fix          # Fix code style issues
poetry run poe type              # Type checking
poetry run poe bandit            # Security scanning

# Documentation
poetry run poe docs:build        # Build documentation
poetry run poe docs:generate     # Generate API reference

# Release (maintainers)
poetry run poe release patch        # Test release (simulation)
poetry run poe release patch --execute  # Execute patch release

Test Architecture

This project uses a 3-tier testing architecture:

  • Unit Tests (@pytest.mark.unit) - Fast, isolated tests with mocks or fakes
  • Integration Tests (@pytest.mark.integration) - Real infrastructure in isolated environments
  • End-to-End Tests (@pytest.mark.e2e) - Complete workflows (mostly skipped)

Quick feedback during development:

poetry run poe test:unit    # [FAST] Fast (~1s) - run frequently

Verify integrations before commits:

poetry run poe test         # [INFO] Complete test suite (~3s) - run before commits

See Testing Guide for detailed information.


Why It Matters

Most systems fail not because of missing features, but because of tight coupling, implicit dependencies, and unclear responsibilities.

ForgingBlocks helps you design code intentionally — so your system remains testable, extensible, and adaptable as it grows.


Contributing

Contributions are welcome!

  1. Fork the repository
  2. Install dependencies: poetry install
  3. Create a feature branch: git checkout -b feature/your-feature
  4. Make your changes
  5. Run the full test suite: poetry run poe ci:check
  6. Submit a pull request with a clear description

See CONTRIBUTING.md for detailed guidelines.

Release Process

For maintainers preparing releases:

# Prepare release (safe simulation)
poetry run poe release patch

# Execute release (creates branch and PR)
poetry run poe release patch --execute

See RELEASE_GUIDE.md for complete release instructions.


License

MIT — see LICENSE


ForgingBlocks — foundations for clean, testable, and maintainable Python architectures.

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

forging_blocks-0.4.3.tar.gz (37.7 kB view details)

Uploaded Source

Built Distribution

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

forging_blocks-0.4.3-py3-none-any.whl (63.1 kB view details)

Uploaded Python 3

File details

Details for the file forging_blocks-0.4.3.tar.gz.

File metadata

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

File hashes

Hashes for forging_blocks-0.4.3.tar.gz
Algorithm Hash digest
SHA256 a3abf1de4be5889ac258d930a5e0d0247689a5ca1c37998ef89851d6fbba46ef
MD5 dfcf737b4a33ee6680440d1713c5928c
BLAKE2b-256 c04e957dc193479bc63b84e50160d6fbaed8a53dc25e1c369aac6f0619fa5980

See more details on using hashes here.

Provenance

The following attestation bundles were made for forging_blocks-0.4.3.tar.gz:

Publisher: release.yml on forging-blocks-org/forging-blocks

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

File details

Details for the file forging_blocks-0.4.3-py3-none-any.whl.

File metadata

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

File hashes

Hashes for forging_blocks-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 32c7b3d13d848e8bcf27cea17f2afe1a5afc45a83de94b4c01374476d5f30e41
MD5 fa123a4721bdff9b401c38f37e741357
BLAKE2b-256 fbf8c92fd365c0d5110c9d03bc701f3b9bb3c2accecbb7bc3f5a379ca0467449

See more details on using hashes here.

Provenance

The following attestation bundles were made for forging_blocks-0.4.3-py3-none-any.whl:

Publisher: release.yml on forging-blocks-org/forging-blocks

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