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
๐ฆ 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 from scratch 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 development server (coming soon)
m start
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
- Web Framework: Litestar 2.0+
- ORM: SQLAlchemy 2.0 (Async)
- Validation: Pydantic V2
- Task Queue: Taskiq + NATS JetStream
- DI Container: dependency-injector
- Database: PostgreSQL (default), SQLite (testing)
- Cache/Events: Redis
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file framework_m-0.4.9.tar.gz.
File metadata
- Download URL: framework_m-0.4.9.tar.gz
- Upload date:
- Size: 56.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58a0bffe0edd86115d4392e77d116849e7e71a279486912344ae554dfc9d8316
|
|
| MD5 |
1805b092ed4709422511c8c8480fa553
|
|
| BLAKE2b-256 |
2d24b41e9eedbb9f2f8a0bf23441a533ef5139705289a494931e6952fe8e88ad
|
File details
Details for the file framework_m-0.4.9-py3-none-any.whl.
File metadata
- Download URL: framework_m-0.4.9-py3-none-any.whl
- Upload date:
- Size: 67.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5048b49bc23c286c4667a674fffc5059aaf196749e9c4562c1a1170ff06f07de
|
|
| MD5 |
2423adb341469c31217914f342735b70
|
|
| BLAKE2b-256 |
a09a311b058ec280bad0a87c00064a49842a675ad2edada52c1333d4904e89ea
|