<?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 Ridwan Kamil on Medium]]></title>
        <description><![CDATA[Stories by Ridwan Kamil on Medium]]></description>
        <link>https://medium.com/@kamilkenny22?source=rss-69a3c110544a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*GCEmBfwbHBCUa622</url>
            <title>Stories by Ridwan Kamil on Medium</title>
            <link>https://medium.com/@kamilkenny22?source=rss-69a3c110544a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 12:58:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kamilkenny22/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[Building GM SkillsFlow: From Fragmented Public Data to a Governed Skills Intelligence Platform with…]]></title>
            <link>https://medium.com/@kamilkenny22/building-gm-skillsflow-from-fragmented-public-data-to-a-governed-skills-intelligence-platform-with-3a7c35c9dac4?source=rss-69a3c110544a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a7c35c9dac4</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[microsoft-fabric]]></category>
            <category><![CDATA[cloud-engineering]]></category>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[big-data-analytics]]></category>
            <dc:creator><![CDATA[Ridwan Kamil]]></dc:creator>
            <pubDate>Sun, 20 Sep 2026 22:45:06 GMT</pubDate>
            <atom:updated>2026-09-20T22:51:24.256Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building GM SkillsFlow: From Fragmented Public Data to a Governed Skills Intelligence Platform with Microsoft Fabric</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WSs_OXWTs_sdzSkJqn7i0A.png" /></figure><h3>How I brought apprenticeship, youth-transition and labour-market data together into one automated Greater Manchester data platform using Microsoft Fabric, dimensional modelling, SCD Type 2 and Type 4, GitHub Actions and Azure</h3><p><strong>Live platform:</strong><br><a href="https://gm-skillsflow-kamil-898341.azurewebsites.net/">https://gm-skillsflow-kamil-898341.azurewebsites.net</a></p><p><strong>GitHub:</strong><br><a href="https://github.com/kamilkenny/greater-manchester-skills-opportunity-intelligence">https://github.com/kamilkenny/greater-manchester-skills-opportunity-intelligence</a></p><p>There is a lot of public data available about skills, employment, apprenticeships and young people.</p><p>At first glance, that sounds like a good thing.</p><p>And it is.</p><p>But having a lot of data does not necessarily mean that the information is easy to use.</p><p>That was the starting point for this project.</p><p>I wanted to understand skills and opportunity across Greater Manchester, but the information I needed did not exist in one neat dataset.</p><p>Apprenticeship statistics were available through the Department for Education.</p><p>Youth participation and NEET indicators came through other education datasets.</p><p>Labour-market information came through Nomis.</p><p>Sector classifications were separate again.</p><p>Geographical mappings had their own structures.</p><p>And if I wanted to understand how apprenticeship activity, youth transition and labour-market conditions related to one another across the ten Greater Manchester boroughs, I first had to solve a much bigger problem.</p><p>The data had to be brought together.</p><p>So the question I started with was not:</p><blockquote><strong><em>Can I build a dashboard showing skills data for Greater Manchester?</em></strong></blockquote><p>The more interesting question was:</p><blockquote><strong><em>Can I build a governed data platform that brings independently published datasets together, preserves their history, standardises them, models them properly, automates the whole process and turns the result into something that can actually be used?</em></strong></blockquote><p>That question became my <strong>Greater Manchester Skills &amp; Opportunity Intelligence Platform, GM SkillsFlow</strong>.</p><h3>Project</h3><p><strong>Greater Manchester Skills &amp; Opportunity Intelligence Platform</strong></p><p><strong>GitHub:</strong><br> <a href="https://github.com/kamilkenny/greater-manchester-skills-opportunity-intelligence">https://github.com/kamilkenny/greater-manchester-skills-opportunity-intelligence</a></p><p><strong>Live platform:</strong><br> <a href="https://gm-skillsflow-kamil-898341.azurewebsites.net/">https://gm-skillsflow-kamil-898341.azurewebsites.net</a></p><h3>The dashboard was actually the easy part</h3><p>When people see an analytics project, the first thing they usually notice is the dashboard.</p><p>They see the KPIs.</p><p>They see the charts.</p><p>They see the borough comparisons.</p><p>They see the filters.</p><p>They see the trends.</p><p>But by the time a number appears on a dashboard, a lot has already happened.</p><p>In this project, the real journey looks more like this:</p><pre>Department for Education<br>        +<br>Nomis<br>        +<br>Reference data<br>        ↓<br>Microsoft Fabric Data Factory<br>        ↓<br>Bronze Lakehouse<br>        ↓<br>Silver Lakehouse<br>        ↓<br>Gold Fabric Warehouse<br>        ↓<br>Dimensional modelling<br>        ↓<br>SCD Type 2 and Type 4<br>        ↓<br>Fact tables and analytical marts<br>        ↓<br>Validated JSON export<br>        ↓<br>Private Azure Blob Storage<br>        ↓<br>Azure App Service<br>        ↓<br>Public intelligence dashboard</pre><p>That is the part that interested me most.</p><p>Because a dashboard can look impressive even when the process behind it is weak.</p><p>A number on a screen is only really useful if I can answer questions such as:</p><p>Where did it come from?</p><p>When was the source last processed?</p><p>What transformations were applied?</p><p>Was the original publication preserved?</p><p>Did the pipeline succeed?</p><p>Did a classification change over time?</p><p>Can I reproduce the result?</p><p>And if nothing changed in the source, can the system avoid pretending that something new happened?</p><p>Those questions shaped the architecture of the project.</p><h3>The first problem was not volume. It was fragmentation.</h3><p>The platform brings together several different categories of information.</p><p>The <strong>Department for Education</strong> provides the education and apprenticeship side of the picture.</p><p>That includes information around:</p><ul><li>apprenticeship participation,</li><li>apprenticeship detail,</li><li>levels,</li><li>subject areas,</li><li>youth participation,</li><li>NEET indicators,</li><li>and Not Known indicators.</li></ul><p>Then there is <strong>Nomis</strong>, which provides labour-market information through datasets such as the Annual Population Survey.</p><p>And then there are supporting reference datasets covering areas such as:</p><ul><li>Greater Manchester boroughs,</li><li>apprenticeship levels,</li><li>Sector Subject Areas,</li><li>MBacc gateway mappings,</li><li>and other classifications used to make the datasets analytically consistent.</li></ul><p>Individually, these sources are useful.</p><p>But they were not designed as one system.</p><p>That means different field names.</p><p>Different reporting periods.</p><p>Different structures.</p><p>Different levels of detail.</p><p>Different coding conventions.</p><p>Different assumptions.</p><p>Different update patterns.</p><p>So before I could ask an analytical question, I first had to make the sources speak the same language.</p><p>That became the real engineering challenge.</p><h3>Why I chose Microsoft Fabric as the core platform</h3><p>I wanted this project to reflect a modern data-engineering workflow rather than a collection of disconnected scripts.</p><p>So I built the core platform in <strong>Microsoft Fabric</strong>.</p><p>The architecture follows a Bronze, Silver and Gold pattern.</p><pre>External Data Sources<br>        ↓<br>┌───────────────────────┐<br>│        BRONZE         │<br>│                       │<br>│ Raw source snapshots  │<br>│ Immutable evidence    │<br>└──────────┬────────────┘<br>           ↓<br>┌───────────────────────┐<br>│        SILVER         │<br>│                       │<br>│ Cleaned               │<br>│ Standardised          │<br>│ Validated             │<br>│ Mapped                │<br>└──────────┬────────────┘<br>           ↓<br>┌───────────────────────┐<br>│         GOLD          │<br>│                       │<br>│ Dimensions            │<br>│ Facts                 │<br>│ SCD history           │<br>│ KPIs                  │<br>│ Public marts          │<br>└───────────────────────┘</pre><p>I like this pattern because each layer answers a different question.</p><p>Bronze answers:</p><blockquote><strong><em>What exactly did the source give me?</em></strong></blockquote><p>Silver answers:</p><blockquote><strong><em>What does the data look like after I have cleaned and standardised it?</em></strong></blockquote><p>Gold answers:</p><blockquote><strong><em>How should the organisation analyse it?</em></strong></blockquote><p>Keeping those responsibilities separate made the platform much easier to reason about.</p><h3>Stage 1: preserving the source before doing anything clever</h3><p>One of the principles I carried into this project was:</p><blockquote><strong><em>Never lose the original source just because a cleaner table now exists.</em></strong></blockquote><p>The Bronze layer therefore preserves source snapshots rather than simply replacing yesterday’s data with today’s data.</p><p>That gives me a historical record of what arrived from the source.</p><p>This matters more than it may appear.</p><p>If a downstream table suddenly looks wrong, I can go back.</p><p>If a mapping changes, I can investigate.</p><p>If I need to reprocess a dataset after changing transformation logic, the source evidence still exists.</p><p>If someone asks what the source looked like at a particular point in time, there is something to inspect.</p><p>Bronze therefore became more than a landing area.</p><p>It became the evidence layer.</p><h3>Stage 2: making unrelated datasets analytically consistent</h3><p>The Silver layer is where most of the source-specific complexity begins to disappear.</p><p>This includes work such as:</p><pre>Original field names<br>        ↓<br>Consistent naming<br>        ↓<br>Data type conversion<br>        ↓<br>Missing-value handling<br>        ↓<br>Greater Manchester filtering<br>        ↓<br>Geographical standardisation<br>        ↓<br>Reference mapping<br>        ↓<br>Subject classification<br>        ↓<br>Data-quality checks<br>        ↓<br>Curated Silver tables</pre><p>The important thing here is that I did not want every downstream model to understand how the Department for Education names a field compared with how Nomis structures one.</p><p>That would make the entire platform dependent on the source systems.</p><p>Instead, Silver absorbs that complexity.</p><p>Once the data reaches Silver, the analytical requirement becomes more important than the original source layout.</p><p>The curated model includes datasets around:</p><pre>apprenticeship_lad<br>apprenticeship_detail<br>neet<br>participation<br>nomis_aps<br>mbacc_gateway<br>data_quality_result</pre><p>This became the clean boundary between ingestion and analytical modelling.</p><h3>Stage 3: moving from datasets to a warehouse model</h3><p>Once I had clean datasets, the next question was:</p><blockquote><strong><em>Do I simply expose these tables to the dashboard, or do I model the business properly?</em></strong></blockquote><p>I chose the second option.</p><p>The Gold layer is built in <strong>Microsoft Fabric Warehouse</strong> and uses dimensional modelling.</p><p>Instead of allowing each dataset to live in isolation, I introduced shared dimensions such as:</p><pre>dim_borough<br>dim_time_period<br>dim_ssa_subject<br>dim_apprenticeship_level<br>dim_mbacc_gateway</pre><p>and fact structures such as:</p><pre>fact_apprenticeship_lad<br>fact_apprenticeship_detail<br>fact_neet<br>fact_participation<br>fact_labour_market_aps</pre><p>A simplified view looks like this:</p><pre>DIM TIME<br>                             │<br>                             │<br>DIM BOROUGH ─────────── FACT TABLES ─────────── DIM SUBJECT<br>                             │<br>                             │<br>                     DIM APPRENTICESHIP<br>                          LEVEL<br>                             │<br>                             │<br>                     DIM MBACC GATEWAY</pre><p>This is where the project started to feel less like a collection of datasets and more like an actual analytical system.</p><p>The borough stopped being just a text field repeated across different source tables.</p><p>It became a governed analytical entity.</p><p>The same applied to time periods, subject areas and apprenticeship classifications.</p><h3>Stage 4: SCD Type 2, because history should not disappear</h3><p>One of the most interesting modelling decisions in the project involved slowly changing dimensions.</p><p>Suppose a dimension attribute changes.</p><p>The easiest thing to do is overwrite the existing value.</p><p>But that creates a problem.</p><p>You lose the old state.</p><p>And once history is gone, a historical fact can suddenly appear as though it always belonged to the new classification.</p><p>That was not acceptable for the warehouse I wanted to build.</p><p>So I implemented <strong>Slowly Changing Dimension Type 2</strong>.</p><p>The principle is straightforward:</p><pre>Existing current record<br>        │<br>        │ Tracked attribute changes<br>        ▼<br>Expire current version<br>        │<br>        ├── is_current = 0<br>        └── valid_to = change date<br>        │<br>        ▼<br>Insert new version<br>        │<br>        ├── is_current = 1<br>        └── valid_from = change date</pre><p>This allows the platform to answer two different questions:</p><pre>What is true now?</pre><p>and:</p><pre>What was true at the time this historical fact was recorded?</pre><p>I applied this pattern to analytical dimensions including borough, MBacc gateway and Sector Subject Area structures.</p><p>From a dashboard user’s perspective, this happens quietly in the background.</p><p>From a warehouse perspective, it is one of the features that protects analytical history.</p><h3>Stage 5: SCD Type 4, because not all history belongs in the same table</h3><p>I also used <strong>Slowly Changing Dimension Type 4</strong> for a different requirement.</p><p>Operational configuration has a different problem.</p><p>The production process needs a simple current configuration.</p><p>At the same time, I still want to know what the previous configurations were.</p><p>So rather than mixing all historical versions into the current table, I separated them.</p><p>Conceptually:</p><pre>CURRENT<br>ctl.source_config<br>        │<br>        │ historical versions<br>        ▼<br>HISTORY<br>hist.source_config</pre><p>This gives the system a very clear separation.</p><p>If the question is:</p><blockquote><strong><em>What configuration should the production pipeline use right now?</em></strong></blockquote><p>the answer comes from the current control table.</p><p>If the question is:</p><blockquote><strong><em>What configuration existed previously?</em></strong></blockquote><p>the answer comes from the historical table.</p><p>That is where SCD Type 4 became useful.</p><p>I found it particularly interesting to use Type 2 and Type 4 in the same project because they solve different problems.</p><p>Type 2 protects analytical history inside the dimension.</p><p>Type 4 separates the active operational state from historical states.</p><p>The distinction sounds academic until you actually need both.</p><p>Then it becomes very practical.</p><h3>Stage 6: fact tables gave the dimensions something meaningful to describe</h3><p>Dimensions provide context.</p><p>Facts provide measurement.</p><p>For example:</p><pre>DIM BOROUGH<br>      │<br>      ▼<br>FACT NEET<br>      ▲<br>      │<br>DIM TIME</pre><p>or:</p><pre>DIM TIME<br>                           │<br>                           ▼<br>DIM BOROUGH ── FACT APPRENTICESHIP DETAIL ── DIM SUBJECT<br>                           │<br>                           ▼<br>                  DIM APPRENTICESHIP LEVEL<br>                           │<br>                           ▼<br>                    DIM MBACC GATEWAY</pre><p>This structure means the platform can analyse different subjects, boroughs, periods and pathways without duplicating descriptive information across every fact table.</p><p>It also makes the analytical model reusable.</p><p>That became particularly important because the sources themselves were so different.</p><p>The warehouse became the common language between them.</p><h3>Stage 7: data quality had to be part of the pipeline</h3><p>One of the easiest mistakes in analytics is to treat data quality as something you inspect manually after the pipeline has already run.</p><p>I wanted the opposite.</p><p>The principle was:</p><blockquote><strong><em>Bad data should not quietly become trusted analytical data.</em></strong></blockquote><p>So data-quality checks became part of the transformation process.</p><p>The platform checks areas including:</p><ul><li>required fields,</li><li>missing values,</li><li>duplicates,</li><li>geographical coverage,</li><li>data types,</li><li>expected classifications,</li><li>mapping completeness,</li><li>row counts,</li><li>and unexpected values.</li></ul><p>The logic is simple:</p><pre>Source data<br>     ↓<br>Validation<br>     ↓<br>   PASS?<br>   /   \<br> YES   NO<br>  │     │<br>  ▼     ▼<br>Continue   Record quality issue</pre><p>I also retained quality results rather than allowing them to exist only as notebook output.</p><p>That means data quality itself becomes part of the platform’s historical evidence.</p><h3>Stage 8: creating MBacc pathway intelligence</h3><p>Another part of the project involved mapping apprenticeship subject areas into <strong>MBacc gateway classifications</strong>.</p><p>This created a useful bridge between apprenticeship subjects and broader skills pathways.</p><p>The process had to distinguish between genuinely mapped subjects and categories that were intentionally unmapped.</p><p>That distinction matters.</p><p>A badly designed transformation can quietly drop records that do not match a lookup.</p><p>I did not want that.</p><p>So the model retains and governs those cases explicitly.</p><p>Conceptually:</p><pre>Apprenticeship subject<br>        ↓<br>Sector Subject Area<br>        ↓<br>MBacc mapping<br>        ↓<br>Mapped pathway<br>        OR<br>Explicitly unmapped</pre><p>I prefer this because “unmapped” is useful information.</p><p>Silently disappearing from the dataset is not.</p><h3>Stage 9: I deliberately did not connect the public dashboard directly to the warehouse</h3><p>Once the Gold model existed, I had another architectural choice to make.</p><p>The simplest option would have been:</p><pre>Browser<br>   ↓<br>Fabric Warehouse</pre><p>I deliberately did not do that.</p><p>Instead, approved Gold outputs are exported into a compact set of validated JSON datasets.</p><p>Examples include:</p><pre>borough-current.json<br>borough-kpis.json<br>borough-opportunity.json<br>kpi-definitions.json<br>mbacc-pathways.json<br>skills-supply.json<br>youth-transition.json<br>metadata.json</pre><p>That gives me a clean serving boundary:</p><pre>Fabric Warehouse<br>      ↓<br>Curated analytical output<br>      ↓<br>Validated JSON<br>      ↓<br>Azure Blob Storage<br>      ↓<br>Web application</pre><p>The public application therefore does not need direct warehouse credentials.</p><p>It only sees the information I intentionally publish.</p><p>That improves both security and separation of concerns.</p><h3>Stage 10: private Azure Blob Storage and a live public application</h3><p>The public serving layer runs in Microsoft Azure.</p><p>Validated snapshots are published to <strong>private Azure Blob Storage</strong>.</p><p>The web application is a <strong>Plotly Dash application hosted on Azure App Service</strong>.</p><p>The flow looks like this:</p><pre>Microsoft Fabric Warehouse<br>          ↓<br>Python export<br>          ↓<br>JSON validation<br>          ↓<br>Private Azure Blob Storage<br>          ↓<br>Azure App Service<br>          ↓<br>Plotly Dash<br>          ↓<br>Public user</pre><p>The Blob container is not publicly exposed.</p><p>The application accesses it through Azure identity-based authentication.</p><p>That allowed the serving architecture to remain public-facing without making the underlying storage public.</p><h3>Stage 11: publishing safely using two snapshot slots</h3><p>I also wanted the publication process to avoid another common problem.</p><p>What happens if the application starts reading a new snapshot while only half of the files have been uploaded?</p><p>That could leave the dashboard in a partially updated state.</p><p>So I implemented a two-slot publication model.</p><p>Conceptually:</p><pre>manifest.json<br>                         │<br>                         ▼<br>                    active_slot<br>                         │<br>              ┌──────────┴──────────┐<br>              │                     │<br>           slot-a                slot-b<br>              │                     │<br>        current files          next files</pre><p>A new dataset is first written to the inactive slot.</p><p>Only after all required files are successfully published does the manifest switch the active slot.</p><p>That means the application either sees the old complete snapshot or the new complete snapshot.</p><p>Not something in between.</p><p>It is a small feature, but it makes the serving layer much more robust.</p><h3>Stage 12: what happens when nothing actually changed?</h3><p>This led to another question.</p><p>If the automated pipeline runs tomorrow morning and the source data produces exactly the same public analytical output, should the platform pretend that something new happened?</p><p>I did not think so.</p><p>So I added <strong>NO_CHANGE logic</strong> to the publication process.</p><p>The behaviour is:</p><pre>Run scheduled pipeline<br>        ↓<br>Build Gold model<br>        ↓<br>Export validated snapshot<br>        ↓<br>Compare with current snapshot<br>        ↓<br>Has anything materially changed?<br>       / \<br>     NO   YES<br>     │     │<br>     ▼     ▼<br>NO_CHANGE  Publish<br>     │       │<br>     ▼       ▼<br>Keep        Switch<br>current     snapshot<br>state       and refresh app</pre><p>If nothing changed, the existing live snapshot stays exactly where it is.</p><p>No unnecessary publication.</p><p>No artificial freshness.</p><p>No dashboard reload for the sake of appearing active.</p><p>I like this behaviour because it reflects a more honest idea of what a live data product should be.</p><p>A system can be healthy and current even when the numbers have not changed.</p><h3>Stage 13: automating everything with GitHub Actions</h3><p>Once the engineering flow worked manually, I wanted the platform to operate without me sitting in front of it.</p><p>So I created a production workflow using <strong>GitHub Actions</strong>.</p><p>The workflow performs the complete refresh:</p><pre>GitHub Actions<br>      ↓<br>Authenticate to Microsoft Fabric<br>      ↓<br>Acquire Fabric Warehouse SQL token<br>      ↓<br>Bind Fabric pipelines to automation identity<br>      ↓<br>Run DfE ingestion<br>      ↓<br>Run Nomis ingestion<br>      ↓<br>Bronze → Silver<br>      ↓<br>Silver modelling<br>      ↓<br>Silver → Gold<br>      ↓<br>Export validated public data<br>      ↓<br>Authenticate to Azure<br>      ↓<br>Publish if changed<br>      ↓<br>Refresh application<br>      ↓<br>Verify live health</pre><p>The workflow can be started manually, but it is also scheduled to run automatically.</p><p>That was an important milestone for me.</p><p>There is a difference between:</p><blockquote>I have a pipeline that works when I run it.</blockquote><p>and:</p><blockquote>I have a pipeline that knows how to operate itself.</blockquote><p>The second one feels much closer to a real production system.</p><h3>Stage 14: cross-tenant identity turned out to be one of the most interesting parts</h3><p>The automation also introduced an identity problem.</p><p>Microsoft Fabric and the Azure serving environment were operating under separate Microsoft environments.</p><p>That meant GitHub Actions had to authenticate to both securely.</p><p>I did not want to solve this by putting long-lived passwords or client secrets into GitHub.</p><p>So I implemented <strong>OpenID Connect workload identity federation</strong>.</p><p>The architecture became:</p><pre>GitHub Actions<br>      │<br>      ├── OIDC → Fabric automation identity<br>      │<br>      └── OIDC → Azure serving identity</pre><p>The live application itself uses a separate Managed Identity with read access to Blob Storage.</p><p>This creates a useful separation:</p><pre>Fabric automation identity<br>        ↓<br>Runs data pipelines<br></pre><pre>Azure publishing identity<br>        ↓<br>Publishes validated data<br></pre><pre>App Service identity<br>        ↓<br>Reads published data</pre><p>Each identity has a different responsibility.</p><p>That is much better than giving one account permission to everything.</p><h3>A small lesson about short-lived tokens</h3><p>One issue during automation was particularly instructive.</p><p>The Fabric pipeline chain takes several minutes to run.</p><p>The GitHub OIDC assertion used during initial login has a short lifetime.</p><p>So by the time the pipeline finished and the exporter requested a SQL token, the original assertion had already expired.</p><p>The solution was to acquire and cache the Fabric Warehouse SQL token immediately after login, before starting the long pipeline chain.</p><p>It was a small fix.</p><p>But it reinforced something I keep seeing in cloud projects:</p><blockquote><strong><em>Authentication architecture is part of data engineering architecture.</em></strong></blockquote><p>A pipeline can be logically perfect and still fail because the identity layer was designed as an afterthought.</p><h3>The final architecture</h3><p>The completed architecture now looks like this:</p><pre>DEPARTMENT FOR EDUCATION<br>                 +<br>               NOMIS<br>                 +<br>           REFERENCE DATA<br>                 │<br>                 ▼<br>      MICROSOFT FABRIC DATA FACTORY<br>                 │<br>                 ▼<br>              BRONZE<br>       Immutable source history<br>                 │<br>                 ▼<br>              SILVER<br>       Cleaned and standardised<br>                 │<br>                 ▼<br>        GOLD FABRIC WAREHOUSE<br>                 │<br>        ┌────────┴────────┐<br>        │                 │<br>        ▼                 ▼<br>   SCD TYPE 2        SCD TYPE 4<br> Analytical history  Operational history<br>        │                 │<br>        └────────┬────────┘<br>                 ▼<br>          DIMENSIONS + FACTS<br>                 │<br>                 ▼<br>           ANALYTICAL MARTS<br>                 │<br>                 ▼<br>      VALIDATED JSON EXPORT<br>                 │<br>                 ▼<br>      PRIVATE AZURE BLOB STORAGE<br>                 │<br>                 ▼<br>          AZURE APP SERVICE<br>                 │<br>                 ▼<br>        GM SKILLSFLOW DASHBOARD</pre><p>And around that entire flow sits:</p><pre>GitHub Actions<br>+<br>OIDC Federation<br>+<br>Managed Identity<br>+<br>Health Validation</pre><h3>What the dashboard actually provides</h3><p>The public application contains several analytical perspectives.</p><p>These include:</p><h3>Overview</h3><p>A high-level picture of Greater Manchester skills and opportunity indicators.</p><h3>Borough Explorer</h3><p>A way to compare individual Greater Manchester boroughs across selected measures.</p><h3>MBacc Pathways</h3><p>A view of apprenticeship subject areas through MBacc pathway classifications.</p><h3>Trends</h3><p>Historical movement across selected education, youth-transition and labour-market indicators.</p><h3>Data &amp; Methodology</h3><p>Information explaining the source, interpretation and analytical approach behind the published indicators.</p><p>I wanted the application to remain understandable to someone who does not care about Bronze, Silver, OIDC or slowly changing dimensions.</p><p>All of that complexity should support the experience, not dominate it.</p><h3>One thing I deliberately did not implement</h3><p>There was one architecture discussion I had with myself near the end.</p><p>Should every refresh become fully incremental?</p><p>Should I introduce source watermarks, Delta MERGE operations and row-level incremental processing?</p><p>Technically, yes, that could be done.</p><p>But I decided not to introduce it into the current version.</p><p>The current dataset size does not justify adding another layer of operational complexity simply because incremental loading sounds more sophisticated.</p><p>The existing design is clear, reproducible and stable.</p><p>And the NO_CHANGE publication logic already prevents unnecessary public snapshot replacement.</p><p>So the current approach is:</p><pre>Reliable full analytical refresh<br>        +<br>Immutable source preservation<br>        +<br>Change-aware public publication</pre><p>rather than:</p><pre>Complex incremental engineering<br>for the sake of complexity</pre><p>That was also a useful engineering lesson.</p><p>Not every technically possible feature belongs in the first production version.</p><h3>Some lessons that stood out</h3><p>This project reinforced several things for me.</p><h3>1. Multi-source integration is often harder than the visualisation</h3><p>The chart is usually the easy part.</p><p>The hard part is making independently published datasets behave like one analytical system.</p><h3>2. Preserve raw data</h3><p>Transformation logic changes.</p><p>Mappings change.</p><p>Business definitions change.</p><p>The raw source should still exist.</p><h3>3. Historical modelling matters</h3><p>If dimensions change, overwriting them may silently rewrite the meaning of historical facts.</p><p>SCD Type 2 provides a way to preserve that context.</p><h3>4. Operational history is different from analytical history</h3><p>SCD Type 4 gave me a cleaner way to separate the configuration the platform uses today from the configuration it used previously.</p><h3>5. Public applications do not always need direct warehouse access</h3><p>A governed serving layer can simplify both security and application performance.</p><h3>6. Automation without identity design is incomplete</h3><p>OIDC and Managed Identity became just as important to the production workflow as Python and SQL.</p><h3>7. “No change” is a valid result</h3><p>A healthy data pipeline should be able to say:</p><blockquote><strong><em>I checked. Nothing changed. The current state remains valid.</em></strong></blockquote><p>That is better than generating a new version simply because a scheduled job ran.</p><h3>8. The data product is bigger than the dashboard</h3><p>The dashboard is the visible surface.</p><p>The actual product includes ingestion, storage, governance, modelling, quality, security, automation and serving.</p><h3>What this project allowed me to practise</h3><p>From a technical perspective, GM SkillsFlow brought together a wide range of areas I wanted to work with in one coherent project:</p><ul><li>Microsoft Fabric Data Factory</li><li>Microsoft Fabric Lakehouse</li><li>Microsoft Fabric Warehouse</li><li>Medallion architecture</li><li>Python</li><li>PySpark</li><li>SQL</li><li>dimensional modelling</li><li>fact modelling</li><li>SCD Type 2</li><li>SCD Type 4</li><li>data-quality engineering</li><li>multi-source ingestion</li><li>immutable source preservation</li><li>analytical marts</li><li>JSON serving layers</li><li>Azure Blob Storage</li><li>Azure App Service</li><li>Plotly Dash</li><li>GitHub Actions</li><li>workload identity federation</li><li>OpenID Connect</li><li>Managed Identity</li><li>scheduled cloud automation</li><li>health monitoring</li><li>and secure public application delivery</li></ul><p>But what I found more valuable was not any individual technology.</p><p>It was making them work together.</p><h3>From public datasets to an intelligence product</h3><p>The final platform represents this journey:</p><pre>Fragmented public data<br>        ↓<br>Governed ingestion<br>        ↓<br>Preserved source evidence<br>        ↓<br>Clean analytical datasets<br>        ↓<br>Historical modelling<br>        ↓<br>Dimensional warehouse<br>        ↓<br>Trusted analytical outputs<br>        ↓<br>Secure cloud publication<br>        ↓<br>Automated serving<br>        ↓<br>Public intelligence</pre><p>That was the objective from the beginning.</p><p>Not simply:</p><blockquote><strong><em>Can I build a dashboard?</em></strong></blockquote><p>But:</p><blockquote><strong><em>Can I build the engineering system that allows several independent public datasets to become one trustworthy, repeatable and operational intelligence product?</em></strong></blockquote><p>For me, that is where the real value of GM SkillsFlow sits.</p><p>The dashboard is simply where the work becomes visible.</p><h3>Project</h3><p><strong>Greater Manchester Skills &amp; Opportunity Intelligence Platform</strong></p><p><strong>GitHub:</strong><br> <a href="https://github.com/kamilkenny/greater-manchester-skills-opportunity-intelligence">https://github.com/kamilkenny/greater-manchester-skills-opportunity-intelligence</a></p><p><strong>Live platform:</strong><br> <a href="https://gm-skillsflow-kamil-898341.azurewebsites.net/">https://gm-skillsflow-kamil-898341.azurewebsites.net</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a7c35c9dac4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Production-Grade Greater Manchester Transport Intelligence Platform: From Raw GTFS Files…]]></title>
            <link>https://medium.com/@kamilkenny22/building-a-production-grade-greater-manchester-transport-intelligence-platform-from-raw-gtfs-files-a552b7c015b8?source=rss-69a3c110544a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a552b7c015b8</guid>
            <category><![CDATA[microsoft-fabric]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[data-lakehouse]]></category>
            <category><![CDATA[sql-development]]></category>
            <dc:creator><![CDATA[Ridwan Kamil]]></dc:creator>
            <pubDate>Wed, 19 Aug 2026 23:28:57 GMT</pubDate>
            <atom:updated>2026-08-19T23:38:46.908Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IxQnAxrKEnFnylcyQxVBFw.png" /></figure><h3>Building a Production-Grade Greater Manchester Transport Intelligence Platform: From Raw GTFS Files to Azure, Fabric and a Live Web Dashboard</h3><h3>Project</h3><p><strong>Greater Manchester Transport Intelligence Platform</strong></p><p><strong>GitHub: </strong><a href="https://github.com/kamilkenny/greater-manchester-transport-data-platform">https://github.com/kamilkenny/greater-manchester-transport-data-platform</a></p><p><strong>Production Live platform:</strong><br><a href="https://gm-transport-intelligence-kamil.azurewebsites.net/">https://gm-transport-intelligence-kamil.azurewebsites.net/</a></p><h3>How I turned public timetable publications into an automated, governed and cloud-deployed transport data platform using Python, SQL, Azure, GitHub Actions, Microsoft Fabric, FastAPI and modern data engineering practices.</h3><p>A transport dashboard can tell you that Greater Manchester has hundreds of routes, thousands of stops and tens of thousands of scheduled journeys.</p><p>But that was not the question that interested me.</p><p>The more interesting question was:</p><blockquote><strong><em>Where did those numbers come from, how trustworthy are they, what changed since the previous publication, and can the whole process update itself without someone manually rebuilding the analysis every day?</em></strong></blockquote><p>That question became the starting point for my <strong>Greater Manchester Transport Intelligence Platform</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6TOpH3qjfIiav7-R6a_I1Q.png" /></figure><p>What began as an exercise in analysing public transport timetable data gradually became a much larger data-engineering project: automated ingestion, immutable source preservation, validation, dimensional modelling, Azure SQL warehousing, governed analytics, API serving, cloud deployment, orchestration, monitoring and a public-facing intelligence dashboard.</p><p>The goal was not simply to build another dashboard.</p><p>The goal was to build the <strong>data platform behind the dashboard</strong>.</p><h3>The problem: dashboards are easy to build, trustworthy data pipelines are harder</h3><p>Public transport data looks simple when viewed from the outside.</p><p>There are routes.</p><p>There are stops.</p><p>There are operators.</p><p>There are scheduled trips.</p><p>But the moment you begin working with real timetable publications, the engineering questions become much more interesting.</p><p>What happens when a new timetable publication arrives?</p><p>How do you know it is different from yesterday’s publication?</p><p>What happens if the same file is processed twice?</p><p>How do you preserve historical versions?</p><p>How do you detect incomplete or invalid data?</p><p>How do you turn millions of timetable records into analytical information without making the dashboard slow?</p><p>And how do you prove to a stakeholder that the number on the screen came through a controlled and reproducible process?</p><p>Those were the questions I wanted this project to answer.</p><h3>The data source</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PsuiA9ty9rd1Nr7jxZrvGA.png" /></figure><p>The platform uses timetable data published by <strong>Transport for Greater Manchester (TfGM)</strong> in <strong>General Transit Feed Specification (GTFS)</strong> format.</p><p>GTFS is widely used for representing scheduled public transport networks. It contains related datasets describing areas such as:</p><ul><li>agencies and operators,</li><li>routes,</li><li>stops,</li><li>trips,</li><li>service calendars,</li><li>stop times,</li><li>journey shapes,</li><li>and timetable metadata.</li></ul><p>A single publication therefore contains several related files rather than one simple table.</p><p>That immediately turns the problem into a data-engineering problem.</p><h3>From source file to governed transport intelligence</h3><p>The final production flow became:</p><pre>Transport for Greater Manchester</pre><pre>GTFS timetable publication</pre><pre>│</pre><pre>▼</pre><pre>GitHub Actions</pre><pre>│</pre><pre>▼</pre><pre>Publication checksum</pre><pre>/             \</pre><pre>Unchanged          Changed</pre><pre>│                  │</pre><pre>▼                  ▼</pre><pre>Stop safely      Preserve snapshot</pre><pre>│</pre><pre>▼</pre><pre>Validation</pre><pre>│</pre><pre>▼</pre><pre>Azure SQL staging</pre><pre>│</pre><pre>▼</pre><pre>Dimensional warehouse</pre><pre>│</pre><pre>▼</pre><pre>Governed analytics</pre><pre>│</pre><pre>▼</pre><pre>SQLite serving layer</pre><pre>│</pre><pre>▼</pre><pre>FastAPI</pre><pre>│</pre><pre>▼</pre><pre>Microsoft Azure App Service</pre><pre>│</pre><pre>▼</pre><pre>Public intelligence dashboard</pre><p>This architecture is important because each layer has a different responsibility.</p><p>The dashboard is only the final presentation layer.</p><p>Most of the engineering happens long before a chart appears on screen.</p><h3>Stage 1 — Automated ingestion and immutable source preservation</h3><p>The first engineering requirement was simple:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wkxizilWpbjq3-DPZuYrlg.png" /></figure><blockquote><em>Never lose the original publication.</em></blockquote><p>Whenever a new GTFS publication is collected, the platform preserves the original source snapshot rather than overwriting yesterday’s data.</p><p>Each publication is associated with a checksum.</p><p>This allows the pipeline to answer:</p><blockquote><em>Have I already processed this exact publication?</em></blockquote><p>If the checksum matches the previously processed source, the pipeline stops safely with an unchanged-publication status.</p><p>That behaviour is deliberate.</p><p>Without it, a scheduled pipeline could repeatedly load the same source and gradually create duplicate or inconsistent records.</p><p>This concept is known as <strong>idempotency</strong>.</p><p>It is not the most visually exciting part of a dashboard, but it is one of the most important characteristics of a dependable production pipeline.</p><h3>Stage 2 — Validation before loading</h3><p>The next principle was:</p><blockquote><em>Bad data should not quietly become analytical data.</em></blockquote><p>Before the warehouse is refreshed, the source publication is profiled and validated.</p><p>The platform performs checks around areas such as:</p><ul><li>required fields,</li><li>missing records,</li><li>duplicate records,</li><li>source consistency,</li><li>row counts,</li><li>relationships between timetable entities,</li><li>and pipeline execution outcomes.</li></ul><p>Instead of treating validation as a manual inspection step, I integrated it into the engineering workflow.</p><p>This means the platform has a distinction between:</p><pre>Data received</pre><p>and:</p><pre>Data trusted for analytical use</pre><p>That distinction becomes particularly important when data is eventually consumed by decision-makers.</p><h3>Stage 3 — Designing the Azure SQL data platform</h3><p>Once validated, the timetable data moves into <strong>Microsoft Azure SQL Database</strong>.</p><p>I deliberately separated the data into engineering layers rather than using one large collection of tables.</p><p>The structure includes concepts such as:</p><pre>Staging</pre><pre>↓</pre><pre>Warehouse</pre><pre>↓</pre><pre>Analytics</pre><pre>↓</pre><pre>Governance</pre><h3>Staging</h3><p>The staging layer represents validated source data closely enough to maintain lineage with the original GTFS publication.</p><h3>Warehouse</h3><p>The warehouse layer reorganises the data into structures designed for reliable analytical use.</p><p>This includes dimension and fact-style modelling around areas such as:</p><ul><li>routes,</li><li>stops,</li><li>operators,</li><li>service calendars,</li><li>trips,</li><li>stop activity,</li><li>and scheduled service.</li></ul><h3>Analytics</h3><p>The analytical layer turns engineering tables into stakeholder-oriented information.</p><p>Examples include:</p><ul><li>route service intelligence,</li><li>stop activity intelligence,</li><li>operator summaries,</li><li>network daily summaries,</li><li>transport-mode summaries,</li><li>pipeline health,</li><li>publication change summaries,</li><li>and dashboard KPIs.</li></ul><h3>Governance</h3><p>The governance layer records information about processing and pipeline execution so that the system can explain what happened rather than simply present an output.</p><h3>Stage 4 — Working with real transport-data scale</h3><p>One of the most useful parts of the project was seeing how quickly apparently simple timetable data becomes large.</p><p>A production refresh processed approximately:</p><p>Dataset measureScaleAgencies/operators28Routes711Stops15,731Trips81,796Shape records~2.29 millionStop-time records~3.51 millionHigh-volume staged records~5.80 millionRoute-service analytical facts~169,869Stop-service analytical facts~5.38 million</p><p>That scale changes how you approach the problem.</p><p>For example, loading millions of stop-time records should not be handled in the same way as loading a 28-row operator table.</p><p>The pipeline therefore uses controlled loading patterns and separates reference, network and high-volume ingestion paths.</p><p>The result is a much more realistic engineering architecture than simply reading every CSV into memory and sending it directly to a dashboard.</p><h3>Stage 5 — Turning warehouse data into stakeholder intelligence</h3><p>Once the warehouse existed, the next question became:</p><blockquote><em>What would someone responsible for transport planning actually want to understand?</em></blockquote><p>The analytical model was therefore designed around interpretable operational questions.</p><p>For example:</p><h3>Network scale</h3><p>How many routes, stops, scheduled trips and timetable events are currently represented?</p><h3>Service intensity</h3><p>Which routes have the strongest scheduled service based on factors such as frequency, trip volume and coverage?</p><h3>Stop activity</h3><p>Which locations have the highest concentration of scheduled activity?</p><h3>Operator contribution</h3><p>How much scheduled service is associated with each operator?</p><h3>Accessibility reporting</h3><p>How complete is the accessibility information contained in the source timetable publication?</p><h3>Publication changes</h3><p>What changed between one timetable publication and the next?</p><h3>Pipeline health</h3><p>Did the underlying data-engineering process complete successfully?</p><p>This last point is particularly important.</p><p>A business user should not only see the metric.</p><p>They should also be able to understand whether the pipeline producing that metric is healthy.</p><h3>Stage 6 — A lightweight serving layer instead of exposing the warehouse directly</h3><p>One design decision I made was not to make the public dashboard query the analytical warehouse directly for every browser request.</p><p>Instead, governed analytical outputs are exported into a compact <strong>SQLite serving database</strong>.</p><p>The production serving database currently contains:</p><pre>17 governed analytical tables</pre><pre>~203,000 serving rows</pre><p>This creates a clean separation:</p><pre>Engineering platform</pre><pre>↓</pre><pre>Governed analytics</pre><pre>↓</pre><pre>Read-only serving database</pre><pre>↓</pre><pre>Application</pre><p>The approach provides several benefits:</p><ul><li>faster application reads,</li><li>lower coupling between the public dashboard and warehouse,</li><li>smaller deployment footprint,</li><li>clear read-only serving boundary,</li><li>and reduced exposure of engineering infrastructure.</li></ul><p>This was one of the architectural decisions that helped turn the project from a data-analysis exercise into a data product.</p><h3>Stage 7 — Building the API layer with FastAPI</h3><p>The dashboard does not read database files directly from browser-side JavaScript.</p><p>Instead, I built a <strong>FastAPI</strong> application that exposes approved analytical endpoints.</p><p>Representative endpoints support information such as:</p><pre>/health</pre><pre>/api/overview</pre><pre>/api/network-trends</pre><pre>/api/routes</pre><pre>/api/stops</pre><pre>/api/map-stops</pre><pre>/api/operators</pre><pre>/api/locations</pre><pre>/api/pipelines</pre><pre>/api/data-quality</pre><pre>/api/publication-changes</pre><p>This separation provides a cleaner application architecture:</p><pre>Browser</pre><pre>↓</pre><pre>FastAPI</pre><pre>↓</pre><pre>Governed SQLite serving database</pre><p>It also means the browser never needs Azure SQL credentials.</p><h3>Stage 8 — Deploying the intelligence platform to Microsoft Azure</h3><p>The production application is deployed to <strong>Microsoft Azure App Service</strong>.</p><p>The deployed stack includes:</p><ul><li>Python,</li><li>FastAPI,</li><li>SQLite,</li><li>HTML,</li><li>CSS,</li><li>JavaScript,</li><li>Chart.js,</li><li>Leaflet,</li><li>and Azure App Service.</li></ul><p>The production deployment also exposes a health endpoint that checks the application and serving-database state.</p><p>That became particularly useful during deployment troubleshooting because it allowed me to distinguish between:</p><pre>Application started</pre><p>and:</p><pre>Application started and analytical data is healthy</pre><p>Those are not always the same thing.</p><h3>Stage 9 — Automating the pipeline with GitHub Actions</h3><p>A data platform only becomes genuinely useful when it can operate repeatedly.</p><p>I therefore created a GitHub Actions production workflow that performs the scheduled refresh process.</p><p>The workflow includes:</p><ul><li>scheduled execution,</li><li>manual execution,</li><li>dependency installation,</li><li>SQL connectivity,</li><li>source change detection,</li><li>controlled retries,</li><li>governed pipeline execution,</li><li>serving-database export,</li><li>Azure deployment,</li><li>production smoke testing,</li><li>and evidence preservation.</li></ul><p>The production workflow is scheduled daily.</p><p>But one important point is that this is <strong>scheduled batch ingestion</strong>, not real-time streaming.</p><p>That distinction matters.</p><p>The dashboard may refresh frequently in the browser, but new source information only becomes available when TfGM publishes a new timetable and the ingestion workflow processes it.</p><p>If the publication is unchanged, the engineering system deliberately stops rather than manufacturing a new dataset.</p><h3>Stage 10 — Making the dashboard look alive without pretending the data changed</h3><p>This led to another interesting lesson.</p><p>A dashboard can refresh every few minutes and still legitimately display the same headline figures.</p><p>For example, the number of routes may remain unchanged while individual stop times or service patterns change.</p><p>So simply changing a KPI is not evidence of freshness.</p><p>A better platform should communicate:</p><ul><li>when the source was last checked,</li><li>when the latest new publication was ingested,</li><li>whether the source publication changed,</li><li>and when the next automated check will occur.</li></ul><p>This is a much more meaningful definition of a “live” analytical product than continuously changing numbers for visual effect.</p><h3>Stage 11 — Adding Microsoft Fabric as an enterprise orchestration layer</h3><p>I also extended the project with a separate <strong>Microsoft Fabric</strong> implementation.</p><p>The purpose was not to replace the working production pipeline.</p><p>Instead, Fabric demonstrates how the governed platform can participate in a broader enterprise data ecosystem.</p><p>The Fabric work includes:</p><ul><li>Microsoft Fabric workspace configuration,</li><li>Data Factory pipeline creation,</li><li>Azure SQL connectivity,</li><li>Copy Job execution,</li><li>Lakehouse delivery,</li><li>retry configuration,</li><li>run history,</li><li>orchestration monitoring,</li><li>and validation testing.</li></ul><p>One successful Fabric Copy Job transferred a governed Azure SQL analytical dataset into the Fabric Lakehouse and recorded its run history through Fabric monitoring.</p><p>This creates two useful perspectives:</p><pre>Permanent production path</pre><pre>GitHub Actions → Azure SQL → Analytics → SQLite → FastAPI → Azure</pre><p>and:</p><pre>Enterprise analytical path</pre><pre>Azure SQL → Microsoft Fabric Data Factory → Lakehouse / OneLake</pre><p>The production platform remains independent while Fabric demonstrates enterprise orchestration capability.</p><h3>Architecture overview</h3><pre>Transport for Greater Manchester GTFS</pre><pre>↓</pre><pre>GitHub Actions</pre><pre>↓</pre><pre>Source validation</pre><pre>↓</pre><pre>Azure SQL</pre><pre>↓</pre><pre>Governed analytics</pre><pre>↓</pre><pre>SQLite</pre><pre>↓</pre><pre>FastAPI</pre><pre>↓</pre><pre>Azure App Service</pre><pre>↓</pre><pre>Stakeholder dashboard</pre><h3>Data model overview</h3><p>A simplified analytical model can be represented as:</p><pre>DIM OPERATOR</pre><pre>│</pre><pre>│</pre><pre>DIM ROUTE ─── FACT SERVICE ─── DIM DATE</pre><pre>│</pre><pre>│</pre><pre>DIM STOP</pre><p>Additional analytical facts capture areas such as:</p><ul><li>route service by day,</li><li>stop service activity,</li><li>publication changes,</li><li>pipeline execution,</li><li>data-quality results,</li><li>and network summaries.</li></ul><p>This makes the project particularly useful for demonstrating both data engineering and business intelligence modelling.</p><h3>What the dashboard provides</h3><p>The stakeholder-facing dashboard includes:</p><h3>Executive KPIs</h3><ul><li>active operators,</li><li>published routes,</li><li>network stops,</li><li>scheduled trips,</li><li>timetable stop events,</li><li>data freshness.</li></ul><h3>Network trends</h3><p>Daily scheduled activity and route coverage over time.</p><h3>Mode analysis</h3><p>Bus and tram contribution to the timetable network.</p><h3>Route intelligence</h3><p>Comparative route rankings using scheduled service intensity.</p><h3>Geographic intelligence</h3><p>An interactive Leaflet map showing where scheduled activity is concentrated across Greater Manchester.</p><h3>Stop intelligence</h3><p>Leading stops based on scheduled network activity.</p><h3>Operator analysis</h3><p>Relative scheduled contribution by operator.</p><h3>Accessibility reporting</h3><p>Coverage and completeness of accessibility information in the source publication.</p><h3>Publication intelligence</h3><p>Changes between timetable publications.</p><h3>Operational monitoring</h3><p>Pipeline status, success rates and data-quality outcomes.</p><h3>A technical stack built around the full data lifecycle</h3><p>The implemented technology stack includes:</p><pre>SOURCE</pre><pre>Transport for Greater Manchester</pre><pre>GTFS timetable publications</pre><pre>ENGINEERING</pre><pre>Python 3.12</pre><pre>SQL</pre><pre>pytest</pre><pre>Ruff</pre><pre>ORCHESTRATION</pre><pre>GitHub Actions</pre><pre>Microsoft Fabric Data Factory</pre><pre>WAREHOUSE</pre><pre>Microsoft Azure SQL Database</pre><pre>FABRIC</pre><pre>Microsoft Fabric Lakehouse</pre><pre>Microsoft OneLake</pre><pre>SERVING</pre><pre>SQLite</pre><pre>FastAPI</pre><pre>FRONT END</pre><pre>HTML</pre><pre>CSS</pre><pre>JavaScript</pre><pre>Chart.js</pre><pre>Leaflet</pre><pre>CLOUD DELIVERY</pre><pre>Microsoft Azure App Service</pre><pre>VERSION CONTROL</pre><pre>Git</pre><pre>GitHub</pre><p>What I like most about this stack is that no single tool is treated as the project.</p><p>The project is the <strong>flow of trusted data through the tools</strong>.</p><h3>Some engineering lessons from the project</h3><p>Several lessons stood out.</p><h3>1. Data freshness is not the same as continuously changing numbers</h3><p>A pipeline can be healthy and current even when the headline KPI remains unchanged.</p><p>The important question is whether the source was checked and whether the current publication was processed.</p><h3>2. Idempotency is essential for scheduled pipelines</h3><p>A recurring workflow must know whether it has already processed the current source.</p><p>Otherwise automation can create more problems than it solves.</p><h3>3. Preserve the raw source</h3><p>Once transformed data exists, it is tempting to focus only on analytical tables.</p><p>But immutable raw snapshots provide lineage and make later investigation possible.</p><h3>4. Serving architecture matters</h3><p>A public application does not necessarily need direct warehouse access.</p><p>A compact, governed serving layer can simplify security and improve performance.</p><h3>5. Monitoring belongs inside the architecture</h3><p>A pipeline that silently fails is not production-ready.</p><p>Operational state should be visible alongside analytical state.</p><h3>6. Data engineering is ultimately about trust</h3><p>The most important output is not a chart.</p><p>It is being able to explain:</p><blockquote><em>where the chart came from,</em></blockquote><blockquote><em>when the data was processed,</em></blockquote><blockquote><em>whether the pipeline succeeded,</em></blockquote><blockquote><em>what transformations were applied,</em></blockquote><blockquote><em>and whether the result can be reproduced.</em></blockquote><h3>What this project demonstrates</h3><p>From a technical perspective, the project allowed me to apply and strengthen skills across:</p><ul><li>end-to-end ETL/ELT design,</li><li>data ingestion,</li><li>source-version preservation,</li><li>checksum-based change detection,</li><li>data validation,</li><li>SQL development,</li><li>dimensional modelling,</li><li>star-schema design,</li><li>high-volume batch processing,</li><li>governed analytical views,</li><li>API development,</li><li>cloud deployment,</li><li>CI/CD,</li><li>scheduled workflow automation,</li><li>data-quality monitoring,</li><li>pipeline observability,</li><li>Microsoft Fabric orchestration,</li><li>Lakehouse integration,</li><li>and stakeholder-facing analytics.</li></ul><p>But perhaps more importantly, it required connecting all of those skills into one coherent system.</p><h3>From timetable files to a data product</h3><p>The final platform does much more than display Greater Manchester transport information.</p><p>It demonstrates the journey:</p><pre>Public source data</pre><pre>↓</pre><pre>Trusted engineering</pre><pre>↓</pre><pre>Governed analytical model</pre><pre>↓</pre><pre>Operational monitoring</pre><pre>↓</pre><pre>Cloud application</pre><pre>↓</pre><pre>Stakeholder intelligence</pre><p>That was the objective from the beginning.</p><p>Not simply to ask:</p><blockquote><em>“Can I build a dashboard?”</em></blockquote><p>but:</p><blockquote><strong><em>“Can I build the engineering system that makes the dashboard trustworthy, repeatable and operational?”</em></strong></blockquote><p>For me, that is where the real value of the project sits.</p><h3>Project</h3><p><strong>Greater Manchester Transport Intelligence Platform</strong></p><p><strong>GitHub:</strong><br> github.com/kamilkenny/greater-manchester-transport-data-platform</p><p><strong>Production platform:</strong><br> gm-transport-intelligence-kamil.azurewebsites.net</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a552b7c015b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond the Latest Forecast: Building a Live Great Britain Electricity Generation Availability…]]></title>
            <link>https://medium.com/@kamilkenny22/beyond-the-latest-forecast-building-a-live-gb-generation-availability-intelligence-platform-46eaf295f0f3?source=rss-69a3c110544a------2</link>
            <guid isPermaLink="false">https://medium.com/p/46eaf295f0f3</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[pyspark]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[energy]]></category>
            <category><![CDATA[microsoft-azure]]></category>
            <dc:creator><![CDATA[Ridwan Kamil]]></dc:creator>
            <pubDate>Sat, 15 Aug 2026 20:59:04 GMT</pubDate>
            <atom:updated>2026-08-15T22:40:59.263Z</atom:updated>
            <content:encoded><![CDATA[<h3>Beyond the Latest Forecast: Building a Live Great Britain Electricity Generation Availability Intelligence Platform</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cAMZs-dPsU4Dmw3ag6VG2Q.png" /></figure><p><em>How I extended my work in energy forecasting and grid analytics into production data engineering, using Elexon data, PostgreSQL, PySpark, Databricks, Delta Lake, FastAPI, Power BI and Microsoft Azure.</em></p><p><strong>Live application:</strong> <a href="https://gb-generation-intelligence-kamil.azurewebsites.net/">GB Generation Availability Intelligence Platform</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S3vkCwfnRDWYE3FuSTIlfg.png" /></figure><p><strong>Source code:</strong> <a href="https://github.com/kamilkenny/GB-generation-availability-intelligence-platform">View the GitHub repository</a></p><p>Much of my recent work has taken place at the intersection of energy systems, data analytics and artificial intelligence.</p><p><strong>I have developed photovoltaic generation forecasting models, half hourly electricity demand forecasting systems, Great Britain generation forecasting applications and interactive Power BI energy monitoring dashboards. I have also worked on more specialised electricity system projects involving wind forecast revision monitoring, gas demand forecasting under difficult operating regimes, transmission congestion and thermal constraint intelligence, and system operating plan and dispatch readiness monitoring. All these projects are documented in my dedicated GitHub Repository: </strong><a href="https://github.com/kamilkenny?tab=repositories">https://github.com/kamilkenny?tab=repositories</a></p><p>Although these projects addressed different energy system questions, they shared a common purpose: turning complex operational data into information that can support better understanding and decision making.</p><ul><li>Some of the projects concentrated on prediction.</li><li>Others concentrated on monitoring.</li><li>Some explored the causes and costs of transmission constraints, while others examined how forecasts change across successive publications.</li></ul><p>Together, they strengthened my experience in Python, machine learning, time series analysis, dashboard development, Streamlit deployment, Power BI and energy system interpretation.</p><p>However, I wanted my next project to extend my expertise in another direction.</p><p>I did not want to build only another forecasting model or another dashboard. I wanted to take greater ownership of the complete data lifecycle, from source ingestion and historical preservation through distributed processing, data quality, governance, secure analytical serving and public cloud deployment.</p><p>That objective became the foundation of the <strong>GB Generation Availability Intelligence Platform</strong>.</p><h3>Starting with a different question</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*NJsNz13HYx6uMPYenRPxVg.png" /></figure><p>A conventional generation availability dashboard can show how much capacity is currently expected to be available.</p><p>That is useful, but it presents only the latest position.</p><p>I became interested in a deeper question:</p><blockquote><em>What changed between the previous expectation and the current one, and what can the pattern of those changes tell us?</em></blockquote><p>Generation availability is a forward looking expectation.</p><p>A generating unit may initially be expected to provide a certain level of capacity for a future period. As operational information develops, the participant may publish a revised expectation.</p><p>Suppose a unit is initially expected to provide 500 MW. A later publication reduces that expectation to 300 MW.</p><p>If a platform stores only the latest publication, it shows:</p><blockquote><em>Current expected availability = 300 MW</em></blockquote><p>But if both publications are preserved, the platform can also show:</p><blockquote><em>Revision MW = 300 MW − 500 MW = −200 MW</em></blockquote><p>The latest value describes the current position.</p><p>The revision describes how that position changed.</p><p>This difference opened a much wider analytical opportunity.</p><p>Instead of asking only how much generation is expected to be available, I could also ask:</p><ul><li>Which generating units changed?</li><li>Were the changes upward or downward?</li><li>Which fuel categories were responsible for the movement?</li><li>How much revision activity is hidden by net aggregation?</li><li>Are availability expectations remaining stable across publications?</li><li>Is recent revision activity predominantly upward, downward or balanced?</li></ul><p>Those questions moved the project beyond latest state reporting and into publication aware revision intelligence.</p><h3>What gives the platform its edge</h3><p>Generation availability dashboards and outage monitoring systems already exist. The availability of generating units is not a new subject, and I would not claim that displaying expected available capacity is itself novel.</p><p>The distinctive contribution of this platform lies elsewhere.</p><p>Most availability displays concentrate on the latest expected capacity. My platform preserves successive Elexon publications and analyses how the expectation evolves from one publication to the next.</p><p>The key modelling principle is:</p><blockquote><em>Do not overwrite successive publications.</em></blockquote><p>Each publication represents what was known or expected at a particular time. When two publications refer to the same generating unit and future delivery period, both observations are analytically valuable.</p><p>Once I preserved the publication history, revision itself became data.</p><p>This enabled the platform to create three connected levels of intelligence:</p><pre>Generating unit revision<br>          ↓<br>Fuel category revision<br>          ↓<br>Whole system revision</pre><p>The platform does not only show the latest expected availability. It also shows the path through which that expectation developed.</p><p>Consider two future periods that both currently show 50 GW of expected available generation.</p><p>The first may have remained close to 50 GW across every publication.</p><p>The second may have moved repeatedly between 45 GW and 55 GW before arriving at the same 50 GW position.</p><p>A latest state dashboard treats those two periods almost identically.</p><p>A publication aware platform does not.</p><p>The headline figure is the same, but the stability of the expectation behind it is different.</p><p>That distinction led to the most distinctive analytical component of the platform, the custom <strong>Availability Stability and Early Warning</strong> layer.</p><h3>From energy analytics to production data engineering</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*DtkaAEgoDS4NAvI39u9RoQ.png" /></figure><p>This project represents an important development in the direction of my work.</p><p>My earlier projects provided strong experience in forecasting, exploratory analysis, machine learning, dashboard development and energy system interpretation.</p><p>This platform required me to bring those capabilities into a broader production data engineering architecture.</p><p>The project covers:</p><ul><li>API ingestion;</li><li>publication aware historical modelling;</li><li>relational ETL and ELT;</li><li>automated data quality;</li><li>distributed PySpark transformations;</li><li>Parquet and Delta Lake storage;</li><li>Databricks Serverless execution;</li><li>Unity Catalog governance;</li><li>Databricks SQL serving;</li><li>OAuth machine to machine authentication;</li><li>FastAPI development;</li><li>Power BI consumption;</li><li>Azure App Service deployment;</li><li>production monitoring and troubleshooting.</li></ul><p>The analytical idea remained grounded in an energy system problem, but the implementation required much more than analysis.</p><p>It required a trustworthy system around the analysis.</p><h3>The complete architecture</h3><p>The live production path is:</p><pre>Hourly schedule<br>      ↓<br>Elexon Insights API<br>      ↓<br>Databricks Serverless job<br>      ↓<br>Validation and publication identification<br>      ↓<br>Canonical publication snapshots<br>      ↓<br>Unity Catalog Volume<br>      ↓<br>PySpark transformation and revision analytics<br>      ↓<br>Managed Delta tables<br>      ↓<br>Databricks SQL Warehouse<br>      ↓<br>FastAPI analytical service<br>      ↓<br>Microsoft Azure App Service<br>      ↓<br>Public dashboard</pre><p>The platform also contains a separate PostgreSQL engineering path:</p><pre>Elexon source data<br>      ↓<br>Raw schema<br>      ↓<br>Silver schema<br>      ↓<br>Analytics and Gold schema<br>      ↓<br>Governance and audit schema</pre><p>The two paths demonstrate different aspects of data engineering.</p><p>PostgreSQL provides a conventional layered relational implementation, covering schemas, SQL transformations, transactions, idempotent loading and pipeline auditing.</p><p>Databricks provides the live cloud analytical path, covering distributed processing, governed lakehouse storage, scheduled execution and scalable analytical serving.</p><p><strong>Insert the detailed Medium architecture schematic here.</strong></p><p><em>Figure 1. End to end architecture of the GB Generation Availability Intelligence Platform, showing the live Databricks lakehouse, revision intelligence, Stability and Early Warning layer, analytical consumers and the complementary PostgreSQL engineering path.</em></p><h3>Ingesting successive Elexon publications</h3><p>The source is Elexon’s <a href="https://bmrs.elexon.co.uk/api-documentation/endpoint/datasets/UOU2T14D">UOU2T14D dataset</a>, which provides a forward view of generation and interconnector availability.</p><p>The ingestion workflow needed to do more than send an API request.</p><p>It had to:</p><ul><li>retrieve source records consistently;</li><li>handle publication and forecast timestamps;</li><li>identify publication boundaries;</li><li>preserve the relevant source attributes;</li><li>retain successive snapshots;</li><li>recognise genuine duplicate records;</li><li>support deterministic reprocessing;</li><li>prevent already processed history from creating uncontrolled duplication.</li></ul><p>Raw records are preserved before analytical transformations are applied.</p><p>This separation means that the source publication history remains recoverable even if the downstream analytical logic changes.</p><p>It also ensures that the analytical products are derived from a traceable canonical source rather than an uncontrolled collection of temporary API responses.</p><h3>Treating data quality as part of the product</h3><p>An API response returning HTTP 200 does not prove that the data is complete, structurally correct or safe to use.</p><p>I therefore built validation around:</p><ul><li>expected schemas;</li><li>required fields;</li><li>timestamp parsing;</li><li>publication identification;</li><li>duplicate source keys;</li><li>row count behaviour;</li><li>transformation consistency;</li><li>persistence;</li><li>rerun behaviour;</li><li>Spark execution;</li><li>Databricks configuration.</li></ul><p>The pipeline is designed to fail visibly when its assumptions are violated, rather than silently move malformed records into the analytical layer.</p><p>By the final development stage, the project had <strong>52 passing automated tests</strong>.</p><p>These tests covered transformation logic, publication handling, Spark analytics, persistence, idempotency, Databricks wrappers, configuration and data quality behaviour.</p><p>This became increasingly important when the project moved from manual execution to an hourly scheduled workflow.</p><p>Once a pipeline operates without someone watching each run, its validation, logging and failure behaviour become part of the product.</p><h3>Building the relational path in PostgreSQL</h3><p>Before the Databricks production architecture was complete, I implemented a layered relational version of the platform using PostgreSQL.</p><p>The Raw layer preserves source oriented records.</p><p>The Silver layer produces cleaner, typed and standardised representations.</p><p>The Analytics and Gold layer provides consumption ready datasets.</p><p>The Governance layer records pipeline executions and supports operational auditing.</p><p>One of the governance assets is governance.pipeline_run, which captures the operational history of the pipeline.</p><p>This implementation strengthened my practical understanding of:</p><ul><li>relational schema design;</li><li>primary, natural and analytical keys;</li><li>SQL transformation patterns;</li><li>transaction management;</li><li>connection management;</li><li>audit tables;</li><li>idempotent loading;</li><li>governance and operational controls.</li></ul><p>PostgreSQL was not discarded when the Databricks architecture became operational. It remained a complementary engineering path.</p><p>However, I deliberately avoided deploying another production PostgreSQL database simply to copy the same analytical state already stored in Databricks.</p><p>By that stage, Databricks already contained the canonical cloud history, scalable PySpark transformations, managed Delta products, automated hourly processing, Unity Catalog permissions and a Databricks SQL serving layer.</p><p>Adding another production database would have created more synchronisation, more credentials and more duplicated persistence without delivering a clear additional benefit.</p><p>That decision was an important architectural lesson.</p><p>Good data engineering is not about using the greatest number of technologies. It is about selecting technologies for clear purposes and avoiding unnecessary operational complexity.</p><h3>Turning revisions into reusable data products</h3><p>Once canonical publication history existed, I could compare equivalent generating units and future periods across successive publications.</p><p>The basic calculation is:</p><blockquote><em>Revision MW = Current publication available MW − Previous publication available MW</em></blockquote><p>The result is classified as:</p><ul><li>positive, representing an upward revision;</li><li>negative, representing a downward revision;</li><li>zero, representing an unchanged expectation.</li></ul><h3>Unit level revision intelligence</h3><p>At unit level, the platform identifies individual generating units responsible for significant changes.</p><p>If a unit changes from 500 MW to 700 MW, the platform records a 200 MW upward revision.</p><p>If another unit changes from 600 MW to 350 MW, the platform records a 250 MW downward revision.</p><p>This provides information that the latest values alone cannot communicate.</p><h3>Fuel level revision intelligence</h3><p>Individual movements are aggregated by fuel category.</p><p>This helps show whether revision activity is being driven by wind, CCGT, nuclear, biomass, pumped storage, hydro, interconnectors or other represented categories.</p><p>The platform calculates both net revision and absolute revision activity.</p><blockquote><em>Absolute revision activity = Σ |Revision MW|</em></blockquote><p>This distinction is valuable because net aggregation can hide substantial movement.</p><p>Suppose one group of units within a fuel category is revised upward by 2,000 MW, while another group is revised downward by 1,900 MW.</p><p>The net revision is only 100 MW.</p><p>However, the absolute revision activity is 3,900 MW.</p><p>The net value shows the final direction.</p><p>The absolute value shows how much movement occurred underneath it.</p><h3>Whole system revision intelligence</h3><p>Unit and fuel revisions are then aggregated to the represented whole system level.</p><p>This allows the platform to show how the aggregate GB generation availability outlook evolves between publications.</p><p>The resulting datasets can support analysts who want to move between detailed asset changes and broader system level patterns without rebuilding the analytical logic from raw records.</p><h3>Moving the workload into PySpark</h3><p>I implemented the scalable analytical layer using PySpark.</p><p>The Spark workload performs:</p><ul><li>canonical Parquet history reads;</li><li>schema and timestamp handling;</li><li>publication comparisons using window operations;</li><li>unit revision calculations;</li><li>fuel aggregations;</li><li>system aggregations;</li><li>analytical table construction;</li><li>Delta Lake persistence.</li></ul><p>This stage exposed an important engineering reality.</p><p>Data that works correctly in pandas does not automatically behave identically in Spark.</p><p>Timestamp representations, schemas, data types and persistence formats required deliberate compatibility decisions.</p><p>Resolving those differences produced a cleaner boundary between canonical source history and distributed analytical processing.</p><h3>Building the governed Delta products</h3><p>The PySpark workload runs through Databricks Serverless as a repeatable Git backed job.</p><p>Canonical publication snapshots are stored in a Unity Catalog Volume.</p><p>The analytical layer consists of five managed Delta tables:</p><ol><li>fuel_availability_history</li><li>system_availability_history</li><li>unit_revision_history</li><li>fuel_revision_history</li><li>system_revision_history</li></ol><p>These tables separate two important analytical concepts.</p><p>The availability histories describe the expected position.</p><p>The revision histories describe how that position changed.</p><p>This separation makes the outputs easier to understand, govern and reuse.</p><p>The tables are not tied exclusively to the public dashboard. They can also support Power BI analysis, Databricks SQL queries and future analytical applications.</p><p>That reuse is important because different stakeholders consume information differently.</p><p>An analyst may prefer Power BI for detailed exploration.</p><p>A researcher may want the governed historical tables.</p><p>A public or executive user may prefer a focused web application.</p><p>All of those consumers can work from the same governed analytical foundation.</p><h3>Hourly automation and idempotency</h3><p>The production workflow runs hourly.</p><p>Each execution:</p><ol><li>retrieves the available Elexon records;</li><li>validates the source;</li><li>identifies the relevant publication;</li><li>preserves the canonical history;</li><li>calculates the availability and revision datasets;</li><li>persists the managed Delta outputs.</li></ol><p>Hourly scheduling introduced another important engineering question:</p><blockquote><em>What happens if the workflow encounters a publication that has already been processed?</em></blockquote><p>Without controlled rerun behaviour, recurring pipelines can create duplicate records or inconsistent analytical states.</p><p>The pipeline was therefore designed to be idempotent.</p><p>Reprocessing the same canonical history should produce the same governed analytical result, rather than continually add duplicate states.</p><p>Idempotency may not be the most visible feature on a dashboard, but it is one of the most important characteristics of a dependable production pipeline.</p><h3>The Availability Stability and Early Warning layer</h3><p>The revision histories created an opportunity to add another level of interpretation.</p><p>I wanted the dashboard to answer:</p><blockquote><em>How stable has the availability expectation itself been across publications?</em></blockquote><p>That question produced four related indicators.</p><h3>Historical Stability Score</h3><p>The Historical Stability Score measures the proportion of comparable historical unit revision records that remained unchanged between publications.</p><blockquote><em>Historical Stability Score = Unchanged revision records ÷ Total revision records × 100</em></blockquote><p>A high score means that most comparable availability expectations remained unchanged.</p><p>A lower score indicates more revision activity.</p><p>The score does not measure generating plant reliability. It measures the stability of the published expectations.</p><h3>Changed Revision Share</h3><p>The Changed Revision Share provides the complementary perspective.</p><blockquote><em>Stable share + Changed share = 100 per cent</em></blockquote><p>Displaying both measures helps the user understand the score rather than presenting an unexplained index.</p><h3>Recent Net Revision Movement</h3><p>The platform also calculates recent net revision movement across fuel categories.</p><blockquote><em>Recent net revision MW = Σ Fuel net revision MW</em></blockquote><p>A positive result means that recent revisions are net upward.</p><p>A negative result means that recent revisions are net downward.</p><h3>Availability Watch</h3><p>The recent revision direction is translated into an interpretable signal:</p><ul><li><strong>UPWARD BIAS</strong>, when recent movement is positive;</li><li><strong>DOWNWARD WATCH</strong>, when recent movement is negative;</li><li><strong>BALANCED</strong>, when recent movement is approximately neutral.</li></ul><p>The platform also identifies the fuel category with the greatest absolute revision activity.</p><p>This helps answer another useful question:</p><blockquote><em>Which represented generation technology is currently responsible for the greatest volume of adjustment?</em></blockquote><h3>Why the Stability and Early Warning layer is useful</h3><p>The purpose of this layer is not to replace existing Elexon or NESO information.</p><p>Its value lies in adding historical revision context to the latest expected position.</p><p>A stakeholder can see not only that the represented availability is currently 50 GW, but also whether that expectation has remained close to 50 GW or has arrived there after substantial repeated revisions.</p><p>A period with stable publications may require a different level of analytical attention from one experiencing concentrated downward revisions across several units or fuel categories.</p><p>The layer can therefore support:</p><ul><li>monitoring of forecast stability;</li><li>identification of concentrated revision activity;</li><li>comparison of upward and downward movement;</li><li>investigation of the fuel categories driving changes;</li><li>prioritisation of periods that may deserve closer analytical attention;</li><li>communication of revision behaviour to nontechnical users.</li></ul><p>It does not predict a shortage or guarantee physical delivery.</p><p>It provides a transparent summary of behaviour already present in the publication history.</p><p>That interpretability is part of its strength.</p><h3>What the custom indicators do not claim</h3><p>Methodological clarity is particularly important in energy system analysis.</p><p>The Stability Score and Availability Watch are not:</p><ul><li>official NESO or Elexon measures;</li><li>Loss of Load Probability;</li><li>operating margin;</li><li>reserve margin;</li><li>measures of generating plant reliability;</li><li>probabilities of physical delivery;</li><li>forecasts of system shortage.</li></ul><p>They are custom analytical indicators derived from publication to publication revision behaviour.</p><p>This boundary is stated explicitly in the dashboard because a responsible analytical product should explain both what a metric represents and what it does not represent.</p><h3>Designing the dashboard around useful questions</h3><p>The frontend was organised around stakeholder questions rather than the names of database tables.</p><p>The dashboard presents:</p><ul><li>the latest publication;</li><li>represented system available MW;</li><li>publication coverage;</li><li>tracked fuel categories;</li><li>forward availability;</li><li>fuel availability rankings;</li><li>represented capacity mix;</li><li>net and absolute revision activity;</li><li>upward and downward revision directions;</li><li>largest unit revisions;</li><li>most revised fuel;</li><li>Availability Stability and Early Warning indicators.</li></ul><p>Upward and downward movements use clear visual distinctions to reduce the effort required to interpret the results.</p><p>The dashboard also communicates an important limitation of the underlying source data.</p><p>Generation availability records do not necessarily represent every part of the physical GB generation fleet equally. Distributed and embedded generation may not appear in the same way as individually visible Balancing Mechanism units.</p><p>The capacity mix should therefore be interpreted as the mix represented in the source availability data, not as a complete real time census of every generator connected to the GB system.</p><h3>Secure analytical serving</h3><p>I built a FastAPI service between the web application and the Databricks analytical layer.</p><p>The public application does not connect directly from the browser to Databricks.</p><p>The request path is:</p><pre>Browser<br>   ↓<br>FastAPI<br>   ↓<br>Databricks SQL Warehouse<br>   ↓<br>Managed Delta tables</pre><p>Representative endpoints include:</p><ul><li>/health</li><li>/api/kpis</li><li>/api/system-availability</li><li>/api/fuel-availability</li><li>/api/fuel-revisions</li><li>/api/revision-directions</li><li>/api/revision-signals</li><li>/api/top-unit-revisions</li><li>/api/stability-intelligence</li></ul><p>The browser never receives a Databricks token, OAuth secret or database credential.</p><p>For production authentication, I created a dedicated Databricks service principal and configured OAuth machine to machine access.</p><p>The identity received only the permissions required to use the SQL warehouse and read the necessary Unity Catalog analytical tables.</p><p>This provided practical experience with environment based configuration, separation of identities and least privilege access.</p><h3>Deploying the platform to Microsoft Azure</h3><p>The stakeholder facing application is deployed through Microsoft Azure App Service.</p><p>The application stack includes:</p><ul><li>Python;</li><li>FastAPI;</li><li>Gunicorn;</li><li>Uvicorn;</li><li>Jinja2;</li><li>JavaScript;</li><li>Chart.js;</li><li>HTML;</li><li>CSS.</li></ul><p>Secrets and configuration values are supplied through the application environment rather than stored in the repository or exposed in browser side code.</p><p>Deployment moved the project from a repository that worked locally to a public data product that independently accesses its governed cloud data source.</p><h3>A production failure that became part of the learning</h3><p>The Azure application initially started successfully.</p><p>The health endpoint responded correctly.</p><p>The dashboard HTML loaded.</p><p>However, the analytical API returned HTTP 503.</p><p>That combination was useful because it helped isolate the failure:</p><pre>Azure application       ✓<br>FastAPI process         ✓<br>Public routing          ✓<br>Databricks query path   ✗</pre><p>I reproduced the production configuration locally using the same service principal and obtained the underlying error:</p><pre>invalid_client: Client authentication failed</pre><p>The issue was not caused by Spark, Unity Catalog, Delta Lake, FastAPI, networking or SQL syntax.</p><p>The problem was the OAuth client credential pair.</p><p>I regenerated the production secret, validated it before deployment, updated the Azure configuration, restarted the application and repeated the public endpoint tests.</p><p>The health, KPI, revision signal, stability intelligence and dashboard routes then returned successfully.</p><p>This experience reinforced another important lesson.</p><p>Production data engineering does not end with transformation code. It also involves tracing failures through application, authentication, analytical and storage layers and using evidence to identify the faulty boundary.</p><h3>How this project broadens my expertise</h3><p>My earlier projects demonstrated my ability to analyse energy data, build forecasting models, evaluate machine learning performance and translate technical results into interactive dashboards.</p><p>This project adds another direction to that experience.</p><p>It demonstrates that I can also:</p><ul><li>design publication aware historical data models;</li><li>build layered relational and lakehouse architectures;</li><li>develop scheduled and idempotent pipelines;</li><li>implement distributed transformations;</li><li>create governed analytical data products;</li><li>establish data quality and automated testing;</li><li>expose analytical datasets through secure APIs;</li><li>configure production machine identities;</li><li>deploy and troubleshoot a multi service cloud application.</li></ul><p>The project therefore connects my energy systems background with broader data engineering capability.</p><p>The energy domain provides the purpose.</p><p>The engineering architecture makes the analysis repeatable, governed and reusable.</p><p>The dashboard communicates the outcome.</p><p>Together, those layers create something more valuable than an isolated model or visualisation.</p><h3>Limitations</h3><p>No analytical platform is complete without clearly stated limitations.</p><p>First, generation availability is not the same as actual generation. A unit being available does not mean that it will be dispatched.</p><p>Second, publication stability is not physical reliability. A stable forecast can still be incorrect, while a revised forecast may reflect valuable new operational information.</p><p>Third, the Availability Watch is not an official system warning. It summarises revision direction within the represented publication history.</p><p>Fourth, source coverage affects interpretation. Not all distributed or embedded generation is represented in the same manner.</p><p>Finally, the platform depends on the continued availability of its source data and cloud services.</p><p>These limitations do not weaken the project. They define its correct analytical use.</p><h3>Where I would take the platform next</h3><p>Several future extensions follow naturally from the current architecture.</p><h3>Lead time sensitive stability</h3><p>A revision made shortly before delivery may carry a different analytical meaning from one made several days ahead.</p><p>Future versions could segment or weight revision behaviour according to forecast lead time.</p><h3>Unit stability profiles</h3><p>Generating units could be compared by revision frequency, direction and magnitude, while maintaining careful language around what those patterns imply.</p><h3>Revision anomaly detection</h3><p>Historical revision distributions could help identify unusually large, concentrated or rapidly repeated changes.</p><h3>Downward revision clusters</h3><p>The platform could identify periods when several units or fuel categories experience coincident downward revisions.</p><h3>Additional system context</h3><p>Availability revisions could be analysed alongside demand, wind forecasts, operating margin, interconnector availability and other relevant system indicators.</p><h3>Configurable notifications</h3><p>Large or concentrated revision events could trigger threshold based notifications for users who do not want to monitor the dashboard continuously.</p><p>The governing principle would remain unchanged: clearly distinguish a transparent analytical indicator from an official operational signal.</p><h3>Final reflection</h3><p>The most important lesson from this project is that data engineering is not simply moving data from one location to another.</p><p>It is about creating trustworthy systems around data:</p><pre>Understand the question<br>        ↓<br>Acquire and preserve the source<br>        ↓<br>Validate the data<br>        ↓<br>Design the historical model<br>        ↓<br>Build repeatable transformations<br>        ↓<br>Govern access<br>        ↓<br>Automate execution<br>        ↓<br>Serve reusable data products<br>        ↓<br>Communicate the outputs<br>        ↓<br>Monitor the production system</pre><p>The completed GB Generation Availability Intelligence Platform now runs that lifecycle from Elexon publication to a publicly accessible Azure application.</p><p>Its most interesting contribution is not the latest MW number displayed on the screen.</p><p>It is the ability to preserve how that number evolved and turn the history into unit, fuel and whole system revision intelligence.</p><p>The latest number tells us the expected position.</p><p>The revision history tells us how that expectation arrived there.</p><p><strong>Explore the live platform:</strong> <a href="https://gb-generation-intelligence-kamil.azurewebsites.net/">GB Generation Availability Intelligence Platform</a></p><p><strong>Review the source code:</strong> <a href="https://github.com/kamilkenny/GB-generation-availability-intelligence-platform">GitHub repository</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46eaf295f0f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Open Grid Data to Azure: Building a Great Britain Grid Congestion and Constraint Cost…]]></title>
            <link>https://medium.com/@kamilkenny22/from-open-grid-data-to-azure-building-a-great-britain-grid-congestion-and-constraint-cost-e5c4e90a54a0?source=rss-69a3c110544a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5c4e90a54a0</guid>
            <dc:creator><![CDATA[Ridwan Kamil]]></dc:creator>
            <pubDate>Thu, 06 Aug 2026 23:47:25 GMT</pubDate>
            <atom:updated>2026-08-07T01:09:32.768Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oDbgywBQ1w1CWMfOzFMHvw.png" /></figure><h3>From Open Grid Data to Azure: Building a Great Britain Grid Congestion and Constraint Cost Intelligence Platform</h3><h3>How I combined NESO data, Azure SQL Database, machine learning, Plotly Dash, GitHub Actions and Azure App Service to build an end-to-end power-system analytics application</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wALZe-6nnv1a2EshLw3h4Q.png" /></figure><p>Over the past years, I have been developing a series of practical energy-data applications around Great Britain’s electricity system.</p><p>Among them, I recently designed a <strong>GB Wind Forecast Revision Monitor</strong>, to collect successive versions of NESO’s 14-day wind forecast and show how the expected generation profile changed as the delivery date approached.</p><p>I developed a <strong>Great Britain Operating Margin Intelligence Dashboard</strong>, which broadened the analysis beyond one renewable-energy variable. That project brought together demand, operating margin, standing reserve, imbalance and dispatch headroom to provide a clearer view of system readiness.</p><p>For this latest project, I wanted to take another step forward.</p><p>Rather than monitor only one forecast or one area of system operation, I wanted to build a platform that connected:</p><ul><li>day-ahead transmission congestion exposure;</li><li>realised thermal constraint costs;</li><li>historical machine-learning evidence;</li><li>Electricity Ten Year Statement planning information;</li><li>cloud database engineering;</li><li>and production-style deployment on Microsoft Azure.</li></ul><p>That became the <strong>Great Britain Grid Congestion and Constraint Cost Intelligence Platform</strong>.</p><h3>Explore the live dashboard</h3><p><a href="https://gb-grid-congestion-kamil-898341.azurewebsites.net/">https://gb-grid-congestion-kamil-898341.azurewebsites.net</a></p><h3>Review the GitHub repository</h3><p><a href="https://github.com/kamilkenny/GB-Grid-Congestion-Intelligence-Analytics">https://github.com/kamilkenny/GB-Grid-Congestion-Intelligence-Analytics</a></p><h3>Why I developed this project</h3><p>Electricity has to be moved from where it is generated to where it is needed.</p><p>That sounds straightforward, but the electricity transmission network does not have unlimited capacity. At different times, expected power flows across parts of the network can approach or exceed the available transfer capability.</p><p>When this happens, the system operator may need to take balancing or redispatch actions. For example, generation may need to be reduced in one location and increased somewhere else.</p><p>These actions can result in constraint costs.</p><p>From an analytics perspective, the challenge is that the evidence needed to understand congestion and constraint costs is distributed across several datasets and time horizons.</p><p>A user may want to know:</p><ul><li>Which transmission areas showed forecast congestion pressure?</li><li>On which days did forecast limit exceedance increase?</li><li>How large was the maximum settlement-period exceedance?</li><li>How did realised thermal constraint costs change over time?</li><li>Were high-cost days more common when forecast exposure was higher?</li><li>Can historical data help rank the risk of a high-cost event?</li><li>What does long-term transmission planning information suggest about future boundary requirements?</li><li>Are there data-quality issues that could affect the interpretation?</li></ul><p>Answering these questions requires more than creating a few charts.</p><p>It requires a structured process covering:</p><ul><li>data discovery;</li><li>ingestion;</li><li>cleaning;</li><li>validation;</li><li>feature engineering;</li><li>database design;</li><li>machine-learning evaluation;</li><li>visual communication;</li><li>cloud deployment;</li><li>and governance.</li></ul><p>I therefore designed the project as an <strong>analytical decision-support and planning-intelligence platform</strong>, rather than as a collection of disconnected visualisations.</p><h3>The data used in the project</h3><p>The platform brings together three main areas of NESO open data.</p><h3>1. Day-Ahead Constraint Flows and Limits</h3><p>This dataset provides information about expected day-ahead power flows across transmission boundaries and the limits associated with those boundaries.</p><p>It forms the basis for indicators such as:</p><ul><li>forecast boundary flow;</li><li>available boundary limit;</li><li>forecast utilisation;</li><li>available headroom;</li><li>forecast limit exceedance;</li><li>number of affected constraint groups;</li><li>maximum single-period exceedance;</li><li>and MWh-equivalent forecast exposure.</li></ul><p>An important interpretation point is that a forecast limit exceedance is an <strong>analytical exposure measure</strong>.</p><p>It does not, by itself, confirm that a physical overload occurred.</p><p>It indicates that the forecast flow was above the recorded limit within the source data and therefore deserves further examination.</p><h3>2. Thermal Constraint Costs</h3><p>The thermal constraint cost data provides the realised daily financial outcome used in the historical analysis.</p><p>This allowed me to move beyond looking only at forecast network pressure.</p><p>I could also examine:</p><ul><li>daily and monthly cost behaviour;</li><li>cumulative costs;</li><li>high-cost days;</li><li>financial-year comparisons;</li><li>cost distribution by exposure band;</li><li>and the relationship between forecast pressure and realised cost.</li></ul><h3>3. Electricity Ten Year Statement information</h3><p>The Electricity Ten Year Statement, commonly referred to as ETYS, adds a longer-term planning perspective.</p><p>It allows the platform to examine:</p><ul><li>transmission boundaries;</li><li>boundary capability;</li><li>future transfer requirements;</li><li>planning scenarios;</li><li>projected years;</li><li>and potential capability gaps.</li></ul><p>These datasets serve different purposes.</p><p>The day-ahead data provides short-term forecast evidence.</p><p>The thermal constraint cost data provides realised historical outcomes.</p><p>The ETYS data provides a longer-term network-planning view.</p><p>Bringing the three together creates a more complete analytical picture than examining them separately.</p><h3>Designing the data-engineering pipeline</h3><p>One of my main goals was to treat the project as a proper data-engineering application rather than a notebook containing a long sequence of analysis cells.</p><p>The final workflow followed this structure:</p><pre>NESO open datasets<br>        ↓<br>Source discovery and metadata preservation<br>        ↓<br>Python ingestion<br>        ↓<br>Data cleaning and schema standardisation<br>        ↓<br>Validation and quality checks<br>        ↓<br>Feature and indicator engineering<br>        ↓<br>Azure SQL Database<br>        ↓<br>Approved analytical SQL views<br>        ↓<br>Plotly Dash application<br>        ↓<br>Azure App Service</pre><p>During the ingestion and transformation process, I worked through several practical data issues, including:</p><ul><li>inconsistent source column names;</li><li>numeric values stored as text;</li><li>missing values;</li><li>duplicate records;</li><li>changing date formats;</li><li>settlement-period conversion;</li><li>alignment of half-hourly and daily datasets;</li><li>aggregation of forecast exposure;</li><li>and preservation of data-quality findings.</li></ul><p>I also separated the raw data layer from the final dashboard layer.</p><p>The application does not calculate every analytical measure directly from raw files each time a user opens the dashboard.</p><p>Instead, cleaned and structured outputs are stored in Azure SQL Database and exposed through approved analytical views.</p><p>This approach makes the project easier to:</p><ul><li>maintain;</li><li>test;</li><li>document;</li><li>audit;</li><li>and extend.</li></ul><p>It also reduces the risk of different charts applying inconsistent definitions to the same metric.</p><h3>Why Azure was central to the project</h3><p>I did not want Azure to be added only at the final stage so I could say that the dashboard was cloud hosted.</p><p>I wanted Azure to be part of the actual engineering architecture.</p><p>The completed platform uses:</p><ul><li><strong>Azure SQL Database</strong> as the analytical data layer;</li><li><strong>Azure App Service</strong> to host the live Dash application;</li><li><strong>Azure App Settings</strong> for database and runtime configuration;</li><li><strong>Azure resource groups</strong> to organise the deployment;</li><li><strong>Azure deployment logs</strong> for troubleshooting;</li><li><strong>OpenID Connect authentication</strong> between GitHub Actions and Azure;</li><li>and a public application-health endpoint for validation.</li></ul><p>This gave me practical exposure to the type of Azure-based data and analytics workflow frequently requested in energy-sector roles.</p><h3>Azure SQL Database as the analytical foundation</h3><p>One of the biggest improvements over my earlier applications was moving the analytical database into <strong>Azure SQL Database</strong>.</p><p>My previous wind-monitoring and operating-margin projects used PostgreSQL hosted through Supabase.</p><p>Those projects were valuable because they helped me understand:</p><ul><li>relational database design;</li><li>SQL querying;</li><li>cloud database connections;</li><li>connection pooling;</li><li>and application-to-database integration.</li></ul><p>For this congestion project, I wanted to work more deeply within the Microsoft data ecosystem.</p><p>I therefore created an Azure SQL environment and structured the analytical data under the dbo schema.</p><p>The database supports information for:</p><ul><li>daily integrated congestion and cost evidence;</li><li>monthly trend analysis;</li><li>forecast stress and cost relationships;</li><li>machine-learning scores;</li><li>model evaluation metrics;</li><li>model-governance decisions;</li><li>ETYS planning context;</li><li>data-quality records;</li><li>and pipeline-status information.</li></ul><p>The live application validates access to <strong>11 approved Azure SQL analytical views</strong>.</p><p>The dashboard filters also query the approved analytical layer rather than accessing raw source data directly.</p><p>This improved my practical understanding of:</p><ul><li>Azure SQL deployment;</li><li>relational data modelling;</li><li>SQL views;</li><li>analytical data marts;</li><li>SQL Server-compatible connectivity;</li><li>ODBC drivers;</li><li>secure credentials;</li><li>environment variables;</li><li>and cloud database troubleshooting.</li></ul><p>Database credentials are not stored directly inside the application source code.</p><p>They are supplied through Azure App Service configuration and environment variables.</p><p>This was important both for security and for making the application portable across development and production environments.</p><h3>Developing the application with Plotly Dash and Flask</h3><p>The final application was built using <strong>Plotly Dash</strong>, with Flask providing the underlying web server.</p><p>I chose Dash because it allowed me to combine:</p><ul><li>Python data-processing logic;</li><li>interactive Plotly visualisations;</li><li>filters;</li><li>callbacks;</li><li>database queries;</li><li>tables;</li><li>and a responsive browser interface.</li></ul><p>The application retrieves different analytical outputs from Azure SQL, including:</p><ul><li>daily evidence;</li><li>monthly trends;</li><li>stress-and-cost relationships;</li><li>model scores;</li><li>model metrics;</li><li>model-governance records;</li><li>ETYS planning information;</li><li>data-quality findings;</li><li>and pipeline status.</li></ul><p>The dashboard is divided into six main sections.</p><h3>1. Executive Overview</h3><p>The Executive Overview is intended to answer the first question most users will have:</p><blockquote><em>What does the available evidence currently show?</em></blockquote><p>It presents headline indicators such as:</p><ul><li>total thermal constraint cost;</li><li>latest available date;</li><li>days containing forecast limit exceedance;</li><li>number of high-cost days;</li><li>total forecast exposure;</li><li>peak settlement-period exceedance;</li><li>number of historically scored days;</li><li>and recorded data-quality issues.</li></ul><p>It also includes:</p><ul><li>monthly cost and exposure comparisons;</li><li>the distribution of cost outcomes;</li><li>and a written summary of the latest evidence.</li></ul><p>The aim is to allow a stakeholder to understand the scale and direction of the available congestion and cost information before moving into more detailed analysis.</p><h3>2. Congestion and Cost</h3><p>The Congestion and Cost section focuses on historical patterns.</p><p>It includes:</p><ul><li>daily thermal constraint cost;</li><li>cumulative constraint cost;</li><li>a calendar heatmap of forecast exposure;</li><li>monthly cost rankings;</li><li>financial-year comparisons;</li><li>and a detailed daily evidence table.</li></ul><p>The table can be:</p><ul><li>filtered;</li><li>sorted;</li><li>and exported.</li></ul><p>Users can filter the dashboard by:</p><ul><li>date range;</li><li>financial year;</li><li>forecast-exposure band;</li><li>and thermal-cost outcome.</li></ul><p>One principle I maintained throughout the project was to distinguish clearly between <strong>forecast exposure</strong> and <strong>realised constrained energy</strong>.</p><p>The forecast exposure measure is derived from the size and duration of forecast limit exceedance.</p><p>It is expressed as an MWh-equivalent analytical measure.</p><p>It should not be interpreted as confirmed constrained energy.</p><h3>3. Stress and Cost</h3><p>The Stress and Cost section examines how forecast network-pressure indicators have historically related to realised thermal constraint costs.</p><p>The visualisations include:</p><ul><li>a forecast-exposure and cost scatter plot;</li><li>cost distribution by exposure band;</li><li>high-cost-event rate by exposure band;</li><li>and a correlation heatmap.</li></ul><p>This section is useful for identifying patterns that may deserve further investigation.</p><p>However, a strong historical association does not automatically prove causation.</p><p>Constraint costs can be affected by several factors, including:</p><ul><li>generation availability;</li><li>demand;</li><li>planned and unplanned outages;</li><li>location of generation;</li><li>market conditions;</li><li>interconnector behaviour;</li><li>and wider balancing requirements.</li></ul><p>For that reason, the dashboard describes the results as historical analytical associations.</p><p>It does not claim that one forecast indicator directly caused a specific constraint cost.</p><h3>4. Machine Learning Performance Analysis</h3><p>The project also includes a machine-learning classification model for ranking the risk of a high thermal constraint cost event.</p><p>I used a chronological evaluation design rather than randomly mixing older and newer observations.</p><p>This was important because electricity-system data is time dependent.</p><p>A random split can allow patterns from later periods to influence the model’s evaluation on earlier records.</p><p>That can make performance look more reliable than it would be in practice.</p><p>The final evaluation included a locked chronological test period.</p><p>The model achieved:</p><ul><li><strong>ROC AUC:</strong> 0.878</li><li><strong>Average Precision:</strong> 0.4565</li><li><strong>Average Precision lift:</strong> 4.89 times the underlying event rate</li><li><strong>High-cost event detection:</strong> 71.4%</li><li><strong>Precision:</strong> 0.2632</li><li><strong>F1 score:</strong> 0.3846</li><li><strong>F2 score:</strong> 0.5319</li><li><strong>Alert share:</strong> 25.33%</li></ul><p>These results require a balanced interpretation.</p><p>The ROC AUC of 0.878 indicates that the model was good at ranking higher-risk days above lower-risk days.</p><p>The average-precision lift of 4.89 shows that the model provided substantially more useful ranking information than the underlying event prevalence alone.</p><p>The model also identified 71.4% of the high-cost events within the locked test period.</p><p>However, the precision result shows that a significant number of flagged days did not become high-cost events.</p><p>The alert share was also higher than the preferred deployment level.</p><p>For this reason, I did not present the model as ready for operational alerting.</p><p>The dashboard retains the full evaluation output, including:</p><ul><li>the historical risk-score timeline;</li><li>confusion matrix;</li><li>event rate by risk-score band;</li><li>metric comparison;</li><li>classification outcome filter;</li><li>and formal model-governance decision.</li></ul><p>The score is described as an <strong>uncalibrated empirical ranking</strong>, not as a literal probability.</p><p>This is an important distinction.</p><p>A score of 0.80 should not automatically be interpreted as an 80% probability of a high-cost event.</p><p>The model demonstrated strong ranking performance and useful event detection, but it remains an analytical research decision-support model.</p><p>It is not presented as an operationally approved alerting model.</p><h3>5. Electricity Ten Year Statement Context</h3><p>The ETYS section provides a longer-term planning view.</p><p>Users can explore:</p><ul><li>individual transmission boundaries;</li><li>planning scenarios;</li><li>boundary categories;</li><li>projection years;</li><li>transfer requirements;</li><li>available capability;</li><li>and projected capability gaps.</li></ul><p>This section helps connect short-term congestion evidence with longer-term network-planning information.</p><p>It does not mean that a day-ahead forecast exceedance directly predicts a future reinforcement requirement.</p><p>Instead, it allows users to move between two related questions:</p><blockquote><em>Where has congestion pressure appeared historically?</em></blockquote><p>and:</p><blockquote><em>Where could future transfer requirements place additional pressure on network capability?</em></blockquote><p>This combination makes the dashboard relevant not only to historical cost analysis, but also to planning and scenario-based discussion.</p><h3>6. Quality and Governance</h3><p>One lesson I have learned from developing several analytics applications is that confidence in an output depends on more than whether the chart loads correctly.</p><p>Users also need to understand:</p><ul><li>where the data came from;</li><li>when it was updated;</li><li>whether issues were detected;</li><li>how those issues were handled;</li><li>what definitions were used;</li><li>and whether a model passed its deployment criteria.</li></ul><p>The Quality and Governance page therefore includes:</p><ul><li>pipeline status;</li><li>data availability;</li><li>recorded data-quality issues;</li><li>issue descriptions;</li><li>resolution notes;</li><li>analytical definitions;</li><li>methodology boundaries;</li><li>and model-use restrictions.</li></ul><p>This part of the project was important because it makes uncertainty visible.</p><p>It is easy to build a dashboard that only presents polished outputs.</p><p>It is more valuable to build one that also explains the conditions under which those outputs should be trusted.</p><h3>Deploying the application to Azure App Service</h3><p>The completed Dash application is hosted on <strong>Azure App Service</strong> using a Linux Python environment.</p><p>The deployment required practical work with:</p><ul><li>Azure subscriptions;</li><li>resource groups;</li><li>Linux App Service;</li><li>Python runtime configuration;</li><li>environment variables;</li><li>startup configuration;</li><li>database connectivity;</li><li>deployment logs;</li><li>cloud permissions;</li><li>and production debugging.</li></ul><p>The application exposes a /health endpoint.</p><p>This endpoint verifies:</p><ul><li>that the web application is responding;</li><li>that the Azure SQL connection succeeds;</li><li>and that the expected analytical views are available.</li></ul><p>This became particularly useful during deployment.</p><p>A website can be technically online while still failing to connect to its database.</p><p>A deployment workflow can also complete successfully while the wrong version of the application is being served.</p><p>The health endpoint and live layout checks provide additional evidence that the intended application is actually working.</p><h3>Creating a CI/CD pipeline with GitHub Actions</h3><p>The project uses <strong>GitHub Actions</strong> to deploy the application to Azure.</p><p>The deployment workflow follows this process:</p><pre>Application change<br>        ↓<br>Git commit<br>        ↓<br>Push to the main branch<br>        ↓<br>GitHub Actions checks out the repository<br>        ↓<br>Python files are syntax checked<br>        ↓<br>An Azure deployment package is created<br>        ↓<br>GitHub authenticates with Azure<br>        ↓<br>The package is deployed to Azure App Service<br>        ↓<br>The public health endpoint is validated</pre><p>The workflow validates the main application and its supporting modules before creating a ZIP deployment package from the app_service directory.</p><p>This means that obvious Python syntax errors can be detected before the package reaches Azure.</p><p>The deployment then uses the Azure web-app deployment action to publish the package to Azure App Service.</p><h3>Secure Azure authentication through OpenID Connect</h3><p>Authentication between GitHub Actions and Azure uses <strong>OpenID Connect</strong>, commonly called OIDC.</p><p>This was an important part of the project.</p><p>A less secure approach would involve storing a permanent Azure password or deployment credential inside GitHub.</p><p>With OIDC, GitHub Actions requests a short-lived access token from Azure.</p><p>Azure only issues that token when the request matches the configured trust relationship.</p><p>This required me to work with:</p><ul><li>Azure service principals;</li><li>application registrations;</li><li>managed identities;</li><li>federated credentials;</li><li>tenant identifiers;</li><li>subscription identifiers;</li><li>GitHub workflow permissions;</li><li>and repository trust conditions.</li></ul><p>This approach improved the security of the deployment pipeline and gave me direct experience with cloud authentication beyond simply copying a deployment password into a secret field.</p><h3>One of the most useful deployment lessons</h3><p>One of the most useful lessons came after a workflow reported a successful deployment, but the public application still displayed an earlier version.</p><p>The Azure deployment itself had succeeded.</p><p>The problem was that the redesigned application file existed in the local development working directory but had not been committed and pushed to the branch used by GitHub Actions.</p><p>The workflow therefore deployed the latest committed version, which was still the older application.</p><p>This reinforced an important point:</p><blockquote><em>A green deployment status does not automatically prove that the intended code is live.</em></blockquote><p>To resolve the issue, I traced the deployment through:</p><ul><li>the local Git commit;</li><li>the remote GitHub branch;</li><li>the workflow commit SHA;</li><li>the application file contained in that commit;</li><li>the deployment package;</li><li>and the live Dash layout returned by Azure.</li></ul><p>I later updated the validation process so that the monitored workflow had to match the exact commit intended for deployment.</p><p>This debugging experience strengthened my understanding of:</p><ul><li>version control;</li><li>Git working trees;</li><li>local and remote branches;</li><li>deployment artifacts;</li><li>commit traceability;</li><li>GitHub Actions;</li><li>and production validation.</li></ul><p>These are the kinds of lessons that do not usually appear when an application is only run locally inside a notebook.</p><h3>How this project improves on my previous work</h3><p>I see this project as a clear progression across three applications.</p><h3>GB Wind Forecast Revision Monitor</h3><p>The wind application concentrated on one important source of uncertainty:</p><ul><li>changes in 14-day wind forecasts;</li><li>successive forecast versions;</li><li>trend monitoring;</li><li>and forecast-revision behaviour.</li></ul><p>It helped me develop experience with:</p><ul><li>automated data collection;</li><li>historical storage;</li><li>SQL;</li><li>and cloud visualisation.</li></ul><h3>Great Britain Operating Margin Intelligence Dashboard</h3><p>The next project widened the analysis to several system indicators:</p><ul><li>electricity demand;</li><li>operating margin;</li><li>standing reserve;</li><li>imbalance;</li><li>dispatch headroom;</li><li>and system-readiness classifications.</li></ul><p>It also strengthened my experience with:</p><ul><li>Plotly Dash;</li><li>PostgreSQL;</li><li>GitHub Actions;</li><li>Azure App Service;</li><li>cloud database connections;</li><li>and executive-style visual communication.</li></ul><h3>Grid Congestion and Constraint Cost Intelligence Platform</h3><p>This latest project advances the work through:</p><ul><li>multiple integrated NESO datasets;</li><li>half-hourly, daily and planning-horizon evidence;</li><li>Azure SQL Database;</li><li>controlled analytical views;</li><li>machine-learning classification;</li><li>chronological evaluation;</li><li>model governance;</li><li>ETYS planning analysis;</li><li>a multi-page Dash application;</li><li>secure OIDC deployment;</li><li>and automated post-deployment validation.</li></ul><p>The earlier projects taught me how to monitor an energy-data stream.</p><p>This project required me to think about how to engineer, govern, deploy and communicate an entire cloud analytical system.</p><h3>What the project taught me</h3><h3>Cloud engineering is more than hosting</h3><p>Making a dashboard available through a public URL is only one part of deployment.</p><p>A production-style cloud application also requires attention to:</p><ul><li>security;</li><li>database access;</li><li>configuration;</li><li>runtime behaviour;</li><li>deployment identity;</li><li>logging;</li><li>application health;</li><li>and repeatability.</li></ul><h3>The database layer shapes the dashboard</h3><p>A dashboard becomes easier to maintain when important calculations and transformations are organised in documented SQL views.</p><p>This also reduces the risk of different charts applying different definitions to the same measure.</p><h3>Model performance must be communicated honestly</h3><p>The classifier demonstrated strong ranking performance and useful high-cost-event detection.</p><p>At the same time, its precision and alert volume remained important limitations.</p><p>Presenting both the strengths and the weaknesses makes the model evidence more credible.</p><h3>Energy data needs interpretation boundaries</h3><p>Terms such as:</p><ul><li>forecast exceedance;</li><li>constraint;</li><li>risk;</li><li>capability;</li><li>and capability gap</li></ul><p>can easily be misunderstood.</p><p>The application therefore includes definitions and methodology notices alongside the visualisations.</p><h3>A technically correct chart is not always a useful chart</h3><p>A useful chart should help the user understand:</p><ul><li>what the metric represents;</li><li>why it matters;</li><li>how to interpret it;</li><li>and what should be investigated next.</li></ul><p>This principle became increasingly important as the application grew.</p><h3>Who could use an application like this?</h3><p>The platform may be useful to:</p><ul><li>energy-data analysts;</li><li>power-system researchers;</li><li>network-planning teams;</li><li>constraint-cost analysts;</li><li>forecasting teams;</li><li>energy-market analysts;</li><li>students;</li><li>and organisations developing internal grid-intelligence tools.</li></ul><p>It can support:</p><ul><li>historical period comparison;</li><li>identification of cost peaks;</li><li>identification of forecast-exposure peaks;</li><li>examination of stress-and-cost relationships;</li><li>machine-learning performance review;</li><li>transmission-boundary planning analysis;</li><li>and evidence-based discussion.</li></ul><p>The platform is independently developed from public data.</p><p>It is an analytical decision-support application and should not be treated as a substitute for official system-operation tools.</p><h3>Future development</h3><p>There are several ways the project could be extended.</p><p>Possible next steps include:</p><ul><li>fully scheduled end-to-end source ingestion;</li><li>additional automated data-quality checks;</li><li>model probability calibration;</li><li>periodic model retraining;</li><li>model-drift monitoring;</li><li>weather and renewable-generation features;</li><li>interconnector information;</li><li>generation-mix data;</li><li>boundary-level forecasting;</li><li>automated reports;</li><li>email or Microsoft Teams notifications;</li><li>application authentication;</li><li>and a dedicated API layer.</li></ul><p>Another useful extension would be to compare:</p><ul><li>day-ahead congestion exposure;</li><li>actual balancing actions;</li><li>realised constrained volume;</li><li>and final constraint cost.</li></ul><p>That would create a clearer analytical path from forecast network pressure to realised operational and financial outcomes.</p><h3>Conclusion</h3><p>The Great Britain Grid Congestion and Constraint Cost Intelligence Platform began with a question:</p><blockquote><em>How does day-ahead transmission congestion pressure relate to realised thermal constraint cost?</em></blockquote><p>It developed into an end-to-end project involving:</p><ul><li>NESO open-data integration;</li><li>Python data engineering;</li><li>data validation;</li><li>feature engineering;</li><li>Azure SQL Database;</li><li>machine learning;</li><li>model governance;</li><li>interactive visualisation;</li><li>Git and GitHub;</li><li>secure CI/CD;</li><li>and Microsoft Azure deployment.</li></ul><p>For me, the most important result is not one model score or one dashboard chart.</p><p>It is the experience of taking an energy-data question through the full lifecycle:</p><pre>Analytical question<br>        ↓<br>Data discovery<br>        ↓<br>Data engineering<br>        ↓<br>Database design<br>        ↓<br>Analysis and modelling<br>        ↓<br>Visual communication<br>        ↓<br>Cloud deployment<br>        ↓<br>Validation and governance</pre><p>This project brought together my interests in:</p><ul><li>power systems;</li><li>energy forecasting;</li><li>data analytics;</li><li>machine learning;</li><li>cloud engineering;</li><li>and decision-support application development.</li></ul><p>It also strengthened my ability to work within the Microsoft Azure environment, from Azure SQL Database and App Service to secure GitHub Actions deployment and post-deployment validation.</p><p>That is the direction in which I want to continue developing my work: building energy-data systems that are technically robust, clearly communicated and useful for real analytical and planning questions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5c4e90a54a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building the Great Britain Operating Margin Intelligence Dashboard with Python, PostgreSQL, GitHub…]]></title>
            <link>https://medium.com/@kamilkenny22/building-the-great-britain-operating-margin-intelligence-dashboard-with-python-postgresql-github-720b24cc2df4?source=rss-69a3c110544a------2</link>
            <guid isPermaLink="false">https://medium.com/p/720b24cc2df4</guid>
            <category><![CDATA[energy-data-engineering]]></category>
            <category><![CDATA[python-web-developer]]></category>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[power-system]]></category>
            <dc:creator><![CDATA[Ridwan Kamil]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 11:37:41 GMT</pubDate>
            <atom:updated>2026-08-09T22:43:58.895Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building the Great Britain Operating Margin Intelligence Dashboard with Python, PostgreSQL, GitHub Actions and Microsoft Azure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ikVYiqvJh3M74BGhPzc-Jw.png" /></figure><p><strong>View the source code on GitHub:</strong></p><p><a href="https://github.com/kamilkenny/GB-System-Operating-Plan-and-Dispatch-Readiness-Monitor">GitHub - kamilkenny/GB-System-Operating-Plan-and-Dispatch-Readiness-Monitor: Dispatch Readiness and Operating Margin Intelligence Dashboard. NESO explains that the System Operating Plan is produced by the control room strategy team at key demand peaks or troughs called Cardinal Points, then handed to the real time energy team to support operational decisions</a></p><blockquote><strong><em>Live application:</em></strong><em><br> </em><a href="https://neso-gb-dispatch-readiness-kamil-hpaqe7d2eucebfa2.germanywestcentral-01.azurewebsites.net/"><em>View the Great Britain Operating Margin Intelligence Dashboard</em></a></blockquote><p><strong>Introduction</strong></p><p>Electricity-system datasets contain a great deal of useful information, but they are rarely easy to understand at first glance.</p><p>A System Operating Plan can include demand forecasts, reserve requirements, operating margins, dispatch availability, contingency values and imbalance measurements. Each variable has operational meaning. However, placing those variables in a spreadsheet or database does not automatically turn them into information that someone can interpret quickly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ni8aWyKaVjUtKyszeXx1qw.jpeg" /></figure><p>The bigger challenge is turning the data into answers.</p><ul><li>What is happening across the system?</li><li>Is the available operating margin sufficient?</li><li>Does standing reserve appear to cover the requirement?</li><li>Which indicator is creating pressure?</li><li>Is a weaker condition isolated or appearing repeatedly?</li><li>Which operating period deserves closer attention?</li></ul><p>These questions motivated me to develop the <strong>Great Britain Operating Margin Intelligence Dashboard</strong>.</p><p>The application collects publicly available System Operating Plan data, stores historical records in PostgreSQL, calculates analytical indicators and presents the results through an interactive dashboard hosted on Microsoft Azure.</p><p>This was not simply a dashboard-design exercise. It became an end-to-end project involving energy-system analysis, Python development, SQL, cloud databases, automated workflows, secure authentication and application deployment.</p><h3>Moving beyond wind forecast monitoring</h3><p>Before starting this project, I developed a <a href="https://medium.com/@kamilkenny22/building-a-cloud-based-neso-wind-forecast-revision-monitor-with-python-supabase-github-actions-699e348dae71">GB Wind Forecast Monitoring Project</a>, which tracks changes in published wind-generation forecasts and highlights significant forecast revisions. The deployed <a href="https://neso-wind-forecast-monitor-knbc32cgs89awbzxdfujqi.streamlit.app/">live monitoring application</a></p><p>That earlier application focused on detecting changes in published wind-generation forecasts and highlighting significant forecast revisions. It helped me build practical experience in automated data collection, time-series monitoring and renewable-energy analytics.</p><p>However, wind generation is only one part of electricity-system operation.</p><p>A wider operational assessment also needs to consider demand, available reserve, system margin, dispatch flexibility, imbalance and contingency requirements. Looking at one variable alone cannot provide the full picture.</p><p>The question behind my work therefore changed from:</p><blockquote><strong><em>How is the wind forecast changing?</em></strong></blockquote><p>to:</p><blockquote><strong><em>What does the wider operating position of the electricity system look like, and where might closer attention be required?</em></strong></blockquote><p>That change in perspective became the foundation of the Great Britain Operating Margin Intelligence Dashboard.</p><h3>Understanding the System Operating Plan</h3><p>The project uses System Operating Plan data published by the National Energy System Operator.</p><p>As part of its daily planning process, the control-room strategy team produces System Operating Plans around important demand peaks and troughs. These periods are described as <strong>Cardinal Points</strong>. The plan provides a snapshot of the information available ahead of those operating periods and supports the preparation of a secure, economic and flexible operating position.</p><p>This makes the dataset particularly useful for operational analytics.</p><p>It is not simply a record of historical generation. It includes information relating to planned system conditions at important points during the operating day.</p><p>The structured resource is made available through the NESO Open Data Portal and its CKAN Data API, making it possible to retrieve the records programmatically rather than downloading and processing files manually.</p><h3>Project objective</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*-oTKDXdSiMHHaz8fSTfHpw.png" /></figure><p>My objective was to build a cloud-based analytical system capable of:</p><ol><li>collecting structured System Operating Plan data</li><li>preserving historical snapshots in a relational database</li><li>cleaning and standardising the source fields</li><li>calculating useful operational indicators</li><li>translating technical measurements into clearer classifications</li><li>presenting the results through an interactive dashboard</li><li>automating data collection and application deployment</li><li>making the application publicly accessible through cloud hosting</li></ol><p>I also followed one important design principle throughout the project:</p><blockquote><strong><em>A useful dashboard should not only show a chart. It should explain what the chart represents, why it matters, how it should be interpreted and what deserves further investigation.</em></strong></blockquote><p>The project was therefore built around interpretation rather than visualisation alone.</p><h3>The complete architecture</h3><p>The final pipeline follows this structure:</p><pre>System Operating Plan Open Data API<br>                  ↓<br>Python data collector<br>                  ↓<br>Cleaning and transformation<br>                  ↓<br>Operational indicator engineering<br>                  ↓<br>Supabase PostgreSQL database<br>                  ↓<br>SQLAlchemy and Pandas data-access layer<br>                  ↓<br>Plotly Dash application<br>                  ↓<br>GitHub Actions automation<br>                  ↓<br>Microsoft Azure App Service</pre><p>Each part has a specific purpose.</p><p>The API provides the source information. Python collects and transforms it. PostgreSQL retains the records. Dash presents the analysis. GitHub Actions handles scheduled processes and deployment, while Azure hosts the live application.</p><h3>Stage 1: Collecting the source data</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*91yAysZNOeYA0CW-kdzv4Q.png" /></figure><blockquote><strong><em>Suggested section graphic:</em></strong><em> Data source → Python collector → validated records</em></blockquote><p>The first stage was developing a Python collector that could retrieve System Operating Plan records automatically.</p><p>Making an API request is only one small part of a reliable collection process. The collector also needs to determine whether the response is valid and whether the expected fields are present.</p><p>My collection workflow was designed to:</p><ul><li>retrieve the latest available records</li><li>confirm that the API returned a successful response</li><li>check the structure of the returned data</li><li>handle missing or malformed values</li><li>standardise date and time fields</li><li>convert operational fields into suitable numeric types</li><li>distinguish new records from previously stored records</li><li>preserve the collection timestamp</li><li>prevent unnecessary duplication</li><li>log failures for investigation</li></ul><p>The historical-snapshot element was particularly important.</p><p>If the application stored only the latest available record, it would not be possible to examine how system conditions developed across different publications or operating periods.</p><p>By retaining historical records, the dashboard can support:</p><ul><li>trend analysis</li><li>Cardinal Point comparisons</li><li>status distributions</li><li>identification of repeated Watch or Severe conditions</li><li>examination of how readiness changes over time</li></ul><p>This moved the project from being a simple API viewer to becoming a historical monitoring system.</p><h3>Stage 2: Designing the PostgreSQL data layer</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*hi_buHSAJCGro8LXqe52lA.png" /></figure><blockquote><strong><em>Suggested section graphic:</em></strong><em> Cleaned data → relational table → historical query layer</em></blockquote><p>I used <strong>Supabase PostgreSQL</strong> as the project’s cloud database.</p><p>Supabase provides a managed PostgreSQL database with SQL access, database-management tools and several connection options, including direct, session-pooler and transaction-pooler connections.</p><p>The database stores information covering areas such as:</p><ul><li>SOP date and time</li><li>report date</li><li>publication version</li><li>publication status</li><li>Cardinal Point</li><li>customer-demand forecast</li><li>total SOP demand</li><li>standing-reserve requirement</li><li>standing-reserve availability</li><li>reserve coverage</li><li>reserve gap</li><li>positive and negative reserve</li><li>system residual values</li><li>imbalance</li><li>absolute imbalance</li><li>contingency requirement</li><li>operating-margin surplus</li><li>trigger level</li><li>margin relative to trigger</li><li>dispatch headroom</li><li>component scores</li><li>readiness score</li><li>Watch and Severe flags</li><li>operational-attention summary</li><li>data-collection timestamp</li></ul><p>The database design needed to support two different requirements.</p><p>First, it had to preserve the source records accurately. Second, it had to store the calculated indicators required by the dashboard.</p><p>That meant thinking carefully about:</p><ul><li>consistent column names</li><li>primary or unique identifiers</li><li>numeric data types</li><li>timestamps and time zones</li><li>update logic</li><li>duplicate prevention</li><li>historical storage</li><li>query ordering</li><li>connection security</li><li>performance as the table grows</li></ul><h3>What this taught me about SQL</h3><p>The SQL part of the project went beyond writing a basic SELECT statement.</p><p>I worked with:</p><ul><li>relational table design</li><li>field mapping</li><li>ordered queries</li><li>filtering</li><li>insert and update operations</li><li>historical record retention</li><li>derived attributes</li><li>timestamp processing</li><li>SQLAlchemy database engines</li><li>connection strings</li><li>transaction handling</li><li>cloud database connection limits</li></ul><p>One of the strongest lessons was that a query working locally does not automatically mean that the database layer is production-ready.</p><p>A deployed application must open connections carefully, release them correctly and remain stable when several dashboards, collectors or development sessions access the database at the same time.</p><h3>Stage 3: Engineering operational indicators</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/407/1*M9IruoQmrbdhV3a4g8_mGg.png" /></figure><blockquote><strong><em>Suggested section graphic:</em></strong><em> Raw values → formulas and rules → operational classifications</em></blockquote><p>Raw measurements can be difficult to interpret without context.</p><p>For example, an operating margin of 850 MW may be immediately meaningful to a specialist. A wider audience, however, may not know whether that value represents a comfortable or concerning position.</p><p>I therefore developed a set of derived indicators and simplified analytical classifications.</p><h3>Reserve coverage ratio</h3><p>The reserve coverage ratio compares standing-reserve availability with the reserve requirement:</p><pre>Reserve coverage ratio =<br>Standing reserve availability ÷ Standing reserve requirement</pre><p>A value of 1.00 means that the recorded availability is equal to the recorded requirement.</p><p>A value below 1.00 means that availability is below the requirement.</p><p>For dashboard interpretation, I used the following analytical bands:</p><p>Reserve coverageDashboard classificationBelow 0.80Critical0.80 to below 0.90Watch0.90 to below 1.00Adequate1.00 or aboveComfortable</p><h3>Reserve gap</h3><p>The reserve gap is calculated as:</p><pre>Reserve gap MW =<br>Standing reserve availability − Standing reserve requirement</pre><p>A positive result indicates a surplus relative to the recorded requirement.</p><p>A negative result indicates a shortfall.</p><h3>Margin versus trigger</h3><p>This indicator shows the position of operating margin relative to the recorded trigger level:</p><pre>Margin versus trigger MW =<br>Operating margin surplus − Trigger level</pre><h3>Dispatch headroom</h3><p>Dispatch headroom is calculated from the relevant dispatch-availability fields:</p><pre>Dispatch headroom MW =<br>TEMX − TEOL</pre><p>It provides an analytical view of the remaining dispatch flexibility represented by those source variables.</p><h3>Absolute imbalance</h3><p>Imbalance may be positive or negative, depending on direction.</p><p>For pressure monitoring, I also calculate its absolute magnitude:</p><pre>Absolute imbalance MW =<br>|System imbalance|</pre><p>This allows the dashboard to focus on the size of the imbalance rather than only its direction.</p><h3>Operating-margin classification</h3><p>For clearer visual interpretation, operating margin is grouped into four project-specific categories:</p><p>Operating marginClassificationBelow 500 MWCritical500 to 999 MWWatch1,000 to 2,999 MWAdequate3,000 MW or aboveStrong</p><h3>System-readiness score</h3><p>The dashboard also combines selected information relating to:</p><ul><li>operating margin</li><li>reserve coverage</li><li>imbalance pressure</li><li>dispatch headroom</li></ul><p>The output is presented as a readiness score between 0 and 100 and assigned one of four statuses:</p><ul><li>Comfortable</li><li>Watch</li><li>Tight</li><li>Critical</li></ul><p>The indicator is intended to make it easier to identify periods that appear stronger or weaker across several variables.</p><p>However, this distinction is essential:</p><blockquote><strong><em>The readiness score and its thresholds are analytical constructs developed for this project. They are not official NESO metrics or control-room operating limits.</em></strong></blockquote><p>They are used to support visual interpretation and demonstrate how several variables can be combined within a decision-support prototype.</p><h3>Stage 4: Building the dashboard</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*Vmo9UPO65JqVcRu2jLwIrQ.png" /></figure><blockquote><strong><em>Suggested section graphic:</em></strong><em> Database → Dash callbacks → interactive operational views</em></blockquote><p>The front end was developed using <strong>Plotly Dash</strong>.</p><p>Dash allows layouts, dropdowns, tables, graphs and interactive callbacks to be created in Python. When a user changes an input, a callback can retrieve or process the new information and update the relevant dashboard components.</p><p>This suited the project because the application needed to:</p><ul><li>query data from PostgreSQL</li><li>apply user-selected filters</li><li>identify the latest operational position</li><li>generate Plotly figures</li><li>update several visual components together</li><li>refresh automatically</li><li>provide detailed hover information</li><li>display historical records</li><li>respond to manual refresh requests</li></ul><h3>Executive KPI cards</h3><p>The first section provides a quick summary of:</p><ul><li>number of records displayed</li><li>latest SOP time</li><li>readiness score</li><li>readiness status</li><li>operating margin</li><li>reserve coverage</li><li>dispatch headroom</li></ul><p>The intention is to let the user understand the latest filtered position before moving into the detailed analysis.</p><h3>Operational gauges</h3><p>Three gauges display:</p><ul><li>system readiness</li><li>operating margin</li><li>reserve coverage</li></ul><p>The colour bands provide an immediate visual indication of the current analytical category.</p><h3>Executive interpretation</h3><p>The application generates short written summaries of the latest position.</p><p>Instead of displaying only a number, it explains:</p><ul><li>the current category</li><li>whether the position appears comfortable or concerning</li><li>which indicator seems weaker</li><li>what area may deserve closer monitoring</li></ul><p>These statements are analytical explanations, not instructions for real-world system operation.</p><h3>Readiness trend</h3><p>The readiness trend shows whether the combined analytical score is:</p><ul><li>improving</li><li>stable</li><li>weakening</li><li>repeatedly entering lower-status bands</li></ul><p>Hover information provides the underlying SOP time, Cardinal Point, margin and reserve values.</p><h3>Operating-margin safety view</h3><p>Instead of displaying only a compressed MW line, this chart shows movement between:</p><ul><li>Strong</li><li>Adequate</li><li>Watch</li><li>Critical</li></ul><p>The original megawatt values remain available through the chart tooltip.</p><h3>Reserve-coverage analysis</h3><p>The reserve visual shows how availability compares with the reserve requirement over time.</p><p>A reference line at 1.00 makes it easier to identify periods when recorded availability is below the requirement.</p><h3>Cardinal Point comparison</h3><p>The Cardinal Point view compares average readiness across important periods of the operating day.</p><p>It can help identify periods associated with:</p><ul><li>lower average readiness</li><li>weaker operating margin</li><li>lower reserve coverage</li><li>more Watch flags</li><li>more Severe flags</li></ul><h3>Operational-attention analysis</h3><p>The dashboard counts Watch and Severe conditions across four areas:</p><ul><li>margin</li><li>reserve</li><li>dispatch headroom</li><li>imbalance</li></ul><p>This helps answer a more useful question than simply asking whether readiness is lower:</p><blockquote><strong><em>Which component is contributing most frequently to the weaker condition?</em></strong></blockquote><h3>Detailed records table</h3><p>The final table exposes the records behind the charts.</p><p>Rows are conditionally formatted according to readiness status, making it easier to distinguish Comfortable, Watch, Tight and Critical records while retaining access to the original values.</p><h3>Stage 5: Automating the pipeline with GitHub Actions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*H7m1uzsg0C7SBYgxTow8cg.png" /></figure><blockquote><strong><em>Suggested section graphic:</em></strong><em> Scheduled trigger → Python job → database update → Azure deployment</em></blockquote><p>Once the collector and dashboard were working, the next challenge was removing the need to run them manually.</p><p>I used <strong>GitHub Actions</strong> for two main purposes:</p><ol><li>scheduled data collection</li><li>continuous application deployment</li></ol><p>The collection workflow can run the Python collector on a defined schedule. It retrieves current records, processes the values and updates the PostgreSQL database.</p><p>The deployment workflow follows a separate process:</p><pre>Update the application code<br>            ↓<br>Commit the changes<br>            ↓<br>Push to the main branch<br>            ↓<br>GitHub Actions builds the application<br>            ↓<br>Dependencies are installed and validated<br>            ↓<br>The application is deployed to Azure</pre><p>Microsoft supports GitHub Actions as a CI/CD method for Python applications hosted on Azure App Service. A workflow can be configured to run when code is pushed to a selected branch and then build and deploy the application automatically.</p><p>This changed the way I approached the project.</p><p>Instead of treating deployment as a one-off manual task, I began treating the application as a maintained service with a repeatable release process.</p><p>That introduced me to practical CI/CD concepts such as:</p><ul><li>workflow files</li><li>branch triggers</li><li>build jobs</li><li>deployment jobs</li><li>repository secrets</li><li>deployment artefacts</li><li>failed-job logs</li><li>rerunning workflows</li><li>separation between code and configuration</li></ul><h3>Stage 6: Securing the Azure deployment</h3><blockquote><strong><em>Suggested section graphic:</em></strong><em> GitHub repository → OIDC token → Azure managed identity → App Service</em></blockquote><p>The GitHub workflow authenticates with Azure using <strong>OpenID Connect</strong>, also known as OIDC.</p><p>OIDC allows a GitHub Actions workflow to request a short-lived Azure access token instead of storing a long-lived cloud password in the repository. GitHub’s official guidance describes this as a way for workflows to access Azure resources without keeping persistent Azure credentials as GitHub secrets.</p><p>Microsoft also recommends OIDC authentication for GitHub Actions deployments to Azure App Service.</p><h3>The deployment problem I encountered</h3><p>My first deployment did not succeed.</p><p>The application build completed, but the Azure login step failed because the federated identity stored in Azure did not exactly match the identity claim presented by the GitHub workflow.</p><p>The error reported that no matching federated identity record could be found.</p><p>To resolve it, I had to:</p><ol><li>inspect the complete GitHub Actions error</li><li>identify the exact OIDC subject claim</li><li>open the user-assigned managed identity in Azure</li><li>create a matching federated credential</li><li>rerun the failed workflow</li></ol><p>Once the subject values matched, both the build and deployment jobs completed successfully.</p><p>That experience strengthened my practical understanding of:</p><ul><li>user-assigned managed identities</li><li>OpenID Connect</li><li>federated credentials</li><li>subject claims</li><li>audience and issuer values</li><li>repository and branch trust</li><li>workflow permissions</li><li>short-lived cloud tokens</li><li>secure CI/CD authentication</li></ul><p>It also reminded me that deployment errors are often configuration problems rather than application-code problems.</p><p>The green build result showed that the Python application had packaged successfully. The red deployment result pointed specifically to authentication.</p><p>Reading the logs carefully made the difference.</p><h3>Deploying the Python application on Azure</h3><p>The application is hosted on <strong>Azure App Service for Linux</strong>.</p><p>Azure App Service can install Python dependencies from a root-level requirements.txt or supported project file when build automation is enabled. It also allows application settings to be supplied as environment variables and supports custom Gunicorn startup commands.</p><p>The dashboard uses the following startup command:</p><pre>gunicorn --bind=0.0.0.0 --timeout 600 app:server</pre><p>In this command:</p><ul><li>app refers to the app.py module</li><li>server refers to the Flask server exposed by Dash</li><li>Gunicorn serves the Python application</li><li>Azure routes incoming web traffic to the running service</li></ul><p>Sensitive information is not written directly into the source code.</p><p>The PostgreSQL connection string is stored as an Azure App Service environment variable called:</p><pre>DATABASE_URL</pre><p>This separates the code from its deployment configuration and prevents database credentials from being committed to the public repository.</p><p>It is also important to describe the architecture accurately:</p><blockquote><em>The application is hosted on Microsoft Azure, while the PostgreSQL database is hosted on Supabase.</em></blockquote><p>It is therefore an <strong>Azure application deployment with cloud PostgreSQL integration</strong>, rather than an Azure SQL Database implementation.</p><h3>A major deployment lesson: database connection pooling</h3><p>One of the most useful lessons came after the application was already live.</p><p>The dashboard started displaying an error indicating that the maximum number of Supabase session-mode clients had been reached.</p><p>At the same time, the database connection also failed in my earlier wind-monitoring application.</p><p>The issue appeared because several services were accessing the same connection pool:</p><ul><li>the new Azure dashboard</li><li>an earlier dashboard deployment</li><li>the wind-monitoring application</li><li>scheduled GitHub Actions collectors</li><li>occasional local development sessions</li></ul><p>The applications were originally using the Supabase session pooler on port 5432.</p><p>SQLAlchemy also maintains an application-side connection pool by default. With several deployed services, idle or repeated connections could consume the available database sessions.</p><h3>The correction</h3><p>I made three changes:</p><ol><li>moved the applications to the Supabase transaction pooler on port 6543</li><li>disabled SQLAlchemy’s application-side pool using NullPool</li><li>ensured that database queries use context-managed connections</li></ol><p>Supabase identifies port 6543 as the shared transaction-pooler connection and recommends this mode for applications with transient or auto-scaling connections. Its SQLAlchemy guidance also shows the use of NullPool.</p><p>The corrected engine configuration follows this pattern:</p><pre>from sqlalchemy import create_engine<br>from sqlalchemy.pool import NullPool</pre><pre>engine = create_engine(<br>    database_url,<br>    poolclass=NullPool,<br>    connect_args={<br>        &quot;sslmode&quot;: &quot;require&quot;,<br>        &quot;connect_timeout&quot;: 10,<br>    },<br>)</pre><p>SQLAlchemy’s official documentation confirms that NullPool can be used when connection pooling needs to be disabled.</p><p>Each query is then executed inside a managed block:</p><pre>with engine.connect() as connection:<br>    dataframe = pd.read_sql_query(query, connection)</pre><p>When the query finishes, the connection is released.</p><p>This taught me an important lesson:</p><blockquote><strong><em>A cloud deployment is not complete simply because the website opens. The application must also manage databases, credentials, errors and shared resources responsibly.</em></strong></blockquote><h3>How the dashboard can be useful</h3><p>The dashboard is best described as an <strong>analytical prototype and portfolio application</strong>.</p><p>It demonstrates how publicly available operational data can be reorganised into a clearer monitoring and decision-support interface.</p><p>Potential users could include:</p><ul><li>energy-data analysts</li><li>power-system researchers</li><li>forecasting teams</li><li>electricity-market analysts</li><li>postgraduate students</li><li>operational-planning researchers</li><li>organisations developing internal monitoring tools</li></ul><p>The dashboard can help users:</p><ul><li>explore conditions across different Cardinal Points</li><li>compare operating margin and reserve coverage</li><li>identify periods with weaker analytical readiness</li><li>distinguish isolated events from repeated patterns</li><li>examine which indicators contribute to operational pressure</li><li>communicate technical system information to a wider audience</li></ul><p>It is not connected to NESO’s internal control-room systems and should not be used as a substitute for official operating tools or professional power-system decisions.</p><h3>Replicating the approach for other energy applications</h3><p>One of the most useful characteristics of the project is that the architecture is reusable.</p><p>The same structure can be applied to many other energy-data problems:</p><pre>Identify the operational question<br>                  ↓<br>Connect to a reliable data source<br>                  ↓<br>Automate data collection<br>                  ↓<br>Design the database structure<br>                  ↓<br>Engineer meaningful indicators<br>                  ↓<br>Build an interpretable dashboard<br>                  ↓<br>Deploy and monitor the application</pre><h3>Wind-generation monitoring</h3><p>A similar platform could monitor:</p><ul><li>day-ahead wind forecasts</li><li>changes between forecast publications</li><li>forecast versus actual generation</li><li>ramp events</li><li>regional performance</li><li>forecast uncertainty</li></ul><h3>Solar-generation monitoring</h3><p>A solar application could combine:</p><ul><li>irradiance</li><li>cloud cover</li><li>temperature</li><li>forecast PV output</li><li>measured generation</li><li>forecast error</li><li>seasonal performance</li></ul><h3>Electricity-demand analysis</h3><p>The same pipeline could support:</p><ul><li>day-ahead demand forecasts</li><li>actual demand</li><li>peak-demand periods</li><li>weather sensitivity</li><li>weekday and weekend behaviour</li><li>forecast errors</li></ul><h3>Battery-storage monitoring</h3><p>For battery systems, the indicators could include:</p><ul><li>state of charge</li><li>charge and discharge power</li><li>availability</li><li>cycling</li><li>response events</li><li>revenue</li><li>degradation</li></ul><h3>Interconnector analysis</h3><p>An interconnector dashboard could track:</p><ul><li>imports and exports</li><li>scheduled flows</li><li>actual flows</li><li>available capacity</li><li>congestion</li><li>price differentials</li></ul><h3>Local energy systems</h3><p>The architecture could also be adapted for:</p><ul><li>university campuses</li><li>industrial facilities</li><li>microgrids</li><li>community energy projects</li><li>hybrid PV and grid systems</li><li>electric-vehicle charging networks</li></ul><h3>Conclusion</h3><p>The Great Britain Operating Margin Intelligence Dashboard began as an attempt to make System Operating Plan data easier to understand.</p><p>It developed into a complete data-engineering and cloud-deployment project involving:</p><ul><li>API integration</li><li>Python data transformation</li><li>SQL and PostgreSQL</li><li>operational indicator engineering</li><li>interactive visualisation</li><li>GitHub Actions</li><li>secure cloud authentication</li><li>database connection management</li><li>Microsoft Azure deployment</li></ul><p>The project also represents a progression in my energy-analytics work.</p><p>My earlier wind-monitoring application focused on one important source of uncertainty. This dashboard examines a broader operational picture by bringing demand, reserve, margin, imbalance and dispatch flexibility together.</p><p>The biggest lesson was that building the dashboard was only one part of the task.</p><p>A useful analytical application also requires:</p><ul><li>a clearly defined question</li><li>a reliable source</li><li>careful data validation</li><li>appropriate database design</li><li>meaningful indicators</li><li>secure infrastructure</li><li>efficient connection management</li><li>repeatable deployment</li><li>honest communication of limitations</li></ul><p>That combination is what turns a collection of charts into a functioning analytical system.</p><h3>Live project</h3><p><a href="https://neso-gb-dispatch-readiness-kamil-hpaqe7d2eucebfa2.germanywestcentral-01.azurewebsites.net/">Open the Great Britain Operating Margin Intelligence Dashboard</a></p><h3>References</h3><ol><li><strong>National Energy System Operator.</strong> <em>System Operating Plan (SOP).</em> Official explanation of System Operating Plans, Cardinal Points and published resources.</li><li><strong>National Energy System Operator.</strong> <em>System Operating Plan — Data Table.</em> Structured SOP data and API resource.</li><li><strong>Microsoft.</strong> <em>Deploy Python web apps to Azure App Service by using GitHub Actions.</em></li><li><strong>Microsoft.</strong> <em>Deploy to Azure App Service using GitHub Actions.</em></li><li><strong>Microsoft.</strong> <em>Configure a Linux Python application on Azure App Service.</em></li><li><strong>GitHub.</strong> <em>Configuring OpenID Connect in Azure.</em></li><li><strong>GitHub.</strong> <em>OpenID Connect reference.</em></li><li><strong>Supabase.</strong> <em>Connect to your PostgreSQL database.</em></li><li><strong>Supabase.</strong> <em>Using SQLAlchemy with Supabase.</em></li><li><strong>SQLAlchemy.</strong> <em>Connection pooling and NullPool.</em></li><li><strong>Plotly.</strong> <em>Dash: an open-source Python framework for analytical data applications.</em></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=720b24cc2df4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Cloud Based NESO Wind Forecast Revision Monitor with Python, Supabase, GitHub Actions…]]></title>
            <link>https://medium.com/@kamilkenny22/building-a-cloud-based-neso-wind-forecast-revision-monitor-with-python-supabase-github-actions-699e348dae71?source=rss-69a3c110544a------2</link>
            <guid isPermaLink="false">https://medium.com/p/699e348dae71</guid>
            <dc:creator><![CDATA[Ridwan Kamil]]></dc:creator>
            <pubDate>Thu, 23 Jul 2026 13:26:16 GMT</pubDate>
            <atom:updated>2026-08-09T22:29:51.890Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Cloud Based NESO Wind Forecast Revision Monitor with Python, Supabase, GitHub Actions and Streamlit</h3><p>A practical energy analytics project for monitoring Great Britain’s 14 day ahead wind generation forecasts, tracking forecast revisions, and turning open energy data into a live cloud dashboard:</p><p><strong>Deployed App: </strong><a href="https://neso-wind-forecast-monitor-knbc32cgs89awbzxdfujqi.streamlit.app/">https://neso-wind-forecast-monitor-knbc32cgs89awbzxdfujqi.streamlit.app/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gQXmMDzk7h1s9hrkrRlgEg.png" /></figure><p><strong>Respository: </strong><a href="https://github.com/kamilkenny/neso-wind-forecast-monitor">https://github.com/kamilkenny/neso-wind-forecast-monitor</a></p><h3>Introduction</h3><p>Renewable energy forecasting is becoming increasingly important as power systems continue to integrate more wind and solar generation. Unlike conventional generation, renewable output depends heavily on weather conditions, which means forecasts can change as new information becomes available.</p><p>For this project, I built a <strong>NESO Wind Forecast Revision Monitor</strong>, a cloud based application that collects, stores, monitors and visualises Great Britain’s 14 day ahead wind generation forecast data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*YbXJX-Lnc5oBEUj0XzyWJQ.jpeg" /></figure><p>The key idea behind the project is simple:</p><blockquote><em>It is not enough to only know the latest wind forecast. It is also useful to understand how that forecast has changed compared with the previous forecast.</em></blockquote><p>These changes are known as <strong>forecast revisions</strong>. Tracking them can help identify periods where expected wind generation has increased or reduced significantly. This is useful for energy system planning, operational awareness, flexibility management, market analysis and renewable integration.</p><p>The data used in this project comes from the National Energy System Operator, NESO. NESO publishes 14 day ahead wind forecast data through its open data portal, and the dataset contains national 0 to 14 day ahead wind forecasts used in the GB electricity system forecasting process.</p><h3>Why I Built This Project</h3><p>The motivation for this project came from a practical energy system question:</p><blockquote><em>How can we automatically monitor changes in wind generation forecasts and make them visible through a </em><a href="https://neso-wind-forecast-monitor-knbc32cgs89awbzxdfujqi.streamlit.app/"><em>live dashboard</em></a><em>?</em></blockquote><p>In energy analytics, many projects stop at downloading a dataset and producing a static chart. I wanted to go further by building a complete pipeline that behaves more like a real operational analytics tool.</p><p>The project was designed to:</p><ul><li>Retrieve the latest wind forecast automatically</li><li>Store each forecast publication separately</li><li>Preserve historical forecast runs</li><li>Compare new forecasts against previous forecasts</li><li>Detect meaningful forecast swings</li><li>Visualise the latest forecast in a clear dashboard</li><li>Deploy the tool online so it can be accessed from anywhere</li></ul><p>This made the project a good opportunity to combine my interests in <strong>energy systems, forecasting, SQL databases, cloud deployment and data engineering</strong>.</p><h3>The Energy System Context</h3><p>Electricity systems must maintain a constant balance between supply and demand. NESO’s Electricity National Control Centre works continuously to balance electricity supply and demand, and forecasting is one of the key functions required for managing the GB transmission system.</p><p>As more renewable generation connects to the system, forecasting becomes even more important. Wind and solar output can vary significantly depending on weather conditions, and this variability affects system operation, reserve requirements, market decisions and balancing actions.</p><p>NESO explains that the Balancing Mechanism is used to address differences between generation and demand that may not have been foreseen by market participants.</p><p>This is where forecast monitoring becomes valuable. If expected wind output changes sharply between forecast publications, it can indicate future operational pressure, flexibility needs, or potential changes in market behaviour.</p><h3>Project Objective</h3><p>The objective of the project was to build a working cloud based application that can:</p><ol><li>Connect to the NESO open data API</li><li>Fetch the latest 14 day ahead wind forecast</li><li>Store each forecast publication in a PostgreSQL database</li><li>Automatically update the database using GitHub Actions</li><li>Deploy an interactive <a href="https://neso-wind-forecast-monitor-knbc32cgs89awbzxdfujqi.streamlit.app/">Streamlit dashboard</a></li><li>Display the latest wind forecast</li><li>Track the number of stored forecast runs</li><li>Compare forecast revisions once multiple runs are available</li><li>Provide a foundation for future alerting and advanced analytics</li></ol><p>The project is not only a dashboard. It is an end to end data workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qrCXZgHPircQk1UVN6qN_Q.png" /></figure><h3>Data Source</h3><p>The data source is the <strong>NESO 14 Days Ahead Wind Forecast</strong> dataset.</p><p>NESO provides access to this dataset through its data portal and CKAN Data API. The specific resource used in this project is the national 14 day ahead wind forecast resource with the resource identifier:</p><p>NESO’s API guidance recommends using the CKAN Datastore API for efficient retrieval and filtering of records from CKAN resources.</p><p>In this project, the Python collector sends a request to the NESO CKAN API endpoint and retrieves the latest forecast records.</p><p>The dataset provides forecasted wind generation values over a future delivery window. This makes it suitable for monitoring expected wind output across the coming days.</p><h3>Project Architecture</h3><p>The project follows a simple but powerful architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*s5nnQr1IfKKX2mW_l2BJcQ.png" /></figure><p>Each component has a clear role:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*W1gzVu75xlB3GKwEpbOrow.png" /></figure><p><strong>Streamlit Community Cloud</strong> allows apps to be deployed from a GitHub repository, while Streamlit secrets allow sensitive values such as database connection strings to be stored outside the code.</p><p><strong>Supabase</strong> provides a managed PostgreSQL database and supports connecting to the database using a PostgreSQL connection string.</p><p><strong>GitHub Actions</strong> supports manual workflow runs through workflow_dispatch and scheduled workflow automation, making it suitable for collecting new forecast data without running the script manually.</p><p>For example:</p><p>Latest forecast value for 26 July 10:00 = 7,500 MW</p><p>Previous forecast value for 26 July 10:00 = 6,900 MW</p><p>Revision = +600 MW</p><p>This allows the dashboard to answer questions such as:</p><ul><li>Has the wind forecast increased or decreased?</li><li>Which future delivery periods changed the most?</li><li>Are there major swings in the coming days?</li><li>Is the forecast becoming more stable or more uncertain?</li><li>Which forecast horizon shows the largest revisions?</li></ul><p>This is where the project becomes more useful than a basic visualisation.</p><h3>Step 5: Automating Collection with GitHub Actions</h3><p>After the database connection worked, the next step was automation.</p><p>Instead of running the collector manually, I created a GitHub Actions workflow. The workflow can be triggered manually and can also be scheduled to run automatically.</p><p>The workflow performs these steps:</p><ol><li>Checks out the GitHub repository</li><li>Sets up Python</li><li>Installs the required packages</li><li>Reads the database connection string from GitHub Secrets</li><li>Runs the collector script</li><li>Inserts any new forecast data into Supabase</li></ol><p>This was an important part of the project because it turned the collector into an automated data ingestion process.</p><p>It also introduced practical CI/CD concepts, including:</p><ul><li>Repository structure</li><li>Dependency management</li><li>Workflow files</li><li>Secure environment variables</li><li>Automation logs</li><li>Debugging deployment errors</li><li>Separating local code from cloud execution</li></ul><h3>Step 6: Building the Streamlit Dashboard</h3><p>The dashboard was built using Streamlit.</p><p>The purpose of the dashboard is to make the stored forecast data easy to explore and understand.</p><p>The deployed dashboard currently displays:</p><ul><li>Latest forecast publication time</li><li>Peak forecast</li><li>Average forecast</li><li>Average capacity factor</li><li>Forecast delivery window</li><li>14 day forecast line chart</li><li>Number of stored forecast runs</li><li>Newest run in the database</li><li>Threshold controls for monitoring forecast swings</li><li>Dashboard refresh control</li></ul><p>The interface provides a simple way to monitor wind forecast behaviour without manually downloading data from the NESO portal.</p><p>Streamlit was useful because it allowed the Python analysis to be converted into a live web application without needing a separate frontend framework.</p><h3>Step 7: Deploying to Streamlit Cloud</h3><p>Once the app worked, it was deployed to Streamlit Community Cloud.</p><p>The deployment process involved:</p><ul><li>Uploading the code to GitHub</li><li>Creating a Streamlit Cloud app from the GitHub repository</li><li>Selecting app.py as the main file</li><li>Adding the database connection string as a Streamlit secret</li><li>Rebooting the app</li><li>Testing the deployed dashboard</li></ul><p>This stage helped strengthen my understanding of application deployment, cloud configuration and secure secrets management.</p><p>One of the key lessons was that GitHub Actions secrets and Streamlit secrets are separate. GitHub Actions needs the secret to run the collector, while Streamlit needs the secret to connect the dashboard to the database.</p><h3>Dashboard Output</h3><p>The current dashboard shows a live 14 day wind forecast profile.</p><p>From the deployed application, the dashboard displays values such as:</p><ul><li>Forecast publication time</li><li>Peak forecast in MW</li><li>Average forecast in MW</li><li>Average capacity factor</li><li>Stored forecast runs</li><li>Future delivery window</li></ul><p>As more forecast runs are collected, the revision monitoring section becomes more powerful because the system can compare more forecast publications over time.</p><p>This means the app will become more useful as the database archive grows.</p><h3>Why Forecast Revision Monitoring Matters</h3><p>Forecast revision monitoring is useful because energy decisions are not made from one forecast alone. They are made from a changing stream of forecasts.</p><p>A large upward revision may suggest that more wind generation is expected than previously estimated. A large downward revision may suggest that less renewable output is expected, which may require closer attention to demand, reserve, interconnector flows, storage or dispatchable generation.</p><p>This kind of monitoring can support:</p><ul><li>Grid operation awareness</li><li>Renewable integration</li><li>Flexibility planning</li><li>Short term market analysis</li><li>Reserve planning</li><li>Energy trading insight</li><li>Forecast quality monitoring</li><li>Operational decision support</li></ul><p>For example, if a forecasted wind drop appears several days ahead, analysts can start investigating whether the change is isolated, persistent, or part of a wider weather driven system pattern.</p><h3>How This Can Benefit the Energy System</h3><p>A tool like this can provide several benefits.</p><h3>1. Better visibility of renewable variability</h3><p>Wind generation can vary significantly. A revision monitor helps users see when expected output is changing.</p><h3>2. Improved operational awareness</h3><p>Forecast changes can highlight periods where closer operational attention may be required.</p><h3>3. Support for balancing decisions</h3><p>Electricity balancing depends on understanding expected generation and demand. Forecast revision monitoring can support earlier identification of changing conditions.</p><h3>4. Better use of flexibility</h3><p>If wind forecasts change, flexible assets such as batteries, demand response and interconnectors may become more important.</p><h3>5. Market insight</h3><p>Energy traders and analysts can use forecast revisions to understand changing renewable expectations.</p><h3>6. Forecast performance learning</h3><p>Over time, archived forecasts can be compared with actual wind generation to evaluate forecast accuracy.</p><h3>7. Foundation for machine learning</h3><p>Once enough historical forecast runs are stored, the dataset can support machine learning models for forecast stability, error prediction and revision pattern detection.</p><h3>Replicating the Project for Other Energy Sources</h3><p>One strong advantage of this architecture is that it is reusable.</p><p>The same pipeline can be adapted for many other energy datasets.</p><h3>Solar Forecasting</h3><p>The system can be adapted to monitor solar generation forecasts. NESO also publishes embedded wind and solar forecast data, including forecasts up to 14 days ahead.</p><p>A solar revision monitor could track:</p><ul><li>Solar forecast changes</li><li>Cloud cover driven revisions</li><li>Day ahead solar uncertainty</li><li>Seasonal solar patterns</li><li>Forecast drops during low irradiance periods</li></ul><h3>Demand Forecasting</h3><p>The same method can be used for national demand forecasts. Demand forecast revisions are valuable because demand affects balancing, reserve planning and market operation.</p><p>A demand version could monitor:</p><ul><li>Peak demand revisions</li><li>Morning and evening demand ramps</li><li>Weather driven changes</li><li>Weekday and weekend demand behaviour</li><li>Forecast uncertainty around public holidays</li></ul><h3>Interconnector Flow Monitoring</h3><p>The architecture can also be adapted for interconnector forecasts or actual flows.</p><p>This could support analysis of:</p><ul><li>Import and export behaviour</li><li>Cross border energy dependency</li><li>Market coupling effects</li><li>Changes in expected flows during high renewable periods</li></ul><h3>Battery Storage and Flexibility</h3><p>The same approach can be extended to battery storage signals and flexibility events.</p><p>This could help monitor:</p><ul><li>Charging and discharging periods</li><li>Response to low renewable generation</li><li>Flexibility requirements</li><li>Peak shaving opportunities</li></ul><h3>Electricity Price Monitoring</h3><p>The system can also be adapted for price related data, especially where prices are influenced by renewable output, demand and system constraints.</p><p>A price version could track:</p><ul><li>Day ahead prices</li><li>Intraday price changes</li><li>Negative price periods</li><li>Price volatility</li><li>Relationship between wind forecasts and market prices</li></ul><h3>Skills Strengthened Through the Project</h3><p>This project was very useful because it brought several skills together in one workflow.</p><h3>SQL and Database Skills</h3><p>The project strengthened my understanding of:</p><ul><li>PostgreSQL table design</li><li>Database connection strings</li><li>SQL queries</li><li>Distinct forecast run counting</li><li>Time based filtering</li><li>Insert logic</li><li>Avoiding duplicate records</li><li>Cloud database management</li></ul><h3>Python Data Engineering</h3><p>The project improved my ability to:</p><ul><li>Connect to APIs</li><li>Process JSON data</li><li>Use pandas for data transformation</li><li>Clean time series data</li><li>Convert data types</li><li>Handle missing or repeated records</li><li>Prepare data for database insertion</li></ul><h3>Forecasting and Energy Analytics</h3><p>The project deepened my understanding of:</p><ul><li>Forecast horizons</li><li>Forecast publication times</li><li>Forecast delivery windows</li><li>Forecast revision logic</li><li>Renewable generation variability</li><li>Wind generation uncertainty</li><li>Operational relevance of forecast changes</li></ul><h3>Cloud Deployment</h3><p>The deployment process strengthened my skills in:</p><ul><li>GitHub repository management</li><li>Streamlit Cloud deployment</li><li>Cloud secrets management</li><li>Application debugging</li><li>Requirements files</li><li>Runtime errors</li><li>Production style app configuration</li></ul><h3>Automation and CI/CD</h3><p>Using GitHub Actions helped me understand:</p><ul><li>Scheduled workflows</li><li>Manual workflow triggers</li><li>Workflow logs</li><li>Secure secrets</li><li>Automated data collection</li><li>Cloud based script execution</li></ul><h3>Dashboard Development</h3><p>The Streamlit app improved my ability to:</p><ul><li>Build interactive dashboards</li><li>Display KPIs</li><li>Use charts for time series analysis</li><li>Add user controls</li><li>Create refresh buttons</li><li>Connect a frontend dashboard to a backend database</li></ul><h3>Main Challenges and How I Solved Them</h3><h3>Challenge 1: Moving from local storage to cloud storage</h3><p>The project initially worked with local outputs, but this was not suitable for a deployed app. The solution was to use Supabase PostgreSQL so that both the collector and dashboard could access the same database.</p><h3>Challenge 2: Storing each forecast run correctly</h3><p>To calculate revisions, each forecast publication needed to be stored separately. The database design had to preserve publication timestamps and delivery timestamps.</p><h3>Challenge 3: Automating data collection</h3><p>Manual collection was not enough. GitHub Actions was introduced to run the collector automatically and keep the database updated.</p><h3>Challenge 4: Managing secrets securely</h3><p>The database URL could not be stored directly inside the code. GitHub Secrets and Streamlit Secrets were used separately to protect the connection string.</p><h3>Challenge 5: Deployment debugging</h3><p>The app required the correct main file path, the correct requirements file, and properly formatted secrets. Solving these issues helped me understand how cloud deployment behaves differently from local development.</p><h3>Current Features</h3><p>The current version of the dashboard includes:</p><ul><li>Live cloud hosted Streamlit app</li><li>NESO API data extraction</li><li>Supabase PostgreSQL backend</li><li>Forecast run archive</li><li>Latest forecast visualisation</li><li>Forecast publication time display</li><li>Peak forecast KPI</li><li>Average forecast KPI</li><li>Capacity factor KPI</li><li>Stored run count</li><li>Refresh control</li><li>Threshold settings for forecast revision monitoring</li><li>GitHub Actions automation</li></ul><h3>What I Learned</h3><p>This project helped me understand how real energy analytics systems are built beyond notebooks.</p><p>I learned that a useful analytics product requires more than a chart. It requires:</p><ul><li>A reliable data source</li><li>A repeatable data collection process</li><li>A database</li><li>Automation</li><li>A dashboard</li><li>Secure configuration</li><li>Deployment</li><li>Clear interpretation of results</li></ul><p>It also helped me connect my background in renewable energy forecasting with practical data engineering.</p><p>For me, the biggest learning point was this:</p><blockquote><em>Forecasting is not only about predicting the future. It is also about monitoring how expectations about the future keep changing.</em></blockquote><p>That is exactly what this project tries to capture.</p><h3>Conclusion</h3><p>The NESO Wind Forecast Revision Monitor is a practical cloud based energy analytics project that turns open wind forecast data into a live monitoring dashboard.</p><p>It combines:</p><ul><li>Open energy data</li><li>Python</li><li>SQL</li><li>PostgreSQL</li><li>Supabase</li><li>GitHub Actions</li><li>Streamlit</li><li>Cloud deployment</li><li>Forecast revision analytics</li></ul><p>The project demonstrates how public energy datasets can be transformed into useful decision support tools for renewable integration, power system operation and energy market analysis.</p><p>As the electricity system becomes more dependent on weather driven renewable generation, tools that monitor forecast changes will become increasingly useful.</p><p>This project is a step toward that direction.</p><h3>References</h3><ol><li>National Energy System Operator, NESO Data Portal, 14 Days Ahead Wind Forecasts.</li><li>NESO API Guidance, CKAN Datastore API.</li><li>NESO, Electricity National Control Centre and system operation.</li><li>NESO, Balancing Britain’s electricity system.</li><li>Streamlit Community Cloud deployment documentation.</li><li>Streamlit Community Cloud secrets management documentation.</li><li>Supabase PostgreSQL connection documentation.</li><li>GitHub Actions workflow trigger documentation.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=699e348dae71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI-DRIVEN FORECASTING AND MODELLING OF GREAT BRITAIN’S SYSTEM OPERATOR GENERATION OUTPUTS…]]></title>
            <link>https://medium.com/@kamilkenny22/ai-driven-forecasting-and-modelling-of-great-britains-system-operator-generation-outputs-bdcce3a6a387?source=rss-69a3c110544a------2</link>
            <guid isPermaLink="false">https://medium.com/p/bdcce3a6a387</guid>
            <category><![CDATA[time-series-forecasting]]></category>
            <category><![CDATA[demand-generation]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[big-data-analytics]]></category>
            <category><![CDATA[energy-forecast]]></category>
            <dc:creator><![CDATA[Ridwan Kamil]]></dc:creator>
            <pubDate>Thu, 05 Mar 2026 13:45:49 GMT</pubDate>
            <atom:updated>2026-03-29T11:51:08.620Z</atom:updated>
            <content:encoded><![CDATA[<h3>AI-DRIVEN FORECASTING AND MODELLING OF GREAT BRITAIN’S SYSTEM OPERATOR GENERATION OUTPUTS (2009–2026) TO OPTIMISE NATIONAL GRID PLANNING AND DECARBONISATION PATHWAYS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CL3Rc0tClOfYXAmHZiykVA.png" /></figure><h3>PROJECT OVERVIEW</h3><p>The UK electricity system is transitioning rapidly. Accurate short-term forecasting is vital for balancing the grid as we integrate more intermittent renewable sources.</p><p>This project utilises a Multivariate Time-Series approach to predict Total Electricity Generation. By training a machine and deep learning model on historical data (2009–2026) from the NESO Data Bank Portal, the model identifies seasonal rhythms, daily demand ramps, and long-term trends to provide actionable grid analytics using <strong>16 years of half-hourly Great Britain operational energy mix data (1.14 billion MW records)</strong>. <strong><em>The project utilized Databricks for the high-performance ingestion and structuring of massive datasets, which were subsequently managed within a MySQL environment to ensure relational integrity.</em></strong> The Developed Forecasting Model has been deployed on this:</p><p><a href="https://kamil-uk-energy-generation-real-time-forecast.streamlit.app/"><strong>Streamlit web-link:</strong></a></p><h3><a href="https://kamil-uk-energy-generation-real-time-forecast.streamlit.app/">https://kamil-uk-energy-generation-real-time-forecast.streamlit.app/</a></h3><p><strong>or</strong></p><p><a href="https://deployment-of-uk-electricity-generation.onrender.com/"><strong>Render web-link:</strong></a></p><h3><a href="https://deployment-of-uk-electricity-generation.onrender.com/">https://deployment-of-uk-electricity-generation.onrender.com/</a></h3><p>The deployed web-based-app can perform Offline-Inferencing also known as <strong>HINDCASTING</strong> of past times steps to estimate the residual errors of the model and <strong>FORECASTING</strong> future time steps of generation output.</p><h3>Key Objectives:</h3><blockquote>Grid Balancing: Predict supply requirements to maintain frequency stability.</blockquote><blockquote>Renewable Integration: Optimize the dispatch of zero-carbon sources.</blockquote><blockquote>Operational Efficiency: Reduce reliance on expensive, high-carbon reserve plants.</blockquote><p>This case study analyses UK electricity generation data with the objective of understanding generation dynamics and developing a machine learning model to forecast total electricity generation.</p><h3>Data Source — Historic GB Generation Mix</h3><p>Historic GB generation mix from the 1st of Jan 2009 through to 2026 (Real-Time). Data points are either MW or %.</p><p><strong>The Design and Development was done in Python and uploaded as a file in this dedicated </strong><a href="https://github.com/kamilkenny/A.I.-Forecasting-Modelling-with-Great-Britain-s-System-Operator-Generation-Outputs-NESO-Data-Portal-/blob/main/README.md"><strong>repository</strong></a><strong>: </strong><a href="https://github.com/kamilkenny/A.I.-Forecasting-Modelling-with-Great-Britain-s-System-Operator-Generation-Outputs-NESO-Data-Portal-/blob/main/README.md">https://github.com/kamilkenny/A.I.-Forecasting-Modelling-with-Great-Britain-s-System-Operator-Generation-Outputs-NESO-Data-Portal-/blob/main/README.md</a></p><h3>INTRODUCTION</h3><p>The UK electricity system has undergone significant transformation due to increasing renewable penetration, declining coal usage, and evolving demand patterns. Accurate short-term electricity generation forecasting is critical for:</p><blockquote>Grid stability</blockquote><blockquote>Energy market operations</blockquote><blockquote>Renewable integration planning</blockquote><blockquote>Carbon reduction strategy</blockquote><h3>PROJECT OBJECTIVES</h3><p>The objective of this study is to:</p><p>Perform comprehensive exploratory data analysis (EDA) on UK electricity generation data.</p><blockquote>Engineer predictive temporal and structural features.</blockquote><blockquote>Develop a machine learning forecasting model using XGBoost.</blockquote><blockquote>Evaluate forecasting performance using standard regression metrics.</blockquote><blockquote>Establish a benchmark model for comparison with deep learning architectures (LSTM and Informer).</blockquote><h3>UK ELECTRICITY GENERATION &amp; DECARBONISATION POWER BI ANALYTIC DASHBOARD (2020–2025 DATASET)</h3><p><strong>Data Context and Structure</strong></p><p>The dataset consisted of half-hourly generation records across major fuel sources, including gas, coal, nuclear, wind, solar, hydro, biomass and imports. Aggregated system metrics such as total generation, fossil contribution, renewable contribution, zero-carbon generation, low-carbon generation and carbon intensity were also included. The availability of both absolute generation values in megawatts and percentage shares enabled analysis of structural composition independent of demand fluctuations.</p><p>The dashboard begins with a high-level KPI Panel presenting total generation, average carbon intensity, average renewable share and peak demand. This section provides an immediate executive snapshot of system performance during the study period. It allows rapid evaluation of overall demand magnitude, renewable penetration levels and emission intensity trends.</p><p>By consolidating key indicators at the top of the dashboard, the design mirrors the reporting style used within transmission system operations and policy briefings, ensuring clarity and immediate interpretability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*due0OL7U2YIaQCR26fFykw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NocYDPkb101XrVnUr-FUMw.jpeg" /></figure><p>The data was transformed within Power Query to ensure appropriate data types, temporal segmentation and structural reorganisation for visual modelling. DAX measures were developed to support derived metrics such as net demand and carbon composition breakdown.An analytical dashboard developed in Microsoft Power BI to explore Great Britain’s electricity generation mix over the Period 2020–2025 using modelling historical data. The objective of the case analysis project was to construct an interactive visual framework capable of examining structural fuel composition, renewable penetration levels, carbon intensity behaviour, and system stress indicators at a national scale. The dashboard was designed not merely as a visualisation exercise, but as a structured analytical tool aligned with large-scale energy system objectives such as decarbonisation monitoring, operational flexibility assessment, and generation planning insight.</p><p>The project sought to determine how the GB electricity mix is structured during the study period, whether renewable generation has materially displaced fossil fuels, how fuel composition influences carbon intensity, and when the system experiences elevated stress or emissions.</p><h3>Fossil Fuel versus Renewable Energy Sources Transitionin the Face of Dwindling Carbon Emission</h3><p>A dual-line visual comparing fossil share and renewable share was constructed to assess structural crossover behaviour. This comparison highlights the relative balance between dispatchable fossil generation and variable renewable output. This comparison directly supports evaluation of national transition goals by illustrating how renewable penetration is reshaping the structural composition of the generation mix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ckp4eTYPPN9pLFuC3ItDMQ.jpeg" /></figure><h3>Executive-Level System Indicators</h3><p>The dashboard begins with a high-level KPI panel presenting total generation, average carbon intensity, average renewable share, peak demand, and record generation values for wind and solar.</p><h3>Structural Fuel Mix Analysis</h3><p>The structural behaviour of the generation mix was examined through stacked area charts representing both absolute megawatt contribution and percentage share composition.</p><h3>Carbon Intensity Behaviour and Correlation</h3><p>Carbon intensity trends were analysed using temporal line charts and correlation-based scatter plots. The trend visual reveals seasonal variation, with winter periods displaying elevated carbon intensity consistent with increased reliance on fossil-based generation during high-demand conditions.</p><h3>Net Demand and System Stress Indicators</h3><p>Net demand was calculated as total generation minus wind and solar output, representing the demand that must be met by dispatchable sources such as gas, nuclear and imports. This derived metric provides insight into system stress and flexibility requirements.</p><h3>Zero Carbon versus Low Carbon Decomposition</h3><p>A waterfall visual was developed to distinguish between zero-carbon generation and low-carbon generation. Zero-carbon output, comprising wind, solar, hydro and nuclear, was separated from biomass to illustrate the structural composition of low-carbon supply. This decomposition clarifies that low-carbon generation is not entirely zero-emission, and it quantifies the specific contribution of biomass within the overall low-carbon category.</p><h3>Temporal Behaviour Heatmap</h3><p>A matrix-based heatmap was constructed to visualise hourly demand behaviour across months. Conditional formatting was applied to reveal seasonal and intraday patterns.</p><h3>Strategic Relevance</h3><p>The 2020–2025 exploratory analysis successfully delivered a structured and insight-driven Power BI dashboard capable of visualising generation dynamics, quantifying renewable displacement of fossil fuels, demonstrating carbon-emission relationships, and identifying operational stress periods. The dashboard is suitable for executive reporting, energy system analysis, policy and stakeholders discussion and portfolio demonstration. Its modular design allows for scalability and future expansion into longer historical datasets, incorporating MySQL Database and forecasting extensions.</p><h3>EXPLORATORY DATA ANALYSIS (EDA) — UK ELECTRICITY GENERATION (2009–2026) DATASET USING PYTHON VISUALISATION TOOLS (SEABORN, MATPLOTLIB AND PLOTLY)</h3><h3>DATASET DESCRIPTION</h3><p><strong>Data Overview</strong></p><p>The dataset consists of time-indexed UK electricity generation values at hourly resolution.</p><p><strong>Key Variables Include:</strong></p><blockquote>Total Generation (MW) — Target variable</blockquote><blockquote>Gas</blockquote><blockquote>Coal</blockquote><blockquote>Nuclear</blockquote><blockquote>Wind</blockquote><blockquote>Solar</blockquote><blockquote>Hydro</blockquote><blockquote>Biomass</blockquote><blockquote>Imports</blockquote><blockquote>Storage</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cuXek7bAjU0vh3vLS6KV-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OyneoWutlRrXA_TNUSnvzw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zS_rSEihODWstbcoWvsLbA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jnmmpE-ZdS0PY41qbyW0gA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XPMWAdHVsMDOiY7Pcehi6A.png" /></figure><h3>EXPLORATORY DATA ANALYSIS (EDA) — UK ELECTRICITY GENERATION DATASET</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*ZsBZCvF3W0obbP8lBXJh-w.png" /></figure><h3>EXPLORATORY DATA ANALYSIS (EDA) — UK ELECTRICITY GENERATION DATASET</h3><h3>1. Dataset Overview</h3><blockquote><strong>Data Source:</strong> NESO Data Bank Time Period: 2009–01–01 to 2026–02–14 (half-hourly intervals)</blockquote><blockquote>Total Records: 300,170 rows × 33 columns</blockquote><blockquote><strong>Columns of Interest:</strong></blockquote><blockquote><strong>Generation by Source (MW): </strong>GAS, COAL, NUCLEAR, WIND, WIND_EMB, HYDRO, BIOMASS, SOLAR, OTHER, IMPORTS</blockquote><blockquote><strong>Aggregated Metrics:</strong> STORAGE, GENERATION, LOW_CARBON, ZERO_CARBON, RENEWABLE, FOSSIL</blockquote><blockquote><strong>Percentage Shares (%):</strong> _perc columns (e.g., GAS_perc, COAL_perc, RENEWABLE_perc)</blockquote><blockquote><strong>Carbon Intensity</strong> (gCO₂/kWh)</blockquote><h3>2. Data Quality &amp; Pre-processing</h3><blockquote><strong>Datetime Parsing:</strong> Converted ‘DATETIME’ to datetime type and set as index.</blockquote><blockquote><strong>Missing Values:</strong> None; dataset is complete with all 300,170 entries.</blockquote><blockquote><strong>Data Types:</strong> 18 integer columns, 15 float columns (percentages).</blockquote><blockquote><strong>Initial Observations:</strong></blockquote><blockquote>Fossil fuels (GAS + COAL) dominate generation.</blockquote><blockquote>Renewable contributions are smaller but show gradual growth.</blockquote><blockquote>Imports vary and occasionally contribute significantly to total generation.</blockquote><blockquote>Carbon intensity fluctuates with the share of fossil fuels</blockquote><h3>Descriptive Statistics</h3><blockquote><strong>Generation (MW) Summary: </strong>GAS: Mean ≈ 12,029 MW; max ≈ 27,868 MW</blockquote><blockquote><strong>COAL:</strong> Mean ≈ 5,511 MW; max ≈ 26,044 MW</blockquote><blockquote><strong>NUCLEAR: </strong>Mean ≈ 6,277 MW; max ≈ 9,342 MW</blockquote><blockquote><strong>WIND:</strong> Mean ≈ 4,047 MW; max ≈ 18,382 MW</blockquote><blockquote><strong>HYDRO:</strong> Mean ≈ 395 MW; max ≈ 1,403 MW</blockquote><blockquote><strong>SOLAR: </strong>Mean ≈ 936 MW; max ≈ 14,035 MW</blockquote><blockquote><strong>IMPORTS:</strong> Mean ≈ 2,541 MW; max ≈ 9,148 MW</blockquote><blockquote><strong>Percentage Share Summary:</strong></blockquote><blockquote><strong>Fossil:</strong> Mean ≈ 48.9%</blockquote><blockquote><strong>Renewable: </strong>Mean ≈ 20.1%</blockquote><blockquote><strong>Low Carbon:</strong> Mean ≈ 41.8%</blockquote><blockquote><strong>Zero Carbon:</strong> Mean ≈ 43.1%</blockquote><h3>4. Initial Visualisation Insights A. Source Contribution Over Time</h3><p><strong>A. Line plots of monthly averages by source reveal:</strong></p><blockquote>Coal share declining over the years.</blockquote><blockquote>GAS remains the dominant fossil fuel.</blockquote><blockquote>Wind and Solar gradually increasing.</blockquote><blockquote>Imports vary seasonally, peaking during high-demand periods.</blockquote><p><strong>B. Renewable vs Fossil Share Renewable percentage is increasing over time, while fossil share declines.</strong></p><blockquote>Carbon intensity closely follows fossil share — higher fossil usage → higher carbon intensity.</blockquote><p><strong>C. Carbon Intensity Relationship Scatter plots and hexbin plots show:</strong></p><blockquote>Positive correlation between fossil share and carbon intensity.</blockquote><blockquote>High renewable penetration correlates with lower carbon intensity.</blockquote><p><strong>D. Seasonal &amp; Hourly Patterns Heatmaps of hourly vs monthly average generation:</strong></p><blockquote>Peak generation hours are generally morning and early evening.</blockquote><blockquote>Winter months have higher overall demand.</blockquote><blockquote>Solar contribution is strictly daytime; wind and hydro show variable seasonal patterns.</blockquote><p><strong>E. Density Analysis KDE plots show carbon intensity distribution:</strong></p><blockquote>Peaks around 250–500 gCO₂/kWh (low fossil share periods).</blockquote><blockquote>Long tail for higher intensity during fossil-heavy periods.</blockquote><h3>5. Observed Trends</h3><blockquote>Fossil fuels dominate but are slowly declining.</blockquote><blockquote>Renewables (wind, solar, hydro, biomass) are gradually increasing.</blockquote><blockquote>Carbon intensity follows fossil generation trends and is mitigated by renewable uptake.</blockquote><blockquote>Imports occasionally supplement local generation, impacting carbon intensity and generation mix.</blockquote><blockquote>Hourly and seasonal patterns highlight variability in demand and renewable output. Carbon intensity indicator</blockquote><h3>Contribution of Renewable Energy Sources as Compared to Fossil Fuels</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u3YZ0L7SGQWGpmzVkrHVVQ.png" /></figure><h3>Generation: Seasonal Decomposition</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hvZnQM6QjfTVANLXkLl79w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WilE6_OXdE_hM4PfjjHMPg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*abMsgzwaw9cPDleFl_TF9Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4WUUeJ0vGLPHxYysyZy8eQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FtZyL2TjIX5K4G7Y7ZP2aA.png" /></figure><h3>WIND VS PHOTOVOLTAIC UPTAKE COMPARISON</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uw2rfTlK5Zk6cxtQbfW74g.png" /></figure><h3>FEATURES ENGINEERING</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*ifG7x-YXBfujgx90xbzSHg.png" /></figure><h3>More Time-Based Features</h3><p>I want the model to capture daily, weekly, and yearly patterns:</p><h3>Original generation sources</h3><p>GAS, COAL, NUCLEAR, WIND, WIND_EMB, HYDRO, SOLAR, BIOMASS, IMPORTS, OTHER, STORAGE</p><h3>Aggregate/derived columns:</h3><p>GENERATION (total), CARBON_INTENSITY, LOW_CARBON, ZERO_CARBON, RENEWABLE, FOSSIL</p><h3>Percentage columns:</h3><p>e.g., GAS_perc, COAL_perc, NUCLEAR_perc, WIND_perc, … , RENEWABLE_perc, FOSSIL_perc</p><h3>Time-based features (cyclic encoding):</h3><p>hour, hour_sin, hour_cos</p><p>weekday, weekday_sin, weekday_cos</p><p>month, month_sin, month_cos</p><h3>Lag/rolling features:</h3><p>GENERATION_lag_1, GENERATION_lag_24, GENERATION_lag_168</p><p>GENERATION_roll_24, GENERATION_roll_168</p><p>GENERATION_std_24</p><h3>Source ratios:</h3><p>GAS_ratio, COAL_ratio, WIND_ratio, SOLAR_ratio</p><h3>Weekday/weekend indicator:</h3><p>is_weekend (True/False)</p><h3>DAY-AHEAD (SHORT-TERM) TOTAL GENERATION FORECASTING USING XGBOOST</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N7o22BTKBX4VhPFTRAvMIw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iI78lnI4GUGLTQKUhq8JPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*JUw5qgbxzP7JvhvqSFaUuA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_SSp4qw1yhGgv8CgHhM5rg.png" /></figure><h3>1️⃣ R² = 0.9923 → Extremely High Fit</h3><h3>R² of 0.9923 means:</h3><blockquote>The model explains 99.23% of the variance in total generation. For electricity demand/generation forecasting, anything above:</blockquote><blockquote>0.95 = strong</blockquote><blockquote>0.98 = very strong</blockquote><blockquote>0.99 = near-perfect short-term fit</blockquote><blockquote>So statistically, this is excellent.</blockquote><blockquote>However:</blockquote><blockquote>High R² is expected in short-term power system forecasting because:</blockquote><blockquote>Electricity demand is highly autocorrelated.</blockquote><blockquote>Lag features (especially 1h, 24h) are extremely predictive.</blockquote><blockquote>Daily and weekly seasonality is very structured.</blockquote><blockquote>⚠️ Important: High R² alone does NOT mean operationally perfect.</blockquote><h3>2️⃣ MAE = 408 MW → Practical Error Interpretation</h3><blockquote>Mean Absolute Error = average absolute forecast error.</blockquote><blockquote>Now let’s contextualize:</blockquote><blockquote>GB total generation typically ranges:</blockquote><blockquote>Night low: ~20,000 MW</blockquote><blockquote>Peak winter: ~45,000–50,000 MW</blockquote><blockquote>So 408 MW error relative to:</blockquote><blockquote>30,000 MW average load → 408 / 30,000 ≈ 1.36% error</blockquote><blockquote>That is very good for day-ahead forecasting.</blockquote><blockquote>In power system planning:</blockquote><blockquote>&lt;2% MAE → strong 2–4% → acceptable 5% → operational concern</blockquote><blockquote>The model ≈ ~1–1.5% average deviation</blockquote><blockquote>✅ Operationally strong.</blockquote><h3>3️⃣ RMSE = 543 MW → Sensitivity to Spikes</h3><h3>RMSE penalizes larger errors more than MAE.</h3><blockquote>The RMSE (543 MW) &gt; MAE (408 MW), which means:</blockquote><blockquote>There are some larger occasional errors, likely during:</blockquote><p><strong>Sudden wind ramps</strong></p><p><strong>Evening demand ramps</strong></p><p><strong>Extreme weather days</strong></p><p><strong>Low solar winter periods</strong></p><p><strong>Difference:</strong></p><p><strong>543 − 408 = 135 MW</strong></p><blockquote>This gap is moderate → not extreme. If RMSE were much larger than MAE, we would suspect: Severe spike failures</blockquote><blockquote>Storm ramp errors</blockquote><blockquote>Rare high-magnitude misses</blockquote><blockquote>But the model looks stable.</blockquote><h3>Bias = +15.7 MW</h3><h3>Interpretation:</h3><blockquote>On average, the model overpredicts generation by 15.7 MW.</blockquote><blockquote>Relative to total generation (~30,000–40,000 MW), this is extremely small.</blockquote><h3>SOURCE-LEVEL CONTRIBUTION FORECASTING (TO HELP NESO PLAN FOR RENEWABLE PENETRATION, FOSSIL FALLBACK, AND IMPORTS)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xqB0rA7ZK-nLouTdtdAkUw.png" /></figure><h3>SYSTEM LEVEL OPERATIONAL FORECASTING</h3><p>Build a Source-Level Contribution Forecasting Pipeline to predict:</p><blockquote>Wind generation</blockquote><blockquote>Solar generation</blockquote><blockquote>Fossil fallback (gas/coal)</blockquote><blockquote>Imports</blockquote><blockquote>Renewable penetration (%)</blockquote><blockquote>Fossil penetration (%)</blockquote><p>For day-ahead planning.</p><p><strong>STEP 1 — Define Targets</strong></p><p><strong>STEP 2 — Feature Engineering (Source-Aware)</strong></p><blockquote>I created lags per source. Because each source has different behaviour:</blockquote><blockquote>Wind → stochastic, autocorrelated</blockquote><blockquote>Solar → strong diurnal pattern</blockquote><blockquote>Fossil → residual balancing</blockquote><blockquote>Imports → interconnector-driven</blockquote><p><strong>Step 3 — Lag Engineering (Half-hour data)</strong></p><p><strong>Step 4 — Rolling Means (shifted)</strong></p><p><strong>Step 5 — Add Time Features</strong></p><p><strong>Multi-Model Forecasting</strong></p><h3>WEEKLY RESAMPLED FORECAST</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJZVC_HE2jRqPzDxya10bw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sZdn_kdyDvXIDqXq82lbWA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gg0a8PVDBVOO0gseNtXxHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R82SZx7B0CGMu40riDxC0A.png" /></figure><h3><strong>MONTLY RESAMPLED FORECAST</strong></h3><p><strong>— — WIND Analysis — -</strong></p><p>MAE: 242.96 MW RMSE: 464.16 MW R²: 0.9885 Forecast Bias: -149.17 MW</p><p><strong>— — SOLAR Analysis — -</strong></p><p>MAE: 46.78 MW RMSE: 257.35 MW R²: 0.9906 Forecast Bias: -29.13 MW</p><p><strong>— — FOSSIL Analysis — -</strong></p><p>MAE: 156.06 MW RMSE: 224.23 MW R²: 0.9986 Forecast Bias: 36.46 MW</p><p><strong>— — IMPORTS Analysis — -</strong></p><h3>1. WIND</h3><p>MAE: 242.96 MW, RMSE: 464.16 MW, R²: 0.9885</p><p>The MAE and RMSE are reasonably close, indicating the model’s errors are not dominated by extreme outliers.</p><p>R² of 0.9885 shows the model explains ~99% of the variance, which is excellent.</p><p>Forecast Bias: -149.17 MW</p><p>Negative bias → the model tends to underpredict wind generation on average.</p><p>Considering wind’s max can reach ~18,382 MW, this bias is moderate but worth noting for operational planning.</p><p>Interpretation: High R² and moderate bias indicate good overall predictive performance, but NESO should be cautious about slight underestimation during high wind periods.</p><h3>2. SOLAR</h3><p>MAE: 46.78 MW, RMSE: 257.35 MW, R²: 0.9906</p><p>MAE is very low, indicating precise short-term forecasts on average.</p><p>RMSE is higher due to occasional peaks (solar peaks are sparse but extreme).</p><p>R² is excellent at 0.9906 → almost all variance captured.</p><p>Forecast Bias: -29.13 MW</p><p>Slight underprediction, which is very minor relative to solar’s max (~14,035 MW).</p><p>Interpretation: Highly reliable forecasts for day-ahead solar planning; minimal risk of systematic errors.</p><h3>3. FOSSIL</h3><p>MAE: 156.06 MW, RMSE: 224.23 MW, R²: 0.9986</p><p>Very low MAE and RMSE relative to average fossil generation (~17,507 MW), showing excellent model accuracy.</p><p>R² near 0.999 → model captures almost all variability.</p><p>Forecast Bias: 36.46 MW</p><p>Slight overprediction, very minor relative to total fossil output.</p><p>Interpretation: Fossil forecasts are highly dependable, providing NESO confidence in fall-back and balancing strategies.</p><h3>4. IMPORTS</h3><p>MAE: 342.86 MW, RMSE: 649.39 MW, R²: 0.9072</p><p>Higher MAE and RMSE relative to other sources; imports are more volatile and less predictable.</p><p>R² of 0.9072 → model captures most, but not all, variability; some unexpected swings occur.</p><p>Forecast Bias: -304.79 MW</p><p>Negative bias → model tends to under predict imports, which is critical as underestimation could lead to insufficient supply planning.</p><p>Interpretation: NESO should be cautious; import forecasts are less reliable, and contingency plans may be required.</p><h3>UNIVARIATE LONG SHORT-TERM MEMORY (LSTM) FOR GRID GENERATION FORECASTING</h3><p><strong>UNIVARIATE LSTM:</strong> Relies solely on the lookback window (Last 24 hours).</p><p><strong>MULTIVARIATE LSTM:</strong> Incorporates SINE/COSINE CYCLICAL FEATURES.</p><h3>Univariate LSTM — Full Modelling Result Evaluation Profile:</h3><p>R² Score : 0.9918 MAE : 426.86 MW RMSE : 560.71 MW Bias : 183.31 MW</p><h3>Performance Summary:</h3><p>The current LSTM model demonstrates exceptional predictive accuracy for NESO generation data, effectively capturing nearly all grid variance. Key Performance Indicators: Precision and Variance: The model achieved an R2 of 0.9918, indicating it accounts for over 99% of the observed variance in generation. Error Margins: The Mean Absolute Error (MAE) of 426.86 MW represents a marginal error of approximately 1.1% relative to the average grid load. Consistency: The relatively narrow gap between the MAE and the Root Mean Square Error (RMSE) of 560.71 MW confirms that the model is consistent and not prone to significant outliers or “large-scale” miscalculations.</p><h3>Observations and Areas for Calibration</h3><p>While the overall precision is world-class, the model currently exhibits a positive bias of +183.31 MW. Systematic Over-Prediction: On average, the model predicts slightly more supply than is actually present. Probable Cause: This drift likely occurs during nocturnal “ramp-down” periods, where the model may expect demand to remain higher than the actual recorded drop-off. Operational Impact: In a grid-balancing context, over-predicting supply is generally considered a “safe” error. However, further refinement of the lag features or rolling averages during off-peak transitions could reduce this systematic bias.</p><h3>CONCLUSION</h3><blockquote><strong>This study Conducted structured exploratory data analysis of UK electricity generation</strong></blockquote><blockquote><strong>Engineered temporal and autoregressive features</strong></blockquote><blockquote><strong>Developed an XGBoost, LSTM and Informer Attention Mechanism Model for forecasting benchmark</strong></blockquote><blockquote><strong>Evaluated predictive performance rigorously</strong></blockquote><blockquote><strong>Extracted operational and system-level insights</strong></blockquote><blockquote>The model has been deployed on the web-link: <a href="https://kamil-uk-energy-generation-real-time-forecast.streamlit.app/">https://kamil-uk-energy-generation-real-time-forecast.streamlit.app/</a></blockquote><h3>The results confirm that UK electricity generation is:</h3><blockquote>Highly cyclical</blockquote><blockquote>Strongly autoregressive</blockquote><blockquote>Increasingly influenced by renewable variability</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mH29FIo7lHwkvWQNkIG6UQ.jpeg" /></figure><h3>Modelled By: KAMIL, RIDWAN</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bdcce3a6a387" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>