<?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 David Lee on Medium]]></title>
        <description><![CDATA[Stories by David Lee on Medium]]></description>
        <link>https://medium.com/@davidsamlee?source=rss-8e34b23c18fa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_1Fsi8A1uVpcNW1ePZrzjg.jpeg</url>
            <title>Stories by David Lee on Medium</title>
            <link>https://medium.com/@davidsamlee?source=rss-8e34b23c18fa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 03:38:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@davidsamlee/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[Inside DAL : Delivering performant, read-optimised data from distributed systems]]></title>
            <link>https://medium.com/@davidsamlee/inside-dal-delivering-performant-read-optimised-data-from-distributed-systems-8c2113356481?source=rss-8e34b23c18fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c2113356481</guid>
            <category><![CDATA[opensearch]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[cqrs]]></category>
            <dc:creator><![CDATA[David Lee]]></dc:creator>
            <pubDate>Fri, 08 Aug 2025 12:15:35 GMT</pubDate>
            <atom:updated>2025-08-08T12:37:26.766Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Inside DAL</strong> <strong>: Delivering performant, read-optimised data from distributed systems</strong></h3><h4><strong>We’ve built a powerful framework for doing schema translation and enrichment between our core systems and our web/API/other channels. Interested? Read on.</strong></h4><p>At <a href="https://www.withintelligence.com/">With Intelligence</a>, our success depends on serving the data our clients want, the way they want it. We are constantly enriching <a href="https://www.withintelligence.com/products/">our platform</a> with diverse new <a href="https://www.withintelligence.com/products/our-data/">datasets</a> and surfacing the data in new ways to help clients achieve their aims.</p><p>Powering our platforms are a dedicated research team and a raft of automated (increasingly AI-enabled) data pipelines working to maintain those datasets. We rely on data capture systems which reinforce good data quality and integrity before we publish their data downstream. However, from an engineering perspective, this presents us with a problem that will be familiar to many: <strong><em>The data structures our clients want to consume aren’t good structures for capturing and managing data.</em></strong></p><h4><strong>Reads vs. writes: different needs, different solutions</strong></h4><p>Our clients are not hardcore data analysts. They need simple ways to query and traverse the complex graph of related objects in our datasets (people, organisations, transactions etc.) without having to figure out complex joins across some purist <a href="https://www.datacamp.com/tutorial/third-normal-form">3NF</a>+ schema. They want simple web UIs that let them filter the data in an intuitive way, but then serve them rich content stitched from many interrelated datasets — all loading with sub-second latency.</p><p>To meet these needs, we’ve long recognised the need for separate write- vs. read-optimised data models (a practical implementation of the <a href="https://martinfowler.com/bliki/CQRS.html">CQRS pattern</a>):</p><ul><li>Our <strong>core systems</strong> implement <em>write-optimised</em> models. They have clean, highly normalised databases and granular CRUD APIs to create and mutate records. While we think of them as a single data model at the logical level, each core system defines its own schema encapsulated within its own microservice boundary (following <a href="https://martinfowler.com/bliki/DomainDrivenDesign.html">Domain-Driven Design</a> principles).</li><li>Our <strong>Data Access Layer (DAL)</strong> implements our unified, <em>read-optimised</em> model. It serves data from a large collection of OpenSearch (ElasticSearch) indexes. The values in these documents are sourced from combinations of different core systems, blended in various ways. Our indexed documents are rich, deeply nested JSON structures, each typically ~100–200KB in size. Data is deliberately duplicated across many documents, and numerous enrichments (e.g. aggregated ‘rollup’ values) are included.</li></ul><h4><strong>Schema translation and enrichment: The vital glue in the middle</strong></h4><p>CQRS literature often glosses over the vital glue which makes this pattern work: an <strong>abstraction between the write and read models</strong>, which transforms one to the other. Necessarily (for performance reasons), we can’t perform these transformations on-the-fly; we need to continuously synchronize data from our core systems through to materialised indexes on DAL.</p><p>In our implementation, the DAL engine that performs this synchronisation is one of our most complex internal systems. The engine continually monitors the core systems’ various API endpoints for updates, maps the dependency graph of the related entities, and reactively re-generates the affected documents to reflect updates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*H7BOmRiWqyRIKXR7z6vnjg.png" /><figcaption>Our Data Access Layer provides essential schema translation and enrichment between core systems and channels</figcaption></figure><p>DAL has progressively become the workhorse powering many of our consumer-facing web, API, email and related channels. Daily, it performs around 1 million reindexes across a portfolio of ~7 million JSON documents, serves over 700,000 API requests, and powers over 40,000 emails to our clients.</p><p>But why did we build it from scratch?</p><h4><strong>Existing solutions didn’t work for us</strong></h4><p>The problem of materialising read-optimised views of data is far from unique to With Intelligence, and quasi-off-the-shelf solutions do exist.</p><ul><li>Materialised views have been a feature of SQL databases since the 90s. Reactive, partial updates (essential at the scale of our product datasets) are more specialised, but Oracle’s <a href="https://docs.oracle.com/en/database/oracle/oracle-database/12.2/dwhsg/refreshing-materialized-views.html#GUID-4FD1E4C6-B82F-4B13-880C-80187FA22AAF">fast refresh feature</a> does offer this.</li><li>Alternative approaches include CDC-based tools like DMS or Debezium, coupled with a stateful streaming layer like Flink. <a href="https://materialize.com/">Materialize</a> is also an impressive framework targeting similar use cases.</li><li>On the OpenSearch front: Logstash has a healthy collection of connector plugins, but only very basic transformation capabilities.</li></ul><p>Sadly, none of the above have thus far proven suitable for our use case. Here’s why:</p><ul><li><strong>We’re not in a pure SQL world. </strong>We have various core systems backed by both SQL and NoSQL data sources, with conventional HTTP/REST/JSON APIs as the common abstraction over each. Even in the SQL cases, we wouldn’t want pipelines to directly reference tables and columns in our core databases, as this would create tight coupling that constrains our change agility. And ultimately, DAL consumers are web services that expect the final outputs to be JSON-serialised.</li><li><strong>As a DSL, SQL isn’t abstract/opinionated enough</strong>. Our index mappings are highly complex, but follow largely consistent patterns (e.g. collecting records with a foreign key and presenting these as a nested object under a parent specifying that key). Defining these mappings in pure SQL would yield huge SQL statements which would be prohibitive to understand, debug and manage. Instead, DAL implements a <strong>proprietary mapping framework</strong> with a YAML-based DSL that lets us define mapping transformations in a compact way, re-using common logic extensively to make business logic far easier to define and manage.</li><li>As a language <strong>for defining complex business logic, SQL is a poor choice</strong>. Using a conventional programming language and runtime (in this case, PHP) lets us define procedural logic in a much more expressive way, while drawing on a far deeper (and infinitely extensible) set of libraries to implement anything we need. The resulting code is generally much easier to follow, manage and debug than UDFs implemented in database runtimes.</li></ul><p>Overarching all the above are considerations of <strong>flexibility and control</strong>.</p><ul><li>As the funnel for surfacing data to clients, DAL undergoes continuous change — both extending mappings to surface new data, as well as adding new features such as conflict management and fine-grained access control. Rolling our own framework gives us confidence that we can rapidly adapt the system behaviour to new and emerging requirements, in a way which directly impacts our time to market (and thereby commercial value).</li><li>Similarly, DAL is an operationally critical platform. We need deep observability into indexing processes and precise control to tune system performance — owning our own code helps us ensure we can do this.</li></ul><p><strong>Valuable learnings from the implementation</strong></p><p>What have we learned from the process?</p><ul><li><strong>It’s a LOT of work. </strong>We’ve spent thousands of engineering hours to build DAL to its current maturity level, and continue to invest in ongoing feature and scaling improvements. Off-the-shelf solutions, in comparison, might have given us faster time-to-market, but would also have forced us to compromise our user experience in areas we see as differentiating to our product. Hence, we’ve come to see <strong>effective indexing as a critical strategic capability</strong>.</li><li><strong>Schema design and indexing strategy is key. </strong>Poor choices can have a dramatic impact on performance, which in turn has major impacts on our customer engagement.</li><li><strong>PHP is still great. </strong>It may less popular now, but PHP continues to prove a robust runtime and development language which plays an important role in our polyglot landscape. Symfony framework, in particular, is a brilliant enterprise-grade framework with a great ecosystem of tools and libraries and a focused developer community. Together with strict coding standards, this has enabled us to build a clean, well-componentised codebase for DAL that’s easy to maintain and extend.</li></ul><h4><strong>Conclusion</strong></h4><p>Building DAL has given us a powerful, flexible foundation for client-facing experiences. It’s also reminded us that indexing is not an afterthought — it’s a core capability, tightly tied to product delivery. Investing in a custom framework has paid off through control, speed, and adaptability.</p><h4><strong>If you’re interested in working on practical data management problems with real commercial impact, </strong><a href="https://www.withintelligence.com/about/careers/"><strong>check out our hiring page on WithIntelligence.com</strong></a><strong>.</strong></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c2113356481" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>