Skip to main content

Backend Overview

The Maybern backend is a Django application that provides the API, business logic, and data management for the platform. It’s organized into domain-specific apps that handle different aspects of fund administration.

Architecture

The backend follows a consistent structure across all apps:
backend/
├── server/
│   ├── apps/                 # Django applications
│   │   ├── core/             # Shared utilities and base classes
│   │   ├── clients/          # Customer/tenant management
│   │   ├── celery/           # Async task infrastructure
│   │   ├── events/           # Event system
│   │   └── ...               # Domain-specific apps
│   ├── settings/             # Environment configurations
│   └── urls.py               # URL routing
├── ai/                       # AI chat service
├── wiki/                     # Development documentation
└── config/                   # Environment variables

App Categories

Core Infrastructure

Base classes, utilities, and shared services used across all apps.

Capital Activity

Apps for managing capital calls, distributions, and allocations.

Financial Operations

Apps for fees, transactions, waterfalls, and calculations.

Supporting Apps

Apps for documents, notices, auditing, and feature flags.

Key Concepts

Multi-Tenancy

All data is customer-scoped using customer_id fields. The CustomerTimeStampedModel base class handles this automatically.
class MyModel(CustomerTimeStampedModel):
    # customer_id is automatically added
    name = models.CharField(max_length=255)

Request Context

The RequestCtx object is passed through all service calls, containing:
  • customer_id - Current tenant
  • user_id - Authenticated user
  • feature_flags - Active feature flags
  • request_source - Origin of request (frontend, API, etc.)

Service Layer Pattern

Business logic is organized into services:
  • Public Services - External interface for other apps
  • Private Services - Internal business logic
  • Selectors - Data access patterns
See Services & Selectors for details.

Common Commands

# Run the Django server
just run-server

# Run Celery workers
just run-celery

# Run migrations
just migrate

# Create new migrations
just makemigrations

# Run tests
just test

# Run linting
just lint check

# Fix linting issues
just lint fix