Skip to main content

Welcome to Fluvius Framework

info

Fluvius Framework is a Python library for building domain-driven API & MCP backends with CQRS, event sourcing, and modern architecture patterns.

What is Fluvius?

Fluvius Framework helps you build scalable, maintainable backend applications using:

  • Domain-Driven Design: Organize your code around business domains
  • CQRS: Separate read and write operations for better performance
  • Event Sourcing: Track all changes as immutable events
  • FastAPI Integration: Build REST APIs quickly
  • Multiple Data Backends: Support for PostgreSQL, MongoDB, SQLite, and more

Quick Start

Get started in minutes:

from fluvius.domain import Domain, Aggregate, action
from fluvius.domain.context import SanicContext
from fluvius.data import UUID_GENR

# Define your aggregate
class UserAggregate(Aggregate):
@action(evt_key='user-created', resources=['user'])
async def create_user(self, name: str, email: str):
# Your business logic
return {'name': name, 'email': email}

# Create your domain
class UserDomain(Domain):
__aggregate__ = UserAggregate

# Use it
ctx = SanicContext.create(namespace='app-user')
domain = UserDomain(ctx)
domain.set_aggroot('user', UUID_GENR())

command = domain.create_command('create-user', {
'name': 'John Doe',
'email': '[email protected]'
})

response = await domain.process_command(command)

Key Features

  • Domain-Driven Design: Build applications around business domains
  • CQRS Pattern: Separate commands and queries for scalability
  • Event Sourcing: Automatic event generation and storage
  • FastAPI Integration: REST APIs out of the box
  • Multiple Databases: PostgreSQL, MongoDB, SQLite support
  • Background Workers: Async job processing with ARQ
  • Media Management: File upload and storage
  • Query Builder: Flexible querying with filtering and sorting
  • Authorization: Casbin integration for policy-based access control

Documentation Structure

Get Started

  1. Install Fluvius
  2. Follow the Quick Start Guide
  3. Explore Examples

Need Help?

Let's build something amazing! 🚀