<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abdul Rahim on Medium]]></title>
        <description><![CDATA[Stories by Abdul Rahim on Medium]]></description>
        <link>https://medium.com/@abdulrahimio?source=rss-644a7553646e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZxzeLCDTn9HwmBlPxB6_QQ.jpeg</url>
            <title>Stories by Abdul Rahim on Medium</title>
            <link>https://medium.com/@abdulrahimio?source=rss-644a7553646e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 12:19:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abdulrahimio/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Extending Tazama: A Deep Dive (Part 3) — TCS]]></title>
            <link>https://medium.com/@abdulrahimio/extending-tazama-a-deep-dive-part-3-tcs-7de9cd8c7f39?source=rss-644a7553646e------2</link>
            <guid isPermaLink="false">https://medium.com/p/7de9cd8c7f39</guid>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[systems-thinking]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Abdul Rahim]]></dc:creator>
            <pubDate>Fri, 09 Oct 2026 06:12:46 GMT</pubDate>
            <atom:updated>2026-10-09T06:12:46.848Z</atom:updated>
            <content:encoded><![CDATA[<p>Oct 8, 2026 · @Dev</p><h3>Where we left off</h3><p>In <a href="https://medium.com/@abdulrahimio/extending-tazama-a-deep-dive-part-2-dems-e5ba2b2b0d72">Part 2</a> we watched <strong>DEMS ingest any kind of transactional message</strong> through one catch-all route. The four steps from Part 1 were all still there. Extract. Build objects. Call DB functions. Forward. Only now <strong>every step read its instructions from configuration</strong> instead of code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*OO2QhhryFBfe8uX8XHyEvA.png" /><figcaption>the entire system at one visual glance</figcaption></figure><p>One row in tcs_config. The schema, the mapping, the functions, the endpoint path.</p><p>But wait. <strong>Who writes that row?</strong> 🤔</p><p>That’s <a href="https://github.com/tazama-lf/connection-studio"><strong>TCS</strong></a> (Tazama Connection Studio). DEMS is runtime. TCS is <strong>design time</strong>.</p><p><strong>A quick note on scope: this article covers the TCS backend only.</strong> The frontend gets its own article. Why split them? <strong>Separation of concerns.</strong></p><h3>The big picture</h3><p>First surprise: <strong>the TCS backend has no database of its own.</strong> No ORM. No connection pool. Let’s see how it saves a config:</p><p><em>Every write is an HTTP call to the </em><strong><em>Admin Service</em></strong><em> (</em><em>/v1/admin/tcs/config/write), carrying </em><strong><em>the user&#39;s own token</em></strong><em>. Admin Service owns </em><em>tcs_config. TCS only asks.</em></p><p>So what does the backend actually do? It’s a <strong>gatekeeper</strong>. It decides <strong>who</strong> may do <strong>what</strong> to a config, and <strong>when</strong>. Admin Service does the storing.</p><p>Here’s the journey of one config, from blank page to live traffic:</p><ol><li><strong>Create</strong> it (the endpoint is born)</li><li><strong>Map</strong> it (mapping rules and functions)</li><li><strong>Rehearse</strong> it (simulation)</li><li><strong>Approve</strong> it (maker-checker)</li><li><strong>Switch it on</strong> (and nudge DEMS)</li></ol><p>five stops. Let’s walk them.</p><h3>Stop 1: Create</h3><p>An Editor creates a config. First question TCS asks: <strong>does it already exist?</strong></p><p><em>Same </em><strong><em>endpoint(message family + version + transaction type)</em></strong><em> for the same tenant? Rejected.</em></p><p>Then the most important line in the whole create flow:</p><p><strong><em>The URL is born here.</em></strong><em> </em><em>/{tenant}/{version}/{msgFam}/{transactionType}. Remember Part 2, step 1: </em><strong><em>the URL is the identity</em></strong><em>? This is where that identity gets minted.</em></p><h3>Stop 2: Map</h3><p>A config with a schema but no mapping is just a validator. The interesting part is the rules.</p><p><em>Mapping rules and functions are added </em><strong><em>one at a time</em></strong><em>, and </em><strong><em>only an Editor</em></strong><em> can add them.</em></p><p>What does one rule look like?</p><p><strong><em>Sources</em></strong><em> (paths in the incoming message), a </em><strong><em>destination</em></strong><em>, and a few optional extras: delimiter, prefix, suffix, constant. The exact shape DEMS read in Part 2.</em></p><p>But a destination can’t point just anywhere. TCS keeps a <strong>catalogue of destinations</strong>:</p><p><em>Collection 1 is </em><strong><em>transactionDetails</em></strong><em>. Collection 2 is </em><strong><em>redis</em></strong><em> (the DataCache). Now read the field names. </em><strong><em>TxTp, Amt, Ccy, EndToEndId… dbtrId, cdtrAcctId…</em></strong><em> The same two objects every TMS handler built by hand in Part 1. Now they&#39;re rows in a table.</em></p><p>Functions work the same way: a list of function names (addAccount, addEntity, addDataModelTable…), each with its params. DEMS checks every name against its allowlist later…</p><h3>Stop 3: Rehearse</h3><p>Here’s a part I really like. Before anyone approves anything, an <strong>Editor or an Approver can dry-run the config</strong> against a test message. POST /simulation/run.</p><p><strong><em>Five stages.</em></strong><em> Load the config. Parse the payload (JSON or XML). Validate it against the saved schema. Check that every mapping’s sources </em><strong><em>actually exist</em></strong><em> in the message. Then </em><strong><em>run the mappings</em></strong><em>. A failing stage stops the rehearsal right there.</em></p><p>And stage 5 doesn’t fake it. It runs processMappings from tcs-lib</p><p>So the Editor sees <strong>the exact objects a message would produce</strong>, before the config is anywhere near live traffic.</p><h3>Stop 4: Approve</h3><p>Now the maker-checker part. <strong>Tow roles: Editor, Approver.</strong> And eight statuses:</p><p><em>Numbered on purpose. </em><em>STATUS_01 to </em><em>STATUS_08 </em><strong><em>read like a timeline</em></strong><em>.</em></p><p><em>On approve, TCS asks Admin Service to create </em><strong><em>the history table for this transaction type</em></strong><em>, plus </em><strong><em>one extension table per </em></strong><strong><em>addDataModelTable function</em></strong><em>. By the time DEMS needs to write into those tables, they already exist.</em></p><h3>Stop 5: Switch it on</h3><p>Deployed isn’t the end. There’s one more field: <strong>publishing_status. Active or inactive.</strong></p><p>status is the <strong>approval history</strong>. publishing_status is the <strong>switch</strong>.</p><p><em>A Publisher (or an Approver) flips it. TCS updates the row, then </em><strong><em>notifies DEMS</em></strong><em>. If DEMS can’t be told, the request fails loudly.</em></p><p><em>And this is </em><strong><em>the only place TCS ever calls DEMS.</em></strong><em> A </em><em>PATCH /config-notify/:id. </em><strong><em>An id and a status. No config.</em></strong><em> DEMS re-reads the row itself and refreshes its Redis cache</em></p><p>So TCS and DEMS never hand each other a config. <strong>The row is the contract.</strong> The call is just a nudge: <em>hey, row 42 changed, go look.</em></p><h3>Wrapping up</h3><p>To summarize, one config’s journey through the TCS backend:</p><ol><li><strong>Create</strong>: the endpoint path is minted</li><li><strong>Map</strong>: rules and functions, pointing into a catalogue of destinations</li><li><strong>Rehearse</strong>: the same mapping logic, on a test message, before anyone approves</li><li><strong>Approve</strong>: three permission gates, and the tables get built</li><li><strong>Switch it on</strong>: flip publishing_status, nudge DEMS</li></ol><p>Zoom out on the series for a second.</p><p>Part 1: <strong>four hardcoded handlers</strong>.</p><p>Part 2: <strong>one catch-all route</strong> that reads its instructions from a row.</p><p>Part 3: <strong>the place where that row is written, reviewed and shipped.</strong></p><p>Configure once. Ingest anything.</p><h3>What’s next</h3><p>We stayed on the backend the whole way. But someone has to actually <strong>build</strong> these configs: drop in a sample message, get a schema out of it, wire sources to destinations. That’s the <strong>TCS frontend</strong>, and it gets its own article.</p><p>Stay tuned. Thanks for reading. cheers. ciao.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7de9cd8c7f39" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A rule changes in Tazama — how to test it?]]></title>
            <link>https://medium.com/@abdulrahimio/a-rule-changes-in-tazama-how-to-test-it-39c1a74f78c7?source=rss-644a7553646e------2</link>
            <guid isPermaLink="false">https://medium.com/p/39c1a74f78c7</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <dc:creator><![CDATA[Abdul Rahim]]></dc:creator>
            <pubDate>Wed, 07 Oct 2026 14:33:13 GMT</pubDate>
            <atom:updated>2026-10-07T14:33:13.932Z</atom:updated>
            <content:encoded><![CDATA[<p>This article covers a guide for someone working to <strong>modify existing Tazama rules</strong> (either code or config layer).</p><p>Firstly, you need a good understanding of <a href="https://github.com/tazama-lf/docs/tree/dev"><strong>core Tazama</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-H1EFXMvU08YaFYZwEhepA.png" /><figcaption>This is where you start</figcaption></figure><p>Then, you need to know what the <strong>key configuration artifacts</strong> are in the Tazama core ecosystem and how processing is decoupled from configuration. Key thing to note is that <strong>config is never hard-coded</strong> in code. It is injected. See how at three links: <a href="https://github.com/tazama-lf/docs/blob/dev/Product/complete-example-of-a-network-map.md">A</a>, <a href="https://github.com/tazama-lf/docs/blob/dev/Product/complete-example-of-a-rule-processor-configuration.md">B</a> and <a href="https://github.com/tazama-lf/docs/blob/dev/Product/complete-example-of-a-typology-processor-configuration.md">C</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9iuHrZrcS9UAxLqgjhBosg.png" /><figcaption>At a glance</figcaption></figure><p>Once the core pipeline from <a href="http://github.com/tazama-lf/docs/blob/dev/Product/transaction-monitoring-service-api.md">TMS</a> to <a href="https://github.com/tazama-lf/docs/blob/dev/Product/transaction-aggregation-and-decisioning-processor.md">Event-adjudicator</a> is clear, you make sure you know the <strong>INTENT</strong> and <strong>REASONING</strong> behind <strong>why you are modifying the existing rules</strong>. What is the need? Isn’t Tazama an already perfect system. (HINT: perfection is not a metric, changes always precede requirements)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bQd1NDkrlz3kWKayO_VmbA.png" /><figcaption>Tazama deals with 4 transaction messages in the core</figcaption></figure><h3>Why are the rules changing?</h3><p>Let’s answer that question first, because <strong>everything else in this article follows from it.</strong></p><p>Tazama is not broken. Its stock rules are not wrong. They were built for <strong>a domestic, single-currency deployment</strong> that feeds Tazama its own ISO 20022 messages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*l-R4e4bz8YASIynY1v9HBQ.png" /><figcaption>the wrapper</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jYVHJ61ccXDGYY4XLwRUIQ.png" /><figcaption>context</figcaption></figure><p>Now drop those same rules into <strong>xyz’s DRPP</strong>. A <a href="https://mojaloop.io/">Mojaloop</a> switch. Cross-border payments. It starts with say Zambia–Malawi (ZMW↔MWK) and grows to <strong>21 member states</strong>. And the messages don’t even reach Tazama directly. The <strong>Payment Platform Adapter (PPA)</strong> translates them first.</p><p>The context changed first. The requirements followed.<br>Against that context, <strong>the stock rules break</strong></p><p>Now, something to note:</p><blockquote><strong><em>A rule change is correct when the running pipeline produces the outcomes these documents predict, for the messages the PPA actually sends.</em></strong></blockquote><p>At this point<strong> green unit-test suite is necessary, but not enough.</strong></p><h3>Four things to hold in your head</h3><p>Before we send a single message, here are <strong>four mental models</strong>. The method and the scenarios later on all follow from these.</p><h3>1. A rule change is a promise about outcomes</h3><p>You need to follow one message through the pipeline.</p><p>See the full core pipeline (logs) not just the ALRT/NALT at the end.<br>An ALRT reached through the wrong band is <strong>still a failure</strong>.</p><h3>2. Each message is scored alone, and the pipeline waits for everyone</h3><p>Scoring is <strong>per message</strong>, keyed by the message’s own MsgId. A pacs.008 and its later pacs.002 are <strong>two separate evaluations</strong>. Each with its own typologies, its own maximum score, its own thresholds.</p><p>Within one message, the pipeline waits:</p><ol><li>The typology processor waits until <strong>every rule</strong> the network map lists for a typology, on that message type, has reported.</li><li>The event adjudicator then waits until <strong>every typology</strong> for that message type has reported.</li><li>Only then is <strong>one evaluation</strong> written.</li></ol><p>Two consequences:</p><ul><li><strong>One rule that never answers = no evaluation at all.</strong></li><li>A typology configured(refer to doc mentioned at the start) for a message type must reference <strong>exactly</strong> the rules routed for that message type. No more. No less.</li></ul><h3>3. History is a fixture you build on purpose</h3><p>Rules answer questions about <strong>the past</strong>. So we build that past ourselves, for each scenario, with real messages sent through TMS (this is something you would use custom transaction JSONs for):</p><h3>4. Compare before and after, not just after</h3><p>Run the <strong>same scenarios before and after</strong> the change, each in a fresh identity namespace, and <strong>diff the evaluations</strong>. Every difference must be one the change predicts. <strong>Anything else is a regression.</strong></p><h3>The method</h3><p>Now the fun part. This covers the scenario this article is about: <strong>existing rules or typologies changed in place, with the network map unchanged.</strong></p><h3>Step 1: Write the expectations first</h3><p>Yes. FIRST. Before you touch anything.</p><ul><li><strong>Name the change.</strong> Which rules or typologies, which fields, and whether it’s code, config or both.</li><li><strong>List every typology the rule feeds</strong> and the message types that route the rule to it.</li><li><strong>Write one row per scenario</strong>.</li></ul><h3>Step 2: Prove the pipeline can score the message type</h3><p>Send <strong>one minimal, valid chain</strong> for the message type the rule binds to. Then confirm three things:</p><ol><li>An evaluation is written.</li><li>Every typology for that message type is present.</li><li>Every rule’s result is present in each typology.</li></ol><p>Anything missing? <strong>STOP.</strong> It’s a platform problem, and no rule test on that message type means anything until it’s fixed.</p><h3>Step 3: Record a baseline</h3><p>Run <strong>the full scenario set</strong> against the current configuration, in its own identity namespace. Keep every evaluation it produces. This is your “before”.</p><h3>Step 4: Apply the change and prove it is live</h3><ol><li><strong>Update the configuration row in place.</strong></li><li><strong>Send a canary.</strong> One scenario whose outcome is <strong>only possible under the new configuration</strong>. For example, a value between the old band edge and the new one. Old outcome comes back? <strong>The change is not live yet.</strong></li></ol><p>The canary is the coolest trick in this whole method.</p><h3>Step 5: Run the scenarios</h3><ul><li>Send each chain <strong>in order, one message at a time</strong>, and wait for TMS to accept each message before sending the next.</li><li>Read each evaluation and fill in an <strong>“observed” column</strong> next to every expectation.</li></ul><h3>Step 6: Compare, decide, and roll back if needed</h3><h3>Worked example: an illustrative rule</h3><p>Enough theory. Let’s build one.</p><p>Read the <a href="https://github.com/tazama-lf/docs/blob/dev/Product/complete-example-of-a-network-map.md">A</a>, <a href="https://github.com/tazama-lf/docs/blob/dev/Product/complete-example-of-a-rule-processor-configuration.md">B</a> and <a href="https://github.com/tazama-lf/docs/blob/dev/Product/complete-example-of-a-typology-processor-configuration.md">C</a>. Mention in comments how you would change this typology.</p><h3>What counts as a pass</h3><p>A change passes <strong>only</strong> when ALL of these hold:</p><ul><li><strong>Every message you sent has exactly one evaluation</strong>, or none only where the scenario predicts none.</li><li><strong>No outcome appears that you didn’t predict.</strong> Especially .err.</li><li><strong>Every non-exit outcome occurred</strong> in at least one scenario. No rule is dark.</li></ul><p>And one more, in bold, because it matters: <strong>a missing evaluation is a FAIL. It is never “inconclusive”.</strong></p><h3>Wrapping up</h3><p>So, back to the question from the top. Isn’t Tazama an already perfect system?</p><p><strong>Perfection is not a metric.</strong> Tazama was built for one world, and our world(current integration) is a different one. The rules change to fit it, and testing is how we <strong>prove</strong> they fit.</p><p>Write the expectations first. Check every arrow. Basically validate all your assumptions.</p><p>And once every row matches? NOW you can go party 🍹</p><p>Thanks for reading. cheers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39c1a74f78c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extending Tazama: A Deep Dive (Part 2) — DEMS]]></title>
            <link>https://medium.com/@abdulrahimio/extending-tazama-a-deep-dive-part-2-dems-e5ba2b2b0d72?source=rss-644a7553646e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5ba2b2b0d72</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[design-thinking]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[systems-thinking]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Abdul Rahim]]></dc:creator>
            <pubDate>Mon, 05 Oct 2026 08:02:36 GMT</pubDate>
            <atom:updated>2026-10-05T08:02:36.489Z</atom:updated>
            <content:encoded><![CDATA[<h3>Where we left off</h3><p>In Part 1 we looked at how TMS ingests transactions. Four message types. Four handlers. <strong>Four hard coded recipes.</strong> Each one extracted fields, built a TransactionDetails object and a DataCache, made its DB calls, and forwarded everything to the Event Director.</p><p>The easy fix for a fifth message type was a fifth handler, and off to party. But that doesn’t scale, so the party got cancelled. Instead we ended on one route that catches <strong>every</strong> message:</p><p><strong>ONE FUNCTION TO RULE THEM ALL.</strong></p><p>This part answers the questions we left hanging. How does that one function know what a message looks like? How does it extract fields from a payload it has never seen? How does it decide which DB functions to call? And how does it store data that doesn’t even exist in Tazama’s data model?</p><p>Here’s the twist: <strong>the four steps from Part 1 are all still here, in the same order.</strong> Extract, build the objects, call the DB, forward. The difference is that every step now reads its instructions from <strong>configuration</strong> instead of code. Let’s follow one message through DEMS and see how.</p><h3>The front door</h3><p>Every message enters DEMS through the same route. Let’s look at it.</p><p><em>*endpoint catches </em><strong><em>anything</em></strong><em> after </em><em>/dems-engine/. The commas become slashes, so </em><em>ABL101,v1,iso20022,pain.001 turns into </em><strong><em>/ABL101/v1/iso20022/pain.001</em></strong><em>.</em></p><p>That path isn’t just a URL. <strong>It’s the message’s identity.</strong> The first segment is the tenant, then the version, then the standard, then the message type. Everything DEMS does next is looked up by this one string.</p><p>Since the tenant lives in the path, DEMS has to make sure nobody sends messages on another tenant’s behalf.</p><p><em>The tenant in the URL must match </em><strong><em>the tenant inside the JWT</em></strong><em>. One line of defence before anything else runs.</em></p><h3>Where the instructions come from</h3><p>In Part 1 we said the user has to tell DEMS three things: the shape of the message, which functions to call, and whether to extend the data model. So where does DEMS read all that?</p><p>From a table called <strong>tcs_config</strong>. TCS, the Tazama Connection Studio, writes a row there for every message type a user configures, through the Admin Service. DEMS only reads it.</p><p><em>Redis first, Postgres on a miss. The endpoint path is </em><strong><em>the cache key and the lookup key</em></strong><em>. Only rows with </em><em>publishing_status = &#39;active&#39; count.</em></p><p>Notice what comes back: <strong>four things</strong>. The <strong>schema</strong>, the <strong>mapping</strong>, the <strong>functions</strong>, and the <strong>related transaction</strong>. Those four columns are the entire contract between the config layer and the ingestion layer.</p><p>And here’s a fun fact. tcs_config has <strong>20 columns</strong>, and DEMS reads only <strong>six</strong> of them: those four, plus the endpoint path and the publishing status. The other fourteen (approval status, revision, sample payloads, audit columns) exist for TCS&#39;s design-time work. <strong>The table is TCS&#39;s workspace. DEMS only reads the finished product.</strong></p><p>Also notice there are two status columns. status tracks the approval workflow, while publishing_status is the live switch. So <strong>&quot;approved&quot; and &quot;live&quot; are separate decisions</strong>, which is exactly what you want in a financial system.</p><h3>Keeping the cache honest</h3><p>A cache raises an obvious question. If a user publishes a new config in TCS, how does DEMS find out? Otherwise it keeps serving the old one from Redis.</p><p>The answer lives in a small module called <strong>config-notify</strong>. It does two jobs. First, when DEMS boots, it warms the cache.</p><p><em>On startup, </em><strong><em>every active config is loaded into Redis</em></strong><em> before the first request arrives.</em></p><p>Second, whenever a config is published or switched off, DEMS is told about it through a small authenticated endpoint, PATCH /config-notify/:id.</p><p><em>Re-read </em><strong><em>one row by its id</em></strong><em>, stamp it with the new publishing status, write it back to Redis under its endpoint path.</em></p><p>Switching a config off is neat. The cache entry isn’t deleted; it’s rewritten as <strong>inactive</strong>. On the next request, the lookup sees inactive, ignores the cached entry, falls through to Postgres, finds no active row, and rejects the message. <strong>Off means off, immediately.</strong></p><p>Earlier versions listened on a NATS stream for these notifications. The team moved to a REST endpoint so DEMS wouldn’t have to consume a stream just for this one job.</p><h3>XML in, JSON out</h3><p>ISO 20022 messages often arrive as XML, and everything downstream speaks JSON. Converting is easy. <strong>Converting correctly is not.</strong> XML has no types. &lt;Amt&gt;1000&lt;/Amt&gt; is just text. And a repeating element appears as an object when there&#39;s one of it, and an array when there are two.</p><p>So DEMS cheats, in the best way. <strong>It reads the schema to learn what the XML means.</strong></p><p><em>The schema goes in first. Its </em><strong><em>array fields and string fields</em></strong><em> steer the parser, then a final pass fixes up the shapes.</em></p><p>How does it know which fields are arrays and which are strings? It walks the JSON Schema and writes down the path of every field by type.</p><p><em>A recursive walk over the schema: every </em><em>array path and every </em><em>string path gets </em><strong><em>collected into a list</em></strong><em>.</em></p><p>With those two lists, a single &lt;Othr&gt; element can be wrapped into a one-item array wherever the schema expects an array. Numeric-looking text becomes a number, and <strong>fields the schema marks as strings are turned back into strings</strong>, so the payload lands in exactly the shape the schema describes.</p><p>One more detail: DEMS transforms <strong>before</strong> it validates. That way the same schema validates a message whether it arrived as XML or JSON.</p><h3>Validate or quarantine</h3><p>Now the payload is JSON, and DEMS holds the schema the user defined in TCS. Validation is a job for <strong>AJV</strong>, a JSON Schema validator.</p><p><em>A failed message isn’t just rejected. It’s </em><strong><em>saved to a quarantine table</em></strong><em> with a readable list of everything that didn’t match.</em></p><p>That matters more than it looks. In a fraud system, a malformed message isn’t noise; <strong>it might be the interesting one.</strong> Quarantine means nothing silently disappears, and someone can inspect exactly what was sent and why it failed.</p><h3>The coolest part: getValueByPath</h3><p>Remember Part 1? TMS extracted fields <strong>statically</strong>, with every path written into the handler. DEMS can’t do that, because it doesn’t know the payload’s shape in advance. Nobody does, until a user configures it.</p><p>So here’s the trick. <strong>The path becomes data.</strong> A string like CstmrCdtTrfInitn.GrpHdr.CreDtTm is stored in the mapping config, and one small function walks any object along any such string.</p><p><em>Split the path on dots and </em><strong><em>walk one segment at a time</em></strong><em>. All digits? It’s an array index. Anything missing? Throw, naming the full path.</em></p><p>That’s it. Around 20 lines. Every other dynamic feature in DEMS stands on this function: it’s called from concatenation, split, data model extension, function parameters, related transactions, and data model tables.</p><p>So what does a path look like in a real config? Here’s one rule from the pain.001 mapping.</p><p><em>Three paths, glued together with an empty delimiter, written to </em><strong><em>redis.dbtrId</em></strong><em>. This is the same concatenation the TMS handler did by hand in Part 1, </em><strong><em>now as JSON instead of TypeScript</em></strong><em>.</em></p><p>The result is the debtor’s entity ID: the tenant, the identifier and its scheme, glued into one string.</p><h3>One loop, many mapping types</h3><p>TCS offers a small vocabulary of mapping types: <strong>DIRECT, CONCAT, SPLIT and CONSTANT</strong>. In DEMS, they all live in one loop over the mapping rules.</p><p><em>The destination’s </em><strong><em>prefix decides where a value goes</em></strong><em>: </em><em>transactionDetails. or </em><em>redis. (the DataCache). The rule&#39;s </em><strong><em>shape decides how it&#39;s built</em></strong><em>: an array destination splits, a </em><em>constantValue is copied, everything else is concatenated.</em></p><p>Two things are worth pausing on.</p><p>First, look at the third branch. <strong>Any prefix that isn’t one of the two core objects goes somewhere else entirely.</strong> Hold that thought; it’s how DEMS extends the data model, and we’ll get there shortly.</p><p>Second, there’s no branch for DIRECT. Why? Look at concatenation.</p><p><em>Loop over the sources, extract each with </em><em>getValueByPath, and join with the delimiter. </em><strong><em>A CONCAT of one source is a DIRECT copy.</em></strong><em> No special case needed.</em></p><p>The rules even carry a transformation label like &quot;CONCAT&quot; or &quot;NONE&quot;, but DEMS never reads it. <strong>It decides by shape, not by label.</strong> The label is there for TCS and for humans.</p><h3>Calling functions by name, safely</h3><p>In Part 1, pacs.008 made three DB calls and pacs.002 made <strong>none</strong>. A hardcoded handler just knows. So how does one generic function decide?</p><p>It doesn’t. <strong>The config decides.</strong> The functions column is a list of function names, each with its parameters.</p><p><em>Populating the historical graph, </em><strong><em>written as a list</em></strong><em>: add the accounts, add the entities, link them as account holders.</em></p><p>So pacs.008’s config lists three functions and pacs.002’s lists zero. <strong>There’s no branching in the code at all.</strong> The difference lives entirely in the data.</p><p>Now, how do you call a function whose name arrives as a string? In JavaScript, a method is just a property on an object. So you look it up by name and call it.</p><p><em>One line of dispatch: </em><strong><em>this.databaseOperationsService[functionToCall](...)</em></strong><em>. And right above it, the line that makes it safe: </em><strong><em>the allowlist</em></strong><em>.</em></p><p>That allowlist is doing serious work. Without it, a config could name <strong>any</strong> method on that service, including internal ones. With it, “call anything” becomes <strong>“call one of six”</strong>. Dynamic dispatch with a gate in front is a pattern worth stealing.</p><p>One more subtle bit. Look at the params in the functions config above: redis.dbtrAcctId, transactionDetails.TenantId. Those aren&#39;t payload paths. <strong>They&#39;re Tazama names.</strong></p><p><em>Each param is matched to </em><strong><em>the mapping rule that produces it</em></strong><em>, and that rule’s extraction is re-run against the payload.</em></p><p>So the functions config never needs to know the payload’s shape. It speaks Tazama, and <strong>the mapping layer translates</strong>.</p><h3>Extending the data model</h3><p>Remember the third branch in the mapping loop? Any destination prefix that isn’t transactionDetails or redis lands in a third object, built on the fly: <strong>dynamicMapping</strong>.</p><p><em>A rule with destination </em><em>customerProfile.riskScore creates </em><em>dynamicMapping.customerProfile.riskScore. </em><strong><em>Nothing called </em></strong><strong><em>customerProfile exists in the code. The config invents it.</em></strong></p><p>To store it, the functions config adds an addDataModelTable entry: a table name and two columns, one for the key and one for the data.</p><p><em>Each column says </em><strong><em>where to read from</em></strong><em>: </em><em>dataModel means the </em><em>dynamicMapping bucket, anything else means the raw payload. Both reads use </em><em>getValueByPath.</em></p><p>The table name comes from config, which means it ends up in SQL. So it has to pass a strict check first.</p><p><em>Letters, digits and underscores only. </em><strong><em>Anything else is rejected</em></strong><em> before it gets near a query.</em></p><p>And here’s the trick that makes it all work without a migration per message type.</p><p><em>Every extension table has </em><strong><em>the same four columns</em></strong><em>: </em><em>_key, </em><em>data, </em><em>tenantId, </em><em>creDtTm. Only the table name changes.</em></p><p>DEMS never needs to know what a custom table looks like. <strong>Whatever the user models is stored as a blob under a key.</strong> The core graph works the same way in spirit: accounts and entities are nodes, account holders and transactions are edges, all as plain Postgres rows.</p><h3>pacs.002 and the related transaction</h3><p>A pacs.002 is a status report. It says “this payment went through” but carries almost none of the payment’s details: no amount, no debtor, no creditor. Those live in the original pacs.008. Yet the DataCache needs them.</p><p>TMS handled this by hand. DEMS handles it with <strong>one more config column</strong>: related_transaction. A pacs.002 config simply points at the pacs.008 endpoint.</p><p><em>Read this message’s EndToEndId, </em><strong><em>fetch the original transaction</em></strong><em> with the same ID, run </em><strong><em>the original’s own mapping</em></strong><em> against it, and merge the result into the DataCache.</em></p><p>The nice part is reuse. The pacs.002 config doesn’t duplicate pacs.008’s mapping rules; <strong>it borrows them.</strong> If the pacs.008 mapping changes, the pacs.002 flow picks it up automatically. There’s even a comment in the code that sums it up perfectly: “pacs002 main 2 baar chalega processMapping”. The mapping runs twice: once for the original, once for the status report.</p><h3>Out the door</h3><p>The objects are built, the graph is updated. Time for step four from Part 1: forward to the Event Director. DEMS wraps the transaction and its DataCache into a Tazama payload, then does two things <strong>in parallel</strong>.</p><p><em>Save the transaction history and notify the Event Director over NATS at the same time. </em><strong><em>Promise.allSettled, not </em></strong><strong><em>Promise.all</em></strong><em>, so if both fail, both failures get reported.</em></p><p>History has one last design choice worth showing.</p><p><em>The four message types TMS already knew keep </em><strong><em>their dedicated history tables</em></strong><em>. Everything else falls through to </em><strong><em>a dynamic table</em></strong><em> named after the message type.</em></p><p>That default branch is the whole story in one line: <strong>known messages keep their old homes, and new ones get a generic one.</strong></p><h3>To sum up</h3><p>The same four steps from Part 1, now driven by data:</p><ol><li><strong>Extract</strong>: getValueByPath walks paths stored in the mapping config.</li><li><strong>Build the objects</strong>: the destination prefix routes each value to TransactionDetails, the DataCache, or a brand new dynamicMapping object.</li><li><strong>Call the DB</strong>: function names from config, dispatched by name behind an allowlist.</li><li><strong>Append the DataCache and forward</strong>: history and the Event Director, in parallel.</li></ol><p>Wrapped around them: a schema-aware XML transform, validation with quarantine, and a cache that TCS keeps honest.</p><p>But we’ve only seen one side. Every one of those instructions was written by someone in <strong>TCS</strong>: the schema, the mapping rules, the function list. How does a business user build all that without writing code? How does a config move from draft to approved to live?</p><p>That’s the config layer, and it’s <strong>Part 3</strong>. Stay tuned. 👀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5ba2b2b0d72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extending Tazama — A Deep dive part 1]]></title>
            <link>https://medium.com/@abdulrahimio/extending-tazama-a-deep-dive-part-1-8b255035d334?source=rss-644a7553646e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b255035d334</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Abdul Rahim]]></dc:creator>
            <pubDate>Tue, 29 Sep 2026 05:52:45 GMT</pubDate>
            <atom:updated>2026-09-29T05:52:45.753Z</atom:updated>
            <content:encoded><![CDATA[<p>This video is for those who want to<strong> understand what </strong><a href="https://github.com/tazama-lf/event-monitoring-service/blob/main/README.md"><strong>DEMS</strong></a><strong> is</strong> and how it works, both on a high level and under the hood, to <strong>let the core pipeline ingest any and all kinds of transactional messages. </strong>A bit long, but surely a great lesson in designing systems.</p><p>The most important step is that we start by having a look at <a href="https://github.com/tazama-lf/docs/blob/dev/Product/transaction-monitoring-service-api.md">TMS</a> (<a href="https://github.com/tazama-lf/tms-service">transaction-monitoring-service</a>), which accepts an HTTP request from the DFSP and starts the chain of work. TMS holds the data preparation rules. Static. Hardcoded. How to deal with payment initiation and payment clearing ISO 20022 messages.</p><p>It is the microservice capable of ingesting HTTP requests, all others communicate via NATS. As you see that <strong>TMS is only capable of ingesting and working with 4 ISO 20022 messages</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*N4bLDEcJG1r_H-qB1wWYqw.png" /></figure><p>Our requirement was to be able to ingest new kinds of transactional messages so that new <a href="https://github.com/tazama-lf/docs/blob/dev/Product/complete-example-of-a-rule-processor-configuration.md">rules</a> and <a href="https://github.com/tazama-lf/docs/blob/dev/Product/complete-example-of-a-typology-processor-configuration.md">typologies</a> can be created for the transaction to be evaluated against. With the purpose of extending and making the system more versatile, we set out to THINK.</p><p>Its important at this point to have a look at what each of these handlers do. We will have a look at their code as it is important to understand what <strong>INGESTION </strong>actually means. Its not just accepting the request and giving it</p><p>Let us have a look at Pain001:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jCzqvfuk4mTKE1kwJj5LgA.png" /><figcaption>The first step is <strong>extracting the required data</strong> from the incoming payload. This is common in all 4 handlers</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*Rf5L32p8P325v-zSUuqqiA.png" /><figcaption>Then we create two custom objects for our Data Model. These objects are important<strong> for the internal data rails of Tazama</strong>. Notice how several fields of the objects are made from the concatenation of extracted data peices. Technically, we call it “initial processing of the transaction message<strong> to integrate the message into the Tazama’s historical data store</strong>”</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ejha0ZDeGR0IIQyX0DvXSw.png" /><figcaption>Finally call a few functions <strong>to populate the “historical graph”.</strong> Think of it as <strong>organizing the data for better processing</strong>. And forward the request to the event-director (mircoservice that routes the request to the appropriate rules)</figcaption></figure><p>Let’s have a look at Pacs008 as well to understand how the handling of a message might differ:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qABFAjb0A-3MxRwLuz-jrQ.png" /><figcaption>Extracting information from the payload. Making TransactionDetails and DataCache. Same.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*no5t7XjLM-jYjHTJQOg7MA.png" /><figcaption>Not the same functions are invoked as pain001. Different way to populate the “historical graph”. This became one of the challenges we faced while developing DEMS. How to dynamically invoke functions on runtime</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*c32W0nfVNZFpqqgmAh6Dhg.png" /><figcaption>A little about the function calls mentioned above.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*i_qkKDzgqpsoYle2aha0Jw.png" /><figcaption>why we create the dataCache. <strong>Efficiency is the reason</strong></figcaption></figure><p>To summarize: <br>1. <strong>Extract required data</strong> (depending on payload schema)<br>2. <strong>Make necessary objects</strong> (always two unless extending data model)<br>3. <strong>Invoke the required DB calls</strong> (vary from handler to handler ie: 3 calls in pacs.008 and no calls in pacs.002 → important requirement for DEMS)<br>4. <strong>Append DataCache and forward.</strong></p><p>Now things get incredibly interesting when you think of a 5th message. The easy way would just be to extend TMS. Create a fifth handler and go party 🍹! But wait. Is that scalable? How many handlers can you possibly create? Sorry. Party cancel. Lets get back to work 😄</p><p>Our requirement was to create two services: <strong>one for the configuration</strong> of transactional messages i.e: <a href="https://github.com/tazama-lf/connection-studio"><strong>TCS</strong></a> (Tazama connection studio) and <strong>one for the live ingestion and processing</strong> i.e: <strong>DEMS</strong> (Dynamic event monitoring). A user would use TCS to configure a new type of request, in a way extending Tazama’s core pipeline, and tell DEMS:</p><ol><li>The shape of the message its going to receive (Think of how TMS extracted data. Statically. By hardcoding the paths. <strong>But how would you extract data from a payload that the user has submitted.</strong> It could literally be of any shape. Dynamic extraction of data is the most cool part of DEMS, wait for <strong>getValueByPath </strong>function)</li><li>Which functions to call (depending upon how that particular transaction populates the data model → <strong>dynamically selecting which functions need invocation</strong> is yet another mystery)</li><li>Whether to extend the data model (<strong>new messages may require extended modelling</strong>, objects other than DataCache and TransactionDetails)</li></ol><p>Above are the core requirements. DEMS would only have a single function, a <a href="https://docs.nestjs.com/controllers#route-wildcards">catch-all</a> route wildcard. All new transactions are going to be caught by a single function. <strong>ONE FUNCTION TO RULE THEM ALL.</strong></p><pre>@Controller(&#39;/dems-engine&#39;)<br>@UseGuards(TazamaAuthGuard)<br>export class DemsEngineController {<br>  constructor(<br>    private readonly demsEngineService: DemsEngineService,<br>  ) {}<br><br>  @Post(&#39;*endpoint&#39;)<br>  @RequireDemsWriteRole()<br>  async messageHandler(<br>    @Param(&#39;endpoint&#39;) endpoint: string,<br>    @Body() payload: any,<br>    @User() user: AuthenticatedUser,<br>  ): Promise&lt;MessageHandlerResponse&gt; {<br>    //code<br>  }</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b255035d334" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>