Skip to main content

Explanation: Monolith vs. Macroservice Modes

Framework M operates in two primary execution modes that determine how it handles routing, discovery, and asset resolution. This mode is governed by the FRAMEWORK_MODE environment variable.

MONOLITH Mode (Default)

In Monolith mode, the application assumes it is the sole owner of all resources and the primary server for all assets.

Behavior

  • Routing: API paths are flat (e.g., /api/v1/DocType).
  • Discovery: The framework automatically scans INSTALLED_APPS for MFE remote entries. It assumes all remote entries are served locally from static/mfe/.
  • Broadcast: BroadcastSchema publishes all DocTypes found in the local registry.
  • Shell: The shell is served from the main application's assets.

MACROSERVICE Mode

Macroservice mode is designed for distributed environments where multiple services collaborate to form a single application.

Behavior

  • Routing: API paths are namespaced (e.g., /api/{service_name}/v1/DocType).
  • Discovery: Uses the JIT Oracle protocol. The service only knows about its own resources on startup. It queries the Gateway to find other services.
  • Sovereignty: BroadcastSchema only publishes DocTypes that belong to the service's own app namespace (based on INSTALLED_APPS prefix matching).
  • Asset Resolution: Assets can be proxied to other remote services if FRAMEWORK_M_MFE_PROXY_ENABLED is active.

Summary Table

FeatureMonolith ModeMacroservice Mode
API Prefix/api/v1/api/{service}/v1
DiscoveryAuto-ScanJIT Oracle Query
BroadcastingGlobal (All DocTypes)Scoped (Owned Only)
Local Inter-processInternal MemoryShared JSON File
Production SyncN/ANATS KV Store