<?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 Angelo Gabriel on Medium]]></title>
        <description><![CDATA[Stories by Angelo Gabriel on Medium]]></description>
        <link>https://medium.com/@angelomelodosreis?source=rss-b79f96ed9741------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bqukjyaf7VgXVXdbXUgnMA.jpeg</url>
            <title>Stories by Angelo Gabriel on Medium</title>
            <link>https://medium.com/@angelomelodosreis?source=rss-b79f96ed9741------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 12:22:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@angelomelodosreis/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[Optimizing Data Ingestion with Cloud Run: Strategies for High-Latency APIs]]></title>
            <link>https://medium.com/@angelomelodosreis/optimizing-data-ingestion-with-cloud-run-strategies-for-high-latency-apis-48334fb390e7?source=rss-b79f96ed9741------2</link>
            <guid isPermaLink="false">https://medium.com/p/48334fb390e7</guid>
            <category><![CDATA[data-ingestion]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[google-cloud-run]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Angelo Gabriel]]></dc:creator>
            <pubDate>Mon, 06 Jan 2025 13:38:57 GMT</pubDate>
            <atom:updated>2025-01-06T13:38:57.812Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aw7Cc8IN_8WlbMfQ0kFKoA.png" /></figure><h3>The Challenges of High-Latency APIs in Cloud Run</h3><p>Data ingestion pipelines often rely on APIs to fetch external data, but what happens when those APIs are slow?</p><p>Dealing with high-latency APIs can be a bottleneck for serverless platforms like Cloud Run, where jobs are limited to a maximum execution time of 30 minutes. Without the right strategies, you risk incomplete data processing or, worse, job failures.</p><p>In this article, I’ll share techniques to optimize data ingestion pipelines in Cloud Run, focusing on handling high-latency APIs. From concurrent requests to chunked processing, I’ll walk you through advanced strategies to ensure your pipeline stays efficient, reliable, and within the 30-minute execution limit.</p><h3>Understanding the Problem</h3><p>High-latency APIs present unique challenges for data ingestion pipelines, especially in environments like Cloud Run, where execution time is capped at 30 minutes. Let’s break down some of the common issues:</p><h4>1. Long Response Times</h4><p>APIs that take several seconds (or even minutes) to respond can quickly consume your job’s available runtime, leaving little room for processing or retries. For example, fetching 1,000 records with an API that takes 2 seconds per request would exceed the 30-minute limit.</p><h4>2. Large Datasets with Pagination</h4><p>Many APIs provide data in paginated formats, requiring multiple sequential calls to retrieve the full dataset. If each page takes a long time to fetch, processing the entire dataset within the time limit becomes infeasible.</p><h4>3. Failures and Retries</h4><p>High-latency APIs are often prone to intermittent timeouts or errors, requiring retries to successfully fetch data. Without an optimized retry strategy, these failures can significantly slow down your pipeline.</p><h4>4. Data Integrity Risks</h4><p>Incomplete processing due to the 30-minute limit can leave your pipeline in an inconsistent state. Without proper handling, partially ingested data may corrupt downstream workflows.</p><p>Understanding these challenges is the first step toward designing a pipeline that can handle high-latency APIs efficiently.</p><h3>Key Optimization Strategies</h3><p>To efficiently handle high-latency APIs within Cloud Run’s 30-minute execution limit, you need strategies that maximize throughput, minimize downtime, and ensure reliable processing. Below are some key techniques:</p><h4>1. Concurrent Requests</h4><p>Parallelizing API calls can dramatically reduce total execution time. Python’s asyncio or concurrent.futures libraries enable concurrent requests.</p><p>Here’s an example using asyncio:</p><pre>import asyncio<br>import aiohttp<br><br>async def fetch_data(session, url):<br>    async with session.get(url) as response:<br>        return await response.json()<br>async def fetch_all_data(urls):<br>    async with aiohttp.ClientSession() as session:<br>        tasks = [fetch_data(session, url) for url in urls]<br>        return await asyncio.gather(*tasks)<br># Example usage<br>urls = [f&quot;https://api.example.com/data?page={i}&quot; for i in range(1, 11)]<br>results = asyncio.run(fetch_all_data(urls))<br>print(&quot;Fetched data:&quot;, results)</pre><h4>2. Chunked Processing</h4><p>Breaking the dataset into smaller chunks ensures that each job stays within the time limit. Use pagination or batch processing to retrieve data incrementally.</p><p>Example with pagination logic:</p><pre>import requests<br><br>def fetch_paginated_data(base_url, max_pages):<br>    all_data = []<br>    for page in range(1, max_pages + 1):<br>        response = requests.get(f&quot;{base_url}?page={page}&quot;)<br>        if response.status_code == 200:<br>            all_data.extend(response.json().get(&quot;results&quot;, []))<br>        else:<br>            break<br>    return all_data<br># Fetch up to 10 pages<br>data = fetch_paginated_data(&quot;https://api.example.com/data&quot;, max_pages=10)<br>print(&quot;Fetched paginated data:&quot;, len(data))</pre><h4>3. Retry Mechanisms</h4><p>APIs prone to timeouts or failures require robust retry strategies. Exponential backoff with limited retries is a common approach.</p><p>Example using tenacity:</p><pre>pip install tenacity</pre><pre>from tenacity import retry, stop_after_attempt, wait_exponential<br><br>@retry(stop=stop_after_attempt(5), wait=wait_exponential(multiplier=1, min=2, max=10))<br>def fetch_data_with_retry(url):<br>    response = requests.get(url)<br>    response.raise_for_status()  # Raise error for HTTP failures<br>    return response.json()<br># Usage<br>data = fetch_data_with_retry(&quot;https://api.example.com/data&quot;)<br>print(&quot;Fetched with retry:&quot;, data)</pre><h4>4. Stateful Processing</h4><p>For larger datasets, consider saving intermediate results to Google Cloud Storage (GCS) and restarting from the last checkpoint. This allows subsequent Cloud Run jobs to pick up where the previous one left off.</p><pre>from google.cloud import storage<br>import json<br><br># Save intermediate results to GCS<br>def save_to_gcs(bucket_name, file_name, data):<br>    client = storage.Client()<br>    bucket = client.bucket(bucket_name)<br>    blob = bucket.blob(file_name)<br>    blob.upload_from_string(json.dumps(data), content_type=&quot;application/json&quot;)<br># Example usage<br>save_to_gcs(&quot;your_bucket_name&quot;, &quot;checkpoint.json&quot;, {&quot;last_page&quot;: 5})</pre><p>These strategies ensure that your ingestion pipeline can handle high-latency APIs efficiently, staying within Cloud Run’s constraints while maintaining data integrity.</p><h3>Implementation: Building an Optimized Ingestion Pipeline</h3><p>To demonstrate how these strategies come together, let’s build an optimized data ingestion pipeline for handling high-latency APIs in Cloud Run. This implementation includes parallel requests, chunked processing, retries, and stateful handling.</p><h4>1. Define the Ingestion Logic</h4><p>Start with a Python script that combines the techniques discussed earlier.</p><pre>import asyncio<br>import aiohttp<br>from google.cloud import storage<br>import json<br>from tenacity import retry, stop_after_attempt, wait_exponential<br><br># Fetch paginated data with retries<br>@retry(stop=stop_after_attempt(5), wait=wait_exponential(multiplier=1, min=2, max=10))<br>async def fetch_page(session, url):<br>    async with session.get(url) as response:<br>        response.raise_for_status()<br>        return await response.json()<br># Process data in chunks<br>async def process_chunk(base_url, start_page, end_page, bucket_name):<br>    async with aiohttp.ClientSession() as session:<br>        tasks = [<br>            fetch_page(session, f&quot;{base_url}?page={page}&quot;)<br>            for page in range(start_page, end_page + 1)<br>        ]<br>        results = await asyncio.gather(*tasks)<br>    # Flatten results and save to GCS<br>    flattened_data = [item for page_data in results for item in page_data.get(&quot;results&quot;, [])]<br>    save_to_gcs(bucket_name, f&quot;data_{start_page}_{end_page}.json&quot;, flattened_data)<br># Save data to Google Cloud Storage<br>def save_to_gcs(bucket_name, file_name, data):<br>    client = storage.Client()<br>    bucket = client.bucket(bucket_name)<br>    blob = bucket.blob(file_name)<br>    blob.upload_from_string(json.dumps(data), content_type=&quot;application/json&quot;)<br>    print(f&quot;Data saved to {bucket_name}/{file_name}&quot;)<br># Main entry point for the pipeline<br>def main():<br>    BASE_URL = &quot;https://api.example.com/data&quot;<br>    BUCKET_NAME = &quot;your_bucket_name&quot;<br>    START_PAGE = 1<br>    END_PAGE = 50  # Adjust based on your API&#39;s pagination<br>    CHUNK_SIZE = 10<br>    # Process pages in chunks<br>    for chunk_start in range(START_PAGE, END_PAGE + 1, CHUNK_SIZE):<br>        chunk_end = min(chunk_start + CHUNK_SIZE - 1, END_PAGE)<br>        asyncio.run(process_chunk(BASE_URL, chunk_start, chunk_end, BUCKET_NAME))<br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><h4>2. Containerize the Script</h4><p>Use Docker to package the script for deployment in Cloud Run.</p><p><strong>Dockerfile:</strong></p><pre>FROM python:3.9-slim<br><br>WORKDIR /app<br># Install dependencies<br>COPY requirements.txt .<br>RUN pip install --no-cache-dir -r requirements.txt<br># Copy script files<br>COPY . .<br># Command to run the script<br>CMD [&quot;python&quot;, &quot;main.py&quot;]</pre><p><strong>requirements.txt:</strong></p><pre>aiohttp<br>google-cloud-storage<br>tenacity</pre><h4>3. Deploy to Cloud Run</h4><p>Deploy the containerized pipeline to Cloud Run using the following command:</p><pre>gcloud run deploy ingestion-service \<br>    --image gcr.io/your-project-id/ingestion-image \<br>    --platform managed \<br>    --region your-region \<br>    --allow-unauthenticated</pre><h4>4. Automate with Cloud Scheduler</h4><p>Use Cloud Scheduler to trigger the ingestion pipeline at regular intervals. Configure it with:</p><ul><li><strong>URL</strong>: The endpoint of your Cloud Run service.</li><li><strong>Frequency</strong>: Set in cron format (e.g., 0 3 * * * for 3 AM daily).</li><li><strong>Payload</strong>: Optional JSON payload to pass additional parameters if needed.</li></ul><p>With these components, the pipeline can handle high-latency APIs efficiently, leveraging concurrency, retries, and chunked processing while staying within Cloud Run’s constraints.</p><h3>Deploying and Scaling the Pipeline</h3><p>Once your optimized ingestion pipeline is deployed to Cloud Run, it’s essential to configure it for scalability and reliability. Cloud Run’s serverless nature provides built-in scalability, but fine-tuning its deployment can help you handle high-throughput scenarios more efficiently.</p><h4>1. Auto-Scaling with Cloud Run</h4><p>Cloud Run automatically scales based on incoming requests, but you can control its behavior to optimize performance and costs.</p><p><strong>Key Parameters for Scaling:</strong></p><ul><li><strong>Max Instances:</strong> Limit the number of concurrent instances to prevent overloading downstream systems or APIs.</li><li><strong>Concurrency Settings:</strong> Specify the number of requests a single instance can handle simultaneously.</li><li><strong>Timeouts:</strong> Ensure the timeout aligns with your API’s performance and Cloud Run’s limits (maximum 30 minutes).</li></ul><p>Example deployment with custom scaling:</p><pre>gcloud run deploy ingestion-service \<br>    --image gcr.io/your-project-id/ingestion-image \<br>    --platform managed \<br>    --region your-region \<br>    --allow-unauthenticated \<br>    --max-instances 5 \<br>    --timeout 1800</pre><h4>2. Scheduling and Retries with Cloud Scheduler</h4><p>For periodic execution, Cloud Scheduler can trigger the pipeline at fixed intervals. Here’s how to configure it:</p><ul><li><strong>Frequency:</strong> Set a cron expression, like 0 3 * * * for daily execution at 3 AM.</li><li><strong>HTTP Method:</strong> Use POST to trigger the Cloud Run service.</li><li><strong>Retry Policy:</strong> Enable retries to handle transient failures.</li></ul><p>Example setup using gcloud:</p><pre>gcloud scheduler jobs create http ingestion-job \<br>    --schedule=&quot;0 3 * * *&quot; \<br>    --uri=&quot;https://your-cloud-run-url&quot; \<br>    --http-method=POST \<br>    --max-retries=3</pre><h4>3. Monitoring and Debugging</h4><p>To ensure the pipeline runs smoothly, use Google Cloud’s monitoring tools:</p><ul><li><strong>Logs Explorer:</strong> Review detailed logs of each Cloud Run instance for debugging.</li><li><strong>Cloud Monitoring:</strong> Set up dashboards and alerts to track API latencies, request volumes, and instance counts.</li><li><strong>Trace and Profiler:</strong> Analyze performance bottlenecks in your pipeline.</li></ul><p>By configuring auto-scaling, scheduling, and monitoring, your pipeline becomes resilient to high API latencies and scalable for increasing workloads.</p><h3>Conclusion</h3><p>Building efficient data ingestion pipelines on Cloud Run requires balancing flexibility, performance, and reliability.</p><p>When dealing with high-latency APIs, implementing strategies like concurrent requests, chunked processing, retries, and stateful handling ensures that your pipeline remains robust and scalable — even within the 30-minute execution limit.</p><p>Cloud Run’s serverless capabilities, combined with tools like Cloud Scheduler and Google Cloud Storage, provide a solid foundation for automating data ingestion workflows. By incorporating advanced techniques and fine-tuning deployment settings, you can handle even the most challenging APIs with confidence.</p><p>As data engineers, mastering these approaches not only optimizes workflows but also ensures data readiness for downstream analytics and decision-making.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48334fb390e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Nested Data Structures: Handling Lists and Dictionaries in API Ingestion Pipelines]]></title>
            <link>https://medium.com/@angelomelodosreis/mastering-nested-data-structures-handling-lists-and-dictionaries-in-api-ingestion-pipelines-8a2f6da99990?source=rss-b79f96ed9741------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a2f6da99990</guid>
            <category><![CDATA[data-ingestion]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[json]]></category>
            <dc:creator><![CDATA[Angelo Gabriel]]></dc:creator>
            <pubDate>Fri, 13 Dec 2024 14:07:25 GMT</pubDate>
            <atom:updated>2024-12-13T14:07:25.276Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Vi8KI0M8ZYht05EQ5ouiMA.png" /></figure><h3>The Complexity of API Responses</h3><p>When working with APIs for data ingestion, responses often come in the form of JSON — a flexible but sometimes overwhelming format.</p><p>These responses are rarely flat and straightforward; instead, they often contain deeply nested structures with dictionaries inside lists, lists inside dictionaries, or even more intricate combinations.</p><p>Efficiently accessing and processing these structures is crucial for building robust ingestion pipelines. Whether it’s extracting specific fields, handling missing data, or navigating optional attributes, mastering these techniques ensures that you can transform raw API responses into clean, analysis-ready datasets.</p><p>In this article, we’ll dive into advanced techniques for handling nested data structures in Python, exploring scenarios that go beyond the basics and tackling real-world challenges in API ingestion.</p><h3>Understanding Nested Data Structures</h3><h3>Understanding Nested Data Structures</h3><p>API responses often come in a variety of nested formats, making it essential to understand how to navigate them effectively. A typical JSON response might include dictionaries, lists, or combinations of both. Let’s look at a common example:</p><pre>{<br>  &quot;user&quot;: {<br>    &quot;id&quot;: 123,<br>    &quot;name&quot;: &quot;John Doe&quot;,<br>    &quot;contact&quot;: {<br>      &quot;email&quot;: &quot;john.doe@example.com&quot;,<br>      &quot;phone&quot;: &quot;123-456-7890&quot;<br>    }<br>  },<br>  &quot;orders&quot;: [<br>    {<br>      &quot;order_id&quot;: &quot;A001&quot;,<br>      &quot;items&quot;: [<br>        {&quot;product&quot;: &quot;Laptop&quot;, &quot;price&quot;: 1200},<br>        {&quot;product&quot;: &quot;Mouse&quot;, &quot;price&quot;: 25}<br>      ]<br>    },<br>    {<br>      &quot;order_id&quot;: &quot;A002&quot;,<br>      &quot;items&quot;: [<br>        {&quot;product&quot;: &quot;Keyboard&quot;, &quot;price&quot;: 45}<br>      ]<br>    }<br>  ]<br>}</pre><p>This response combines:</p><ol><li><strong>Dictionaries</strong>: Used to store key-value pairs (e.g., user and orders).</li><li><strong>Lists</strong>: Collections of items, such as orders or items within each order.</li><li><strong>Nested Structures</strong>: Lists within dictionaries, and dictionaries within lists.</li></ol><h4>Key Challenges:</h4><ul><li><strong>Depth</strong>: Accessing deeply nested data can be cumbersome, especially when you need multiple levels of traversal.</li><li><strong>Optional Fields</strong>: Not all keys are guaranteed to exist in every response.</li><li><strong>Inconsistent Formats</strong>: Some fields may unexpectedly contain different data types.</li></ul><p>Understanding these patterns is the first step toward building robust and flexible data parsing logic.</p><h3>Accessing Nested Data with Python</h3><p>Python provides powerful tools for navigating and extracting data from nested structures like dictionaries and lists. Let’s explore how to handle such cases effectively.</p><h4>1. Accessing Nested Dictionaries</h4><p>To access nested dictionaries, use a series of key lookups:</p><pre># Accessing nested data<br>user_data = response[&quot;user&quot;]<br>user_email = user_data[&quot;contact&quot;][&quot;email&quot;]<br>print(f&quot;User Email: {user_email}&quot;)<br># Output: User Email: john.doe@example.com</pre><h4>2. Accessing Data in Nested Lists</h4><p>When working with lists, you’ll often iterate through them to access individual elements:</p><pre># Iterating through orders<br>for order in response[&quot;orders&quot;]:<br>    print(f&quot;Order ID: {order[&#39;order_id&#39;]}&quot;)<br>    for item in order[&quot;items&quot;]:<br>        print(f&quot;  Product: {item[&#39;product&#39;]}, Price: ${item[&#39;price&#39;]}&quot;)</pre><h4>3. Handling Missing Keys Gracefully</h4><p>API responses may not always include every key. Use .get() to avoid KeyError exceptions:</p><pre># Safely accessing optional keys<br>phone = response[&quot;user&quot;][&quot;contact&quot;].get(&quot;phone&quot;, &quot;No phone provided&quot;)<br>print(f&quot;Phone: {phone}&quot;)</pre><h4>4. Combining List and Dictionary Traversals</h4><p>For more complex cases, combine list and dictionary access:</p><pre># Extracting all products from all orders<br>all_products = [<br>    item[&quot;product&quot;]<br>    for order in response[&quot;orders&quot;]<br>    for item in order[&quot;items&quot;]<br>]<br>print(f&quot;Products: {all_products}&quot;)<br># Output: Products: [&#39;Laptop&#39;, &#39;Mouse&#39;, &#39;Keyboard&#39;]</pre><p>Python’s flexibility makes it easy to handle these scenarios, but as the data gets more complex, additional strategies may be required. Next, we’ll tackle some advanced techniques for even more challenging structures.</p><h3>Handling Complex Scenarios</h3><p>When working with deeply nested or inconsistent API responses, straightforward access methods often fall short. Advanced techniques can help you extract the data efficiently while handling edge cases.</p><h4>1. Accessing Deeply Nested Data</h4><p>For deeply nested structures, a reusable function can simplify traversal:</p><pre>def get_nested_value(data, keys, default=None):<br>    for key in keys:<br>        if isinstance(data, dict):<br>            data = data.get(key, default)<br>        else:<br>            return default<br>    return data<br><br># Example usage<br>email = get_nested_value(response, [&quot;user&quot;, &quot;contact&quot;, &quot;email&quot;])<br>print(f&quot;Email: {email}&quot;)</pre><p>This function ensures safe traversal and avoids repetitive code for deeply nested lookups.</p><h4>2. Handling Lists of Dictionaries</h4><p>When dealing with lists of dictionaries, you might need to extract data based on conditions:</p><pre># Find the first order with more than one item<br>multi_item_order = next(<br>    (order for order in response[&quot;orders&quot;] if len(order[&quot;items&quot;]) &gt; 1),<br>    None<br>)<br>print(f&quot;Multi-item Order: {multi_item_order}&quot;)</pre><p>This approach uses next() and a generator expression for concise filtering.</p><h4>3. Dealing with Optional or Inconsistent Data</h4><p>API responses often include fields that vary in type or availability. Use flexible parsing strategies:</p><pre># Handle inconsistent &quot;price&quot; field types (e.g., string vs. numeric)<br>for order in response[&quot;orders&quot;]:<br>    for item in order[&quot;items&quot;]:<br>        price = item.get(&quot;price&quot;)<br>        if isinstance(price, str) and price.isdigit():<br>            price = int(price)<br>        print(f&quot;Product: {item[&#39;product&#39;]}, Price: {price}&quot;)</pre><h4>4. Flattening Nested Structures</h4><p>Flattening a complex structure into a flat list or dictionary is useful for further processing:</p><pre># Flatten all items into a single list<br>flat_items = [<br>    {&quot;order_id&quot;: order[&quot;order_id&quot;], **item}<br>    for order in response[&quot;orders&quot;]<br>    for item in order[&quot;items&quot;]<br>]<br>print(flat_items)</pre><p>This flattens order_id into each item, creating a simpler structure for downstream analysis.</p><h3>Optimizing Data Parsing</h3><p>When dealing with large API responses, optimizing your data parsing logic becomes critical. Advanced techniques can help you extract data efficiently while maintaining performance and readability.</p><h4>1. Using List Comprehensions for Efficiency</h4><p>List comprehensions offer a concise and performant way to extract and transform data from nested structures:</p><pre># Extract all product names using a list comprehension<br>product_names = [<br>    item[&quot;product&quot;]<br>    for order in response[&quot;orders&quot;]<br>    for item in order[&quot;items&quot;]<br>]<br>print(f&quot;Product Names: {product_names}&quot;)<br># Output: Product Names: [&#39;Laptop&#39;, &#39;Mouse&#39;, &#39;Keyboard&#39;]</pre><p>This approach minimizes loops and improves clarity.</p><h4>2. Creating Reusable Parsing Functions</h4><p>Reusable functions simplify your pipeline by encapsulating common parsing logic:</p><pre>def parse_order(order):<br>    return [<br>        {&quot;order_id&quot;: order[&quot;order_id&quot;], &quot;product&quot;: item[&quot;product&quot;], &quot;price&quot;: item[&quot;price&quot;]}<br>        for item in order[&quot;items&quot;]<br>    ]<br><br># Apply parsing to all orders<br>parsed_orders = [entry for order in response[&quot;orders&quot;] for entry in parse_order(order)]<br>print(parsed_orders)</pre><p>This method keeps your code modular and easy to maintain.</p><h4>3. Using Generators for Large Datasets</h4><p>For APIs that return large datasets, generators allow you to process data lazily, reducing memory usage:</p><pre>def extract_items(data):<br>    for order in data[&quot;orders&quot;]:<br>        for item in order[&quot;items&quot;]:<br>            yield {&quot;order_id&quot;: order[&quot;order_id&quot;], &quot;product&quot;: item[&quot;product&quot;], &quot;price&quot;: item[&quot;price&quot;]}<br><br># Process items one at a time<br>for item in extract_items(response):<br>    print(item)</pre><p>Generators are particularly useful when working with paginated API responses.</p><h4>4. Pre-Compiling Parsing Logic with jsonpath-ng</h4><p>For complex JSON structures, the jsonpath-ng library provides a declarative way to access data:</p><pre>pip install jsonpath-ng</pre><pre>from jsonpath_ng import parse<br><br># Define a JSONPath query<br>jsonpath_query = parse(&quot;$.orders[*].items[*].product&quot;)<br><br># Apply query to extract product names<br>product_names = [match.value for match in jsonpath_query.find(response)]<br>print(product_names)<br><br># Output: [&#39;Laptop&#39;, &#39;Mouse&#39;, &#39;Keyboard&#39;]</pre><p>This approach allows for robust and dynamic parsing of complex JSON structures.</p><h3>Real-World Application</h3><p>The techniques discussed above become powerful when integrated into a real-world API ingestion pipeline. Let’s see how these methods can be combined in a practical example.</p><h4>Integrating Parsing Logic into a Data Pipeline</h4><p>Imagine a pipeline that ingests data from an external API and stores it in Google Cloud Storage. Here’s how the parsing logic can be embedded:</p><pre>import requests<br>import json<br>from google.cloud import storage<br><br># Step 1: Fetch API Data<br>def fetch_api_data(api_url, headers):<br>    response = requests.get(api_url, headers=headers)<br>    response.raise_for_status()  # Handle HTTP errors<br>    return response.json()<br><br># Step 2: Parse Nested Data<br>def parse_data(response):<br>    return [<br>        {&quot;order_id&quot;: order[&quot;order_id&quot;], **item}<br>        for order in response[&quot;orders&quot;]<br>        for item in order[&quot;items&quot;]<br>    ]<br><br># Step 3: Save Parsed Data to Google Cloud Storage<br>def save_to_gcs(data, bucket_name, file_name):<br>    storage_client = storage.Client()<br>    bucket = storage_client.bucket(bucket_name)<br>    blob = bucket.blob(file_name)<br>    blob.upload_from_string(json.dumps(data), content_type=&#39;application/json&#39;)<br>    print(f&quot;Data saved to GCS: {file_name}&quot;)<br><br># Step 4: Main Pipeline Logic<br>def run_pipeline(api_url, headers, bucket_name, file_name):<br>    response = fetch_api_data(api_url, headers)<br>    parsed_data = parse_data(response)<br>    save_to_gcs(parsed_data, bucket_name, file_name)<br><br># Example Usage<br>API_URL = &quot;https://api.example.com/orders&quot;<br>HEADERS = {&quot;Authorization&quot;: &quot;Bearer YOUR_ACCESS_TOKEN&quot;}<br>BUCKET_NAME = &quot;your_bucket_name&quot;<br>FILE_NAME = &quot;parsed_orders.json&quot;<br>run_pipeline(API_URL, HEADERS, BUCKET_NAME, FILE_NAME)</pre><h4>Key Features of This Pipeline:</h4><ol><li><strong>Dynamic Data Parsing</strong>: The parse_data function dynamically extracts and flattens nested fields.</li><li><strong>Error Handling</strong>: The fetch_api_data function ensures the pipeline can gracefully handle HTTP errors.</li><li><strong>Scalability</strong>: The modular design makes it easy to adapt the pipeline for new APIs or changes in response structure.</li></ol><p>This example demonstrates how mastering nested data structures enables you to create pipelines that are robust, efficient, and ready for real-world demands.</p><h3>Conclusion</h3><p>API responses are rarely straightforward, and handling their nested data structures is a critical skill for data engineers.</p><p>By mastering techniques to access, parse, and optimize lists and dictionaries in Python, you can build ingestion pipelines that are robust, efficient, and ready to tackle even the most complex data formats.</p><p>From safely accessing deeply nested fields to leveraging advanced tools like generators and JSONPath queries, these strategies ensure that your pipeline remains adaptable and scalable.</p><p>When integrated into real-world workflows, these techniques not only streamline data processing but also prepare your datasets for analysis and decision-making.</p><p>Whether you’re dealing with an API for the first time or refining your approach for a high-volume system, these methods will set you up for success in creating professional-grade pipelines.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a2f6da99990" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating ETL in BigQuery: Transforming Data for Scalable Analytics]]></title>
            <link>https://medium.com/@angelomelodosreis/automating-etl-in-bigquery-transforming-data-for-scalable-analytics-c4b2efa077f0?source=rss-b79f96ed9741------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4b2efa077f0</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-pipeline]]></category>
            <dc:creator><![CDATA[Angelo Gabriel]]></dc:creator>
            <pubDate>Thu, 05 Dec 2024 14:34:12 GMT</pubDate>
            <atom:updated>2024-12-05T14:34:12.163Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hnKncedEPWPNdyfZ-5exCg.png" /></figure><h3>The Importance of Automating ETL</h3><p>In any data engineering workflow, the ETL (Extract, Transform, Load) process is at the core of turning raw data into actionable insights.</p><p>When working with large datasets, manual workflows are not only time-consuming but also prone to errors. Automating ETL pipelines ensures that data processing is consistent, scalable, and efficient.</p><p>In a recent project, I faced the challenge of integrating and transforming data from external APIs into a clean and structured format for analytics. This involved automating the entire process within BigQuery, from loading raw data to applying advanced transformations.</p><p>In this article, I’ll walk you through how I tackled this, sharing insights and techniques for automating ETL workflows in BigQuery.</p><h3>Creating the Table Structure in BigQuery</h3><p>A well-designed schema is the foundation of an effective ETL pipeline. Defining the right structure ensures that data is stored in a way that facilitates efficient querying and analysis. For this project, I created a table in BigQuery with a schema optimized for handling the structured data retrieved from external APIs.</p><h4>Key Considerations for Schema Design:</h4><ol><li><strong>Field Types</strong>: Use appropriate data types like STRING, NUMERIC, and TIMESTAMP to match the expected format of the incoming data.</li><li><strong>Nested Structures</strong>: For fields that contain complex data (like JSON objects), BigQuery’s STRUCT and ARRAY types allow for better organization.</li><li><strong>Partitioning and Clustering</strong>: Partition tables by date and cluster by frequently filtered fields to improve performance.</li></ol><p>Here’s a generalized SQL example for creating a BigQuery table:</p><pre>CREATE TABLE `project_id.dataset_id.table_name` (<br>  transaction_id STRING,<br>  customer_id STRING,<br>  product_id STRING,<br>  transaction_date TIMESTAMP,<br>  amount NUMERIC,<br>  custom_fields STRUCT&lt;<br>    field1 STRING,<br>    field2 STRING,<br>    field3 STRING<br>  &gt;<br>)<br>PARTITION BY DATE(transaction_date)<br>CLUSTER BY product_id, customer_id;</pre><p>This schema supports nested fields for custom data while ensuring efficient storage and querying with partitioning and clustering.</p><p>With the table structure in place, the next step is to load the data into BigQuery for transformation.</p><h3>Loading Data into BigQuery</h3><p>Once the table schema is defined, the next step is to load the raw data into BigQuery. Using Google Cloud Storage (GCS) as an intermediary simplifies this process, especially for JSON files retrieved from APIs.</p><h4>Steps for Data Loading:</h4><ol><li><strong>Upload Data to GCS</strong>: The filtered API data is first saved as JSON files in a GCS bucket. This ensures a reliable and scalable storage layer before ingestion into BigQuery.</li><li><strong>Load Data into BigQuery</strong>: The bigquery.Client library in Python provides an efficient way to transfer data from GCS to BigQuery.</li></ol><p>Here’s an example of the Python code used for this step:</p><pre>from google.cloud import bigquery<br><br>def load_data_to_bigquery():<br>    # Initialize BigQuery client<br>    client = bigquery.Client()<br><br># Define table ID and GCS file URI<br>    table_id = &quot;project_id.dataset_id.table_name&quot;<br>    uri = &quot;gs://your_bucket_name/filtered_data.json&quot;<br>    <br># Configure the load job<br>    job_config = bigquery.LoadJobConfig(<br>        source_format=bigquery.SourceFormat.NEWLINE_DELIMITED_JSON,<br>        autodetect=False,  # Use schema defined during table creation<br>        write_disposition=bigquery.WriteDisposition.WRITE_APPEND  # Append new data<br>    )<br>    <br># Load data from GCS to BigQuery<br>    load_job = client.load_table_from_uri(uri, table_id, job_config=job_config)<br>    load_job.result()  # Wait for the job to complete<br><br>    print(f&quot;Data successfully loaded into {table_id}&quot;)</pre><h4>Why Use GCS as an Intermediary?</h4><ul><li><strong>Scalability</strong>: GCS can handle large files efficiently.</li><li><strong>Flexibility</strong>: Storing raw data allows reprocessing or auditing if needed.</li><li><strong>Seamless Integration</strong>: GCS integrates natively with BigQuery, simplifying the loading process.</li></ul><p>With the data successfully loaded into BigQuery, the focus shifts to transforming it into a clean, analysis-ready format.</p><h3>Transforming Data in BigQuery</h3><p>After loading the data into BigQuery, the transformation step ensures that raw data is cleaned, normalized, and structured for analysis.</p><p>BigQuery’s SQL capabilities make it a powerful tool for this purpose, allowing you to handle complex transformations directly within the data warehouse. Here are some of the key transformations:</p><h4>Flattening Nested Fields</h4><p>If your data includes nested JSON structures, you can use SQL to extract and flatten these fields for easier querying:</p><pre>SELECT<br> transaction_id,<br> customer_id,<br> product_id,<br> transaction_date,<br> amount,<br> custom_fields.field1 AS field1,<br> custom_fields.field2 AS field2,<br> custom_fields.field3 AS field3<br>FROM `project_id.dataset_id.table_name`;</pre><h4><strong>Standardizing Data Formats</strong></h4><p>To ensure consistency, standardize data formats such as dates or numeric fields:</p><pre>SELECT<br> transaction_id,<br> customer_id,<br> product_id,<br> FORMAT_TIMESTAMP(‘%Y-%m-%d’, transaction_date) AS transaction_date,<br> SAFE_CAST(amount AS NUMERIC) AS amount<br>FROM `project_id.dataset_id.table_name`;</pre><h4><strong>Adding Derived Fields</strong></h4><p>Create additional fields for analysis, such as categorizing transactions or calculating metrics:</p><pre>SELECT<br> *,<br> CASE<br> WHEN amount &gt; 100 THEN ‘High Value’<br> ELSE ‘Low Value’<br> END AS transaction_category<br>FROM `project_id.dataset_id.table_name`;</pre><h3>Why Transform Data in BigQuery?</h3><p>BigQuery stands out as a powerful tool for ETL processes, especially when dealing with large and complex datasets.</p><p>By leveraging its capabilities, the ETL pipeline not only becomes efficient but also highly scalable. Here are some of the key benefits:</p><ol><li><strong>Scalability</strong><br>BigQuery’s serverless architecture ensures that the pipeline can handle growing data volumes without requiring manual intervention or infrastructure scaling. Whether dealing with hundreds of records or billions, the performance remains consistent.</li><li><strong>Cost Efficiency</strong><br>With BigQuery’s pay-as-you-go model, you only pay for the storage and processing you use. Combined with techniques like partitioning and clustering, costs can be further optimized by reducing the amount of data scanned during queries.</li><li><strong>Simplified Workflow</strong><br>By centralizing both data storage and transformation in BigQuery, the need for external tools is minimized. This reduces complexity and makes the pipeline easier to maintain.</li><li><strong>Automation-Friendly</strong><br>BigQuery integrates seamlessly with tools like Google Cloud Storage, Cloud Run, and Cloud Scheduler, making it ideal for automated ETL pipelines. Jobs can be scheduled to run at regular intervals, ensuring data is always up-to-date.</li><li><strong>Advanced SQL Features</strong><br>BigQuery’s SQL capabilities allow for complex transformations, including handling nested and semi-structured data. This makes it possible to transform raw data into analysis-ready datasets directly within the platform.</li></ol><p>By leveraging these benefits, the ETL pipeline not only streamlined the data processing workflow but also enabled faster, more reliable insights.</p><h3>Conclusion</h3><p>Automating ETL processes in BigQuery transforms raw data into actionable insights with minimal manual intervention. By designing a pipeline that integrates Google Cloud Storage and BigQuery, and leveraging advanced SQL transformations, I was able to create a scalable, efficient, and reliable workflow.</p><p>This approach not only reduced errors and improved processing speed but also laid the groundwork for handling increasingly complex datasets. BigQuery’s robust features, combined with automation tools, ensure that the pipeline remains adaptable for future growth and evolving data needs.</p><p>The lessons learned from this project highlight the importance of aligning technology choices with business requirements, ensuring both scalability and cost efficiency in data engineering workflows.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4b2efa077f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Raw Data to Insights: Building a Scalable API Integration Pipeline]]></title>
            <link>https://medium.com/@angelomelodosreis/from-raw-data-to-insights-building-a-scalable-api-integration-pipeline-be2f39a5ce65?source=rss-b79f96ed9741------2</link>
            <guid isPermaLink="false">https://medium.com/p/be2f39a5ce65</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[data-pipeline]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-ingestion]]></category>
            <dc:creator><![CDATA[Angelo Gabriel]]></dc:creator>
            <pubDate>Tue, 19 Nov 2024 20:07:01 GMT</pubDate>
            <atom:updated>2024-11-19T20:07:01.442Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wl8DZjxj80OJkl8E1jEJMQ.png" /></figure><h3>The Need for Scalable Data Integration Pipelines</h3><p>Integrating external data via APIs is a crucial step in modern data workflows, enabling organizations to enrich their datasets with valuable insights. However, this process is rarely straightforward.</p><p>Recently, I faced a challenge in my work that required building a scalable pipeline to consume, filter, and store data from a dynamic API for further analysis.</p><p>In this article, I’ll share the technical steps I used to tackle this problem, from handling authenticated API requests to automating the entire process with cloud tools. Whether you’re building your first API integration or optimizing an existing one, these strategies will help you create a robust and scalable solution.</p><h3>Environment Setup for API Integration</h3><p>Building a reliable API integration starts with the right tools and environment. For this project, I chose Python for its extensive library support and Google Cloud Storage (GCS) for storing raw data securely and efficiently. Python’s requests library made it easy to handle API calls, while the google.cloud.storage library ensured seamless integration with GCS.</p><p>Here’s a generalized example of how I set up the environment:</p><p><strong>Install Required Libraries</strong>: Use pip to install the necessary libraries:</p><pre>pip install requests google-cloud-storage</pre><p><strong>Authenticate with Google Cloud</strong>: Ensure you have a service account key file and authenticate your environment:</p><pre>export GOOGLE_APPLICATION_CREDENTIALS=&quot;path/to/your/key.json&quot;</pre><p><strong>Basic Configuration</strong>: Create a Python script to initialize the necessary configurations for API calls and GCS operations:</p><pre>import os<br>from google.cloud import storage<br><br># Set up Google Cloud Storage client<br>storage_client = storage.Client()<br><br># Define bucket name for storing raw data<br>BUCKET_NAME = &quot;your_bucket_name&quot;<br><br># Define API endpoint and headers<br>API_ENDPOINT = &quot;https://api.example.com/data&quot;<br>HEADERS = {<br>    &quot;Authorization&quot;: &quot;Bearer YOUR_ACCESS_TOKEN&quot;<br>}</pre><p>With this setup, the environment was ready to handle API requests and store the data efficiently. The next step was to design the process for consuming and filtering API data.</p><h3>API Data Consumption</h3><p>Consuming data from an external API requires handling authentication, managing dynamic responses, and filtering relevant fields to reduce data overhead. The API I worked with provided structured yet verbose responses, making it essential to extract only the fields required for analysis.</p><p>Here’s how I approached the task:</p><h4><strong>Authentication and API Requests</strong></h4><p>Most APIs require authentication, often using tokens. I utilized Python’s requests library to send authenticated GET requests to the API. Here’s a professional example:</p><pre>import requests<br><br># Define API endpoint and headers<br>API_ENDPOINT = &quot;https://api.example.com/data&quot;<br>HEADERS = {<br> &quot;Authorization&quot;: &quot;Bearer YOUR_ACCESS_TOKEN&quot;<br>}<br><br># Send GET request<br>response = requests.get(API_ENDPOINT, headers=HEADERS)<br><br>if response.status_code == 200:<br> data = response.json()<br> print(&quot;API data retrieved successfully!&quot;)<br>else:<br> print(f&quot;Error: {response.status_code} - {response.text}&quot;)</pre><h4><strong>Filtering Relevant Fields</strong></h4><p>The raw API response often contains more fields than necessary. To streamline the data, I filtered only the required fields, ensuring the dataset remained concise and relevant. For instance, here’s how I extracted specific fields:</p><pre>filtered_data = []<br>for item in data[&quot;records&quot;]:  # Assuming &#39;records&#39; contains the main data<br>    filtered_item = {<br>        &quot;field1&quot;: item.get(&quot;field1&quot;),<br>        &quot;field2&quot;: item.get(&quot;field2&quot;),<br>        &quot;nested_field&quot;: item[&quot;nested&quot;].get(&quot;field3&quot;) if &quot;nested&quot; in item else None<br>    }<br>    filtered_data.append(filtered_item)<br><br>print(&quot;Filtered data ready for storage.&quot;)</pre><p>By combining authentication and precise field selection, I ensured the data was ready for the next step: storage in Google Cloud Storage.</p><h3>Storing Data in Google Cloud Storage</h3><p>Once the API data was filtered, the next step was to store it securely in Google Cloud Storage (GCS). Storing data in GCS provides a scalable and reliable solution, ensuring the pipeline can handle large volumes of data with ease.</p><p>Here’s how I implemented this step:</p><h4><strong>Initialize the GCS Client</strong></h4><p>Using the google.cloud.storage library, I set up a GCS client to interact with the storage bucket:</p><pre>from google.cloud import storage<br>import json<br><br>def save_to_gcs(data, bucket_name, file_name):<br>    # Initialize the GCS client<br>    storage_client = storage.Client()<br>    bucket = storage_client.bucket(bucket_name)<br>    blob = bucket.blob(file_name)<br><br>    # Upload data as JSON<br>    blob.upload_from_string(json.dumps(data), content_type=&#39;application/json&#39;)<br>    print(f&quot;Data saved to {bucket_name}/{file_name}&quot;)</pre><h4><strong>Save the Filtered Data</strong></h4><p>After processing the API response, I stored the filtered data in GCS as a JSON file. Here’s the integration of the storage function:</p><pre># Example usage<br>filtered_data = [...]  # Result of the API filtering step<br>BUCKET_NAME = &quot;your_bucket_name&quot;<br>FILE_NAME = &quot;filtered_data.json&quot;<br><br>save_to_gcs(filtered_data, BUCKET_NAME, FILE_NAME)</pre><h4>Why JSON?</h4><p>JSON is a flexible and lightweight format that aligns well with the semi-structured nature of API data. It’s also compatible with BigQuery, allowing seamless ingestion in later steps.</p><p>With the data securely stored in GCS, the foundation of the pipeline was complete. The next challenge was automating this process for periodic execution.</p><h3>Automating the Process with Cloud Run</h3><p>Manually executing the pipeline for every data update isn’t scalable, especially in dynamic environments where frequent updates are required. To automate the process, I containerized the ingestion script and deployed it using <strong>Google Cloud Run</strong>, ensuring the pipeline could run seamlessly on demand.</p><p>Here’s how the automation was implemented:</p><h4><strong>Containerizing the Script</strong></h4><p>To deploy the script on Cloud Run, I used Docker to package the code and its dependencies. Below is the Dockerfile used to build the container:</p><pre># Use an official Python runtime as a parent image<br>FROM python:3.9-slim<br><br># Set the working directory in the container<br>WORKDIR /app<br><br># Copy requirements and install dependencies<br>COPY requirements.txt .<br>RUN pip install --no-cache-dir -r requirements.txt<br><br># Copy the script into the container<br>COPY . .<br><br># Command to run the ingestion script<br>CMD [&quot;python&quot;, &quot;ingest_data.py&quot;]</pre><h4>Deploying to Cloud Run</h4><p>After building the container, I deployed it to Cloud Run with the following command:</p><pre>gcloud run deploy ingestion-service \<br>    --image gcr.io/your-project-id/ingestion-image \<br>    --platform managed \<br>    --region your-region \<br>    --allow-unauthenticated</pre><p>This deployment allows the service to be triggered via HTTP requests or scheduled for periodic execution.</p><h4>3. Scheduling with Cloud Scheduler</h4><p>To ensure the pipeline runs automatically, I used <strong>Google Cloud Scheduler</strong> to trigger the Cloud Run service at regular intervals. Here’s how the scheduler was configured:</p><ul><li><strong>URL:</strong> The HTTP endpoint of the Cloud Run service.</li><li><strong>Schedule:</strong> Cron format (e.g., 0 8 * * * for daily execution at 8 AM).</li><li><strong>Payload:</strong> Optional JSON payload for any parameters required by the script.</li></ul><p>With Cloud Run and Cloud Scheduler, the pipeline was fully automated, ensuring the data ingestion process ran consistently and without manual intervention.</p><h3>Results and Benefits</h3><p>Implementing this automated pipeline brought significant improvements to the data ingestion process. By leveraging tools like Python, Google Cloud Storage, Cloud Run, and Cloud Scheduler, the pipeline became both scalable and efficient. Here are the key results:</p><ol><li><strong>End-to-End Automation</strong><br>The entire process — from consuming API data to storing it in GCS — was fully automated, eliminating the need for manual intervention. This saved time and reduced the potential for human error.</li><li><strong>Scalability</strong><br>By using Google Cloud’s managed services, the pipeline can handle increasing volumes of data without requiring additional resources or complex reconfigurations.</li><li><strong>Clean and Structured Data</strong><br>Filtering data at the ingestion stage ensured that only relevant fields were stored, reducing overhead and making downstream processes more efficient.</li><li><strong>Periodic Execution</strong><br>With Cloud Scheduler, the pipeline runs automatically at predefined intervals, ensuring that data remains up-to-date for analysis.</li></ol><p>These improvements not only streamlined the workflow but also laid the foundation for more advanced data processing and analysis in future steps.</p><h3>Conclusion</h3><p>Integrating external data via APIs is a critical step in building robust data pipelines. By automating the entire process — from API consumption to storing filtered data in Google Cloud Storage — this pipeline demonstrates how to handle dynamic datasets efficiently and at scale.</p><p>Using tools like Python, Cloud Run, and Cloud Scheduler, the solution ensures reliability, scalability, and automation, making it ready to handle future data needs with minimal adjustments. The lessons learned in this project highlight the importance of designing pipelines that not only meet current requirements but are also adaptable for growth and complexity.</p><p>This approach is a powerful example of how data engineering can turn raw data into actionable insights while maintaining efficiency and precision.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be2f39a5ce65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streamlining Transaction Data for Accurate Sales Analysis]]></title>
            <link>https://medium.com/@angelomelodosreis/streamlining-transaction-data-for-accurate-sales-analysis-afb7c56a571b?source=rss-b79f96ed9741------2</link>
            <guid isPermaLink="false">https://medium.com/p/afb7c56a571b</guid>
            <category><![CDATA[row-number]]></category>
            <category><![CDATA[sales-data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-cleaning]]></category>
            <dc:creator><![CDATA[Angelo Gabriel]]></dc:creator>
            <pubDate>Wed, 06 Nov 2024 18:25:09 GMT</pubDate>
            <atom:updated>2024-11-06T18:25:09.160Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Csj-5stcOdWcB01UAD_61g.png" /></figure><h3>The Complexity of Transaction-Based Data</h3><p>In data analysis, working with transaction-based datasets can quickly become complex. I recently faced a challenge with a dataset where each sale could have multiple transaction attempts, making it difficult to accurately analyze sales and avoid duplicate counts. This structure complicates dashboard creation and analysis, as you want to make sure that each sale is counted only once.</p><p>In this article, I’ll share some of the strategies I used to streamline transaction data, transforming it into a cleaner structure that’s easier to analyze and visualize.</p><h3>The Problem: Multiple Transaction Attempts and Duplicate Counts</h3><p>In transaction-based datasets, it’s common to encounter multiple transaction attempts for the same sale. This happens when a customer makes several attempts to complete a purchase — whether due to technical issues, payment failures, or other reasons.</p><p>As a result, you end up with multiple entries for what should be a single sale. Without careful handling, this can lead to duplicate counts in your analysis, skewing metrics like total sales or conversion rates.</p><p>For instance, if you’re calculating total sales, counting every transaction attempt as a separate sale would inflate your numbers, making your insights less reliable.</p><p>To solve this, I needed a way to identify and group related transactions, ensuring that each sale was counted only once.</p><h3>Solution 1: Using Row Numbers to Manage Sequences</h3><p>To address the issue of multiple transaction attempts, I used the ROW_NUMBER() function to establish a sequence within each group of transactions. This allowed me to identify the initial (or successful) attempt in a series and filter out any duplicates.</p><p>By partitioning the data by customer and product, and ordering by transaction date, I could assign a unique row number to each transaction attempt. This row number helped differentiate between the first transaction and any subsequent attempts, ensuring that only valid sales were included in the final analysis.</p><p>Here’s a generalized SQL example showing how I used ROW_NUMBER():</p><p>Here’s a generalized SQL example showing how I used ROW_NUMBER():</p><pre>SELECT *,<br>    ROW_NUMBER() OVER (PARTITION BY customer_id, product_id ORDER BY transaction_date) AS row_number<br>FROM transactions_data;</pre><p>With this approach, you can filter the data to include only the first row for each customer-product combination, effectively removing duplicate attempts and keeping the dataset accurate for analysis.</p><h3>Solution 2: Creating a Unique Sale Identifier</h3><p>To further streamline the dataset and ensure each sale was tracked accurately, I implemented a unique sale identifier. This sale_id allowed me to group all related transaction attempts under a single identifier, providing a consolidated view of each sale.</p><p>By combining the use of ROW_NUMBER() with a unique ID generator, I could assign the same sale_id to all transaction attempts linked to a single sale. Here’s an example of how this was done:</p><pre>SELECT <br>    transaction_id,<br>    customer_id,<br>    product_id,<br>    transaction_date,<br>    amount,<br>    CASE <br>        WHEN row_number = 1 THEN CONCAT(&#39;S-&#39;, transaction_id)<br>        ELSE LAG(CONCAT(&#39;S-&#39;, transaction_id)) OVER (PARTITION BY customer_id ORDER BY transaction_date)<br>    END AS sale_id<br>FROM (<br>    SELECT *,<br>        ROW_NUMBER() OVER (PARTITION BY customer_id, product_id ORDER BY transaction_date) AS row_number<br>    FROM transactions_data<br>) t;</pre><p>In this code:</p><ul><li>The sale_id is created by assigning a unique identifier to the first transaction attempt (using the CONCAT function).</li><li>For subsequent rows in the same group, the previous sale_id is applied, consolidating all related transactions under a single sale.</li></ul><p>With this unique identifier, it’s easy to filter and count each sale accurately, providing a clearer, more accurate basis for analysis.</p><h3>Simplifying Complex Data for Clearer Analysis</h3><p>When working with transaction-based data, dealing with multiple attempts for the same sale can complicate analysis and lead to inaccurate insights.</p><p>By implementing techniques like ROW_NUMBER() and creating a unique sale_id, I was able to transform a complex transaction dataset into a cleaner, more accurate structure.</p><p>These solutions help ensure that each sale is counted only once, making analysis more reliable and dashboards more insightful. With a streamlined dataset, the challenges of duplicate counting and transaction clutter are minimized, enabling clearer, more actionable insights.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afb7c56a571b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Overcoming Temporal Chart Limitations with Blended Data Sources in Looker Studio]]></title>
            <link>https://medium.com/@angelomelodosreis/overcoming-temporal-chart-limitations-with-blended-data-sources-in-looker-studio-17539f387250?source=rss-b79f96ed9741------2</link>
            <guid isPermaLink="false">https://medium.com/p/17539f387250</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[looker-studio]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-modeling]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Angelo Gabriel]]></dc:creator>
            <pubDate>Mon, 28 Oct 2024 14:49:49 GMT</pubDate>
            <atom:updated>2024-10-28T14:49:49.778Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dBrmMN02sXpsWNxVu8OxEg.jpeg" /></figure><h3>Challenges with Temporal Data Visualization in Looker</h3><p>Working with data visualization tools is often straightforward, but things can get tricky when you need to analyze data over time. Temporal charts — like those that group data by day, month, or year — are essential for identifying trends and patterns.</p><p>However, in Looker, creating these charts becomes challenging when your data comes from multiple sources. The tool only allows temporal aggregation when using a single data source, which can limit your analysis.</p><p>In this article, I’ll share how I tackled this issue by consolidating data from different sources into a unified view, making temporal analysis smooth and efficient.</p><h3>The Problem: Blended Data Sources and Temporal Aggregation</h3><p>When working with multiple data sources, it’s common to blend them in visualization tools to create comprehensive dashboards. However, Looker’s limitation becomes apparent when you try to aggregate temporal data (e.g., grouping by date, month, or year). The tool only supports these types of aggregations when all the data comes from a single source.</p><p>This restriction can hinder your ability to track trends over time, especially if your data is spread across different platforms or systems. Imagine trying to analyze monthly sales when the data is split between two sources — suddenly, a straightforward chart becomes a complex issue.</p><h3>Solution: Creating a Unified View for Smooth Temporal Analysis</h3><p>To overcome this limitation, the solution was to consolidate data from multiple sources into a single, unified view in the database. By merging datasets at the database level, Looker could treat this view as a single source, enabling seamless temporal aggregation.</p><p>For example, let’s say you have sales data coming from two platforms. By creating a view that combines these datasets, you can bypass the blending limitation and analyze the data over time without any issues. Here’s a more refined SQL example:</p><pre>CREATE OR REPLACE VIEW consolidated_sales AS<br>SELECT <br>    t1.transaction_id,<br>    t1.customer_id,<br>    t1.product_id,<br>    t1.transaction_date,<br>    t1.amount,<br>    &#39;Platform A&#39; AS source,<br>    CURRENT_TIMESTAMP() AS created_at<br>FROM source1_transactions t1<br>WHERE t1.transaction_date BETWEEN &#39;2023-01-01&#39; AND &#39;2023-12-31&#39;<br>UNION ALL<br>SELECT <br>    t2.transaction_id,<br>    t2.customer_id,<br>    t2.product_id,<br>    t2.transaction_date,<br>    t2.amount,<br>    &#39;Platform B&#39; AS source,<br>    CURRENT_TIMESTAMP() AS created_at<br>FROM source2_transactions t2<br>WHERE t2.transaction_date BETWEEN &#39;2023-01-01&#39; AND &#39;2023-12-31&#39;;</pre><p>With this unified view, you can now create temporal charts in Looker, grouping data by day, month, or year without worrying about source limitations. It’s a robust solution that makes your analysis smoother and more flexible.</p><h3>Unifying Data for Better Temporal Insights</h3><p>When working with multiple data sources, limitations in visualization tools like Looker can make it difficult to analyze trends over time. By consolidating data into a single, unified view at the database level, you can bypass these constraints and create seamless temporal charts.</p><p>This approach not only simplifies your analysis but also improves data governance, ensuring that your datasets are consistent and easy to manage. With a unified view, you get the flexibility to slice and analyze your data without worrying about source limitations, making it easier to uncover valuable insights.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17539f387250" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Slice and Dice: Unlocking the Power of OLAP for Flexible Data Analysis]]></title>
            <link>https://medium.com/@angelomelodosreis/mastering-slice-and-dice-unlocking-the-power-of-olap-for-flexible-data-analysis-48958991d0cd?source=rss-b79f96ed9741------2</link>
            <guid isPermaLink="false">https://medium.com/p/48958991d0cd</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[olap]]></category>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[olap-cube]]></category>
            <dc:creator><![CDATA[Angelo Gabriel]]></dc:creator>
            <pubDate>Tue, 22 Oct 2024 17:52:15 GMT</pubDate>
            <atom:updated>2024-10-22T17:52:15.449Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KjvlAUk0ds_jZswiL6_41g.png" /></figure><h3>What’s Slice and Dice in OLAP?</h3><p>In the world of data analysis, flexibility is key. OLAP (Online Analytical Processing) cubes provide a multi-dimensional way to explore and analyze data, and the techniques known as “slice and dice” are the tools that make this exploration powerful.</p><p>They allow analysts to filter and rearrange data quickly, giving deeper insights without complicated queries.</p><p>Think of it like slicing through a cake — sometimes you just want to see one layer, and other times you want to see multiple slices side by side.</p><p>In the data world, slice and dice give you that same flexibility, helping you find patterns hidden beneath the surface.</p><h3>The Slice: Focusing on a Single Dimension</h3><p>The “slice” in slice and dice refers to filtering data by one specific dimension.</p><p>For example, if you’re analyzing sales data, you might want to focus on a single year to see how sales performed in that specific period. By slicing the OLAP cube, you’re essentially cutting out just the part of the data that matches your chosen filter.</p><p>Let’s say you have a dataset of sales across multiple years. Here’s how you might slice the data to focus only on sales from 2023:</p><pre>SELECT product, region, SUM(sales)<br>FROM sales_data<br>WHERE year = 2023<br>GROUP BY product, region;</pre><p>This simple slice gives you a clear view of how products performed in 2023, without the distraction of other years’ data.</p><h3>The Dice: Filtering Multiple Dimensions</h3><p>“Dicing” takes things a step further by letting you filter data across multiple dimensions at once. This technique allows you to drill down even deeper, revealing patterns that might be hidden if you only looked at one dimension.</p><p>For example, let’s say you want to analyze sales for a specific product in a particular region and during a specific time period. You can “dice” the data by filtering on all these dimensions simultaneously:</p><pre>SELECT product, region, SUM(sales)<br>FROM sales_data<br>WHERE year = 2023<br>  AND product = &#39;Laptop&#39;<br>  AND region = &#39;North America&#39;<br>GROUP BY product, region;</pre><p>With this query, you’re dicing the data to focus on sales of laptops in North America for 2023. This multi-dimensional approach helps you zoom in on the exact insights you need.</p><h3>Why Slice and Dice Is Powerful for Analysis</h3><p>The beauty of slice and dice lies in its simplicity and flexibility. Without writing complex queries or restructuring your data, you can easily filter it based on the dimensions that matter to you.</p><p>Whether you’re looking at a single dimension like time (slice) or analyzing multiple dimensions at once (dice), these techniques make it possible to gain deeper insights into your data.</p><p>Slice and dice are especially useful in business intelligence tools, where analysts need quick answers to specific questions. Instead of running multiple reports or creating new queries each time, they can simply slice or dice the OLAP cube to view the data from different angles.</p><h3>Slice and Dice for Better Insights</h3><p>Mastering slice and dice gives you the flexibility to cut through your data in a way that makes sense for your analysis.</p><p>Whether you’re slicing by a single year or dicing across multiple categories, this technique ensures that you can explore your data from all the right angles — without the headache of complex querying. It’s like having a toolkit that helps you extract the insights that matter most.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48958991d0cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizing Data Ingestion for Large Datasets in Google BigQuery]]></title>
            <link>https://medium.com/@angelomelodosreis/optimizing-data-ingestion-for-large-datasets-in-google-bigquery-6312fdc3c6a6?source=rss-b79f96ed9741------2</link>
            <guid isPermaLink="false">https://medium.com/p/6312fdc3c6a6</guid>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-ingestion]]></category>
            <category><![CDATA[data-pipeline]]></category>
            <dc:creator><![CDATA[Angelo Gabriel]]></dc:creator>
            <pubDate>Tue, 15 Oct 2024 13:38:25 GMT</pubDate>
            <atom:updated>2024-10-15T13:38:25.670Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9wkJak51y1ynCLmh" /></figure><h3>Why Ingestion Optimization Matters in BigQuery</h3><p>When dealing with large datasets, the cost and performance of querying in BigQuery can add up quickly. Optimizing data ingestion is the first step in ensuring your workflows run smoothly.</p><p>By making a few smart choices — like how you partition data or what format you use — you can drastically improve query speed and reduce costs.</p><p>Think of it like packing for a long trip: a well-organized suitcase (or dataset) makes the journey faster, lighter, and way less expensive.</p><h3>Partitioning for Faster Queries</h3><p>Partitioning is one of the most effective ways to speed up queries in BigQuery, especially when you’re working with large datasets.</p><p>By breaking your data into chunks based on a specific column (such as date), BigQuery can focus on the relevant partitions, skipping the rest of the data and returning results much faster.</p><p>For example, imagine you’re running an e-commerce site and have millions of rows of sales data. If you partition the data by the <strong>order date</strong>, querying last month’s sales becomes much quicker because BigQuery can look directly at the relevant partitions and ignore the rest.</p><p>This simple adjustment not only speeds up queries but also reduces the cost of scanning unnecessary data. It’s like having a well-organized filing system — when you need a document from last month, you don’t have to sift through the entire year’s worth of paperwork to find it.</p><h3>Choosing the Right Compression Format</h3><p>When you’re dealing with large datasets, every bit of storage counts. Choosing the right compression format, like Parquet or Avro, can significantly reduce storage costs while speeding up the ingestion process. These formats are optimized for large datasets, offering better performance compared to uncompressed formats like CSV.</p><p>Imagine trying to send a massive email attachment. If you compress the file before sending, it not only transfers faster but also takes up less space. Similarly, using Parquet or Avro allows you to store more data efficiently and makes querying faster because less data needs to be processed.</p><p>For example, if you’re ingesting a sales dataset with millions of rows, switching from CSV to Parquet could cut your storage costs by more than half, while also reducing query processing time. It’s a win-win!</p><h3>Batch vs. Streaming Ingestion: When to Use Each</h3><p>When ingesting data into BigQuery, you have two main options: batch ingestion and real-time streaming. Each has its pros and cons, depending on your needs.</p><p><strong>Batch ingestion</strong> is ideal for larger chunks of data that don’t need to be processed immediately. For instance, you might collect daily sales data from an e-commerce platform and upload it all at once at the end of the day. This method is efficient for processing large amounts of data at once and can be more cost-effective since BigQuery is optimized for handling batch loads.</p><p><strong>Streaming ingestion</strong>, on the other hand, is perfect when you need real-time updates, like monitoring live transactions or tracking user activity on a website. It’s a little more expensive than batch processing, but the trade-off is real-time insights. Imagine a logistics company tracking delivery updates in real time — streaming ingestion makes sure they always have the latest data at their fingertips.</p><p>The key is knowing when each approach makes sense. If real-time insights aren’t critical, batch ingestion can save you both time and money.</p><h3>Simple Tweaks, Big Impact</h3><p>Optimizing data ingestion in BigQuery doesn’t have to be complicated, but it can make a huge difference.</p><p>By applying simple techniques like partitioning your data, choosing the right compression format, and selecting the proper ingestion method (batch vs. streaming), you can significantly improve both performance and cost efficiency.</p><p>These small adjustments might seem minor, but when you’re dealing with large datasets, they add up quickly. It’s like packing smart for a trip — the right suitcase and the right strategy make everything easier, faster, and a lot less stressful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6312fdc3c6a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Cassandra’s Consistency and Availability Trade-offs]]></title>
            <link>https://medium.com/@angelomelodosreis/understanding-cassandras-consistency-and-availability-trade-offs-f80e2a81bd60?source=rss-b79f96ed9741------2</link>
            <guid isPermaLink="false">https://medium.com/p/f80e2a81bd60</guid>
            <category><![CDATA[database-scalability]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[cassandra]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Angelo Gabriel]]></dc:creator>
            <pubDate>Thu, 10 Oct 2024 13:09:55 GMT</pubDate>
            <atom:updated>2024-10-10T13:09:55.814Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Trade-off Cassandra Makes</h3><p>In distributed databases, you can’t have it all — kind of like trying to plan a group dinner.</p><p>This is where Cassandra shines, letting you choose between consistency and availability depending on your needs. But you’ll have to make some trade-offs.</p><p>Cassandra gives you control over these decisions, offering flexible consistency levels.</p><p>Want more availability with a bit of lag on data consistency? No problem. Need strict consistency but can wait for it? Cassandra’s got you covered too.</p><p>Let’s dive into how this flexibility works and why it matters.</p><h3>Consistency Levels in Cassandra: How Flexible is “Eventually Consistent”?</h3><p>One of Cassandra’s key strengths is its tunable consistency, which allows you to control how data is replicated across nodes.</p><p>This flexibility is especially useful in distributed systems where network failures are common, but you still need your system to stay up.</p><p>Cassandra offers several consistency levels, from <strong>ANY</strong> (fast but less reliable) to <strong>ALL</strong> (slower but guarantees data consistency across all replicas).</p><p>The most commonly used is <strong>QUORUM</strong>, which strikes a balance — data is written to a majority of nodes, ensuring availability while maintaining reasonable consistency.</p><p>In practice, this means you get to choose: is it more important for your data to be quickly available, or should every replica agree on the state of your data before moving on?</p><h3>Use Case Example: Choosing Consistency for a Real-World Application</h3><p>Let’s say you’re building an e-commerce platform. During checkout, data consistency is critical — you don’t want users paying for the same item twice!</p><p>In this case, you’d set Cassandra’s consistency level to <strong>ALL</strong> or <strong>QUORUM</strong> to ensure all replicas have the most recent data before confirming the transaction.</p><p>On the other hand, for something like product browsing, where quick access matters more than absolute accuracy, you might go with <strong>ONE</strong> or <strong>ANY</strong>. This way, the system remains responsive even if a few nodes are out of sync.</p><p>This flexibility is what makes Cassandra a great choice for high-traffic, distributed applications, letting you tailor the consistency level to different parts of your system.</p><h3>Scalability in Action: Cassandra’s Performance at Scale</h3><p>One of Cassandra’s most impressive features is its ability to scale linearly. As you add more nodes to a Cassandra cluster, its performance improves predictably. This means it’s not just about handling more data — it’s about handling it efficiently without bottlenecks.</p><p>For example, the graph below shows how Cassandra scales in terms of write performance as the number of nodes increases. With a replication factor of 3, adding nodes dramatically improves client writes per second, maintaining a near-linear growth.</p><p>This is why companies like Netflix rely on Cassandra for their high-volume, high-availability needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i1Z1wFNlNhVLaOML.png" /></figure><p>When data grows, Cassandra doesn’t buckle under the pressure. Instead, it handles millions of writes per second with ease, making it a perfect solution for large-scale systems where uptime and performance are non-negotiable.</p><h3>When to Favor Availability over Consistency (and Vice Versa)</h3><p>Cassandra’s flexibility is one of its greatest strengths. By allowing you to tune consistency levels based on your application’s needs, it gives you control over how data is handled.</p><p>For mission-critical operations, favoring consistency ensures accuracy, while for high-availability use cases, favoring availability keeps systems responsive.</p><p>In the end, choosing Cassandra means you’re prepared for large-scale systems where data replication and performance can’t be compromised.</p><p>Whether you prioritize consistency or availability, Cassandra’s architecture is ready to handle the pressure — just like the marathon runner who doesn’t slow down when the going gets tough.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f80e2a81bd60" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Story: A New Approach to UX/UI Design (free template)]]></title>
            <link>https://medium.com/design-bootcamp/design-story-a-new-approach-to-ux-ui-design-free-template-ab943b59ca47?source=rss-b79f96ed9741------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab943b59ca47</guid>
            <category><![CDATA[product-design]]></category>
            <category><![CDATA[design-thinking]]></category>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[design-process]]></category>
            <category><![CDATA[ui-design]]></category>
            <dc:creator><![CDATA[Angelo Gabriel]]></dc:creator>
            <pubDate>Wed, 21 Feb 2024 15:13:45 GMT</pubDate>
            <atom:updated>2024-03-01T19:34:29.340Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CUE2IJg-L7Oq2Qa6d-zfBg.png" /></figure><p>You’ve probably bumped into three common things in the world of UX/UI Design:</p><ul><li>Storyboard</li><li>Persona</li><li>User Story</li></ul><p>Now, these aren’t just fancy design terms; they’re like our trusty guides helping us really get what our users need, forming the foundation of our design choices.</p><p>Let’s pause and think about something different for a sec.</p><blockquote><em>What if we added a bit of storytelling to the mix? What if we came up with something totally new?</em></blockquote><p>Well, that’s where the idea for Design Story popped up and I decided to create a new method.</p><h3>Objective</h3><p>The primary objective of the Design Story method is to enhance user-centered design practices by leveraging narrative elements such as storytelling, personas, user stories, and storyboards.</p><p>This methodology aims to improve team understanding, promote empathy, and facilitate effective communication throughout the design process, ultimately resulting in more innovative and user-focused digital experiences.</p><h3>Benefits of Design Story</h3><p>Picture Design Story as a tiny book or quick movie. When you share it with the team, everyone gets the same story.</p><blockquote>Sure, like any tale, people might see it a bit differently. But the best part, I think, is that it helps everyone get those “aha” moments.</blockquote><ul><li><strong>Enhancing User Understanding:</strong> Design Story can be harnessed to deepen the team’s understanding of users’ needs, behaviors, and goals. This can lead to designs that are more in tune with user expectations.</li><li><strong>Fostering Empathy:</strong> The aim may be to forge an emotional connection between the team and users, promoting empathy and sensitivity towards the experiences and challenges faced by users.</li><li><strong>Facilitating Team Communication:</strong> Design Story can serve as a tool to streamline communication within the team, ensuring everyone shares a common understanding of personas, stories, and user objectives.</li><li><strong>Boosting Creativity and Innovation: </strong>A goal could be to stimulate creativity and innovation within the team, encouraging the generation of innovative solutions to user problems.</li><li><strong>Enhancing Stakeholder Engagement:</strong> Making user stories more accessible and engaging for stakeholders who may not be deeply involved in the design process can be desirable for increased stakeholder engagement.</li><li><strong>Optimizing Decision-Making:</strong> Increasing clarity in decision-making throughout the design process can be an objective. This can be achieved through narratives that present the trade-offs and implications of different design choices.</li><li><strong>Facilitating New Team Member Integration</strong>: Turning Design Story into an effective integration tool for new team members allows them to quickly grasp users, objectives, and project context.</li></ul><h3>Step-by-Step Guide to Creating a Design Story</h3><p>I’m here for the community, and I’ve made a guide just for you, fellow designer.</p><p>The idea is for you to follow these steps and craft your own stories for whatever projects you’re into — be it an app, a web page, or any other solution.</p><p>This guide keeps it simple and clear, giving you straightforward instructions on how to make your story.</p><h4>1. Introduction</h4><ul><li>Start by introducing the main character or user of your design story. Describe their background, age, profession, and any relevant details that set the stage for the narrative.</li></ul><h4>2. Context Setting</h4><ul><li>Provide a brief overview of the environment in which the character operates. This could include their physical surroundings, daily activities, and any challenges they face.</li></ul><h4>3. Persona Development</h4><ul><li>Dive deeper into the persona’s characteristics, needs, motivations, and pain points. Craft a relatable and memorable persona that the team can empathize with.</li></ul><h4>4. User Storytelling</h4><ul><li>Craft user stories that encapsulate specific goals, actions, and outcomes. Frame these stories as scenarios, making them relatable and relevant to the user’s journey.</li></ul><h4>5. Storyboarding</h4><ul><li>Visualize the user stories through storyboards. Use sketches or visuals to illustrate key touchpoints in the user’s journey. These could be moments of interaction with the product or service.</li></ul><h4>6. Challenge Introduction</h4><ul><li>Introduce a challenge or obstacle that the character faces. This could be a common pain point in their journey that your design aims to address. Clearly articulate the problem to be solved.</li></ul><h4>7. Solution Introduction</h4><ul><li>Present design solutions or features that address the identified challenge. Showcase how these solutions align with user needs and goals. This is the turning point in the narrative.</li></ul><h4>8. User Journey Progression</h4><ul><li>Progress through the user journey, showcasing how the character interacts with the designed solution. Highlight key moments of interaction and illustrate the positive impact of the design.</li></ul><h4>9. Iterations and Adaptations</h4><ul><li>Illustrate how the design evolves based on user feedback and testing. Emphasize the iterative nature of the design process, showcasing refinements made to enhance the user experience.</li></ul><h4>10. Climax/Resolution</h4><ul><li>Conclude the Design Story with a climactic moment — a positive resolution that reflects the character’s success or achievement. Showcase the transformative impact of the design solution.</li></ul><h4>11. Conclusion</h4><ul><li>Summarize the key takeaways from the Design Story. Reinforce the user-centered design principles and the team’s commitment to creating meaningful and impactful user experiences.</li></ul><h3>Tips:</h3><ul><li><strong>Keep it narrative:</strong> Craft the Design Story as a continuous narrative, similar to a short story or a movie script.</li><li><strong>Focus on emotions: </strong>Highlight the emotional journey of the user to make the story more engaging and relatable.</li><li><strong>Use visuals:</strong> Incorporate visuals, such as sketches or storyboards, to enhance the storytelling experience.</li><li><strong>Iterate and refine:</strong> Don’t hesitate to iterate on your Design Story. Refine it based on team feedback and insights gathered throughout the design process.</li></ul><h3>Example of a Design Story: HomeChef App</h3><p>Personally, I find examples really helpful for learning new concepts. So, let’s jump into one.</p><p>Meet HomeChef App, an app aimed at simplifying home cooking using ingredients already stocked in people’s kitchens. Take a look!</p><p><em>In New York city, where time is a precious commodity, lives Mia, a 30-year-old professional with a passion for healthy living. In her cozy apartment, nestled among the city lights, Mia juggles a demanding job, daily workouts, and a commitment to preparing wholesome meals.</em></p><p><em>Despite her determination, Mia often finds herself standing in front of an open refrigerator, contemplating the mismatched ingredients within. This culinary challenge becomes the catalyst for an innovative journey.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*tF4qIftJ6pfJTNZwhXhZug.jpeg" /></figure><p><em>Meanwhile, across the digital landscape, resides a team of developers and designers eager to transform the way individuals approach home-cooked meals. The idea for the “HomeChef” app is born — an app that not only suggests recipes but crafts culinary adventures based on the ingredients available at home.</em></p><p><em>Mia explores the app for the first time, and the introductory screen welcomes her with a personalized touch. The app learns about her dietary preferences, cooking skill level, and favorite ingredients. This is Mia’s culinary sanctuary, designed to harmonize with her unique tastes and lifestyle.</em></p><figure><img alt="Young woman looking at her phone." src="https://cdn-images-1.medium.com/max/638/1*yHryvq37ESuQqWw5wkjyng.jpeg" /></figure><p><em>As Mia interacts with the app on her smartphone, she embarks on a user journey, creating delicious and healthy dinners using the ingredients in her fridge. Visuals showcase Mia selecting ingredients, receiving step-by-step guidance, and, in a moment of culinary triumph, presenting a beautifully plated meal.</em></p><p><em>Her challenges — limited time, diverse ingredient availability, and the need for variety — are addressed by the HomeChef app. It introduces personalized recipe recommendations, cooking time estimations, and creative ingredient substitutions.</em></p><figure><img alt="Young woman looking at her phone and cooking." src="https://cdn-images-1.medium.com/max/640/1*D8yUdpyVaekdPYRxV5rspA.jpeg" /></figure><p><em>Mia discovers recipes tailored to her preferences, gains insights into the nutritional value of each meal, and receives cooking tips from renowned chefs.</em></p><p><em>In conclusion, Culinary Harmony isn’t just about an app recommending recipes; it’s a narrative of Mia’s culinary journey — seamless, personalized, and health-conscious. The HomeChef app becomes a trusted ally, transforming every meal into a delightful exploration of flavors and well-being.</em></p><h3>Conclusion</h3><p>In the world of UX/UI Design, Design Story is like the friendly guide that shows you a new way.</p><blockquote>It’s not just about making things look good; it’s about telling stories that people can connect with.</blockquote><p>As we’ve explored this method, we’ve found it’s more than just a tool — it’s a way to make sure everyone on the team understands users and their needs.</p><p>Design Story helps us talk to each other better and be more creative. It’s like the storyteller in our design process, making sure our projects are not just pretty but also meaningful.</p><blockquote>So, for fellow designers out there, give Design Story a try. Let it be your helper in making your projects not just cool designs but stories that people enjoy and find useful.</blockquote><h3>Free template</h3><p>Since Medium doesn&#39;t allow to share PDF files, I invite you to connect with me on <a href="https://www.linkedin.com/in/angelo-melo-dos-reis/">LinkedIn</a>. You can send me a DM and you&#39;ll be glad to share the free PDF template with you.</p><p>Or, if you prefer, here is the image file.</p><figure><img alt="Image of template of the Design Story method by Ângelo Gabriel" src="https://cdn-images-1.medium.com/max/1024/1*W7tEKoWF2XdE72W52y8nyw.png" /></figure><p>Also, feel free to leave your thoughts in the comment section below. I’d be more than happy to hear your opinion!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab943b59ca47" width="1" height="1" alt=""><hr><p><a href="https://medium.com/design-bootcamp/design-story-a-new-approach-to-ux-ui-design-free-template-ab943b59ca47">Design Story: A New Approach to UX/UI Design (free template)</a> was originally published in <a href="https://medium.com/design-bootcamp">Bootcamp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>