A modern, metadata-driven business application framework
Project description
Framework M
A modern, metadata-driven business application framework in Python 3.12+.
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
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.2.5.tar.gz.
File metadata
- Download URL: framework_m-0.2.5.tar.gz
- Upload date:
- Size: 456.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc91c986719d6db751bec500b2eeb5146342c9066f5550041f38650b52db9ff2
|
|
| MD5 |
8203018191642623efbc6206f5dcdf0d
|
|
| BLAKE2b-256 |
ac437579a94671293569b05c752fc76a2ef0163c2a033145b2267bfa3dc7e01b
|
File details
Details for the file framework_m-0.2.5-py3-none-any.whl.
File metadata
- Download URL: framework_m-0.2.5-py3-none-any.whl
- Upload date:
- Size: 310.8 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 |
81e33d8df8f9085f3c860ed18355c070beebac63a87fc996d229f8f32dc4f5d2
|
|
| MD5 |
92cb2f3f2b32bfc41f20a7d6d98851ce
|
|
| BLAKE2b-256 |
05563acb4246485565ab51092ae7cb2489ed7d92eefd0b0106ec0f66cb5989a7
|