Structum Lab - Framework DocumentationΒΆ

Documentation Source Code Python 3.11+ License: Apache-2.0

Feature

Status

Details

Version

0.1.0

Alpha

License

Apache-2.0

Β© 2025 PythonWoods

[!NOTE] Versioning Note: The project is currently in Alpha Phase. All packages (Core and Plugins) follow synchronized versioning (β€œLockstep”) with the main framework (structum).


OverviewΒΆ

Structum (lat. struttura): A solid, invisible, and modular foundation for modern Python applications.

Structum Lab is not another web framework, CLI tool, or ORM. It’s a foundational framework designed to manage application lifecycle, configuration, observability, and plugin ecosystemsβ€”leaving you free to choose your preferred technologies for the final implementation.

PhilosophyΒΆ

  • Protocol-First Architecture: Built on typing.Protocol interfaces, not rigid inheritance

  • Zero Core Dependencies: structum-core uses only Python Standard Library

  • Enterprise-Ready: Production features (health checks, metrics, graceful shutdown) from day one

  • Modular by Design: Install only what you need via independent packages


Quick NavigationΒΆ

πŸŽ“ Learning PathΒΆ

Step

Guide

Description

1

Installation

Clone and install from source

2

User Tutorial

From installation to your first plugin

3

Configuration Philosophy

Understand the 5-layer model

4

Developer Tutorial

Contributing to Structum

πŸ“¦ Core ModulesΒΆ

πŸ”Œ PluginsΒΆ

πŸ“š GuidesΒΆ


InstallationΒΆ

[!IMPORTANT] Alpha Status: Structum is currently in alpha phase (v0.1.0). Packages are not yet published to PyPI. Installation is only available from source.

From Source (Required)ΒΆ

# Clone repository
git clone https://github.com/PythonWoods/structum.git
cd structum

# Install all packages + dev tools (mypy, pytest, ruff, etc.)
uv sync --extra dev

Note: This installs all workspace packages (packages/*) in editable mode with development dependencies.

Future: PyPI Installation (Coming Soon)ΒΆ

Once packages are published to PyPI, you will be able to install via:

# Meta-package (all features)
pip install structum

# Individual packages
pip install structum-core structum-dynaconf

Quick StartΒΆ

1. Minimal Example (Core Only)ΒΆ

The configuration system works out-of-the-box without any setup using structum-core:

from structum.config import get_config

# Get the singleton instance
config = get_config()

# Write configuration (automatically persisted)
config.set("server.host", "0.0.0.0")
config.set("server.port", 8080)

# Read configuration (with safe defaults)
host = config.get("server.host", default="localhost")
port = config.get("server.port", default=8000)

print(f"Server starting on {host}:{port}")

2. Production Example (With Plugins)ΒΆ

Full-featured application using structum (Meta):

from structum.config import set_config_provider, get_config
from structum.plugins.dynaconf import DynaconfConfigProvider
from structum.plugins.observability import setup_logging, get_logger
from structum.plugins.bootstrap import SystemBootstrapper, EnvValidator

def setup_application():
    """
    Initialize Structum with production features.
    """
    # 1. Validation: Ensure environment is ready
    boot = SystemBootstrapper()
    boot.add_validator(EnvValidator(required=["APP_ENV", "DB_URL"]))
    boot.run_or_exit()
    
    # 2. Configuration: Load multi-layer config
    provider = DynaconfConfigProvider(root_path=".", env_prefix="MYAPP")
    set_config_provider(provider)
    
    # 3. Observability: Setup structured logging
    setup_logging()
    
    get_logger(__name__).info("Application initialized")

if __name__ == "__main__":
    setup_application()


Project StructureΒΆ

Structum Lab uses a monorepo architecture with distributed packages:

structum/
β”œβ”€β”€ packages/                          # Distribution Packages
β”‚   β”œβ”€β”€ core/                          # [structum-core] Protocols & Base
β”‚   β”œβ”€β”€ meta/                          # [structum] Meta-package bundle
β”‚   β”œβ”€β”€ dynaconf/                      # [structum-dynaconf] Plugin
β”‚   β”œβ”€β”€ observability/                 # [structum-observability] Plugin
β”‚   β”œβ”€β”€ auth/                          # [structum-auth] Plugin
β”‚   β”œβ”€β”€ database/                      # [structum-database] Plugin
β”‚   β”œβ”€β”€ di/                            # [structum-di] Plugin
β”‚   └── bootstrap/                     # [structum-bootstrap] Plugin
β”‚
β”œβ”€β”€ demo/                              # Example applications
β”‚   β”œβ”€β”€ 01-logging-basics/
β”‚   β”œβ”€β”€ 02-observability-full/
β”‚   └── ...
β”‚
└── pyproject.toml                     # Workspace Orchestrator

Architecture OverviewΒΆ

Protocol-Based DesignΒΆ

Structum separates interfaces (protocols) from implementations (plugins):

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Application Code                      β”‚
β”‚   Uses: get_config(), get_logger()      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Structum Core (structum-core)         β”‚
β”‚   β€’ ConfigProviderInterface             β”‚
β”‚   β€’ LoggerInterface                     β”‚
β”‚   β€’ AuthInterface                       β”‚
β”‚   β€’ DatabaseInterface                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Plugin Implementations                β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚ Dynaconf β”‚Observableβ”‚ Auth     β”‚   β”‚
β”‚   β”‚ Provider β”‚ Logger   β”‚ Provider β”‚   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Benefits:

  • Testability: Mock providers without changing application code

  • Flexibility: Switch implementations (JSON β†’ Dynaconf β†’ Vault) without refactoring

  • Type Safety: Full static type checking with mypy strict mode


Core FeaturesΒΆ

Feature

Description

Configuration

Multi-layer config with dot-notation, environment overrides, persistence

Logging

Structured logging with context propagation and log levels

Authentication

JWT tokens, RBAC authorization, password hashing

Database

Connection pooling, transactions, health checks

Observability

Prometheus metrics, OpenTelemetry traces

Bootstrap

Environment validation, fail-fast startup

Dependency Injection

Clean Architecture support with dependency-injector


Why Structum?ΒΆ

vs Django/FastAPIΒΆ

Structum is not a replacement. It’s an underpinning. Use Django ORM, FastAPI routing, or Flask viewsβ€”Structum manages the lifecycle beneath them.

vs Direct Library UsageΒΆ

Instead of manually wiring pydantic, structlog, prometheus_client, Structum provides a unified API with consistent patterns.

vs No FrameworkΒΆ

As projects grow, you’ll reinvent configuration management, logging setup, health checks. Structum provides these patterns from day one.


Next StepsΒΆ

  1. Configuration Guide - Deep dive into configuration management

  2. Enterprise Architecture - Building production systems

  3. API Reference - Complete API documentation


SupportΒΆ


LicenseΒΆ

Apache 2.0 - See LICENSE