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_APPSfor MFE remote entries. It assumes all remote entries are served locally fromstatic/mfe/. - Broadcast:
BroadcastSchemapublishes 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:
BroadcastSchemaonly publishes DocTypes that belong to the service's own app namespace (based onINSTALLED_APPSprefix matching). - Asset Resolution: Assets can be proxied to other remote services if
FRAMEWORK_M_MFE_PROXY_ENABLEDis active.
Summary Table
| Feature | Monolith Mode | Macroservice Mode |
|---|---|---|
| API Prefix | /api/v1 | /api/{service}/v1 |
| Discovery | Auto-Scan | JIT Oracle Query |
| Broadcasting | Global (All DocTypes) | Scoped (Owned Only) |
| Local Inter-process | Internal Memory | Shared JSON File |
| Production Sync | N/A | NATS KV Store |