|
| 1 | +# `mdr_restapi` — Base |
| 2 | + |
| 3 | +FastAPI base for the LIF **Metadata Repository (MDR)**: the control-plane service that holds the LIF schema(s), transformation definitions, value sets, and per-tenant configuration. Most LIF services load their schema and transformation rules from here at startup. |
| 4 | + |
| 5 | +The base is split into many endpoint modules (one per concern) which `core.py` mounts under stable URL prefixes. |
| 6 | + |
| 7 | +## Endpoint groups |
| 8 | + |
| 9 | +| Prefix | Module | What it does | |
| 10 | +|---|---|---| |
| 11 | +| `/datamodels` | `datamodel_endpoints` | LIF data models — Base LIF, Org LIF, target transformation models | |
| 12 | +| `/entities` | `entity_endpoints` | Entity definitions within a data model | |
| 13 | +| `/entity_associations` | `entity_association_endpoints` | Entity-to-entity relationships | |
| 14 | +| `/attributes` | `attribute_endpoints` | Scalar attributes within entities | |
| 15 | +| `/entity_attribute_associations` | `entity_attribute_association_endpoints` | Which attributes belong to which entities | |
| 16 | +| `/inclusions` | `inclusions_endpoints` | Reusable attribute groups (e.g., Contact, Address) | |
| 17 | +| `/value_sets` + `/value_set_values` | `valueset_endpoint`, `value_set_values_endpoint` | Strict + extensible enumerations | |
| 18 | +| `/transformation_groups` | `transformation_endpoint` | JSONata-based source→target transformations | |
| 19 | +| `/value_mappings` | `value_mapping_endpoints` | Code/value crosswalks used during transformation | |
| 20 | +| `/search` | `search_endpoint` | MDR-wide full-text search | |
| 21 | +| `/datamodel_constraints` | `datamodel_constraints_endpoints` | Constraint rules per model | |
| 22 | +| `/import_export` | `import_export_endpoints` | Bulk import/export of MDR content | |
| 23 | +| `/generate_jinja` | `generate_jinja_endpoint` | Template generation for derived schemas | |
| 24 | +| `/tenants` | `tenant_endpoints` | Self-serve tenant lifecycle (#883/#884): provision, workspace listing/selection, invite tokens | |
| 25 | + |
| 26 | +## Auth |
| 27 | +`AuthMiddleware` (from `mdr_auth/core`) supports three principals: API-key (services), Cognito JWT (end users), and legacy HS256 JWT (pre-Cognito callers). The middleware also resolves `request.state.tenant_schema` per request based on Cognito groups + optional workspace-selection cookie — see [`docs/design/cross-cutting/self-serve-tenant-auth.md`](../../../docs/design/cross-cutting/self-serve-tenant-auth.md). |
| 28 | + |
| 29 | +## Composes |
| 30 | +- `datatypes` — common payload shapes |
| 31 | +- `mdr_auth` — auth middleware + JWT/cookie/invite-token helpers |
| 32 | +- `mdr_dto` — wire-format DTOs |
| 33 | +- `mdr_services` — business logic (tenant_service, transformation_service, etc.) |
| 34 | +- `mdr_utils` — config, DB session factory, logger |
| 35 | + |
| 36 | +## Deployed as |
| 37 | +`projects/lif_mdr_api/` (API) + `projects/lif_mdr_database/` (Postgres + Flyway migrations). |
| 38 | +Frontend: `frontends/mdr-frontend/`. |
0 commit comments