OGRE (Optimal Government Rule Engine): A Complete Guide for Developers

 





Introduction ( परिचय )

Modern government systems का सबसे बड़ा challenge हमेशा एक ही रहा है — policy बदलती रहती है, और tech system वही पुराने rules पर चलता रहता है। Result?

  • Delays

  • Duplicate logic

  • अलग-अलग systems में inconsistencies

  • हर छोटी rule change के लिए developers पर dependency

इसी समस्या को solve करने के लिए GovTech ने बनाया — OGRE (Optimal Government Rule Engine).
OGRE एक Whole-of-Government BRMS (Business Rule Management System) है जो agencies को allow करता है:

  • Policy rules को low-code तरीके से define करने के लिए

  • इन rules को APIs के द्वारा किसी भी application में integrate करने के लिए

  • Single source of truth बनाकर duplication और errors हटाने के लिए

  • Policy teams को rule updates खुद करने देने के लिए, बिना dev sprint का इंतज़ार किए

GovTech की terms में —
“Turn policy into executable logic fast, standardised and maintainable way.”


🧠 Why OGRE Exists ( OGRE की ज़रूरत क्यों पड़ी )

Singapore Government के बहुत सारे workflows — grants, subsidies, licensing, approvals, eligibility checks — ये सब rule-based logic पर चलते हैं।

Problem ये थी कि:

  • हर agency खुद logic लिखती थी

  • Policy updates आते ही सारा कोड बदलना पड़ता था

  • Audit trails नहीं होते थे

  • Business teams किसी भी change के लिए dev टीम को ping करती रहती थीं

OGRE solves this beautifully:

  • Rules no-code/low-code interface में बनते और manage होते हैं

  • Versioning + governance built-in है

  • Systems OGRE से API call करके decision लेते हैं

  • Rule updates बिना deployment के live हो जाते हैं

ये वही चीज़ है जो banks में BRMS जैसे Drools, Blaze आदि करते हैं — लेकिन OGRE government-scale और Singapore standards में built है।


⚙️ OGRE Architecture (High-Level)

कल्पना कर Directus Optical CMS जैसे systems को OGRE से जोड़ने का मतलब क्या है:

[Policy Team] → defines rule in OGRE UI ↓ [OGRE Rule Engine] ↓ exposes REST APIs for evaluation ↓ [Applications: Directus, Node.js, Java, .NET] call OGRE API → get rule decision → act

Practical example (Optical CMS PR Journey या BCA POC जैसे projects):

  • Eligibility check

  • Date validations

  • Computation logic

  • Auto-approval rules

  • Status transitions
    ये सब OGRE में बन सकते हैं और Directus केवल data manage करेगा।


🧩 OGRE Features (मुख्य विशेषताएँ)

  • Low-Code Business Rule Modeller

  • ✔ Versioning + Rule Governance

  • ✔ Rule Execution via REST API

  • ✔ Reusable Golden Templates

  • ✔ Audit Trails

  • ✔ Easy integration with backend systems

  • ✔ Faster rule updates — no code deployment required


🚀 Implementation Guide (OGRE कैसे लागू करें)




Step 1: Access OGRE Sandbox

GovTech provides a sandbox (agency login required):

🔗 https://brms-sandbox.ogre.gov.sg/landing

Here you can:

  • Create rule sets

  • Upload data models

  • Test rule evaluations

  • Generate rule API endpoints


Step 2: Create a Rule Set

Example use-case (Directus Optical CMS):
PR Journey eligibility check

Policy example:

  • Age ≥ 21

  • Must have valid IPA

  • Nationality ≠ “Others”

  • FIN must match checksum

  • PR Scheme in {E, F, O}

These become rules in OGRE.

OGRE uses:

  • Data model inputs

  • Conditions

  • Outcomes (true/false, message, code, score, workflow action)


Step 3: Publish the Rule Version

Once rule is validated → publish it.
OGRE generates a rule execution API endpoint.


Step 4: Integrate with your application

The API typically looks like:

POST /ogre/api/v1/rules/{ruleSetName}/evaluate Content-Type: application/json Authorization: Bearer <token> { "input": { ... } }

Response:

{ "result": true, "messages": ["Eligible for PR Journey"], "outputs": { "score": 85, "category": "GREEN" } }

अब कोई भी app — Directus Flow, Lambda, Node.js backend — इस result का use कर सकता है।


📡 OGRE API Details (List of APIs)

(GovTech portal के high-level API specs के आधार पर)

Public documentation summary:

🔵 1. Rule Evaluation API

Used by applications to evaluate rules.

POST /ogre/api/v1/rules/{ruleSet}/evaluate

