The Rules domain is the schema registry of MinMaxHub. It enables a data-driven architecture where the shape of content (e.g., a "Spell", "Hero Card", or "Class Feature") is defined as JSON Schema documents, not hardcoded interfaces.
Schema as Data
Instead of hardcoding content types, MinMaxHub stores content schemas as JSON documents:
- Dynamic: Admin users can create new content types (e.g., "Vehicle", "Potion") without a code deployment.
- Universal: The same JSON Schema is used by the frontend (to generate form inputs) and the backend (to validate suggestions).
Rule Document Structure
Code
| Field | Description |
|---|---|
componentKey | Unique identifier within the folder. Acts as the type discriminator. |
schema | JSON Schema Draft 2020-12. Used for validation on the backend and form generation on the frontend. |
uiHints | Optional display configuration: component (React component name), label (display name), plus arbitrary UI settings. |
deprecated | Lifecycle flag. Deprecated rules still function but are flagged in the admin UI. |
createdBy / updatedBy | Who created/last modified the rule. |
Optimistic Concurrency
To prevent conflicting edits, rules use optimistic locking. When you fetch a rule, you receive an ETag header. When saving changes, include the ETag in the If-Match header. If the rule was modified by someone else since you last fetched it, the save is rejected with a 412 Precondition Failed response.
Cross-Domain Usage
Rules are consumed by other domains:
- Nodes validate that referenced rules exist before saving layout templates.
- Suggestions validate submitted values against the rule's JSON Schema before storage.
API Endpoints
| Method | Endpoint | Purpose | Auth |
|---|---|---|---|
GET | /rules/{folder} | List all rules in a folder | Required |
GET | /rules/{folder}/{componentKey} | Get a single rule (includes ETag header) | Required |
POST | /rules/{folder}/{componentKey} | Create a new rule (409 if exists, unless ?overwrite=true) | Required |
PUT | /rules/{folder}/{componentKey} | Update an existing rule (404 if missing) | Required |
All endpoints require authentication. Both POST and PUT support If-Match for optimistic concurrency.
Folder Listing Response
Each rule in a folder listing includes:
| Field | Description |
|---|---|
folder | The folder path |
componentKey | Rule identifier |
deprecated | Boolean |
label | Display name (from uiHints.label, defaults to componentKey) |
createdAt / createdBy | Creation metadata |
updatedAt / updatedBy | Last update metadata |