Structum - Framework DocumentationΒΆ
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 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.Protocolinterfaces, not rigid inheritanceZero Core Dependencies:
structum-coreuses only Python Standard LibraryEnterprise-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 |
Clone and install from source |
|
2 |
From installation to your first plugin |
|
3 |
Understand the 5-layer model |
|
4 |
Contributing to Structum |
π¦ Core ModulesΒΆ
Configuration - Multi-layer config with dot-notation
Authentication - JWT, RBAC, password hashing
Database - Connection pooling, transactions, health checks
Logging - Structured logging facade (Core)
π PluginsΒΆ
Dynaconf - Enterprise configuration engine
Bootstrap - Application lifecycle management
Dependency Injection - DI for FastAPI
Auth - Authentication implementations
Database - SQLAlchemy/PostgreSQL providers
Observability - Structlog/Prometheus backend
π GuidesΒΆ
All Guides & Learning Paths - Start here!
Observability Stack - Logging & Prometheus metrics
Enterprise Architecture - Production patterns
Enterprise Architecture - Building production systems
Configuration Getting Started - Deep dive into configuration
Structum CLI - Command Line Interface Reference
ποΈ Governance & ArchitectureΒΆ
Architectural Constitution - The βSupreme Lawβ of Structum
Why Structum? - Philosophy and technical rationale
Review Checklist - Compliance for PRs
Anti-Patterns - What NOT to do
Mental Model - Visual Architecture Map
Exit Strategy - Decommissioning Protocol
AI Governance - Transparency & Ethics
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 & CLI](cli/index.md) (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 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 |
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ΒΆ
Configuration Guide - Deep dive into configuration management
Enterprise Architecture - Building production systems
API Reference - Complete API documentation
SupportΒΆ
GitHub Issues: github.com/PythonWoods/structum/issues
Discussions: github.com/PythonWoods/structum/discussions
LicenseΒΆ
Apache 2.0 - See LICENSE