Body:

  • Input data object (Directus record)

  • Meta fields (version, environment etc.)

Returns:

  • Pass/Fail

  • Output fields

  • Trace of evaluated rules


🔵 2. Get Rule Metadata

GET /ogre/api/v1/rules/{ruleSet}

Returns:

  • description

  • versions

  • last published date

  • input/output schema


🔵 3. Test Rule Execution (Sandbox)

POST /ogre/api/v1/rules/{ruleSet}/test

Used during setup to validate rule logic.


🔵 4. Version Management APIs

GET /ogre/api/v1/rules/{ruleSet}/versions GET /ogre/api/v1/rules/{ruleSet}/versions/{version}

🔵 5. Audit & Trace API

Shows execution logs (if enabled).


Note: Actual endpoints vary — agencies get detailed API docs after onboarding.


🔗 How to Integrate OGRE with Directus Optical CMS

Directus already acts as a content/data management backend. OGRE provides decision logic.

Optical CMS + OGRE works beautifully together.


⭐ Approach 1: Directus + Flow → HTTP Request to OGRE

Perfect for:

  • Eligibility checks

  • Form validations

  • Auto-approval workflows

  • Status transitions

Directus Flow Structure:

Trigger:

  • Item Create

  • Item Update

Steps:

  1. Read Data (user_profile, BCA_worker_Data etc.)

  2. HTTP Request → OGRE API

  3. Condition Step → Based on OGRE result

  4. Update Data → Update status, send email, generate log

HTTP Request Example (inside Directus Flow)

URL:

https://ogre.gov.sg/api/v1/rules/PRJ_Eligibility/evaluate

Headers:

Authorization: Bearer {{env.OGRE_TOKEN}} Content-Type: application/json

Body:

{ "input": { "Age": "{{read.Age}}", "IPA_Expiry": "{{read.IPA_Expiry}}", "Nationality": "{{read.Nationality}}", "Scheme": "{{read.PR_Scheme}}" } }

Response Handling:

{{http.result}} {{http.result.outputs.category}}

⭐ Approach 2: Using Node.js Lambda Integration (Recommended for PRJ, BCA POC)

Your architecture already uses Lambdas for:

  • Reading SFTP

  • Processing INCOMING files

  • Creating/updating Directus records

  • Generating ACK files

इन lambdas में आप OGRE को call कर सकते हो.

Node.js example:

const axios = require("axios"); async function evaluateEligibility(data) { const res = await axios.post( "https://ogre.gov.sg/api/v1/rules/PRJ_Eligibility/evaluate", { input: data }, { headers: { Authorization: `Bearer ${process.env.OGRE_TOKEN}`, "Content-Type": "application/json" } } ); return res.data; }

⭐ Approach 3: OGRE as Validation Layer for CMS API Gateway

Optical CMS (Directus) → API Gateway → OGRE → CMS
Use case:

  • Grants

  • Compliance checks

  • Nationality validation

  • License logic

  • Worker test eligibility (BCA use case)


🧪 Example Use Case for BCA POC – OGRE Integration

Rule:

If Trade_Specialization = "SEC(K)" AND Age between 2160 AND Passport valid THEN → Eligible for Test Booking ELSE → Reject

Directus Flow:

  • Facilitator uploads worker data →

  • Flow calls OGRE →

  • OGRE returns validation →

  • System assigns status:

    • "Eligible for Test Booking"

    • OR "Rejected – Age Criteria Failed"


🎯 Benefits for Directus + OGRE Integration

  • No hardcoded logic in flows/scripts

  • Policy updates don’t require code change

  • Faster sprint cycles

  • Policy + tech in sync

  • Clear governance

  • Reusable rule templates

  • Easier audit trail

  • Centralised decision-making for multiple portals






🔥 1. SEQUENCE DIAGRAMS 

A) Directus → OGRE → Directus Flow (Eligibility Check)

This sequence diagram explains how a Directus Flow calls OGRE to determine eligibility.

Title: Directus Flow Eligibility Check via OGRE User Directus CMS: Creates/updates user_profile record Directus CMS Directus Flow Engine: Trigger Flow (Create/Update) Directus Flow Engine Directus API: Read user_profile data Directus Flow Engine OGRE Rule Engine: POST /rules/PRJ_Eligibility/evaluate Body: { input: user_data } OGRE Rule Engine OGRE Decision Module: Evaluate rules, run conditions, compute result OGRE Decision Module Directus Flow Engine: Return result: { result: true/false, outputs: {...}, messages: [...] } Directus Flow Engine Directus CMS: Update record (status, eligibility, reason) Directus CMS User: Status updated in UI (Eligible / Rejected)

B) Lambda → OGRE → Directus (BCA Worker Workflow)

