<?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 Gurleenkaurbali on Medium]]></title>
        <description><![CDATA[Stories by Gurleenkaurbali on Medium]]></description>
        <link>https://medium.com/@gurleenkaurbali20?source=rss-fb633207579f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ksbPPMFJbg864MHm</url>
            <title>Stories by Gurleenkaurbali on Medium</title>
            <link>https://medium.com/@gurleenkaurbali20?source=rss-fb633207579f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 16:21:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gurleenkaurbali20/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[What I Learned About Data Modeling]]></title>
            <link>https://medium.com/@gurleenkaurbali20/what-i-learned-about-data-modeling-4a408a8157d0?source=rss-fb633207579f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a408a8157d0</guid>
            <category><![CDATA[data-modeling]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Gurleenkaurbali]]></dc:creator>
            <pubDate>Fri, 04 Sep 2026 12:37:56 GMT</pubDate>
            <atom:updated>2026-09-04T12:37:56.365Z</atom:updated>
            <content:encoded><![CDATA[<p>Every dashboard you’ve ever opened, every SQL query you’ve ever run, every Power BI report that just <em>worked, </em>none of that happened by accident. Behind all of it sits a decision, usually made long before anyone touched a chart, about how the underlying data should be structured and connected.</p><p>That decision-making process is called <strong>data modeling</strong>, and it’s one of those topics that quietly underpins almost everything in analytics and engineering, yet rarely gets talked about outside of database courses. I spent the last few weeks studying it properly, not just enough to define the terms, but enough to understand <em>why</em> each concept exists and what problem it solves. This article is my attempt to walk through what I learned, in the order it actually clicked for me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*nNp9q6oekCWffkFR1x0Dcw.png" /></figure><blockquote><strong>Why data modeling matters in the first place</strong></blockquote><p>Imagine a database with no plan behind it, tables added ad hoc, columns duplicated across different places, no clear rules about how a customer relates to an order. It might work for a while. But the moment you need to scale it, query it reliably, or hand it off to someone else, the cracks show: inconsistent data, slow queries, and reports that don’t agree with each other.</p><p>Data modeling exists to prevent exactly that. It’s the process of creating a structured representation of your data and the relationships within it — a blueprint that determines how data is organized, stored, and accessed before a single table gets built. Get the model right, and everything downstream - queries, dashboards, applications, becomes easier to build and trust. Get it wrong, and you spend your time fighting the data instead of using it.</p><blockquote><strong>The three levels of a data model</strong></blockquote><p>One of the more useful mental shifts I picked up is that “a data model” isn’t one single thing, it exists at three different levels of abstraction, each one closer to the physical database than the last.</p><p><strong>Conceptual data model.</strong> This is the big-picture view. It defines the entities that matter to the business; Customer, Order, Product, and how they relate to each other, without touching any technical detail. No data types, no keys, no tables. If you’re in a room with business stakeholders sketching out “a customer places orders, an order contains products,” you’re working at the conceptual level.</p><p><strong>Logical data model.</strong> This is one layer more detailed. It specifies the attributes each entity has, the relationships between them, and any constraints, but it’s still independent of any particular database technology. A logical model might say “Customer has a Customer_ID, Name, and Email, and Customer_ID is unique” without caring whether that ends up in PostgreSQL, MySQL, or Snowflake.</p><p><strong>Physical data model.</strong> This is the model as it actually gets implemented. It defines the real table structures, column data types, indexes, and storage mechanisms needed to make the database perform well and stay consistent. This is where the logical design gets translated into something a database engine can actually run.</p><p>A useful analogy: designing a house starts with a concept sketch (rooms and how they connect), moves to a detailed blueprint (exact measurements, wiring, plumbing), and ends with the actual building. Same idea, three levels of resolution.</p><blockquote><strong>Entity-Relationship (ER) modeling</strong></blockquote><p>ER modeling is probably the most familiar data modeling technique, and it’s usually where conceptual and logical models take shape. It revolves around three building blocks:</p><ul><li><strong>Entities</strong> — the “things” in your system: Customer, Product, Order.</li><li><strong>Attributes</strong> — the properties that describe an entity, like a Customer’s name, age, or phone number.</li><li><strong>Relationships</strong> — how entities connect to each other.</li></ul><p>Take a simple online store as an example:</p><ul><li><strong>Product</strong>: name, price</li><li><strong>Order</strong>: order ID, location, customer ID, date</li><li><strong>Customer</strong>: name, address, email</li></ul><p>The relationships between them might look like:</p><ul><li>A customer <em>places</em> orders — a <strong>one-to-many</strong> relationship, since one customer can place many orders, but each order belongs to one customer.</li><li>An order <em>contains</em> products — a <strong>many-to-many</strong> relationship, since one order can include multiple products, and a single product can appear across many orders.</li></ul><p>This is the level of modeling most people picture when they hear “database design,” and it’s the foundation that most relational databases are built on.</p><blockquote><strong>Dimensional modeling: the backbone of analytics</strong></blockquote><p>If ER modeling is the foundation for transactional systems, <strong>dimensional modeling</strong> is the one that matters most once you move into analytics and reporting, which is exactly why it’s worth understanding well if you’re learning SQL and Power BI.</p><p>Dimensional modeling organizes data into two main types of tables:</p><p><strong>Fact tables</strong> sit at the center of the model and hold the transactional, measurable data, things you can sum, average, or count. Sales amount, quantity sold, order total, timestamps. These are the numbers a report is actually reporting on.</p><p><strong>Dimension tables</strong> surround the fact table and hold the descriptive, contextual attributes that give those numbers meaning; the <em>who, what, where,</em> and <em>when</em>. A dimension table isn’t just “categorical data” in a loose sense; it’s the structured context (customer details, product attributes, store location, calendar dates) that lets you slice and filter the numbers in the fact table.</p><p>For a sales database, that might look like:</p><ul><li><strong>Fact table</strong>: Sales (order amount, quantity, date key, customer key, product key)</li><li><strong>Dimension tables</strong>: Customer, Product, Time, Store</li></ul><p>Arranged together, this creates a <strong>star schema, </strong>dimension tables connected directly to a central fact table, like spokes on a wheel. When a dimension table itself gets broken down further into related sub-tables (say, Product splits into Product and Category), the structure becomes a <strong>snowflake schema, </strong>more normalized, but with a few more joins to traverse.</p><p>This is exactly why a well-built Power BI data model, one built around a clear star schema, feels so much faster and easier to work with than a single sprawling flat table trying to do everything at once. The separation between “the numbers” (fact table) and “the context” (dimension tables) is what makes filtering, slicing, and aggregating fast and intuitive.</p><blockquote><strong>Object-oriented data modeling</strong></blockquote><p>Object-oriented modeling takes a different angle: instead of just tables and rows, it treats data as <strong>objects, </strong>things that carry both data <em>and</em> behavior. An object combines its attributes (data) with methods (functions or actions it can perform), and the model describes how these objects interact.</p><p>A car, for example, is an object: it has data like color, model, and speed, and behaviors like start(), accelerate(), and stop().</p><p>Applied to something like a library system, the objects might be:</p><ul><li><strong>Book</strong>: name, author, print date, ISBN, with behaviors like checkOut() and return()</li><li><strong>Member</strong>: name, number, email, phone, age, with behaviors like borrow() and return()</li><li><strong>Librarian</strong>: name, contact, employee ID, with behaviors like addBook() and removeBook()</li></ul><p>This style of modeling shows up far more often in software engineering and application design than in analytics, but it’s useful to understand because it explains how systems bundle data together with the logic that acts on it, a different mental model from the purely structural one that ER and dimensional modeling use.</p><blockquote><strong>NoSQL data modeling</strong></blockquote><p>Everything above assumes a fairly rigid structure, fixed tables, fixed columns. NoSQL modeling throws that assumption out. NoSQL databases are built for data that doesn’t have or doesn’t need a fixed schema: data that changes shape over time or needs to scale flexibly.</p><p>In a document-based NoSQL database like MongoDB, data is organized into collections of documents, and each document can have its own structure. Instead of splitting a user’s information across multiple related tables the way a relational database would, a single JSON-like document can hold everything about that user in one place:</p><pre>{<br>  &quot;user_id&quot;: 123,<br>  &quot;name&quot;: &quot;Alice Smith&quot;,<br>  &quot;email&quot;: &quot;alice@example.com&quot;,<br>  &quot;address&quot;: {<br>    &quot;street&quot;: &quot;123 Main St&quot;,<br>    &quot;city&quot;: &quot;New York&quot;,<br>    &quot;zip&quot;: &quot;10001&quot;<br>  },<br>  &quot;purchases&quot;: [<br>    { &quot;product_id&quot;: 101, &quot;price&quot;: 19.99 },<br>    { &quot;product_id&quot;: 202, &quot;price&quot;: 49.99 }<br>  ]<br>}</pre><p>This flexibility makes NoSQL well suited to applications that need fast iteration or need to scale across large, less predictable datasets at the cost of some of the structural guarantees a relational database provides.</p><blockquote><strong>How the levels and techniques connect</strong></blockquote><p>Putting it all together, here’s how the three levels of abstraction map onto the modeling techniques:</p><ul><li><strong>Conceptual data model → ER modeling.</strong> Defines high-level business entities and relationships without technical detail, think of an ER diagram showing how Customers, Orders, and Products relate.</li><li><strong>Logical data model → ER, dimensional, and object-oriented modeling.</strong> Specifies structure, attributes, and constraints without locking into a specific storage engine, like a star schema outlining a Sales fact table connected to Time, Product, and Customer dimensions.</li><li><strong>Physical data model → dimensional, object-oriented, and NoSQL modeling.</strong> Represents how data is actually stored and optimized, an indexed relational schema in PostgreSQL, or a MongoDB document storing a flexible user profile.</li></ul><blockquote><strong>Normalization vs. denormalization</strong></blockquote><p>This is the trade-off that ties the whole topic together, and it’s the one I initially misunderstood the most.</p><p><strong>Normalization</strong> means breaking data into multiple related tables to remove duplication and improve consistency. It’s the default approach for transactional systems (OLTP), where accuracy and update-safety matter most.</p><p>For example, instead of repeating a customer’s name and email on every single order row, you normalize by separating the data:</p><pre>Customers(Customer_ID, Name, Email)<br>Orders(Order_ID, Customer_ID, Product, Price)</pre><p>Now a customer’s details live in exactly one place. Update their email once, and every order referencing that Customer_ID reflects it, no redundant data, no risk of one order row saying “Alice” and another saying “Alice Smith” for the same person.</p><p><strong>Denormalization</strong> goes the other way: combining data into fewer tables to reduce the number of joins needed, which improves query performance. This is the approach reporting and analytics systems often favor. Instead of joining Customers, Orders, and Products every time a dashboard refreshes, a pre-aggregated, denormalized table can serve the same query dramatically faster.</p><p>I used to think normalization was simply “the correct way” to design a database and denormalization was a shortcut people took when they were being lazy. What actually changed my mind was realizing it isn’t about right or wrong at all, it’s about <em>purpose</em>. A banking system needs normalization to avoid data anomalies when money is involved. A dashboard that refreshes every morning needs denormalization so it doesn’t grind to a halt running the same seven joins on every load. Same underlying data, completely different priorities depending on what you’re optimizing for.</p><blockquote><strong>Where this connects back to analytics and reporting</strong></blockquote><p>If you’re learning SQL, Power BI, or any BI tool, the concept that will save you the most time is dimensional modeling. Almost every well-designed semantic model or Power BI dataset you’ll encounter is, underneath, a star schema, a fact table of measures surrounded by dimension tables of context. Once you can recognize that shape, you can look at <em>any</em> dashboard and immediately guess how the underlying tables are probably structured, long before you ever see the data model view.</p><p>Understanding normalization vs. denormalization also explains a pattern that confuses a lot of people early on: why does the source database look nothing like the reporting tables built on top of it? It’s not an inconsistency, it’s two systems optimized for two different jobs. The transactional database is normalized for accuracy. The reporting layer is denormalized (or built as a star schema) for speed and usability.</p><blockquote><strong>A reflection</strong></blockquote><p>What surprised me most about studying this topic wasn’t any single concept, it was realizing how much of “good data work” is really just picking the right model for the job, rather than following one universally correct pattern. Every technique here; ER, dimensional, object-oriented, NoSQL, normalized, denormalized, is a deliberate trade-off, not a rulebook. Once that reframing clicked, dashboards, schemas, and even messy legacy databases started making a lot more sense: they’re not random, they’re decisions someone made, for reasons that usually become obvious once you know what to look for.</p><p>I still have a lot more to learn here, but for the first time, I feel like I’m looking at data instead of just looking through it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a408a8157d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Was Confused by async/await in Python — Here’s What Finally Made It Click]]></title>
            <link>https://medium.com/@gurleenkaurbali20/i-was-confused-by-async-await-in-python-heres-what-finally-made-it-click-ef3528321766?source=rss-fb633207579f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef3528321766</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[asynchronous-programming]]></category>
            <category><![CDATA[await]]></category>
            <category><![CDATA[confusion]]></category>
            <category><![CDATA[async]]></category>
            <dc:creator><![CDATA[Gurleenkaurbali]]></dc:creator>
            <pubDate>Thu, 11 Jun 2026 06:10:00 GMT</pubDate>
            <atom:updated>2026-06-11T06:10:00.775Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A beginner’s guide to asynchronous programming, written by someone who was just as lost as you are right now.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bi0sYc8YyT-nWTDz" /></figure><p><em>I was studying asynchronous programming in Python. I understood the concept vaguely — “it runs things simultaneously, it’s faster, etc.” But the moment I sat down to actually write code, I hit a wall.</em></p><p><em>Two </em><em>await keywords. One inside the function, one outside. Why? Aren&#39;t they doing the same thing? And what even IS an event loop? And why does </em><em>asyncio.run() break in Google Colab??</em></p><p><em>I had so many questions. So I went down the rabbit hole, broke a lot of code, confused myself thoroughly, and eventually — it clicked.</em></p><p><em>This article is me handing you the map I wish I had.</em></p><h4>First, Why Does async Even Exist?</h4><p><em>Imagine you’re making a web app. A user clicks a button, your code fires an API request, and now your entire program just… sits there. Waiting. The CPU is idle. Nothing else can run. The user is staring at a loading spinner.</em></p><p><em>That’s </em><strong><em>synchronous</em></strong><em> (normal) programming. One thing at a time, in order. Each line waits for the previous one to finish.</em></p><pre>data = fetch_from_api()   # whole program freezes until this returns<br>process(data)              # only starts after the above is done</pre><p><em>This is fine for simple scripts. But what if you have 10 API calls to make? You’d wait for each one sequentially. Slow, wasteful, inefficient.</em></p><p><strong><em>Asynchronous programming</em></strong><em> solves this. Instead of freezing and waiting, your program says:</em></p><blockquote><strong>“This is going to take a while. Go do something else. I’ll let you know when I’m done.”</strong></blockquote><p><em>The CPU doesn’t sit idle. Other tasks run in the meantime. When the slow thing finishes, you pick up from where you left off.</em></p><p><em>That’s the whole idea. Everything else is just the mechanics of how to do it.</em></p><h4>The Terms (Simply Explained)</h4><p><em>Before we write code, let’s get three terms out of the way. I’ll keep it short.</em></p><p><strong><em>Coroutine</em></strong><em> — a function defined with </em><em>async def. It&#39;s a function that can pause and resume. Not that it always will — but it has that capability.</em></p><pre>async def say_hello():   # this is a coroutine<br>    print(&quot;Hello!&quot;)</pre><p><strong><em>Event Loop</em></strong><em> — think of it as the engine running everything. It manages all your coroutines, decides which one runs next, and switches between them when one is waiting. You don’t interact with it directly much — it works in the background.</em></p><p><strong><em>await</em></strong><em> — the keyword that says “this might take time.” When the program hits an </em><em>await, it can pause that coroutine and let the event loop run something else. We&#39;ll go much deeper on this — it&#39;s where I got confused too.</em></p><h3>Your First async Function</h3><pre>import asyncio<br><br>async def say_hello():      # say_hello is a coroutine<br>    print(&quot;Starting...&quot;)<br>    await asyncio.sleep(2)  # pause here for 2 seconds<br>    print(&quot;Hello world&quot;)<br><br>async def main():           # another coroutine<br>    await say_hello()<br><br>await main()   # how we run it in Google Colab<br><br># Output:<br># Starting...<br># Hello world</pre><p>Straightforward enough. But wait — why are there <strong>two</strong> await keywords? One inside say_hello, one when calling it. Are they doing the same thing?</p><p>No. And this is exactly where I got confused. Let’s fix that.</p><h4>The “Two Awaits” Confusion (The Thing Nobody Explains Clearly)</h4><p><em>When I first saw this, my brain said:</em></p><blockquote>“There are two await keywords — one inside the function, one outside. Are they doing the same thing? Why do we need both?&quot;</blockquote><p><em>They look identical. But they’re working at different levels.</em></p><h4>The Outer await task()</h4><pre>async def main():<br>    await task()<br>    print(&quot;Done&quot;)</pre><p><em>main() is saying:</em></p><blockquote>“Run the coroutine task() and don&#39;t let me continue until it is completely finished.&quot;</blockquote><p><em>This </em><em>await is for the </em><strong><em>caller</em></strong><em>. </em><em>main will not print </em><em>&quot;Done&quot; until </em><em>task() is fully done.</em></p><h4>The Inner await asyncio.sleep(2)</h4><pre>async def task():<br>    print(&quot;Starting...&quot;)<br>    await asyncio.sleep(2)<br>    print(&quot;Completed&quot;)</pre><p><em>task() is saying:</em></p><blockquote>“I cannot continue right now. Give control back to the event loop.”</blockquote><p><em>This is the </em><strong><em>actual suspension point</em></strong><em>. This is where the event loop can switch to another coroutine and do something useful instead of sitting idle.</em></p><h4>The Mental Model</h4><pre>Event Loop<br>    |<br>    └── task()<br>           |<br>           └── await asyncio.sleep(2)</pre><p><em>The outer </em><em>await task() is saying to the event loop:</em></p><blockquote><strong>“Run task and tell me when it’s finished.”</strong></blockquote><p><em>The inner </em><em>await asyncio.sleep(2) is task saying to the event loop:</em></p><blockquote><strong>“I am waiting. You can run something else for now.”</strong></blockquote><p><strong><em>The one-liner:</em></strong><em> The outer </em><em>await waits for the coroutine to finish, while the inner </em><em>await marks where the coroutine can pause and give control back to the event loop.</em></p><p><em>So during those 2 seconds:</em></p><pre>main        → waiting for task<br>task        → waiting for sleep<br>event loop  → free to run other coroutines</pre><p><em>That’s the important picture.</em></p><h4>But Why Make the Function async at All?</h4><p><em>This was my next question.</em></p><p><em>Simple answer: </em><strong><em>you cannot use </em></strong><strong><em>await inside a regular function.</em></strong><em> Python will throw a SyntaxError.</em></p><pre>def say_hello():<br>    await asyncio.sleep(2)  # ❌ SyntaxError — can&#39;t use await here</pre><p><em>async def is the prerequisite. It tells Python:</em></p><blockquote>“This function may pause at some point. Don’t treat it like a normal function that runs start to finish. Make it a coroutine — something the event loop knows how to pause and resume.”</blockquote><p><em>In real code, you wouldn’t use </em><em>asyncio.sleep — that&#39;s just a fake stand-in for something slow. In practice it would be an API call, a database query, a file read:</em></p><pre>async def get_user():<br>    response = await call_some_api()   # the real slow thing<br>    return response</pre><p><em>The </em><em>async on the function is just the declaration: &quot;hey, somewhere inside me I&#39;m going to wait on something slow.&quot; And </em><em>await inside it is where that waiting actually happens.</em></p><h4>The Google Colab Confusion</h4><p><em>Here’s something that tripped me up specifically because I was coding in Google Colab.</em></p><p><em>In a normal Python script, you start everything with:</em></p><pre>asyncio.run(main())</pre><p><em>asyncio.run() does three things:</em></p><ol><li><em>Creates a new event loop</em></li><li><em>Runs your coroutine on it</em></li><li><em>Closes the loop when done</em></li></ol><p><em>But in Google Colab — and Jupyter notebooks in general — </em><strong><em>there’s already a running event loop.</em></strong><em> It’s built into the notebook environment.</em></p><p><em>So when you try </em><em>asyncio.run() in Colab, Python goes:</em></p><pre>RuntimeError: asyncio.run() cannot be called from a running event loop</pre><p><em>That’s why in Colab you just write:</em></p><pre>await main()   # directly, no asyncio.run() needed</pre><p><em>You’re already inside a running event loop. You just hook into it.</em></p><p><em>This is also what created my “two awaits” confusion. The </em><em>await main() in Colab looked like it meant the same thing as the </em><em>await inside the function — but it was actually serving a completely different purpose. One was starting the coroutine (because </em><em>asyncio.run() wasn&#39;t available). The other was the actual pause point.</em></p><p><em>Same keyword. Completely different jobs. No wonder it was confusing.</em></p><h4>Still Sequential — The Concurrency Problem</h4><p><em>Okay so far so good. But here’s a trap:</em></p><pre>async def main():<br>    await task1()<br>    await task2()<br>    await task3()</pre><p><em>This looks async. It uses </em><em>await and everything. But it&#39;s still </em><strong><em>sequential.</em></strong></p><p><em>main waits for </em><em>task1 to fully finish, then starts </em><em>task2, then starts </em><em>task3. Total time = task1 time + task2 time + task3 time.</em></p><pre>async def task1():<br>    print(&quot;Task 1 starting...&quot;)<br>    await asyncio.sleep(4)<br>    print(&quot;Task 1 completed&quot;)<br>async def task2():<br>    print(&quot;Task 2 starting...&quot;)<br>    await asyncio.sleep(2)<br>    print(&quot;Task 2 completed&quot;)<br>async def task3():<br>    print(&quot;Task 3 starting...&quot;)<br>    await asyncio.sleep(1)<br>    print(&quot;Task 3 completed&quot;)<br>async def main():<br>    await task1()<br>    await task2()<br>    await task3()<br>await main()<br># Output:<br># Task 1 starting...<br># Task 1 completed       ← waits 4 seconds<br># Task 2 starting...<br># Task 2 completed       ← waits 2 more seconds<br># Task 3 starting...<br># Task 3 completed       ← waits 1 more second<br># Total: 7 seconds</pre><p><em>For real concurrency — running things simultaneously — you need </em><em>asyncio.gather().</em></p><h4>asyncio.gather() — The Real Concurrency</h4><p><em>gather() takes multiple coroutines and runs them all at once:</em></p><pre>async def main():<br>    print(&quot;Starting main...&quot;)<br>    await asyncio.gather(task1(), task2(), task3())<br>    print(&quot;All tasks completed&quot;)<br>await main()<br># Output:<br># Starting main...<br># Task 1 starting...<br># Task 2 starting...<br># Task 3 starting...<br># Task 3 completed    ← finished first (1 second)<br># Task 2 completed    ← finished second (2 seconds)<br># Task 1 completed    ← finished last (4 seconds)<br># All tasks completed<br># Total: 4 seconds (not 7!)</pre><p><em>All three started together. The shortest finished first. Total time = the longest task, not the sum of all.</em></p><p><em>That’s actual asynchronous programming.</em></p><h4>Bonus: gather() can collect return values too</h4><pre>async def calculate_sum():<br>    print(&quot;Calculating sum...&quot;)<br>    await asyncio.sleep(4)<br>    return 2 + 3<br>async def calculate_product():<br>    print(&quot;Calculating product...&quot;)<br>    await asyncio.sleep(2)<br>    return 2 * 3<br>async def main():<br>    results = await asyncio.gather(calculate_sum(), calculate_product())<br>    print(&quot;Results:&quot;, results)<br>await main()<br># Output:<br># Calculating sum...<br># Calculating product...<br># Results: [5, 6]</pre><p><em>gather() returns a list of results in the same order you passed the coroutines — even if they finished in a different order.</em></p><h4>asyncio.create_task() — For More Control</h4><p><em>gather() is great for &quot;run these all at once and wait for everything.&quot; But sometimes you want more control — start a task, let it run in the background, and collect the result later when you need it.</em></p><p><em>That’s </em><em>create_task():</em></p><pre>async def task1():<br>  print(&quot;Task 1 starting...&quot;)<br>  await asyncio.sleep(4)<br>  print(&quot;Task 1 completed&quot;)<br>async def task2():<br>  print(&quot;Task 2 starting...&quot;)<br>  await asyncio.sleep(2)<br>  print(&quot;Task 2 completed&quot;)<br>async def task3():<br>  print(&quot;Task 3 starting...&quot;)<br>  await asyncio.sleep(1)<br>  print(&quot;Task 3 completed&quot;)<br>async def main():<br>    print(&quot;Main starting...&quot;)<br>    t1 = asyncio.create_task(task1())   # scheduled, starts immediately<br>    print(&quot;Task 1 is running in the background&quot;)<br>    t2 = asyncio.create_task(task2())   # scheduled, starts immediately<br>    print(&quot;Task 2 is running in the background&quot;)<br>    t3 = asyncio.create_task(task3())   # scheduled, starts immediately<br>    print(&quot;Task 3 is running in the background&quot;)<br>    await t1   # now collect<br>    await t2<br>    await t3<br>    print(&quot;All tasks completed&quot;)<br>await main()<br># Output:<br># Main starting...<br># Task 1 is running in the background<br># Task 2 is running in the background<br># Task 3 is running in the background<br># Task 1 starting...<br># Task 2 starting...<br># Task 3 starting...<br># Task 3 completed<br># Task 2 completed<br># Task 1 completed<br># All tasks completed</pre><p><em>The tasks are scheduled and running the moment </em><em>create_task() is called. The </em><em>await later is just you saying &quot;okay I need the result now.&quot;</em></p><h4>The Mental Model — Everything Together</h4><p><em>Here’s the complete picture in one place:</em></p><pre>async def task()<br>    → &quot;I contain slow operations. I&#39;m a coroutine.&quot;<br>await task()<br>    → &quot;Start running this. I&#39;ll wait here for the result.&quot;<br>await asyncio.sleep() / await api_call() / await db_query()<br>    → &quot;THIS is the actual pause. Event loop, go do other things.&quot;<br>asyncio.gather(task1(), task2())<br>    → &quot;Run all of these concurrently. Wait for all to finish.&quot;<br>asyncio.create_task(task())<br>    → &quot;Schedule this. It runs in background. I&#39;ll collect it later.&quot;<br>asyncio.run(main())<br>    → &quot;Create an event loop, run everything, close when done.&quot;<br>    → (Don&#39;t use in Colab - event loop already exists there)</pre><h4>One Last Thing — What async is Actually For</h4><p><em>async works best with </em><strong><em>I/O bound tasks</em></strong><em> — things where your code is waiting for something external:</em></p><ul><li><em>API calls</em></li><li><em>Database queries</em></li><li><em>File reads/writes</em></li><li><em>Network requests</em></li></ul><p><em>It does NOT help with </em><strong><em>CPU bound tasks</em></strong><em> — heavy computation, image processing, ML training. For those, you’d use multiprocessing instead.</em></p><p><em>The key insight: async is useful when your code is waiting, not when it’s working. If the CPU is busy, async won’t help. If the CPU is sitting idle waiting for a response — async is exactly the tool.</em></p><h4>Wrapping Up</h4><p><em>When I started studying this, I had one specific confusion that nobody seemed to address directly: </em><strong><em>why are there two </em></strong><strong><em>await keywords, and are they doing the same thing? </em></strong><em>Once that clicked, everything else fell into place.</em></p><p><em>If you’re studying this in Google Colab and </em><em>asyncio.run() is breaking — now you know why. The event loop already exists. Just </em><em>await directly.</em></p><p><em>Happy coding. 🙂</em></p><p><em>Written while studying async Python for the first time and getting thoroughly confused along the way.</em></p><p><em>P.S. — I’m still learning, so if I’ve gotten anything wrong or if something could be explained better, do let me know in the comments! Would love to learn from you too.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef3528321766" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Chaos to Clarity: How I Built a Centralized SOC Analytics Platform- CyberPulse]]></title>
            <link>https://medium.com/@gurleenkaurbali20/from-chaos-to-clarity-how-i-built-cyberpulse-gurleenkaurbali-9dc8dfa6068d?source=rss-fb633207579f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9dc8dfa6068d</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Gurleenkaurbali]]></dc:creator>
            <pubDate>Sun, 07 Jun 2026 09:21:16 GMT</pubDate>
            <atom:updated>2026-06-07T09:21:16.079Z</atom:updated>
            <content:encoded><![CDATA[<p><em>From a real-world problem to a fully deployed, cloud-hosted analytics platform — this is the story of CyberPulse.</em></p><h3><strong><em>The Problem That Started It All</em></strong></h3><p><em>While working with a cybersecurity team, one of the first things I noticed was how the security analysts operated. Every week, the team would manually pull data from multiple security tools, copy numbers into Excel sheets, format them, and paste them into PowerPoint slides for management review.</em></p><p><em>Six tools. Six separate logins. Six different export formats. One very tedious Monday morning.</em></p><p><em>The data existed. The insights were there. But they were scattered, manual, and time-consuming to produce. There was no single place where a manager could look and immediately understand the security posture of the organization.</em></p><p><em>That gap became my project.</em></p><h3><strong><em>The Idea: One Platform, All Tools</em></strong></h3><p><em>I wanted to build something that would answer a simple question: </em><strong><em>“What is our security status right now?”</em></strong><em> without anyone having to open six different tabs.</em></p><p><em>The vision was straightforward:</em></p><p><strong><em>Upload security exports → Compute KPIs → Explore executive dashboards</em></strong></p><p><em>I named it </em><strong><em>CyberPulse</em></strong><em>. The pulse of your cyber defense, in one place.</em></p><h3>Thinking Through the Architecture</h3><p><em>Before writing a single line of code, I spent time thinking about the design. This is where I made what I consider the most important decision of the entire project.</em></p><p><em>The naive approach would be to store raw data and run aggregation queries every time the dashboard loads. Fast to build, but slow to run — and messy to maintain.</em></p><p><em>Instead, I designed a </em><strong><em>3-layer architecture</em></strong><em>:</em></p><p><strong>Layer 1 — Upload Tracking</strong> <em>Every file upload gets recorded in an </em><em>upload_master table before any processing happens. This gives a full audit trail and enables duplicate detection using SHA-256 file hashing. If someone tries to upload the same file twice, the system catches it immediately.</em></p><p><strong>Layer 2 — Raw Tables</strong> <em>One table per security tool stores the original ingested data exactly as it came in — </em><em>raw_falcon, </em><em>raw_cyble, </em><em>raw_siem, and so on. This preserves data lineage and makes debugging straightforward.</em></p><p><strong>Layer 3 — KPI Master</strong> <em>This is the key insight: instead of querying raw tables on every dashboard load, a separate computation step pre-calculates all metrics and stores them in a single </em><em>kpi_master table. The dashboard reads </em><strong><em>exclusively</em></strong><em> from this one table.</em></p><pre>upload_master   →   raw_[tool]   →   kpi_master   →   dashboard</pre><p><em>This means the dashboard is always fast, the codebase stays clean, and adding a new tool only requires three files — not touching the dashboard at all.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yhR_UOEBuAhPyVATRkBZzA.png" /><figcaption><strong>CyberPulse Architecture</strong></figcaption></figure><h3>Building the Pipeline</h3><p><em>The platform follows a 4-stage pipeline that I built to be modular and tool-agnostic:</em></p><p><strong>Stage 1 — Upload</strong> <em>The user selects a tool, uploads an Excel file, and the system validates it, hashes it for duplicate detection, logs it in </em><em>upload_master, and runs the appropriate ingestion script to clean and insert rows into the raw table.</em></p><p><strong>Stage 2 — Ingest</strong> <em>Each tool has its own </em><em>*_upload.py script that knows how to read that tool&#39;s Excel format, clean the columns, handle datetime parsing, and insert rows with the correct </em><em>upload_id foreign key linking back to the audit record.</em></p><p><strong>Stage 3 — Compute</strong> <em>The user triggers KPI computation for a specific upload. Each tool has a </em><em>*_kpi.py script that reads from the raw table, calculates metrics — total alerts, breakdowns by severity, status, date, resolution type — and returns a structured list of KPI rows that get inserted into </em><em>kpi_master.</em></p><p><strong>Stage 4 — Visualize</strong> <em>The dashboard reads from </em><em>kpi_master with a simple date-range overlap filter. No joins, no aggregations at query time — just clean, fast reads rendered into Plotly charts.</em></p><h3>The Dashboard</h3><p><em>Building the dashboard was honestly the most enjoyable part. I went with a dark SOC-themed aesthetic — deep blacks, cyan accents, glowing metric cards — because security operations centers run dark interfaces for a reason, and I wanted the tool to feel native to that environment.</em></p><p><em>Each security tool gets its own tab with charts tailored to what that tool measures:</em></p><ul><li><strong><em>CrowdStrike Falcon</em></strong><em> → Severity donut, Alert status funnel, TP/FP resolution donut, MTTR gauge, Daily volume trend</em></li><li><strong><em>Cyble</em></strong><em> → Threat severity, Dark web sources treemap, Keywords bar, Daily trend</em></li><li><strong><em>SIEM</em></strong><em> → Severity distribution, Alert categories, False positive rate gauge, TP/FP bullet charts</em></li><li><strong><em>Trend Vision</em></strong><em> → Threat type mix, Delivery status, Quarantine rate gauge</em></li><li><strong><em>Netskope</em></strong><em> → OS distribution, Security coverage gauge, Tunnel status</em></li><li><strong><em>Com Olho</em></strong><em> → Vulnerability severity, SLA compliance, Bug bounty rewards, Age analysis</em></li></ul><p><em>One thing I got right early: </em><strong><em>date range filtering</em></strong><em>. Select January only — see January data. Select January and February — the visuals correctly combine and aggregate both months. This required careful thinking about how KPI rows are stored and how the overlap filter works across multiple uploads.</em></p><h3>A Bug I Almost Missed</h3><p><em>While testing with two months of data, I noticed something odd. Selecting a single month showed correct numbers on the KPI cards. Selecting both months — the charts combined correctly, but the cards still showed only one month’s data.</em></p><p><em>The culprit was a single line of code:</em></p><pre># Wrong — picks only the first matching row<br>return r[&quot;kpi_value&quot;].iloc[0] if not r.empty else default</pre><pre># Fixed — sums all matching rows across uploads<br>return r[&quot;kpi_value&quot;].sum() if not r.empty else default</pre><p><em>When two months are selected, there are two rows for “Total Alerts” — one per upload. </em><em>.iloc[0] grabbed only the first. </em><em>.sum() fixed it for counts. I also had to be careful to use </em><em>.mean() instead of </em><em>.sum() for averaged KPIs like MTTR and Resolution Rate — summing two monthly averages gives a nonsense number.</em></p><p><strong><em>Small bug, important lesson: always test with multi-period data.</em></strong></p><h3>Deployment</h3><p><em>I wanted this to be publicly accessible, not just running on my laptop. The challenge with a Streamlit + MySQL stack is that both parts need to be hosted.</em></p><p><em>After researching options, I went with:</em></p><ul><li><strong><em>Aiven</em></strong><em> — free managed MySQL in the cloud (DigitalOcean Bangalore region, which made sense for an India-based project)</em></li><li><strong><em>Streamlit Community Cloud</em></strong><em> — free app hosting, connects directly to the GitHub repo</em></li></ul><p><em>The setup involved migrating my local schema to Aiven, updating the database connection to read from Streamlit secrets instead of a local </em><em>.env file, and handling SSL — Aiven requires SSL connections, which caught me off-guard initially.</em></p><p><em>The entire deployment took a few hours, and the result is a live, publicly accessible platform at a real URL.</em></p><h3>What I Learned</h3><p><em>Looking back, the technical skills I built are obvious — MySQL schema design, data pipeline engineering, Plotly dashboards, cloud deployment. But the less obvious lessons were more valuable:</em></p><p><strong><em>Design before you code.</em></strong><em> The </em><em>kpi_master architecture decision saved me countless hours of dashboard complexity. Thinking through the data model first made everything else easier.</em></p><p><strong><em>Modularity pays off.</em></strong><em> Because I designed the tool registry pattern, adding a new security tool to the platform is genuinely just 3 files. The dashboard, upload page, and compute page pick it up automatically.</em></p><p><strong><em>Real problems make better projects.</em></strong><em> Building this for an actual use case I observed — not a tutorial dataset or a Kaggle competition — meant every design decision had a real reason behind it.</em></p><p><strong><em>Bugs hide in edge cases.</em></strong><em> The multi-period aggregation bug only appeared when testing with two months of data. If I’d only tested single-month, I’d have shipped broken KPI cards without knowing.</em></p><h3>The Result</h3><p><em>CyberPulse is live. It handles uploads, deduplication, KPI computation, and interactive visualization across 6 security tools. The same workflow that used to take hours of manual copying now takes minutes.</em></p><p><em>🌐 </em><strong><em>Live Demo:</em></strong><em> </em><a href="https://cyberrpulse.streamlit.app/"><em>CyberPulse</em></a><em> on Streamlit Cloud<br> 💻 </em><strong><em>GitHub:</em></strong><em> </em><a href="https://github.com/gurleenkaurbali19/cyber-defense-analytics-platform"><em>cyber-defense-analytics-platform</em></a></p><p><em>If you’re a hiring manager reading this — I’d love to bring this kind of thinking to your team. Feel free to reach out on </em><a href="https://www.linkedin.com/in/gurleen-kaur-bali-4b24b1252/"><em>LinkedIn</em></a><em> or drop me an </em><a href="/service/mailto:gurleenkaurbali20@gmail.com"><em>email</em></a><em>.</em></p><p><em>If you’re a developer — feel free to explore the repo, and star it if you found it useful!</em></p><p><strong>Tags:</strong> #Python #Streamlit #MySQL #Cybersecurity #DataEngineering #SOC #OpenToWork</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9dc8dfa6068d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>