> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gorules.io/llms.txt
> Use this file to discover all available pages before exploring further.

# JDM Standard

> The JSON Decision Model format used by GoRules for portable, version-controllable business rules.

export const SdkOverview = () => {
  const sdks = [{
    name: 'Node.js',
    href: '/developers/sdks/nodejs',
    icon: 'node-js',
    color: '#68a063'
  }, {
    name: 'Python',
    href: '/developers/sdks/python',
    icon: 'python',
    color: '#3776ab'
  }, {
    name: 'Go',
    href: '/developers/sdks/go',
    icon: 'golang',
    color: '#00add8'
  }, {
    name: 'Rust',
    href: '/developers/sdks/rust',
    icon: 'rust',
    color: '#ce422b'
  }, {
    name: 'Java',
    href: '/developers/sdks/java',
    icon: 'java',
    color: '#e76f00'
  }, {
    name: 'Kotlin',
    href: '/developers/sdks/kotlin',
    icon: '/images/kotlin.svg',
    color: '#7f52ff'
  }, {
    name: 'C#',
    href: '/developers/sdks/csharp',
    icon: '/images/dotnet.svg',
    color: '#512bd4'
  }, {
    name: 'Swift',
    href: '/developers/sdks/swift',
    icon: 'swift',
    color: '#f05138'
  }, {
    name: 'WASM',
    href: '/developers/sdks/wasm',
    icon: '/images/wasm.svg',
    color: '#654ff0'
  }];
  return <div style={{
    display: 'grid',
    gridTemplateColumns: 'repeat(4, 1fr)',
    gap: '12px',
    margin: '16px 0'
  }}>
      {sdks.map(sdk => <a key={sdk.name} href={sdk.href} style={{
    display: 'flex',
    alignItems: 'center',
    gap: '10px',
    padding: '14px 16px',
    borderRadius: '8px',
    backgroundColor: '#f8fafc',
    border: '1px solid #e2e8f0',
    textDecoration: 'none'
  }}>
          <Icon icon={sdk.icon} size={18} color={sdk.color} className="my-0" />
          <span style={{
    fontSize: '14px',
    fontWeight: 500,
    color: '#1e293b'
  }}>
            {sdk.name}
          </span>
        </a>)}
    </div>;
};

JDM (JSON Decision Model) is the file format used by GoRules to represent decision graphs. It's a human-readable JSON structure that captures nodes, edges, and configuration in a portable format.

## Why JDM?

| Benefit                  | Description                                        |
| ------------------------ | -------------------------------------------------- |
| **Portable**             | Works across all GoRules SDKs and tools            |
| **Version controllable** | Store in Git alongside your code                   |
| **Human readable**       | Review and diff changes easily                     |
| **Extensible**           | Add custom metadata without breaking compatibility |

## File structure

A JDM file contains three main sections:

```json theme={null}
{
  "nodes": [...],
  "edges": [...],
  "metadata": {...}
}
```

### Nodes

Each node represents a processing step in the decision:

```json theme={null}
{
  "id": "node-1",
  "type": "decisionTableNode",
  "name": "Customer Discount",
  "position": { "x": 200, "y": 100 },
  "content": {
    // Node-specific configuration
  }
}
```

### Edges

Edges define connections between nodes:

```json theme={null}
{
  "id": "edge-1",
  "sourceId": "input-node",
  "targetId": "decision-table-node",
  "sourceHandle": "output",
  "targetHandle": "input"
}
```

### Metadata

Optional metadata about the decision:

```json theme={null}
{
  "metadata": {
    "version": "1.0.0",
    "author": "team@example.com",
    "description": "Customer discount calculation",
    "tags": ["pricing", "discounts"]
  }
}
```

## Loading JDM files

Load and evaluate JDM files using any GoRules SDK:

<SdkOverview />

### Validating structure

The `@gorules/jdm-editor` package exports a Zod schema for validating JDM files:

```typescript theme={null}
import { decisionModelSchema } from '@gorules/jdm-editor/dist/schema';

const content = JSON.parse(await file.text());
const result = decisionModelSchema.safeParse(content);

if (!result.success) {
  console.error('Invalid JDM:', result.error.issues);
}
```

## Version control best practices

### File organization

<Tree>
  <Tree.Folder name="rules" defaultOpen>
    <Tree.Folder name="pricing" defaultOpen>
      <Tree.File name="customer-discount.json" />

      <Tree.File name="volume-discount.json" />
    </Tree.Folder>

    <Tree.Folder name="eligibility" defaultOpen>
      <Tree.File name="loan-qualification.json" />
    </Tree.Folder>
  </Tree.Folder>

  <Tree.File name="README.md" />
</Tree>

### Meaningful commits

```bash theme={null}
git commit -m "Add enterprise tier discount (20% for orders > $10k)"
```

### Review diffs

JDM's JSON format makes diffs readable:

```diff theme={null}
  "rules": [
    {
      "inputEntries": [{ "value": "\"gold\"" }],
-     "outputEntries": [{ "value": "0.15" }]
+     "outputEntries": [{ "value": "0.20" }]
    }
  ]
```

## Exporting from BRMS

The GoRules BRMS exports decisions in JDM format:

1. Open the decision in BRMS
2. Click **Export** in the toolbar
3. Choose **JSON Decision Model (.json)**
4. Save to your repository

## Schema reference

The complete JSON Schema for JDM files is available in the [zen repository](https://github.com/gorules/zen).
