The challenge:

Designing a deterministic, version-controlled rule engine to handle complex multi-layer scoring logic.

The Constraints:

The Solution:

I opted for a Normalized (Flat) Architecture to avoid the complexity of deeply nested configurations. By treating the JSON like a relational database, we decouple the structure from the logic.

{
  version: string,
  // ℹ️ Subsystems act as grouping tags
  subsystems: { id: string, name: string, ... }[],
  // ℹ️ Rules refer to subsystems via ID (Relational style)
  rules: {
    id: string, 
    subsystemId: string,
    operation: { action: 'add' | 'multiply', ... },
    dependency: string // ID of the variable/input it reads from
  }[],
}

With this normalized structure, it is possible to construct a Directed Acyclic Graph (DAG) and apply a Topological Sort. This allows the engine to automatically determine the correct execution order of isolated subsystems based on their data dependencies.

Example: If Subsystem A depends on Subsystem B, and B depends on Subsystem C, the Topological Sort resolves the execution pipeline to: C → B → A.

Key Architectural Benefits:

The Blueprint:

deterministic rule engine architecture