This fits your BCA POC architecture.

Title: Lambda Processing Worker OGRE Directus Update SFTP Server Lambda: Worker incoming file delivered Lambda Lambda Parser: Parse record fields, validate formats Lambda Parser OGRE Rule Engine: POST /rules/BCA_Worker_Eligibility/evaluate Input: FIN, Age, Passport, Trade_Specialisation OGRE Rule Engine Lambda: Returns: result: true/false outputs: { category: "GREEN", reason: "Age valid" } Lambda Directus API: PATCH /items/BCA_worker_Data/{id} Body: eligibility_result, remarks, category Directus API Lambda: 200 OK Lambda SFTP: Generate ACK + move processed file

C) Directus Dashboard → OGRE (Real-Time Rule Evaluation)

Useful when you want live scoring or decision support.

User (Officer) → Directus Admin Dashboard: Open worker/test eligibility page Directus UI → Custom Endpoint / Lambda: Request dynamic evaluation Lambda → OGRE: Evaluate rule with current record data OGRE → Lambda: Return score, decision, recommended actions Lambda → Directus UI: Populate decision panel with OGRE output

🔥 2. ARCHITECTURE DIAGRAM


┌────────────────────────┐ │ Policy Team (अधिकारियों) │ └──────────┬─────────────┘ │ defines rules ▼ ┌────────────────────────┐ │ OGRE Rule UI │ │ Low-code authoring │ └──────────┬─────────────┘ │ publish ▼ ┌────────────────────────┐ │ OGRE Rule Engine │ │ - Versioning │ │ - Rule Execution │ │ - Audit & Trace │ └───────┬─────┬─────────┘ │ │ exposes REST APIs ┌───────▼─────▼─────────┐ │ Application Layer │ │ Directus Optical CMS │ │ Node.js / Lambda │ │ .NET, Java, Python │ └───────┬───────────────┘ │ HTTP POST ▼ ┌────────────────────────┐ │ OGRE API Gateway │ │ ruleSet/evaluate │ └────────────────────────┘

🔥 3. Sample Rule Templates

ये templates ऐसे बनाए हैं कि कोई भी GovTech agency समझ ले — और Directus integration आसान हो जाए.


Template 1: PR Journey Eligibility (OGRE JSON Rule Template)

ruleSet: PRJ_Eligibility version: 1.0 inputs: - Age (number) - IPA_Expiry_Date (date) - Nationality (string) - PR_Scheme (string) - FIN (string) rules: - name: Check Age condition: Age >= 21 && Age <= 60 failMessage: "Age must be between 21–60 years" - name: IPA Validity condition: IPA_Expiry_Date >= today() failMessage: "IPA expiry date is not valid" - name: Valid Nationality condition: Nationality != "OTHERS" failMessage: "Nationality not supported for PR application" - name: Scheme Check condition: PR_Scheme in ["E", "F", "O"] failMessage: "Invalid PR Scheme" outputs: category: logic: if all rules passed → "GREEN" else"RED"

Template 2: BCA Worker Eligibility Rule

ruleSet: BCA_Worker_Eligibility inputs: - Age - Passport_Expiry - Trade_Specialisation - FIN rules: - name: Age Rule condition: Age >= 21 && Age <= 60 failMessage: "Worker age criteria failed" - name: Passport Validity condition: Passport_Expiry > today() failMessage: "Passport expired" - name: Trade Allowed condition: Trade_Specialisation in ["SEC(K)", "Welding", "Formwork"] failMessage: "Invalid trade category" outputs: decision: logic: if ALL passed → "Eligible" else"Rejected" recommended_actions: if age failed → "Check DOB" if passport failed → "Ask worker to renew passport" if trade invalid → "Assign alternative training path"

Template 3: Directus Approval Workflow Rule

ruleSet: Directus_AutoApproval inputs: - Score - Required_Documents_Uploaded - Passport_Valid - Has_Prior_Rejection rules: - Score >= 80 - Required_Documents_Uploaded = true - Passport_Valid = true - Has_Prior_Rejection = false output: status: if ALL PASS → "Auto-Approved" else"Send to CSO Review"

🔥Directus Flow HTTP Request Example

URL: https://ogre.gov.sg/api/v1/rules/PRJ_Eligibility/evaluate

Headers: Authorization: Bearer {{env.OGRE_TOKEN}} Content-Type: application/json Body: { "input": { "Age": {{read.Age}}, "IPA_Expiry_Date": "{{read.IPA_Expiry_Date}}", "Nationality": "{{read.Nationality}}", "PR_Scheme": "{{read.PR_Scheme}}", "FIN": "{{read.FIN}}" } }

Comments