Skip to main content

A modern, metadata-driven business application framework

Project description

Framework M

The complete metadata-driven business application framework for Python 3.12+.

Official Website: frameworkm.dev

Python 3.12+ PyPI version GitLab Pipeline Status License: MIT Code style: ruff Type checked: mypy TestPyPI

๐Ÿ“ฆ Metapackage: This is the primary Framework M package. Installing it gives you everything required to build applications. For individual components, see the Related Packages section.

Overview

Framework M is inspired by Frappe Framework but built with modern Python practices:

  • Hexagonal Architecture: Clean separation via Ports & Adapters
  • Async-First: Native asyncio with Litestar and SQLAlchemy
  • Type-Safe: 100% type hints, mypy strict compatible
  • Stateless: JWT/Token auth, no server-side sessions
  • Metadata-Driven: Define DocTypes as Pydantic models

Installation

pip install framework-m

Or with uv:

uv add framework-m

Quick Start

1. Define a DocType

from framework_m import DocType, Field

class Todo(DocType):
    """A simple task document."""

    title: str = Field(description="Task title")
    description: str | None = Field(default=None, description="Task details")
    is_completed: bool = Field(default=False, description="Completion status")
    priority: int = Field(default=1, ge=1, le=5, description="Priority (1-5)")

2. Use the CLI

# Show version
m --version

# Show framework info
m info

# Start production server
m prod

# Start development server
m dev

Features

Metadata-Driven DocTypes

DocTypes are Pydantic models with automatic:

  • Database table generation
  • REST API endpoints
  • JSON Schema for frontends
  • Validation and serialization

Hexagonal Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     Primary Adapters                        โ”‚
โ”‚         (HTTP API, CLI, WebSocket, Background Jobs)         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Core Domain                            โ”‚
โ”‚              (DocTypes, Controllers, Business Logic)        โ”‚
โ”‚                                                             โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”‚
โ”‚  โ”‚ BaseDocType โ”‚  โ”‚ BaseControllerโ”‚  โ”‚ MetaRegistry โ”‚       โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Ports (Interfaces)                       โ”‚
โ”‚  RepositoryProtocol โ”‚ EventBusProtocol โ”‚ PermissionProtocol โ”‚
โ”‚  StorageProtocol    โ”‚ JobQueueProtocol โ”‚ CacheProtocol      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   Secondary Adapters                        โ”‚
โ”‚     (PostgreSQL, Redis, S3, SMTP, External APIs)            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Built-in Protocols

Protocol Purpose
RepositoryProtocol CRUD operations for documents
EventBusProtocol Publish/subscribe events
PermissionProtocol Authorization with RLS
StorageProtocol File storage abstraction
JobQueueProtocol Background job processing
CacheProtocol Caching layer
NotificationProtocol Email/SMS notifications
SearchProtocol Full-text search
PrintProtocol PDF generation
I18nProtocol Internationalization

Extensibility

Override any adapter via Python entrypoints:

# pyproject.toml
[project.entry-points."framework_m.overrides"]
repository = "my_app.adapters:CustomRepository"

Technology Stack

Project Structure

libs/framework-m/
โ”œโ”€โ”€ src/framework_m/
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ domain/         # DocType, Controller, Mixins
โ”‚   โ”‚   โ””โ”€โ”€ interfaces/     # Protocol definitions (Ports)
โ”‚   โ”œโ”€โ”€ adapters/           # Infrastructure implementations
โ”‚   โ”œโ”€โ”€ cli/                # CLI commands
โ”‚   โ””โ”€โ”€ public/             # Built-in DocTypes
โ””โ”€โ”€ tests/

Development

# Clone and setup
git clone https://gitlab.com/castlecraft/framework-m.git
cd framework-m

# Install dependencies
uv sync --all-extras

# Run tests
uv run pytest

# Type checking
uv run mypy src/framework_m --strict

# Linting
uv run ruff check .
uv run ruff format .

Documentation

Related Packages

Framework M is split into modular packages:

Package Description
framework-m This package - Metapackage with CLI, kernel, and re-exports
framework-m-core Core protocols and dependency injection
framework-m-standard Default adapters (SQLAlchemy, Redis, Litestar)
framework-m-studio Visual DocType builder UI

License

MIT License - see LICENSE for details.

Acknowledgments

Inspired by Frappe Framework, reimagined with:

  • Modern Python (3.12+, async/await, type hints)
  • Clean architecture (Hexagonal/Ports & Adapters)
  • No global state (Dependency Injection)
  • Code-first schemas (Pydantic, not database JSON)

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

framework_m-0.4.13.tar.gz (64.5 kB view details)

Uploaded Source

Built Distribution

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

framework_m-0.4.13-py3-none-any.whl (76.9 kB view details)

Uploaded Python 3

File details

Details for the file framework_m-0.4.13.tar.gz.

File metadata

  • Download URL: framework_m-0.4.13.tar.gz
  • Upload date:
  • Size: 64.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for framework_m-0.4.13.tar.gz
Algorithm Hash digest
SHA256 c3de7bbb5088582c89109e586c0b8151c10360e259ed7130fc5415a3773b3152
MD5 14c0dd687d7e3390399eab844145cf9d
BLAKE2b-256 1e1a74d40dde04bd194afdc3055eaa0faaed7a4ebb4bc9f1ddf70c90598f7d32

See more details on using hashes here.

File details

Details for the file framework_m-0.4.13-py3-none-any.whl.

File metadata

  • Download URL: framework_m-0.4.13-py3-none-any.whl
  • Upload date:
  • Size: 76.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for framework_m-0.4.13-py3-none-any.whl
Algorithm Hash digest
SHA256 ce8fbe81d91a6b6325032b205b121778a71b6d9879c9a54ef74d0077cd869ca0
MD5 bc6f2c81037d9a1db88c305557369cb8
BLAKE2b-256 d4283d541c3b563b95daa5db3c87aa0121828c2ca411d51f7482daf1d5d6794e

See more details on using hashes here.

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