Skip to main content

Modules, flags and runtime settings

Modules (bricks)​

Every module is a brick, defined once in crates/medbrains-core/src/bricks.rs: its id, name, the bricks it depends on, its permission groups, whether it is an add-on, and the editions it ships in. The brick id is the value stored in module_config.code for each hospital.

PieceWhereWhat it does
Brick tablemedbrains-core/src/bricks.rsThe single list of modules and their dependencies
Server gatemedbrains-server-core/src/middleware/entitlement.rsgated(code, router, state) wraps a module's routes: 403 while the brick is off, 503 while its status cannot be read. A brick is on only when it and everything it needs are on
Switch rulessame file, switch_blockersRefuses a switch that would leave a brick without what it needs
Admin screenapps/web/src/pages/admin/settings/ModulesSettings.tsxAdmin → Settings → Modules
Menuapps/web/src/config/navigation.tsHides a switched-off module's menu
Checkmake check-bricksEvery module name comes from bricks.rs

Feature flags​

There is no separate feature-flag system. A capability is a brick (per hospital), a permission (per role or user), or a tenant setting.

Tenant settings​

Hospital settings live in the tenant_settings table, as category/key paths. Read them through medbrains-kernel/src/config.rs (setting_in), or the wrappers in medbrains-server-core/src/tenant_config.rs, which fall back to a default. Writes go through settings_guard.rs. Today only the hospital-wide scope is read; the narrower layers (campus, building, floor, department, user) are planned.

Server configuration​

crates/medbrains-server-core/src/config.rs loads, later winning:

  1. compiled defaults;
  2. config.toml (copy config.toml.example);
  3. environment variables, with .env loaded first.

Other crates also read variables directly. Every one is in the environment variables table, generated from the code.