<?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 AbdulmaLeek Mubaraq on Medium]]></title>
        <description><![CDATA[Stories by AbdulmaLeek Mubaraq on Medium]]></description>
        <link>https://medium.com/@mubaraqabdulmaleek?source=rss-93243801c802------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*usuljuhvnAVAQJRFu7QROA.jpeg</url>
            <title>Stories by AbdulmaLeek Mubaraq on Medium</title>
            <link>https://medium.com/@mubaraqabdulmaleek?source=rss-93243801c802------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 04:34:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mubaraqabdulmaleek/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[A Tale from the Field: The User Left. The Bill Didn’t.]]></title>
            <link>https://medium.com/@mubaraqabdulmaleek/a-tale-from-the-field-the-user-left-the-bill-didnt-10770fdec4b2?source=rss-93243801c802------2</link>
            <guid isPermaLink="false">https://medium.com/p/10770fdec4b2</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[AbdulmaLeek Mubaraq]]></dc:creator>
            <pubDate>Wed, 02 Dec 2026 21:35:17 GMT</pubDate>
            <atom:updated>2026-12-02T21:35:17.113Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Every way a request can end needs a charging rule, and a test that ends it that way. Part 4 of 4.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bdLJGPfa6fKmv4UpEfCTLw.png" /></figure><p>An LLM call costs money the moment the provider answers. Whether your user pays for it depends on how the request ends, and a request can end in more ways than the happy path you wrote first.</p><p>It can succeed. It can fail at the provider. Two requests can race for the same last credits. The answer can come from a cache, so nobody was paid. The client can go away after the model answered but before you charged. I rebuilt the billing layer of my app, and each of those endings had a bug or a design decision waiting in it. One of them I only found by spending a tenth of a cent on a real model.</p><p>The lesson: list every way a request can end, decide what each one costs, and write a test that ends the request exactly that way, against the code that touches the money. The happy path is one ending out of five.</p><h3>What I’m building</h3><p>I’m rebuilding parts of my own app, <a href="https://ankix.tech/">AnkiX</a>, by hand, then comparing the rebuild with the live code. AnkiX turns a document into flashcard decks with an LLM, and I built most of it with AI. (<a href="https://medium.com/@mubaraqabdulmaleek/a-tale-from-the-field-the-test-was-green-the-feature-never-worked-8eab62347a40">Part 1</a> covered parsing, <a href="https://medium.com/@mubaraqabdulmaleek/a-tale-from-the-field-the-json-was-always-valid-e4727ce29fdf">Part 2</a> the generation pipeline, <a href="https://medium.com/@mubaraqabdulmaleek/a-tale-from-the-field-the-judge-agreed-with-me-it-meant-nothing-332f691cdafd">Part 3</a> evals; the rebuild is <a href="https://github.com/maleek004/doc-to-deck-py">doc-to-deck-py</a>, in Python.)</p><p>This layer has three parts, each answering one question:</p><ol><li>A usage ledger: what did the provider charge me? One row per LLM call, with tokens, latency, outcome and the cost in dollars.</li><li>A credit wallet: what does the user pay? Credits are the product’s price: 2 per started 500 words of text sent to the model, plus 1 per card, the same formula as AnkiX.</li><li>Guardrails: what stops a bad day from becoming a big bill? An input budget per call and a daily spend cap.</li></ol><p>Two meters, on purpose. The ledger counts dollars, what I pay. The wallet counts credits, what the user pays. They answer different questions, and keeping them apart is what made the cache bug visible.</p><h3>Pricing a call is a lookup by date</h3><p>The ledger prices each call from a table of dollars per million tokens. Every entry has the date it takes effect, because prices change: one model I use doubles its price on 1 January. A call is priced at the rate in force on the day it ran, and that cost is stored with the row, so a price change never rewrites last month.</p><p>Two details matter more than they look:</p><ul><li>A model with no price gets None, not 0. Zero would say &quot;free&quot;, and a total that includes a free call looks fine. None makes the whole deck&#39;s cost unknown, which is the truth.</li><li>Some models have a tier. Claude Haiku costs five times more per token above 100,000 prompt tokens, and both rates change at once.</li></ul><h3>Ending 1: two requests race for the last credits</h3><p>The obvious way to charge:</p><pre>balance = wallet.balance()<br>if balance &gt;= cost:<br>    wallet.set_balance(balance - cost)</pre><p>Two requests read 10, both see enough for 8, both write 2. The user got 16 credits of cards for 8. Between your read and your write, anything can happen.</p><p>The fix is to make the database do the check and the write in one statement:</p><pre>UPDATE wallet<br>SET balance = balance - :cost<br>WHERE id = 1 AND balance &gt;= :cost<br>RETURNING balance</pre><p>If the balance can’t cover it, no row matches, nothing changes, and you get no row back. There is no gap between the check and the write, because there is no separate check. Underneath it, a CHECK (balance &gt;= 0) on the table refuses a negative balance even if some future code forgets the WHERE.</p><p>The test is the race itself: 20 generate requests at once, on a balance that covers 5. The test holds all 20 at the model until every one has passed the balance check, so all 20 see enough credits. Exactly 5 are charged, the other 15 get a 402 and no cards, and the balance ends at zero. That’s also why the check before the call is only advisory: it turns away a request that clearly can’t pay before money is spent on the provider, but it can’t promise anything. The UPDATE is the only real check.</p><h3>Ending 2: the client goes away after the model answered</h3><p>Here the order matters. The pipeline is: check the balance → call the model → charge. If the client disconnects <em>during</em> the model call, nothing was produced, and nothing should be charged. If it goes away <em>after</em>, the provider has been paid and the cards exist. The charge has to happen anyway.</p><p>In Python, that’s harder than it sounds. When a request’s task is cancelled (a timeout, a server shutting down, middleware that stops work when the client disconnects), asyncio raises CancelledError at whatever await the task is waiting on. Including this one:</p><pre>cards = await generate(request)  # provider paid<br>await wallet.charge(total)       # cancel lands here</pre><p>The cancellation skips the charge, and the user leaves with cards they never paid for. The fix is to run the charge as its own task, which the request’s cancellation doesn’t reach:</p><pre>task = asyncio.create_task(settle(...))<br>_settling.add(task)  # keep a strong reference<br>task.add_done_callback(_settling.discard)<br>return await asyncio.shield(task)</pre><p>asyncio.shield protects the inner task: the request is still cancelled, but the charge finishes. The set is the gotcha. The event loop keeps only weak references to tasks, so a task nobody else holds can be garbage-collected halfway through. The asyncio docs warn about exactly this.</p><p>The test cancels the request after the model answers and before the charge, then checks the charge landed. I checked the test too: with the shield replaced by a plain await, it fails.</p><p>AnkiX, in C#, gets the same guarantee with one argument: it passes CancellationToken.None to the deduction. That works because .NET cancellation is cooperative. Code stops only where something checks the token, so not passing the request&#39;s token is enough. In Python, cancellation is delivered to the task, so opting out takes a separate task. Same rule, different mechanism. Porting one to the other line by line would have left the bug in.</p><h3>Ending 3: the answer came from the cache</h3><p>In Part 3, I put a response cache in front of every real model, so running the evals twice costs nothing. A cache hit reports the original call’s tokens, marked cached. The ledger, which counts dollars, recorded a hit as $0. Correct.</p><p>Then I ran the app against Claude for the first time: one document, two modules, nine cards, $0.00099 in all. I generated the same deck again. The ledger said $0. The wallet charged the full price again.</p><p>The wallet’s rule was “charge for every card returned”. It never asked where the cards came from. The fix is two lines: a cached answer charges no credits, and the page says so (“No credits charged: these cards came from the cache”). A second bug was in the same row: the ledger copied the original call’s latency onto the hit, so a cache read that took milliseconds showed up as the original 5.9-second call.</p><p>Every test was green before that run. I’d tested the cache, and I’d tested the wallet, but no test sent a cached answer through the wallet. The bugs live where two parts you tested separately meet.</p><h3>Ending 4: the provider fails</h3><p>The simplest rule, and still worth a test: a failed call charges no credits. The exception skips the charge step. But the ledger still writes a row, with the outcome and $0, because a failed call is still a call. If your provider is failing 30% of the time, the ledger is where you see it.</p><p>Here is the whole table:</p><p>One ending costs me money and the user nothing: a request that loses the race. The model answered, so the provider was paid, but the charge failed, so the cards aren’t returned. The check before the call keeps that rare; it can’t make it impossible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vPWoFJq294u0On3GK6WFAw.png" /></figure><p><em>Five endings, five rules, five tests.</em></p><h3>Guardrails: refuse before you spend</h3><p>Credits limit what one user can spend. Nothing so far limits what <em>I</em> spend. Two checks run before any real call is sent:</p><ul><li>An input budget. Tokens are estimated as characters ÷ 3, which errs high and needs no network call. Over 8,000, the request gets a 413 and nothing is sent.</li><li>A daily spend cap. The ledger already knows today’s total. Once it reaches the cap ($1 by default), real providers get a 503 until midnight UTC. The fake model still works, and so do cached answers, since they cost nothing.</li></ul><p>And one more refusal: a model with no price is refused. The cap can’t measure what it can’t price, so it fails closed.</p><p>The caveat: the cap is soft. Calls already in flight when it’s crossed can overshoot it. A hard cap would reserve each call’s worst-case cost before sending it. For a dollar a day, soft is fine. For real money, I’d reserve.</p><h3>Back in the field: the right test, on the wrong branch</h3><p>Then I compared the rebuild with AnkiX’s code, as I do at the end of every layer. All of it from reading the code; none of it is fixed yet.</p><p>Most of it matches. The credit formula is the same. The charge is the same single UPDATE … WHERE balance &gt;= cost, in a transaction with its ledger row, with the same CHECK constraint. Extra cards are held back by the same rule. A top-up from a payment webhook is credited once, behind a unique index.</p><p>Then I read the test that guards it. It has exactly the right shape: 20 concurrent deductions on a balance that covers 5, asserting exactly 5 succeed and the balance ends at zero. But it runs on Entity Framework’s in-memory database. And the service has a branch for that: when the database isn’t relational, it skips the SQL and takes a lock in memory instead. So the test proves the lock works. The UPDATE that protects real money, the transaction and the CHECK constraint have never been run by a test. Nothing tests what card generation charges, or the charge after a disconnect, either.</p><p>That’s Part 1’s lesson again: a green test tells you what it ran, not what you meant it to run. The fix is to run that same test against a real Postgres.</p><p>Two more findings:</p><ul><li>No dollar ledger. AnkiX stores tokens and the model name with each successful charge, but no cost, no latency and no failed calls. Calls that fail or get retried are paid to the provider and leave no row. AnkiX can’t say what AI cost it today, and its only kill switch is a manual one.</li><li>Quick capture is underpriced. It charges a flat 1 credit for up to 12,000 characters sent to the model. The same text through the main generator costs about 11.</li></ul><h3>What I do differently now</h3><ol><li>List the endings before writing the charge. Success, failure, race, cache hit, cancellation. Decide each one on purpose.</li><li>Let the database do check-and-write in one statement, and add a constraint underneath it.</li><li>Know how your language cancels. A token you pass, or an exception delivered to the task. The guarantee ports; the code doesn’t.</li><li>Test where the parts meet. My cache and wallet both passed their tests and failed together.</li><li>Keep two meters: what the provider charges you, and what you charge the user. A ledger row for every call, failed ones included.</li><li>Make sure money tests run the money code. Check which branch your test database takes.</li></ol><h3>Practise it</h3><p>The drills are in the AnkiX Study Group <a href="https://ankix.tech/study-groups/ankix-kata-doc-to-deck-py">ankix-kata-doc-to-deck-py</a>:</p><ul><li><a href="https://ankix.tech/exercises?id=731">Charge a wallet in one statement</a> (tested against a rival request that spends between your read and your write)</li><li><a href="https://ankix.tech/exercises?id=732">Price an LLM call on a given day</a> (dates, a prompt-size tier, and None for an unknown model)</li><li><a href="https://ankix.tech/exercises?id=733">The user left before the charge: what now?</a></li></ul><p>Or run it yourself: clone <a href="https://github.com/maleek004/doc-to-deck-py">doc-to-deck-py</a> and run uv run pytest -k layer4. No API key needed.</p><h3>The end of the series</h3><p>Four layers, four comparisons, and the same lesson kept coming back in new forms. A test that checked that output existed, while the feature never worked. JSON that was always valid and sometimes wrong. A judge that agreed with me and meant nothing. A concurrency test that ran the wrong branch. Building it by hand didn’t make me faster than the AI that wrote AnkiX. It made me able to read what it wrote, and every layer found something worth fixing.</p><p><em>How do you charge for an LLM call that the client walked away from? I’d like to hear how your stack handles it.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10770fdec4b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Tale from the Field: The Judge Agreed With Me. It Meant Nothing.]]></title>
            <link>https://medium.com/@mubaraqabdulmaleek/a-tale-from-the-field-the-judge-agreed-with-me-it-meant-nothing-332f691cdafd?source=rss-93243801c802------2</link>
            <guid isPermaLink="false">https://medium.com/p/332f691cdafd</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[AbdulmaLeek Mubaraq]]></dc:creator>
            <pubDate>Wed, 02 Dec 2026 17:34:15 GMT</pubDate>
            <atom:updated>2026-12-02T17:34:15.291Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Why an LLM judge can agree with you on almost every evaluated output and still tell you nothing, and how to measure one before you trust it. Part 3 of 4.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pOBKNvzNGjcWzXulp0W5cw.png" /></figure><p>You change a prompt. The output looks better. Is it?</p><p>Most of us answer that by reading a few outputs and going with our gut. The grown-up answer is an eval: a fixed set of inputs, a way to score the outputs, and a number you can compare before and after. So I built one. And the eval was wrong before the model was. My reference data had three mistakes in it. My quality rule flagged good cards. My LLM judge matched my scores on 67 to 100% of cards, depending on the criterion, and on the cards that mattered did no better than chance.</p><p>None of that was the model’s fault. Each was a measuring instrument I hadn’t measured.</p><p>The lesson: an eval is code, and its numbers are only as good as the instrument behind them. Test every instrument on answers you already know, especially known failures, and compare it with chance, before you believe what it says about your model.</p><h3>What I’m measuring</h3><p>I’m rebuilding parts of my own app, <a href="https://ankix.tech/">AnkiX</a>, by hand, then comparing the rebuild with the live code. AnkiX turns a document into flashcard decks with an LLM, and I built most of it with AI. (<a href="https://medium.com/@mubaraqabdulmaleek/a-tale-from-the-field-the-test-was-green-the-feature-never-worked-8eab62347a40">Part 1</a> covered parsing, <a href="https://medium.com/@mubaraqabdulmaleek/a-tale-from-the-field-the-json-was-always-valid-e4727ce29fdf">Part 2</a> the generation pipeline; the rebuild is <a href="https://github.com/maleek004/doc-to-deck-py">doc-to-deck-py</a>, in Python.)</p><p>AnkiX has no evals at all, so this layer is new. It has four parts:</p><ol><li>A golden set: what should a good deck contain? Five short documents, with 45 key facts written by hand.</li><li>A runner: what did the model actually write? It makes a deck from each document with the prompt under test. Every call goes through a cache, so running it again costs nothing.</li><li>Metrics: how much of the answer key did it cover? Plain code that counts facts covered, cards that shouldn’t exist, quality flags, cost and time.</li><li>An LLM judge: are the cards any good? A second model that checks what code can’t: is each card true to the source, about one thing, clear, and worth remembering?</li></ol><p>A report then puts two runs side by side, before and after a change.</p><p>Each part is a measuring instrument, and each one gave me a wrong reading before I checked it.</p><h3>Instrument 1: the golden set</h3><p>A golden set is the answer key. Mine is five short documents (HTTP caching, photosynthesis, SQL joins, compound interest, and the Roman Republic as a PDF), each with a hand-written list of facts a good deck must cover, things it must not turn into cards, and a range for the number of modules.</p><p>A fact is “covered” when one card contains all of its terms:</p><pre>[[facts]]<br>id = &quot;inputs-outputs&quot;<br>text = &quot;Photosynthesis turns carbon dioxide and water into glucose, releasing oxygen.&quot;<br>terms = [&quot;glucose|C6H12O6&quot;, &quot;oxygen|O2|6O2&quot;]</pre><p>| separates alternatives, and the match is whole words, ignoring case. (Whole words with (?&lt;!\w) and (?!\w) rather than \b, because \b fails on a term that ends in punctuation, like 12.68%.)</p><p>The first real run, Claude Haiku on all five documents, scored 85%. Then I read the misses, and three of them were mine:</p><ul><li>Module count in range: 1 of 5. The planner asks for one module per 2,500 words. My documents have 325 to 500 words, so it asked for one. Every expect file said 2 to 4. The model did what the code told it to.</li><li>A fact split in two. I wrote “ETag revalidation returns 304 Not Modified” as one fact. Claude wrote two better, atomic cards: one on the ETag, one on the 304. A one-card fact can’t match two cards.</li><li>O2 isn&#39;t in 6O2. The equation card was there in every run. But &quot;6O2&quot; is one whole word, so the term &quot;O2&quot; never matched it. That 6O2 in the TOML above is the fix.</li></ul><p>Fixing the first two, in the answer key and not the model, moved coverage to 87% and module count to 5 of 5, rescored from the cache at no cost. I found the third a few runs later; it added about 2 points to every run alike, so the comparisons below don’t change. Before you trust a miss, read the card. The first thing an eval tests is itself.</p><h3>Instrument 2: the before and after</h3><p>With a trusted answer key, I changed one thing: the cards prompt. Version 2 asks for breadth first, a card on each side of a contrast, one card per alternative, the numbers of a worked example kept, and no cards about the document itself (such as how to run its examples). Same model, same plan prompt, same number of cards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G6bIyoReaiteRnZ6gwszbw.png" /></figure><p><em>The same golden set, before and after one prompt change. Each version ran twice.</em></p><p>I ran each version twice with the cache off, because one run of an LLM is an anecdote. The ranges don’t overlap, and the gain comes from the same two documents both times (compound interest 75% → 100%, HTTP caching 90% → 100%). The noise lives elsewhere: photosynthesis moved between 70% and 90% on its own. v2 became the default, at about 17% more cost and a slower deck.</p><p>The same harness ran Gemini 2.5 Flash on v2: 79%. Its cards were broader (“What were the Punic Wars?”, answered with an overview), which packs several facts into one answer and misses the rest. One run only: the free tier allows 20 requests a day.</p><p>That table also hid a third instrument failing. The rule that flags a card which gives its own answer away jumped from 14% to 35% on v2. It was flagging comparison cards, not leaks, and Part 2 told that story: measured on real cards, rewritten, 2%.</p><h3>Instrument 3: the LLM judge</h3><p>Term matching can tell whether a fact is there. It can’t tell whether a card is <em>true</em>, or asks one clear thing, or is worth remembering. For that I used an LLM as a judge:</p><ul><li>A rubric with four criteria, each scored 1 to 5, with written anchors for 5, 3 and 1. The same text goes into the judge’s prompt and into the sheet I labelled by hand, so we score against the same words.</li><li>A different model from the generator. Models tend to prefer their own writing, so Claude’s cards are judged by Gemini, and the code refuses a judge from the same provider.</li><li>The source document in the prompt, so “faithful” means faithful to <em>this</em> text.</li><li>A strict schema: a score of 6 rejects the judgement instead of being clamped to 5, and a missing or repeated card id is an error for that document, never a score of 0.</li></ul><p>Then the rule that matters: the judge isn’t trusted until it’s measured. I labelled 30 real cards by hand and compared.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hk1YpqDv1bAnh1FM_TwLmA.png" /></figure><p><em>High agreement, kappa near zero: the first calibration.</em></p><p>Agreement looks great. Kappa says it’s worthless. Both are right.</p><p>Cohen’s kappa measures how much better than chance two raters agree: 1 is perfect, 0 is no better than chance, below 0 is worse. It subtracts the agreement you’d get by luck, and luck is high when nearly everything passes. Picture 30 cards. I fail card 1, the judge fails card 2, and we pass the rest. We agree on 28 of 30, which is 93%. But on the only question that matters, which cards are bad, we never agree once. Kappa comes out below zero.</p><p>That was my data. Every card was faithful (so kappa is undefined: no failures to agree on), and I’d scored only a handful of cards 3 on the other criteria, none lower. The high agreement was the base rate. On the few cards I marked down, the judge was guessing.</p><p>The fix: give the instrument failures to find. I wrote 16 defective cards on purpose, three or four per document, each aimed at one criterion: a figure swapped for another from the same text (1,628.89 for 1,647.01), six months turned into a year, the wrong join, an overview crammed into one answer, “what does this header control?” with no header named, a disclaimer turned into a card.</p><p>The second run caught 16 of 16, each scored 1 on the criterion it targeted, and on 15 of them the other criteria stayed between 3 and 5. It marks down the right thing, not the whole card. On my 30 real cards, atomic rose to κ 0.46. Unambiguous stayed at 0.00, and the disagreement ran one way: all five cards I scored 3, the judge scored 5.</p><p>So the verdict is split, and written down where the report prints it:</p><ul><li>Trusted for faithful and atomic, as a detector of clear failures.</li><li>Rough signal for unambiguous and worth remembering, where it’s more lenient than I am.</li></ul><p>Then I let it judge the two prompt versions (50 and 51 cards):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PEffzt9rHzFgxgNF6tpAww.png" /></figure><p><em>What the calibrated judge found in the two prompt versions.</em></p><p>No invented facts in either. v2’s three non-atomic cards were its own rules at work (a comparison in one answer, a worked number added to a formula, an extra date): its broader coverage cost a little atomicity. That’s a trade-off to tune in a v3, and I’d never have seen it from coverage alone. And the one card both the judge and the must-not rule rejected was the same sqlite3 “running the examples” card. Two instruments that measured independently and agreed.</p><p>The caveats, because a measurement without them is a sales pitch: the planted defects were written against the rubric, so they’re cleaner than real faults; 46 cards is small; and I ran the judge once, so I don’t know how consistent it is between runs.</p><h3>Back in the field: AnkiX’s labels are thrown away</h3><p>Then I compared the rebuild with AnkiX’s code, as I do at the end of every layer. AnkiX has no golden set, no runner and no judge, so the comparison was with every quality signal it does have. All of it from reading the code; none of it is fixed yet.</p><ul><li>The only test that calls a real model checks that output exists. It asserts success, a non-empty card list and one to five modules. A deck about the wrong document passes. That’s Part 1’s lesson in a new place.</li><li>The quality rules exist twice: C# on the server, and a JavaScript copy in the review screen that lacks the leak rule and the duplicate check. Edit one letter of a card, and the copy’s flags replace the server’s, so the duplicate warning disappears.</li><li>No prompt version is recorded with a generation, so there’s no way to say which prompt made a deck.</li></ul><p>And the biggest one. AnkiX shows every AI-written card in a review screen before saving, where the user approves, edits or rejects it. That is exactly the human label I spent this whole layer producing by hand: 30 cards and 16 planted defects. AnkiX’s users produce them on every generation. And at save, only the approved cards are sent; the rejections, the edits and the link to the prompt that wrote them are gone.</p><p>Log one row per reviewed card (the original text, the final text, approved or not, the quality flags, the model, the prompt version) and two measurements come for free: whether flagged cards really get rejected more often, and a before and after for every prompt change, on real documents. Before you build a judge, check whether your users are already judging, and stop throwing it away.</p><h3>What I do differently now</h3><ol><li>Read the misses before trusting the score. My first three “model failures” were answer-key bugs.</li><li>Run each version at least twice and compare ranges, not single numbers.</li><li>Report kappa next to agreement. When nearly everything passes, agreement measures the base rate.</li><li>Plant failures you know and check that each instrument catches them, on the right criterion.</li><li>Write down what an instrument is trusted for, and print it next to its numbers.</li><li>Look for labels you already have. A review step, an undo, an edit: each is a human judgement.</li></ol><h3>Practise it</h3><p>The drills are in the AnkiX Study Group <a href="https://ankix.tech/study-groups/ankix-kata-doc-to-deck-py">ankix-kata-doc-to-deck-py</a>:</p><ul><li><a href="https://ankix.tech/exercises?id=728">Cohen’s kappa for an LLM judge</a> (including when it’s undefined)</li><li><a href="https://ankix.tech/exercises?id=729">Match golden-set facts by terms</a> (the 12.68% and 6O2 traps)</li><li><a href="https://ankix.tech/exercises?id=730">High agreement, kappa near 0: what does it mean?</a></li></ul><p>Or run it yourself: clone <a href="https://github.com/maleek004/doc-to-deck-py">doc-to-deck-py</a>, run uv run pytest -k layer3, then uv run doctodeck-eval run --provider fake to run the golden set on the built-in fake model, with no API key.</p><p>Next, Part 4, the last one: what all of this costs. A usage ledger for every call, a credit wallet that can’t be charged twice, and the bug in my rebuild where a cache hit that cost $0 still charged the user credits.</p><p><em>How do you know your LLM judge is right? I’d like to hear how you measure yours.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=332f691cdafd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Tale from the Field: The JSON Was Always Valid]]></title>
            <link>https://medium.com/@mubaraqabdulmaleek/a-tale-from-the-field-the-json-was-always-valid-e4727ce29fdf?source=rss-93243801c802------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4727ce29fdf</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <dc:creator><![CDATA[AbdulmaLeek Mubaraq]]></dc:creator>
            <pubDate>Wed, 02 Dec 2026 14:13:13 GMT</pubDate>
            <atom:updated>2026-12-02T14:13:13.454Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Why multi-step LLM pipelines lose data between steps, even when every output passes its schema, and how to fix it. Part 2 of 4.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MjcGYJ8IwNM-yCsXakBI4w.png" /></figure><p>Most LLM features worth building aren’t one call. They’re a pipeline: one call’s output becomes the next call’s input. Summarise, then classify. Plan, then write. Extract, then check.</p><p>Structured output makes each of those calls trustworthy on its own. You hand the model a JSON Schema and the JSON comes back in that shape. In my side-by-side runs, 100% of Gemini’s and Claude’s responses matched the schema.</p><p>And the pipeline still lost data. Not inside any call, but between them: a step quietly dropped part of what the previous step handed it, or put it in the wrong place. Each step checked its own output. No step checked that it kept the previous step’s promise.</p><p>The lesson: a schema checks the shape of one step. To keep data from leaking out between steps, carry ids across every hand-off and check them.</p><h3>The pipeline, and where I looked</h3><p>I’m rebuilding parts of my own app, <a href="https://ankix.tech/">AnkiX</a>, by hand, then comparing the rebuild with the live code line by line. AnkiX turns an uploaded document into flashcard decks, and I built most of it with AI. (<a href="https://medium.com/@mubaraqabdulmaleek/a-tale-from-the-field-the-test-was-green-the-feature-never-worked-8eab62347a40">Part 1</a> covered parsing the document; the rebuild is <a href="https://github.com/maleek004/doc-to-deck-py">doc-to-deck-py</a>, in Python.)</p><p>This part covers the generation pipeline. Two LLM calls, Gemini or Claude, both with structured output:</p><pre>document ─①─► outline ──► PLAN call ─②─► modules ─③─► CARDS call ─④─► one deck per module<br>             (sections)    &quot;group these              &quot;write cards for<br>                            sections into modules&quot;    these modules&quot;</pre><p>The plan call promises: <em>these sections make up this module</em>. The cards call should keep that promise: <em>this card belongs to that module</em>. Each module becomes a deck. Every numbered arrow is a hand-off, and each one leaked something.</p><h3>Four places data leaked out</h3><h4>① Document → prompt: cut without a word</h4><p>A long document doesn’t fit in one prompt, so the text is cut at a limit (12,000 characters in both versions). That’s fine. What isn’t fine is that AnkiX cuts it silently, and it also lists only the first 25 sections of the outline:</p><pre>for (int i = 0; i &lt; request.Sections.Count &amp;&amp; i &lt; 25; i++)<br>{<br>    var s = request.Sections[i];<br>    promptBuilder.AppendLine($&quot;Section {i}: {s.Title} ({s.WordCount} words)&quot;);<br>}<br>...<br>int cut = Math.Min(raw.Length, AiPricingTiers.MaxIngestSourceChars);<br>promptBuilder.AppendLine(raw[..cut]);</pre><p>12,000 characters is a few pages. Upload a 40-page document and the model never sees most of it. The cards look fine, the JSON is valid, and nobody is told the rest was never read.</p><h4>② Plan → modules: a section in two modules, or in none</h4><p>The plan’s output is a list of modules, each with the indices of the sections it covers. The schema guarantees the indices are integers. It can’t guarantee they make sense together. AnkiX repairs only one problem, indices that don’t exist:</p><pre>var safeIndices = rawMod.SectionIndices   // simplified<br>    .Where(idx =&gt; idx &gt;= 0 &amp;&amp; idx &lt; sectionCount)<br>    .ToList();</pre><p>Two other problems pass straight through:</p><ul><li>a section the model put in two modules is carded twice;</li><li>a section the model put in no module never becomes a card. That’s data loss in its purest form: valid JSON, and part of the document silently gone.</li></ul><h4>③ My schema → the provider’s schema: constraints and fields dropped</h4><p>Even the schema itself goes through a hand-off. Each provider speaks its own dialect of JSON Schema, so it gets translated, and translation can drop things:</p><ul><li>AnkiX’s conversion for Claude strips minItems and maxItems at every depth. The plan schema says &quot;2 to 5 modules&quot;; Claude never sees that bound, and nothing checks it afterwards.</li><li>Gemini’s dialect rejects the title keyword, so my translator drops it. But a <em>property</em> called title is data, not the keyword. A translator that deletes every title key quietly deletes a field from every card. The rebuild has a test for exactly that.</li></ul><h4>④ Modules → cards: dealt out like playing cards</h4><p>This is the one that made me write this article. AnkiX’s card schema has no module field. Here is how it decides which module a card belongs to:</p><pre>int modIdx = i % request.Modules.Count;<br>var mod = request.Modules[modIdx];<br>moduleIndex = mod.ModuleIndex;<br>deckTitle = mod.Title;</pre><p>Card <em>i</em> goes to module <em>i</em> mod <em>n</em>, whatever the card is about. That title is passed to the save step as the card’s deck, and cards are grouped into decks by it. If the model writes its cards module by module, in the order the prompt lists the modules, then with three modules about two cards in three land in another module’s deck.</p><p>Every check on that path passes. Every card has a question and an answer, and lands in a real deck. Nothing compares the card with the module it was written for, because nothing carries that information through.</p><h3>The fix: carry ids through, and check them</h3><p>All four leaks have the same shape: one step made a promise, and the next step kept it by <em>assumption</em> (order, position, “the model will see everything”) instead of by <em>id</em>. The rebuild applies one pattern at every hand-off:</p><ol><li><strong>Put the previous step’s id in this step’s output.</strong> The card schema gets a module_index, so the model says which module each card belongs to instead of the code guessing from position:</li></ol><pre>class CardOutput(BaseModel):<br>    front: str<br>    back: str<br>    module_index: int   # &quot;the moduleIndex this card belongs to, from the input&quot;</pre><p>2. <strong>Check the ids against what was asked.</strong> A schema can say “integer”; only your code can say “one of the modules I actually sent”. The plan repair checks every section index against the outline and against what earlier modules already claimed, then gives forgotten sections a home:</p><pre>for index in raw.section_indices:<br>    if not 0 &lt;= index &lt; section_count:<br>        repairs.append(f&quot;Module {n}: dropped section index {index} (only {section_count} sections exist).&quot;)<br>    elif index in claimed:<br>        repairs.append(f&quot;Module {n}: section {index} was already in an earlier module; kept it there.&quot;)<br>    else:<br>        claimed.add(index)<br>        indices.append(index)<br>...<br># Sections the model forgot join the module just before them in reading order.<br>for missing in (i for i in range(section_count) if i not in claimed):<br>    home = next((m for m in reversed(kept) if min(m.indices) &lt; missing), kept[0])<br>    home.indices.append(missing)<br>    repairs.append(f&quot;Section {missing} wasn&#39;t in any module; added it to &#39;{home.title}&#39;.&quot;)</pre><p>The cards step does the same with module_index. If a card names a module that wasn&#39;t sent, it falls back to dealing it out in turn, the way AnkiX always does, but only for that card, and it says so.</p><p>3. <strong>Record every repair.</strong> Each fix above appends a line to repairs, which goes back to the user with the result. A quiet repair just moves the data loss somewhere you can&#39;t see it.</p><p>4. <strong>Flag what you cut.</strong> The rebuild still cuts the text at 12,000 characters, but the result says truncated: true with the characters sent and the total, so the user can be told that only the first part of the document was used.</p><p>And for leak ③: test the translated schema, not just your own. The rebuild’s translator tests check the output Gemini receives, including that a property named title survives while the keyword is dropped.</p><h3>The last hand-off: a check that needed checking</h3><p>The pipeline’s final step is a quality gate. It flags weak cards, including a card whose question gives its own answer away. That gate is a hand-off too: it promises “this card leaks its answer”. So I checked the promise.</p><p>The rule I ported from AnkiX flags a card if any answer word of seven or more letters also appears in the question. On my improved (v2) prompt it flagged 35% of Claude’s cards. I read them: one was a real leak. The rest were comparison cards, which <em>have</em> to repeat their subject:</p><blockquote><em>Q: How does </em><em>no-cache differ from </em><em>no-store? A: </em><em>no-cache lets a cache store the response but revalidate it before every use…</em></blockquote><p>The rewritten rule asks whether the answer adds anything new: no new content word (“What is the stroma, the fluid around thylakoids?” → “The stroma.”), or a number the question already gives (“With max-age=600, for how many seconds…?” → “600 seconds.”). Tested on 17 real Claude cards, then used to rescore the saved runs: flagged cards on the v2 prompt went from 35% to 2%, the one real leak.</p><p>A check is code like any other. Until it’s measured against cards whose answer you know, its percentages are a guess.</p><h3>Also from the field: the call itself</h3><p>A few lessons from around the calls rather than between them, in brief:</p><ul><li>Read why it stopped before what it said. Claude’s SDK helper messages.parse() validates the text as it builds the response, so a refusal or a cut-off raises a validation error before you can read stop_reason. The rebuild calls messages.create() and checks stop_reason first (refusal → REFUSED, max_tokens → TRUNCATED). AnkiX&#39;s Claude client does this right; its Gemini client doesn&#39;t check the equivalent finishReason: MAX_TOKENS.</li><li>Retry only when the next try can succeed. Gemini’s 429 puts the wait in its body (RetryInfo.retryDelay: &quot;18s&quot;), not in a Retry-After header. Read only the header, and you retry after 0.5, 1 and 2 seconds, each try certain to fail. On a free tier of 20 requests a day, I ran out. Both my first version and AnkiX had this blind spot. The fix: read the body, and when the wait is longer than you&#39;ll wait, fail at once and say when to try again.</li><li>Make sure the deadline is yours. My Gemini calls “timed out after 90 s” in under 11 seconds: a shared httpx client&#39;s default 5-second read timeout fired first, and my code reported it as its own.</li><li>Know your model’s thinking setting. Gemini 2.5 limits thinking with thinkingBudget, Gemini 3 with thinkingLevel. Set only the second, and 2.5 thinks without limit: 821 output tokens for a tiny plan, 80 with thinkingBudget: 0.</li></ul><h3>What I do differently now</h3><ol><li>Carry ids across every hand-off, and check them against what was asked. Never infer them from order.</li><li>Make every cut and every repair visible. A silent fix is a silent loss.</li><li>Test the translated schema, not just your own. Each provider dialect is a hand-off too.</li><li>Measure your checks. A quality rule is a classifier; give it labelled examples before trusting it.</li><li>Read why the call stopped, and retry only when the next try can succeed.</li></ol><h3>Practise it</h3><p>The drills are in the AnkiX Study Group <a href="https://ankix.tech/study-groups/ankix-kata-doc-to-deck-py">ankix-kata-doc-to-deck-py</a>:</p><ul><li><a href="https://ankix.tech/exercises?id=708">When to retry a Gemini call, and how long to wait</a></li><li><a href="https://ankix.tech/exercises?id=709">Translate a Pydantic schema for Gemini</a> (the title trap)</li><li><a href="https://ankix.tech/exercises?id=710">Why check stop_reason before parsing Claude’s JSON?</a></li></ul><p>Or run it yourself: clone <a href="https://github.com/maleek004/doc-to-deck-py">doc-to-deck-py</a> and run uv run pytest -k layer2. The providers are tested against mocked HTTP responses, so you don&#39;t need an API key.</p><p>Next, Part 3: measuring whether the cards are any good. On the same five documents, Gemini 2.5 Flash’s cards covered 79% of the key facts and Claude Haiku’s 92–96%. And I built an LLM judge that caught 16 of 16 planted defects, yet on my real cards agreed with me no better than chance on some criteria.</p><p><em>Where have you seen a pipeline step keep its own contract but break the previous one’s? I’d like to hear how you catch it.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4727ce29fdf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Tale from the Field: The Test Was Green. The Feature Never Worked.]]></title>
            <link>https://medium.com/@mubaraqabdulmaleek/a-tale-from-the-field-the-test-was-green-the-feature-never-worked-8eab62347a40?source=rss-93243801c802------2</link>
            <guid isPermaLink="false">https://medium.com/p/8eab62347a40</guid>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ai-assisted-coding]]></category>
            <dc:creator><![CDATA[AbdulmaLeek Mubaraq]]></dc:creator>
            <pubDate>Tue, 01 Dec 2026 14:58:52 GMT</pubDate>
            <atom:updated>2026-12-01T14:58:52.157Z</atom:updated>
            <content:encoded><![CDATA[<p><em>What rebuilding my AI-written document parser taught me about asserting shape, not existence. Part 1 of 4.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*momj4juviph1SfCDhikWmA.png" /></figure><p>A test that only checks that your output exists will pass when your output is wrong. Every programmer knows this the way we know to floss. I learned it properly when I found a feature in my own app that had never worked, not once, sitting behind a test that had always been green.</p><p>This article is about that lesson, and about where the bugs hid once I started looking properly. First, a little context, because this is the first article in a series and you deserve to know what’s going on.</p><h3>What I’m building, and how I got here</h3><p><a href="https://ankix.tech/">AnkiX</a> is a spaced-repetition learning platform I’ve been building: flashcard decks, study groups, coding exercises that run in a sandbox, and an AI feature that turns an uploaded document into a flashcard deck.</p><p>I built a lot of it with AI. It works, it ships, people use it. But there are parts I couldn’t explain line by line, and that bothered me. I don’t want to own a system I can only describe from the outside.</p><p>So I started a habit I call a kata: pick one mechanism in AnkiX, rebuild it by hand in a small standalone repo, test first, until I understand every line. Then put the rebuild side by side with the live code and write down every difference. The differences are where the lessons are.</p><p>The first kata rebuilds AnkiX’s AI pipeline, the one that turns a document into a deck:</p><pre>upload ──► parse into an outline ──► plan modules (LLM) ──► write cards (LLM, structured output)<br>                                                              ──► quality gate ──► charge credits</pre><p>I rebuilt it in Python (<a href="https://github.com/maleek004/doc-to-deck-py">doc-to-deck-py</a>), and added what AnkiX lacks: a way to measure whether the cards are any good, and guardrails on what it all costs. The series has four parts, one lesson each:</p><ol><li>Ingest: turning a file into an outline (this article)</li><li>Generation: structured output from two LLM providers</li><li>Evals: measuring whether a prompt change made the cards better</li><li>Cost: tracking spend and refusing to overspend</li></ol><h3>The step everything else depends on</h3><p>Before any model sees the document, the parser splits it into an outline: sections with a title, a level and a word count. The planner model groups those sections into modules, and the card model writes cards per module. The outline is the model’s map of the document. If the map is one big blob, the model plans one big module, and the deck gets worse however good the model is.</p><p>For a PDF, finding sections means guessing headings from plain text: a numbered line (“2.3 Async streams”), a “Chapter 3”, a short line ending in a colon. The parser also has to remove the noise every page repeats: running headers, footers and page numbers.</p><h3>A green test and a feature that never worked</h3><p>AnkiX’s parser had all of those rules, and they’re reasonable rules. The PDF path started like this: get each page’s text from the PDF library (PdfPig), split it into lines, run the heading rules on each line.</p><p>The catch: PdfPig’s page.Text has no line breaks. When I probed it, each page came back as one long string. So every &quot;line&quot; was a whole page, longer than the 90-character heading limit; no heading rule ever matched, the header and footer comparison never matched either, and every PDF collapsed into a single section named after the file.</p><p>And the test? Here is AnkiX’s PDF test, in full:</p><pre>using var stream = CreateSamplePdfStream(&quot;Introduction to Algorithms\nSorting and searching ...&quot;);<br>var result = await _parser.ParseDocumentAsync(stream, &quot;algorithms.pdf&quot;);<br><br>Assert.Equal(1, result.PageCount);<br>Assert.True(result.WordCount &gt;= 8);<br>Assert.Contains(&quot;Algorithms&quot;, result.CleanText);<br>Assert.NotEmpty(result.Sections);</pre><p>Every assertion is about existence: there is text, there are words, there is at least one section. One section named after the file is not empty. The test passes whether heading detection works or not.</p><p>My rebuild’s tests assert the shape instead:</p><pre>def test_numbered_headings_become_sections():<br>    doc = parse([&quot;1. Introduction&quot;, &quot;Async functions return coroutines.&quot;,<br>                 &quot;2. Cancellation&quot;, &quot;Tasks can be cancelled.&quot;])<br><br>    assert titles(doc) == [&quot;1. Introduction&quot;, &quot;2. Cancellation&quot;]<br>    assert doc.sections[0].word_count == 4</pre><p>When I pointed my first rebuild (in C#) at the same one-line-per-page extraction, 7 of its 10 PDF tests failed. The Python rebuild uses pdfplumber, which groups characters into real lines: on a 3-page sample it finds 5 sections, &quot;2.1 Cancellation&quot; correctly nested under &quot;2. Asyncio&quot;, with the running header, footer and page numbers gone.</p><p>That’s the lesson: assert the shape of the output, not that it exists. Titles, levels, counts: the things that would be different if the feature were broken.</p><h3>Once I was looking: the bugs between the rules</h3><p>After the rebuild, I compared it with the live code line by line. Both versions had the same rules. The remaining bugs weren’t in any rule; they were in the paths between them.</p><p>Order. A running footer is a line at the bottom of at least half the pages. But the last line of a page is usually its page number, which changes every page. Count the bottom lines first and the footer is never at the bottom, so it’s never removed. My rebuild removes page numbers first. AnkiX counts first; that’s harmless today only because there are no real lines to count. Fix the extraction alone and this bug wakes up.</p><p>What counts as a line. Three in the Markdown path, all found by reading the code:</p><ul><li># Part 1, a blank line, ## Chapter A: the blank line counts as a line of Part 1, Part 1 has zero words, so it&#39;s dropped. A parent heading quietly disappears from the outline.</li><li>## Learning C# becomes &quot;Learning C&quot;: every trailing # is trimmed, when Markdown only strips a closing run of # after a space. My rebuild had this exact bug too. The fix is one regex, \s+#+\s*$, and four tests.</li><li>A code line that just says 42 disappears, because the PDF page-number filter also runs on Markdown, which has no pages.</li></ul><p>None of these is a wrong rule. Each one is a correct rule applied to input nobody pictured: a blank line, a page number at the bottom, a language with # in its name.</p><h3>What I do differently now</h3><ol><li>Assert the shape, not the existence. If a test would still pass with the feature deleted, it isn’t testing the feature.</li><li>Feed real-shaped input. Blank lines between headings, a footer above a page number, C#. Real documents are messier than the one-line sample in the test.</li><li>When every rule looks right, check the order and the edges. What counts as a line, and which step runs first.</li></ol><p>None of these AnkiX bugs is fixed yet. Each has a reproducing input and a proposed fix in the kata, waiting for the “pay it back” phase, when the lessons go back into the app.</p><h3>Practise it</h3><p>I put the exercises where I study: an AnkiX Study Group, <a href="https://ankix.tech/study-groups/ankix-kata-doc-to-deck-py">ankix-kata-doc-to-deck-py</a>, with three short drills:</p><ul><li><a href="https://ankix.tech/exercises?id=704">Find Markdown headings outside code fences</a></li><li><a href="https://ankix.tech/exercises?id=705">Strip repeated PDF headers and footers</a></li><li><a href="https://ankix.tech/exercises?id=706">Why check a file’s first bytes instead of its extension?</a></li></ul><p>Or reproduce everything from the repo: clone <a href="https://github.com/maleek004/doc-to-deck-py">doc-to-deck-py</a>, run uv run pytest -k layer1, then uv run doctodeck and upload samples/sample.pdf to see the 5-section outline.</p><p>Next, Part 2: structured output from Gemini and Claude, and why a rule meant to catch cards that give away their own answer flagged 35% of perfectly good ones.</p><p><em>How do you test a parser whose input you can’t fully predict? I’d like to hear what works for you.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8eab62347a40" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting acquainted with PostgreSQL]]></title>
            <link>https://medium.com/@mubaraqabdulmaleek/getting-acquainted-with-postgresql-0bab54126f6b?source=rss-93243801c802------2</link>
            <guid isPermaLink="false">https://medium.com/p/0bab54126f6b</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[postgresql-tutorials]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[AbdulmaLeek Mubaraq]]></dc:creator>
            <pubDate>Tue, 22 Apr 2025 11:51:14 GMT</pubDate>
            <atom:updated>2025-06-30T23:38:17.970Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial , we are going to go over downloading and installing the PostgreSQL package, creating a new database via pgAdmin and querying tables in the database.</p><p>This is aimed at people who might be new to data analytics and wants to set up and use the open source database for the first time.</p><p>Let’s get to it!</p><h3>Downloading the PostgreSQL Windows installer</h3><p><strong>Step 1:</strong> Visit postgresql.org/download and select windows as your operating system</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GsmrPzuBCjdFlczM" /></figure><p><strong>Step 2:</strong> On the next page, click on the ‘Download the installer’ button which should take you to EDB’s (Enterprisedb) page where the installation packages are hosted.</p><p><strong>Step3:</strong> Find the preferred Postgresql version you want from the EDB page and click on the download button under your system’s operating system</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GLcBVA7bGva_WCaa" /></figure><h3>Installing the PostgreSQL package</h3><ul><li>Open the installation package file to begin the setup wizard</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/0*DQtFVmqWP3csz77P" /></figure><ul><li>Specify your installation directory</li><li>Select the components you will like to install</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/0*EblQivdw5MT5g2MU" /></figure><ul><li>Select a data directory. This is where your database data will be stored</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/0*_qjigM5rX7ZRzg4R" /></figure><ul><li>Set up password for your database</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/0*2hYwSL-jpI6ZBKh_" /></figure><ul><li>Set port number for Postgresql or leave it at its default port : 5432. (port number can be changed later in the configuration files, read more <a href="https://risingwave.com/blog/mastering-default-port-for-postgresql-your-ultimate-guide/">here</a>)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/0*inC0AWyAwc3Of0uT" /></figure><ul><li>Leave the locale option as default locale</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/0*ANllPxLMSRkSagOD" /></figure><ul><li>Click next on the pre installation summary page to begin the installation process</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/0*11k0c9rFHTWjQLY2" /></figure><ul><li>At the end of the installation , you can choose to run stack builder to download extensions immediately or not</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/0*3CSu7mehc4g4nGyY" /></figure><h3><strong>Creating a new Postgres database using pgAdmin (in 4 steps)</strong></h3><blockquote>pgAdmin is an IDE for managing and interacting with PostgreSQL database</blockquote><p><strong>Step 1:</strong> Open pgAdmin and click on the servers dropdown on the left side bar</p><p><strong>Step 2:</strong> Connect to the server created earlier using the password set in the previous step</p><p>PS: If you had forgotten your password, follow <a href="https://www.youtube.com/watch?v=NiRiz_ob-VA&amp;t=208s">this video</a> to reset it👍🏽.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/0*c9zIJk-5xayTnhYr" /></figure><p><strong>Step 3:</strong> Right click on the database dropdown under the server and create a new database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/0*rvaWDc7WNi9oSoKX" /></figure><p><strong>Step 4:</strong> Set the name for your new database and click the save button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/0*_cmTEqpeuDTbOo6J" /></figure><h3>Creating and querying a table in your Postgres database (in 2 steps)</h3><p><strong>Step 1:</strong> With the new database selected, click on the Query Tool icon on the left corner of the tool bar or push Alt+Shift+Q to open a query editor</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/0*aHPXbXtMfQXOy81J" /></figure><p><strong>Step 2:</strong> Run the script below which creates a sales table , inserts data into it and selects data from it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*VV7zj4ZMVK-jM53zue3MRg.png" /></figure><p>Expected output :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/0*_jgVdYH2MyD531Ea" /></figure><p>END!</p><p>That’s it for this tutorial. Don’t forget to connect with me on <a href="https://www.linkedin.com/in/mubaraq-abdulmaleek/"><em>Linkedin</em></a></p><p>Thanks for reading, and i’ll catch you in the next one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0bab54126f6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step-by-Step Guide to Setting Up Google Analytics 4 on GitHub Pages]]></title>
            <link>https://medium.com/@mubaraqabdulmaleek/step-by-step-guide-to-setting-up-google-analytics-4-on-github-pages-fbaa5c4db636?source=rss-93243801c802------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbaa5c4db636</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[google-analytics]]></category>
            <category><![CDATA[github-pages]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[portfolio-website]]></category>
            <dc:creator><![CDATA[AbdulmaLeek Mubaraq]]></dc:creator>
            <pubDate>Fri, 20 Sep 2024 17:54:33 GMT</pubDate>
            <atom:updated>2024-11-07T22:50:13.600Z</atom:updated>
            <content:encoded><![CDATA[<h3>Step-by-Step Guide to Setting Up Google Analytics 4 on GitHub Pages (With Screenshots)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*cZkqDuVgYlFOcQ594KHG6Q.png" /></figure><p>As data professionals, we sometimes can’t help but feel the urge to measure, analyze, and improve almost everything we work with. For me, that itch came in the form of wanting to understand what’s happening on my <a href="http://maleek004.github.io/portfolio">portfolio website</a>.</p><p>And now that I’ve moved my portfolio from a free Carrd account to GitHub Pages (i wrote about it <a href="https://medium.com/@mubaraqabdulmaleek/building-a-free-data-analyst-portfolio-website-using-ai-and-github-pages-step-by-step-guide-for-174361901508">here</a>) I can finally scratch that itch… for free!</p><p>So, in this post, I’ll share the steps to set up Google Analytics 4 and start tracking your website traffic right away</p><h3>Setting up GA4 in 6 steps</h3><ol><li><strong>Logged into GA4</strong> at analytics.google.com using my google account</li></ol><p>2. <strong>Created a new account </strong>in the admin section of GA4. In Google Analytics, an account acts as a container for a set of properties (websites or apps you want to track), usually all related to a specific product or project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*d5nm1NYc7RlRQqfFQ8j2Aw.gif" /></figure><p>3. <strong>Set up a new property</strong> for my website within the account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*w0amYundUPxgVGTp28KIzg.png" /></figure><p>4. <strong>Added basic business details</strong> to provide context for tracking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jG8rNMc1qEDc5wl1Nsp11A.png" /></figure><p>5. <strong>Chose ‘Traffic’ as the business objective</strong> and accepted the terms and conditions.</p><p>6. <strong>Configured the data source</strong> by entering my website’s URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3p2X_agf4nM0sL9pwm0faA.png" /></figure><p>This generated a GA4 tag snippet which is to be placed in my website’s HTML.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RsY0_h23MQsNlavK5zolaw.png" /></figure><p>We wouldnt have to go through the stress of pasting this GA4 tag or any other tracking tag manually in our webiste’s HTML though, because Google Tag Manager’s got our back for that !</p><h3>Installing the GA4 tag using Goole Tag Manager</h3><h4>Setting up Google Tag Manager</h4><ul><li><strong>Created a new account and container</strong> in GTM.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ey1jLRL4GrmaqvtIjGaxgQ.png" /></figure><ul><li>This generated two snippets of code, which I added to the head and body sections of my portfolio website’s HTML.</li><li>Pushed the changes to the live website</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wmyMDfPmS5_YPeUUs19KHg.png" /></figure><p>Confirmed that the tag has been installed perfectly by opening the website in a debug window using GTM’s Tag Assistant’s Preview feature. It showed that a tag was found on the page which is perfect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y1Yd-aotF5_4n1ym1uUAaQ.png" /></figure><h4>Installing GA4 Tags through Google Tag Manager in 5 steps</h4><p>Now, to make GTM add the GA4 tag to my website for me.</p><ol><li><strong>Added a new tag</strong> in the GTM workspace by clicking the ‘Add a new Tag’ button.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B8ZfQlPC2iz41go2aAe5Zw.png" /></figure><p>2. <strong>Selected ‘Google Tag’</strong> as the tag type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SLCVAUk3xIf-5XMNlfpoUw.png" /></figure><p>3. <strong>Configured the ‘Google Tag’ tag</strong> by adding my GA4 measurement ID and creating an ‘All Pages’ trigger to make sure that the tag is deployed on all pages of the website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j5huDtrMrz16msoithWbwA.png" /></figure><p>Now if i preview the website using GTM’s tag assistant i will see that there are now 2 tags found on my website, the GTM tag that was pasted to my website’s code manually and the GA4 tag that is now added by GTM</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iwFwhF5wBlSQyGurOtv3sw.png" /></figure><p>4. Submitted the new tag configuration by first clicking the submit button in the top right corner in Tag manager</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0F2J2Un6YLCsAkEiAwj1cw.png" /></figure><p>5. Then gave it a version name and hit the publish button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zl3Q5cMpjZPrFgmeSNTNKQ.png" /></figure><h3>Viewing the traffic data in GA4</h3><p>It takes up to 48 hours for google analytics to start processing data after setting up a property, but in my case i was able to see traffic data in less than 24 hours.</p><p>And here’s a snapshot of the report in GA4</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kt3M-_9un-yaq7I6o9bCkw.png" /></figure><p>That’s a wrap! If you found this guide helpful, be sure to clap for this story and follow me for more practical tips and tutorials.</p><p>Don’t forget to connect with me on <a href="https://www.linkedin.com/in/mubaraq-abdulmaleek/"><em>Linkedin</em></a></p><p>If you’d like to support my work, <a href="http://buymeacoffee.com/Mubaraq_Abdulmaleek">click here</a></p><p>Thanks for reading, and I’ll catch you in the next one.</p><p><strong>Ciao!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbaa5c4db636" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Free Data Analyst Portfolio Website using AI and GitHub Pages : Step-by-Step Guide for…]]></title>
            <link>https://medium.com/@mubaraqabdulmaleek/building-a-free-data-analyst-portfolio-website-using-ai-and-github-pages-step-by-step-guide-for-174361901508?source=rss-93243801c802------2</link>
            <guid isPermaLink="false">https://medium.com/p/174361901508</guid>
            <category><![CDATA[portfolio-website]]></category>
            <category><![CDATA[github-pages]]></category>
            <category><![CDATA[coding-assistant]]></category>
            <category><![CDATA[portfolio]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[AbdulmaLeek Mubaraq]]></dc:creator>
            <pubDate>Tue, 17 Sep 2024 05:36:45 GMT</pubDate>
            <atom:updated>2025-04-28T20:59:59.277Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Free Data Analyst Portfolio Website with GitHub Pages and ChatGPT: Step-by-Step Guide for Beginners</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xm1xB4g14BDfdyK58yrqiw.png" /></figure><h3>Introduction</h3><p>In this blog post i will share a detailed step by step process of how i re-built my porfolio website as a data analyst with little coding experience.</p><p>I’ll explain how to download a free website template, host it for free on GitHub Pages, and use AI to tweak the template’s code. You can view the current version of the final result <a href="https://maleek004.github.io/portfolio/#top">here</a>.</p><h3>Reason for moving my portfolio to Github pages</h3><p>First off, i got this idea about creating a free and customizable portfolio webiste from this <a href="https://www.youtube.com/watch?v=ocdwh0KYeUs&amp;list=PLUaB-1hjhk8H48Pj32z4GZgGWyylqv85f&amp;index=5">video</a> by the great Alex Freberg.</p><p>Though i already have one that i built using carrd <a href="http://mubaraqabdulmaleek.carrd.co/">here</a>, i felt tempted to try this out because while carrd is a great tool, the free version limits the number of elements you can add to your site.</p><p>Another reason I decided to switch was to integrate Google Analytics, a free web analytics tool I’d always wanted to experiment with. Its free to implement with GitHub Pages but unfortunately, that feature is only available on Carrd’s paid plans.</p><p>So, here we go.</p><h3>Choosing a free template from HTML5 up and downloading its source code.</h3><p>The first step for me was selecting the right template from <a href="https://html5up.net/">HTML5up</a>. Other options for getting free website templates are <a href="https://templatesjungle.com/">TemplatedJungle</a> , <a href="http://www.freewebsitetemplates.com/">FreeWebsiteTemplates</a> or <a href="https://www.templatemonster.com/free-website-templates/?srsltid=AfmBOornI2fFDM1dNHoZZ7xNH-91yeMSnKRG2SYIDoR7mZ_w9HRFXUWe">TemplateMonster</a>.</p><p>I knew i wanted a layout with a nice little navigation on one side and the main contents on the other side so that users can easily to jump to whichever section interests them the most. So, i went over all the templates and ended up choosing this one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*SfzzIvg5tp2w9bA_I8ttcQ.gif" /><figcaption>GIF of a portfolio website template</figcaption></figure><p>And then i downloaded the source code by clicking the download button onthe top right corner of the page as seen above.</p><h3>Publishing the source code as it is to a Github page in 3 steps.</h3><p>So, because i also wanted to track every changes i make to the template’s source code while customizing it over time, i decided to publish the template as a github page first before making any changes. These are the 3 steps i took:</p><p><strong>1. Create a new public repository</strong></p><p>First, I created a new public repository on GitHub and named it ‘portfolio.’ I chose this name because the final URL would look like this: my_github_username.github.io/portfolio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bEqHdyu6wF1WCds30_BCRg.png" /><figcaption>github inetrface when creating a new repository</figcaption></figure><p><strong>2. Upload the Template Files</strong></p><p>Next, I uploaded all the files from the template’s source code to this new repository. This is as simple as dragging and dropping the files into the repository on GitHub’s web interface.</p><p><strong>3. Set the Publishing Source</strong></p><p>I navigated to the ‘Pages’ section of the repository’s settings and set the publishing source to the main branch and the /root folder. After a few minutes the website was deployed to my ‘github_username/repository_name’ url</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*lwHvz-CZ05j5EihyPv6fxA.png" /></figure><h3>Customizing the template</h3><p>Now its time to edit the template and make it mine.</p><p>First, I cloned the GitHub repository I had just created and opened the files in <strong>Visual Studio Code (VS Code)</strong>. I also installed <strong>Live Server</strong> extension, which will allow me to see my changes in real-time by running a local version of the website.</p><h4>First push: Making simple changes to the template</h4><p>So, before indulging ChatGPT to make complex changes to the design and layout of the website i made a few basic but important tweaks to the template to personalize it.</p><ol><li><strong>Changed the Title Tag : </strong>Changed the title tag to ‘Abdulmaleek😎 Mubaraq’s Portfolio’ . A website’s title tag is what shows up in the browser’s title bar as well as in search engine’s results pages.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*8xskMUJo7_OiXYV92nyG7Q.png" /><figcaption>title tag section of an HTML file</figcaption></figure><p><strong>2. Updated the Avatar Image: </strong>I swapped the default avatar image with a picture of myself</p><p>3. Personalized the name and Job tile<strong> </strong>in the <strong>logo section</strong>.</p><p>4. Reorganized the navigation section<strong> </strong>and added links to my socials to the <strong>social icon section.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_dk1RP5MBStY-ZeyFPrVqA.png" /><figcaption>HTML code snippet</figcaption></figure><p>5. Edited the Intro and Footer</p><h4>Pushing my first changes to github</h4><p>All the changes i have made so far were on the local verison of the website’s files.</p><p>Now, all i have to do to make the changes go live is to <strong>commit and push </strong>those changes to the remote repo on Github. And because my site is hosted on GitHub Pages, every time I push changes to the remote repository, GitHub automatically updates the live website.</p><p>For this, i used the ‘Commit &amp; Push’ button in VS code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*Y9dN5xrvRiKLfPNu0z0_5w.png" /><figcaption>a section of the VScode interface , with a yellow box highlighting the commit&amp;push button</figcaption></figure><h3>Making complex changes to the website’s source code using AI</h3><p>Changes made or features added to the website from here on will be done using the help of one AI tool or the other.</p><h4>Giving ChatGPT some context…</h4><p>First, to give ChatGPT context on what i was working on , i pasted the HTML code of the template into a new chat along with this prompt</p><blockquote>“I will post the HTML code of a website template below. My goal is to edit it to make it my portfolio website. I want you to understand it and suggest changes to make and also give me tips if I want to change the structure.”</blockquote><p>It responded with a few suggestions and code snippets which i tried and they worked perfectly. This gave me confidence that I could rely on it for more complex edits, and I also started to understand the template’s structure more as I tweaked the suggested code snippets.</p><h4>Customizing the Project Section’s Layout</h4><p>Now, i had a different idea for the layout of the ‘projects’ section, and i needed ChatGPT to generate code for it… So i gave it this follow-up prompt :</p><blockquote>“Help me rewrite the code for the portfolio section. I want it to be a vertical list of containers, each container representing a project. The containers should start with the project title, followed by two screenshots and a short project description in bullet points. At the bottom, include a ‘View More’ button. Also, make sure that if either screenshot is clicked, it opens in full-screen mode, with navigation between the two images in fullscreen.”</blockquote><p>It generated some HTML and CSS code snippets to add to the source code. They worked, but i had to make a few adjustments.</p><p>These were the changes i made to the generated code snippet:</p><ul><li>Increased the width of the project screenshot element in the CSS for better alignment</li><li>Changed the background color of the ‘View More’ button to match other buttons on the website</li><li>Added hover effects to the ‘View More’ button, making the background color change when hovered over, in a way that matches other buttons on the website</li><li>Added font size and font weight to the project details element</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*FYO8cKFBJivzRUCEjgEruQ.png" /></figure><ul><li>Added the project details bullet points and project screenshot file names to the HTML snippet</li></ul><p>This is the final output for the project section compared to what came with the template:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*JytQgOYX4HfOtEU3CBBqWQ.gif" /></figure><h4>Adding a ‘Certifications’ section using ChatGPT.</h4><p>Once again , i needed to add somethng new to the website — a certification section- so i asked ChatGPT for help using this follow-up prompt:</p><blockquote>“I want the certification section to be arranged in rows, with each row containing a screenshot of the certification and the title below it in a container. When any screenshot is clicked, it should open in fullscreen mode, and I should be able to navigate between the images in fullscreen.”</blockquote><p>It generated some HTML and CSS snippets which i edited a little and got this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9oLyiODT1_GcYl7tdNH7cA.png" /></figure><h3>Second Push to Github</h3><p>At the end of my second wave of editing , here’s a summary of the new features and changes I made to the website:</p><ul><li>Added a favicon, which i got from this <a href="https://favicon.io/emoji-favicons/smiling-face-with-sunglasses/#google_vignette">cool website</a>.</li><li>Changed the layout of the ‘Projects’ section .</li><li>Made sure the ‘View More’ button opens the linked page in a new tab.</li><li>Added a ‘Certifications’ section with a new layout.</li><li>Replaced the form in the contact section with a simple note and links to my socials.</li><li>Uploaded my images to the repository and replaced all the placeholder images in the source code with them.</li></ul><p>Check out the current version of the website <a href="https://maleek004.github.io/portfolio/#top">here</a>.</p><h4>Moving Forward</h4><p>That’s it for now! I plan to continue updating the website by adding new features and refining the user experience. I’ll be documenting each update, so stay tuned for more!</p><p>Don’t forget to connect with me on <a href="https://www.linkedin.com/in/mubaraq-abdulmaleek/"><em>Linkedin</em></a></p><p>You want to support my work? <a href="http://buymeacoffee.com/mubaraq_abdulmaleek">click here</a></p><p>Thanks for reading, and I’ll catch you in the next one.</p><p><strong>Ciao!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=174361901508" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[End-to-End ETL and Sales Dashboard on WWI dataset in Microsoft Fabric]]></title>
            <link>https://blog.dataengineerthings.org/end-to-end-etl-and-sales-dashboard-on-wwi-dataset-in-microsoft-fabric-01953545172c?source=rss-93243801c802------2</link>
            <guid isPermaLink="false">https://medium.com/p/01953545172c</guid>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[microsoft-fabric]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[AbdulmaLeek Mubaraq]]></dc:creator>
            <pubDate>Mon, 16 Sep 2024 20:55:12 GMT</pubDate>
            <atom:updated>2024-11-07T22:56:22.071Z</atom:updated>
            <content:encoded><![CDATA[<h3>End-to-End ETL and Sales Dashboard Project in Microsoft Fabric</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*QkoiQ4eock6Fn5GqgEWi_Q.png" /></figure><p>In this post I’m going to share a step by step guide on how I created a sales dashboard for the WideWorldImporters sample database using Microsoft Fabric and PowerBI Desktop.</p><blockquote>You can check out <a href="https://medium.com/@mubaraqabdulmaleek/etl-of-wwi-data-from-sql-server-into-a-microsoft-fabric-lakehouse-warehouse-using-dataflow-gen2-aff34d9414b5">this post</a> for a guide on the ETL process to get the datasets from SQLServer into Microsoft Fabric.</blockquote><blockquote>PS: Check out the Github repository for this project <a href="https://github.com/maleek004/WWI-in-Fabric/tree/main">here.</a></blockquote><h3>Business Demand Overview</h3><h4><strong>Business Problem</strong>:</h4><p>The sales team at WideWorldImporters currently lacks a comprehensive and interactive dashboard that provides insights into various aspects of sales performance. This results in delayed decision-making and missed opportunities to optimize sales strategies.</p><h4><strong>Objective</strong>:</h4><p>Develop a dynamic Sales Dashboard that visualizes key sales data from multiple dimensions (e.g., customer, product, region, and time), to enable the sales team to monitor performance, identify trends, and take data-driven actions. The dashboard should be user-friendly, accessible, and updated in real-time.</p><h4><strong>Stakeholders</strong>:</h4><ul><li><strong>Sales Manager</strong>: Needs to monitor overall sales performance and identify areas for improvement.</li><li><strong>Sales Representatives</strong>: Require detailed insights into their respective territories and customer segments.</li><li><strong>Marketing Team</strong>: Interested in understanding customer behavior and product popularity.</li><li><strong>Logistics Team</strong>: Needs data on delivery performance to optimize operations.</li><li><strong>Executives</strong>: Require high-level overviews for strategic decision-making.</li></ul><h3>User Stories</h3><p><strong>User Story 1</strong>: Sales Performance Overview</p><p>“As a Sales Manager, I want to view the Total Sales, Total Profit, and Profit Margin metrics, so that I can quickly assess the overall financial performance of the company.”</p><p><strong>User Story 2</strong>: Regional Sales Analysis</p><p>“As a Regional Sales Director, I want to compare sales performance across different cities and regions, so that I can allocate resources more effectively and target underperforming areas.”</p><p><strong>Acceptance Criteria</strong>:</p><ol><li>The dashboard should provide a map or chart showing sales by region and city.</li><li>Data should be drillable to see sales at the city level.</li><li>Users should be able to compare different regions side-by-side.</li></ol><p><strong>User Story 3</strong>: Sales Trends Analysis</p><p>“As a Business Analyst, I want to analyze trends in Total Sales and Total Profit over time (monthly, quarterly, yearly), So that I can identify periods of strong or weak sales performance and understand seasonal impacts.”</p><p><strong>User Story 4</strong>: Top-Selling Products</p><p>“As a Marketing Analyst, I want to identify the top 10 best-selling products over the past year, so that I can focus our marketing efforts on promoting these products.”</p><p><strong>Acceptance Criteria</strong>:</p><ol><li>The dashboard should list the top 10 products by sales revenue.</li><li>Each product should be clickable to view more detailed information (e.g., sales by region or customer segment).</li><li>The list should update dynamically based on the selected time period.</li></ol><p><strong>User Story 5</strong>: Delivery Performance</p><p>“As a Logistics Manager, I want to track average delivery times for sales orders, so that I can identify and address any bottlenecks in the delivery process.”</p><p><strong>Acceptance Criteria</strong>:</p><ol><li>The dashboard should display the average delivery time per region, product, and time period.</li><li>Users should be able to view trends in delivery performance over time.</li><li>Alerts should be set up for delivery times that exceed a certain threshold.</li></ol><h3>Data Gathering and Preparation</h3><p>The WWI sample database has been restored in SQL Server and imported into Microsoft Fabric, which I documented in the <a href="https://medium.com/@mubaraqabdulmaleek/etl-of-wwi-data-from-sql-server-into-a-microsoft-fabric-lakehouse-warehouse-using-dataflow-gen2-aff34d9414b5">ETL Guide</a><a href="https://www.linkedin.com/posts/a-random-page_microsoftfabric-dataflow-sql-activity-7218930550584074242-BxOw?utm_source=share&amp;utm_medium=member_desktop">.</a> And some preliminary exploration has been done on the datasets using SparkSQL, which i also documented <a href="https://www.linkedin.com/posts/a-random-page_activity-7228696607674777600-oTDC?utm_source=share&amp;utm_medium=member_desktop">here.</a></p><p>The datasets were structured such that the original tables were stored in a warehouse, and a shortcut was created in a lakehouse (in the same Fabric workspace) pointing to those tables. This is because i wanted the tables to stay in a warehouse so that i can potentially run full transactional DDL and DML queries on them, but also wanted the ability to work with the tables in a Lakehouse notebook.</p><p>The dataset was ready for analysis, i just needed one more view/table to add.</p><h3>Creating a new fact_sales View/table</h3><p>Since the fact_sales table doesn’t link directly to the payment methods table (I found out about this in my previous analysis of the tables), i wanted to create a view that adds the payment method key to each sales transaction (i.e each row) in the sales table (the payment method key can be gotten from the transactions table which i will not be bringing into my semantic model for the sales report).</p><p>These were the steps i took:</p><ul><li>Wrote a cross database query that creates a view in my lakehouse using both the sales and transactions tables from the warehouse (a view can be created in a lakehouse from the SQL analytics endpoint)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/0*Qe5RApa2D93p7mf4" /></figure><ul><li>Wanted to add the new ‘FactSales’ view as part of the model for the report but received a warning that having a view in my semantic model might have some performance implications</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/0*GagZbThspT7kffJK" /></figure><p>So now i have to create a ‘FactSales’ table instead. And since you can not create a table from a Lakehouse’s SQL endpoint, i could either create it from a notebook using spark or from a warehouse using T-SQL.</p><ul><li>While trying to create the new ‘FactSales’ table from a notebook (tables created in a notebook are stored as delta tables in the lakehouse), i will have to enable <strong>column mapping</strong> because the column names from the source tables (i mean the warehouse tables that the shortcuts are pointing to) has spaces in them, and <a href="https://fabric.guru/thoughts-on-spaces-in-workspace-and-column-names-in-microsoft-fabric">Delta tables by default do not allow special characters, including spaces, in column names</a>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*j-cnv0V3as3DbOdn" /></figure><p>But enabling column mapping will make the table unusable in the workspace’s Warehouse, T-SQL endpoint and in semantic models, because they all do not support column mapping.</p><figure><img alt="fabric warehouse interface showing an errr message because a query references a table that uses column mapping, from a lakehouse." src="https://cdn-images-1.medium.com/max/744/0*SIO1oFT7w2mQq1KZ" /></figure><ul><li>So i ended up creating the new FactSales table in the warehouse (under a new schema) and created a shortcut to it from the lakehouse (just like the other tables in the lakehouse).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/0*lLQ3dN54-l42X2B4" /></figure><h3>Creating and preparing a semantic model</h3><ul><li>I created a new custom D<strong>irect Lake semantic model </strong>(from the lakehouse) using the new FactSales table and other dimension tables needed for the report.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/0*PKDkPFFXF8g324NV" /></figure><ul><li>Defined relationship between tables in the semantic model.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*PXkvhrb-UhbVbsrB" /></figure><ul><li>Created some measures for the semantic model right there in Fabric</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/0*RsdWyR95VSw_xVsO" /></figure><ul><li>Changed the data category of the city column to ‘City’ .</li><li>Sorted the ‘month’ column in the date dimension table by the ‘month number’ column so that it gets ordered correctly on visuals</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*QVss4c23WuwTp9I5" /></figure><ul><li>Connected PowerBI desktop to the direct lake semantic model created earlier</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*_BGPDXCnIEpyz-9l" /></figure><ul><li>Created some measures within PowerBI desktop as well .</li></ul><h3>Creating a report in PowerBI desktop and a documentation on how to use it for stakeholders</h3><p>Below are the visuals created for the different user stories in the project, including notes on how to use them, and other necessary descriptions.</p><p><strong>KPI Card for User Story 1 </strong>(for Sales Manager):</p><ul><li>Created a dynamic KPI card that displays the Total Sales, Total Profit, and Profit Margin metrics for the Sales manager</li><li>It can be filtered by year , month , customer , product and sales territory</li><li>The indicator color of the card visual changes to red for any filter where the profit margin drops below 30%</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/0*e4pPpHQGhfsd2dzn" /></figure><p><strong>Map Visual for User Story 2 </strong>(for Regional Sales Director):</p><ul><li>Created a map visual that shows sales across different cities</li><li>It can be drilled up and down between the city and country level</li><li>The tooltip for this visual also shows profit for the location hovered over</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/0*z7_cNduHZyLsTsMs" /></figure><p><strong>Area Chart for User story 3</strong> (Business Analyst):</p><ul><li>Created an area chart showing sales and profit trend by month</li><li>Can be drilled up or down between month and year</li><li>Can be filtered by customer , product and sales territory</li></ul><p><strong>Bar Chart for User story </strong>4 (Marketing Analyst):</p><ul><li>Created a Bar Chart that shows the Top 10 best selling products</li><li>The tooltip for the visual also shows the total quantity sold for a product as well as its unit price</li><li>Can be filtered by Time , Region and every other slicer on the report</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/0*r6_u6i1ZSNSd3q4U" /></figure><p><strong>Table Visual for User Story 5</strong>(for Logistics Manager ):</p><ul><li>Created a table that shows the average delivery day for each product compared to it’s expected delivery days</li><li>Can be filtered by region and time</li><li>Created a data activator alert on the visual that sends an email once the average delivery days for any product become more than a day</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*SmU9_2c3WdydTtPj" /></figure><h3>The Final dashboard</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*bYop6mOwgByAdlYJ" /></figure><p><a href="https://app.powerbi.com/reportEmbed?reportId=7ca2a387-be9e-41e7-b0a5-5b9d42dd3c37&amp;autoAuth=true&amp;ctid=74a63f52-0cf3-4211-b66a-93c49f69cf62">Microsoft Power BI</a></p><p>END!</p><p>Don’t forget to connect with me on <a href="https://www.linkedin.com/in/mubaraq-abdulmaleek/"><em>Linkedin</em></a></p><p>You want to support my work? <a href="http://buymeacoffee.com/mubaraq_abdulmaleek"><em>click here</em></a></p><p>Thanks for reading, and i’ll catch you in the next one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01953545172c" width="1" height="1" alt=""><hr><p><a href="https://blog.dataengineerthings.org/end-to-end-etl-and-sales-dashboard-on-wwi-dataset-in-microsoft-fabric-01953545172c">End-to-End ETL and Sales Dashboard on WWI dataset in Microsoft Fabric</a> was originally published in <a href="https://blog.dataengineerthings.org/">Data Engineer Things</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ETL of WWI data from SQL Server into a Microsoft Fabric Lakehouse / Warehouse using Dataflow Gen2]]></title>
            <link>https://blog.dataengineerthings.org/etl-of-wwi-data-from-sql-server-into-a-microsoft-fabric-lakehouse-warehouse-using-dataflow-gen2-aff34d9414b5?source=rss-93243801c802------2</link>
            <guid isPermaLink="false">https://medium.com/p/aff34d9414b5</guid>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[microsoft-fabric]]></category>
            <category><![CDATA[dataflow]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <dc:creator><![CDATA[AbdulmaLeek Mubaraq]]></dc:creator>
            <pubDate>Mon, 16 Sep 2024 20:09:34 GMT</pubDate>
            <atom:updated>2024-10-30T23:30:52.495Z</atom:updated>
            <content:encoded><![CDATA[<h3>ETL of WWI data from SQL Server into a Microsoft Fabric Lakehouse / Warehouse using Dataflow Gen2 : A Quick Guide.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*HSLb-JPCZJaBvXpiW3W4hw.png" /></figure><h4>Introduction</h4><p>In this post I am going to share a step by step guide on how to easily ingested data from an on premise SQL server into a Microsoft Fabric lakehouse or warehouse using Dataflow Gen2. I’m also going to share how to quickly copy queries from one dataflow to another.</p><h4>Prerequisites</h4><p>For this demo I will be using the WideWorldImporters sample database, which you can learn more about and download <a href="https://learn.microsoft.com/en-us/sql/samples/wide-world-importers-dw-install-configure?view=sql-server-ver16&amp;tabs=sql-server">here</a></p><p>If you are reading this I’m sure you are already familiar with Microsoft Fabric and Dataflow Gen2. But if not, you can check out these ‘Learn Together ’ youtube videos by Microsoft experts: <a href="https://www.youtube.com/watch?v=oFRxuQ7e0E4&amp;list=PL1N57mwBHtN0-AJVURyfqbdmX65JMXSVv&amp;index=21">Fabric &amp; Lakehouses</a> , <a href="https://www.youtube.com/watch?v=EpO0l-CJ1_g">Dataflow</a>.</p><p>Now, these are the steps I took:</p><h4>Setting up SQL Server and a Microsoft Fabric workspace</h4><ul><li>I downloaded the WWI backup file and restored it in SQL Server</li><li>Updated my data gateway app. Learn more about connecting Fabric to on-premise data sources <a href="https://learn.microsoft.com/en-us/fabric/data-factory/how-to-access-on-premises-data">here</a></li><li>Created a new workspace and lakehouse in Microsoft Fabric</li><li>Created a new connection to my SQL server database in Fabric, using my on-premise gateway. this is the connection at the end:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*z1hIJh4nhrtXWRfH" /></figure><h4><strong>Configuring a first Dataflow Gen2 for data ingestion into the Lakehouse</strong></h4><ul><li>I created a dataflow that connects to my on premise SQL Server database using the connection I created in the previous step.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/0*HqEf7vHgszNITdC-" /></figure><ul><li>Renamed the dimension tables (Shortened &#39;Dimension&#39; to &#39;Dim&#39; in the table names) this is just to demonstrate a simple ‘Transformation’ in the process.</li><li>Chose the lakehouse I created earlier as the destination for each query within the DataflowGen2 editor (A destination has to be manually set for eac query in a dataflow one after the other).</li><li>Published the Dataflow to begin the ingestion.</li><li>Assigned both the Dataflow and Lakehouse as items in a ‘Get Data’ and ‘Store’ tasks respectively in a task flow in the Microsoft fabric warehouse. Learn more about task flows in Microsoft Fabric <a href="https://learn.microsoft.com/en-us/fabric/get-started/task-flow-work-with">here</a>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*7mA5v1-gOnlWimZb" /></figure><h4>Configuring a second dataflow for data ingestion into the warehouse</h4><p>Since I wanted to practice ingestion into a Warehouse with the same datasets I used for the lakehouse, I could have used the same dataflow and just changed the destination for each query to the new target warehouse then refreshed the dataflow, but going through each query to do that would take a lot of time. So I took a faster route following these steps:</p><p><strong>Copying queries from one Dataflow (or Power Query) to another in 3 steps</strong></p><ol><li>Selected and copied all the queries from the first dataflow</li><li>Created a new dataflow from the target warehouse’s explorer. Doing this automatically sets that warehouse as the destination for all queries in the dataflow</li><li>Pasted the queries from the first dataflow into the new one and published it.</li></ol><p>And that was it, the datasets were ingested into the warehouse and the lakehouse simultaneously.</p><p>Then I created task flow items in the workspace with appropriate description for both ingestions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*AgH2FnKrU37ihwly" /></figure><p>Don’t forget to connect with me on <a href="https://www.linkedin.com/in/mubaraq-abdulmaleek/"><em>Linkedin</em></a></p><p>You want to support my work? <a href="http://buymeacoffee.com/mubaraq_abdulmaleek">click here</a></p><p>Thanks for reading, and I’ll catch you in the next one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aff34d9414b5" width="1" height="1" alt=""><hr><p><a href="https://blog.dataengineerthings.org/etl-of-wwi-data-from-sql-server-into-a-microsoft-fabric-lakehouse-warehouse-using-dataflow-gen2-aff34d9414b5">ETL of WWI data from SQL Server into a Microsoft Fabric Lakehouse / Warehouse using Dataflow Gen2</a> was originally published in <a href="https://blog.dataengineerthings.org/">Data Engineer Things</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>