<?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 Fajrian Aidil Pratama on Medium]]></title>
        <description><![CDATA[Stories by Fajrian Aidil Pratama on Medium]]></description>
        <link>https://medium.com/@ryanaidilp?source=rss-e720d3034687------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TrxMBxU-Rm_THASCnsoj_w.png</url>
            <title>Stories by Fajrian Aidil Pratama on Medium</title>
            <link>https://medium.com/@ryanaidilp?source=rss-e720d3034687------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 11:35:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ryanaidilp/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[Someone Cloned My Open Source Templates and Sold Them.]]></title>
            <link>https://medium.com/@ryanaidilp/someone-cloned-my-open-source-templates-and-sold-them-f561cfa3dff5?source=rss-e720d3034687------2</link>
            <guid isPermaLink="false">https://medium.com/p/f561cfa3dff5</guid>
            <category><![CDATA[code-generator]]></category>
            <category><![CDATA[code-template]]></category>
            <category><![CDATA[flutter-architecture]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Fajrian Aidil Pratama]]></dc:creator>
            <pubDate>Mon, 13 Jul 2026 07:16:40 GMT</pubDate>
            <atom:updated>2026-07-13T07:16:40.457Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Someone Cloned My Open Source Templates and Sold Them. Here’s the System I Built So It Can’t Happen Again.</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3jrrA1YNhInjqYvC4boEMQ.png" /></figure><p>A few days after Archipelago got its first paid license, someone left a comment on my post that deserved a better answer than a reply thread allows:</p><blockquote>“Congrats, developer tools like this usually win through visible proof more than description, a real repo or a before and after of setup time saved will do more for the next sale than explaining the feature list ever could. Flutter developers especially tend to trust what they can inspect directly over any pitch.”</blockquote><p>That’s a fair instinct. I share it. Most of what I use daily is open source, and I’ve published open source myself — including <a href="https://github.com/banua-coder/pico-sulteng-flutter">pico_sulteng_flutter</a>, a COVID-19 information app for Central Sulawesi built on the same architectural ideas that later became Archipelago. The generator’s CLI is on <a href="https://pub.dev/packages/archipelago_cli">pub.dev</a>, where every line of code that runs on your machine is inspectable, because that’s how pub works.</p><p>So why aren’t the templates public?</p><p>Because I already tried that. This article is about what happened, what I built in response, and — just as important — what that system deliberately does <em>not</em> try to do.</p><h3><strong>The problem I’m actually solving</strong></h3><p>Archipelago is a Flutter boilerplate generator. Its templates — <a href="https://pub.dev/packages/mason">Mason</a> bricks — encode patterns I spent years learning inside production Flutter teams at scale: API/Impl package splits, dual-scope dependency injection, build-time dependency stripping, feature SDK registries, the CI wiring that makes a 90-package monorepo tolerable.</p><p>None of that is secret <em>knowledge</em>. I write and talk about the patterns openly; the documentation site explains them at length. The value is in the thousands of hours of decisions already made, tested, and maintained as one coherent, generated system.</p><p>An early version of these templates was open source. What happened wasn’t the nightmare scenario of piracy forums — it was quieter and more corrosive. People cloned the repository, renamed the template, stripped the attribution, claimed the work as their own, and <strong>sold it</strong>.</p><p>Not “used it to build apps.” That’s the entire point of a template, and I’d celebrate it. They resold the template <em>itself</em>, under their name.</p><p>Open source licenses are a legal tool, not an enforcement mechanism. As a solo developer in Indonesia, sending cross-border takedowns over a renamed repository is not a fight I can win — or even meaningfully start. The only practical protection was to stop handing over the master copy.</p><p>That’s the constraint this system was designed under. Not “hide the ideas” — the ideas are documented publicly — but:</p><blockquote><strong>Make redistribution of the </strong><em>maintained artifact</em><strong> impractical, while keeping everything a paying developer actually touches fully open.</strong></blockquote><h3><strong>The threat model: mason unbundle is a one-liner</strong></h3><p>The natural way to distribute a Mason brick privately is mason unbundle, which packs a template into a single .bundlefile you can host anywhere.</p><p>Here’s the problem. Mason — correctly, and by design — also ships the inverse:</p><pre>mason unbundle auth_sdk.bundle -o ./extracted</pre><p>One command, and a .bundle back into the complete template source. Every file, every hook, ready to rename and re-upload. A bundlefile is not a distribution format; it’s a zip file with better manners.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6XV0t9AuRxZmsKj11XPnQQ.png" /><figcaption>Threat Roundtrip</figcaption></figure><p>If your entire protection is “<em>the download URL is behind a login</em>,” then every customer download is a full source handover, and you’re one shared file away from the clone-rename-resell cycle all over again.</p><p>So the design goal became specific: <strong>a brick artifact at rest — on the CDN, in a customer’s cache, forwarded in a chat group — must be useless to </strong><strong>mason unbundle,</strong> and only become a usable template inside an authorized generation.</p><h3><strong>The architecture: encrypt at rest, sign always, entitle at generation</strong></h3><p>The pipeline has three legs. None of them is exotic; the design is in how they meet.</p><h4><strong>1. The artifact at rest is ciphertext</strong></h4><p>CI bundles each brick with Mason, then encrypts the bundle with <strong>AES-256-GCM</strong> into a format I call .abrick:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0qZ20tk_PNUQyrPlk-A9Gg.png" /><figcaption>.abrick layout</figcaption></figure><p>That .abrickis what lives on the CDN, in the CLI’s local cache, and in any file someone might forward around. Run mason unbundleagainst it and you get nothing — it isn’t a bundle, it’s noise. GCM’s authentication tag also means a tampered file fails loudly instead of unpacking something subtly modified.</p><p>Each brick gets its own key, generated fresh at publish time, and the keys never ship with the artifact. They’re registered with the backend during the release pipeline and live only there.</p><h4><strong>2. Everything is signed, and the verifier is open source</strong></h4><p>Alongside every .abrick, CI publishes its SHA-256 and an <strong>Ed25519 signature</strong> over that hash. The private signing key exists only in CI. The public key is embedded in the CLI at build time.</p><p>Here’s where the transparency argument comes back around: <strong>the CLI is open source on pub.dev.</strong> You can read the exact Dart that recomputes the hash, verifies the signature, and refuses to proceed on mismatch.</p><h4><strong>3. The key is released only for an entitled generation</strong></h4><p>This is the leg that actually stops redistribution. The AES key for a brick is never in the file and never sent on download. It is handed to the CLI <strong>only </strong>when you run a generation and the backend confirms your entitlement — your license, your tier, an active session. The artifact only unlocks inside that authorized generation.</p><p>No entitlement, no key. No key, no usable template. A forwarded .abrick is a locked box whose key is minted per-use, server-side, for the person who paid — and the box does nothing on its own.</p><h3><strong>The publish pipeline, end to end</strong></h3><p>Everything that leaves the build is ciphertext, a hash, and a signature. The key branches off to the backend and never touches the CDN.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3tzdN8POVHU_KBJUfN-HMw.png" /><figcaption><em>What leaves the building: ciphertext + hash + signature. What never does: the AES key, and the plaintext bundle.</em></figcaption></figure><h3><strong>The generation flow, end to end</strong></h3><p>Download is cheap and unprivileged — anyone with a link gets ciphertext. The privileged moment is authorize-generation, and it happens once per generation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ske7prLBNp6eXunCa--uqA.png" /></figure><p><strong>What </strong><strong>mason unbundlesees now — and who can do what</strong></p><p>The point of the whole design collapses into one table. A leaked .abrick is not a leaked template.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2R50Z-FilKAcAk4kCe1KkQ.png" /></figure><p>The theme of that table is simple: <strong>the file and the entitlement are separated, and neither is worth anything without the other.</strong> A copy on its own is inert.</p><p><strong>What this system deliberately does </strong><em>not</em><strong> try to do</strong></p><p>Most “how we secured X” posts stop at the architecture. The part that matters more — especially to a fellow engineer deciding whether to trust the tool — is the boundaries I chose on purpose.</p><ul><li><strong>It is not selling a promise of perfect DRM. </strong>No distribution system is absolute, and I’m not going to claim a cryptographic miracle. What this design targets is the thing that actually hurt me: <em>casual</em> redistribution — the forwarded file, the renamed clone, the reseller who wants a master copy to slap their name on. Raising the cost of that from “one command” to “not worth the effort” is the entire goal, and it’s enough.</li><li><strong>It does not surveil your project.</strong> The authorize-generation call is an entitlement check for the artifact, not telemetry about what you’re building. Once files are generated, they’re yours.</li><li><strong>It does not lock your generated code.</strong> Archipelago’s output is plain Flutter you own outright — no runtime license check, no phone-home, no dependency on my servers to <em>run</em> your app. The protection lives entirely on template distribution. If I vanished tomorrow, your generated project keeps working.</li><li><strong>It does not bind to your hardware.</strong> I deliberately avoided device fingerprinting. It’s brittle in CI/CD (every runner is a “new device”), it breaks when you get a new laptop, and it’s the number-one reason developers abandon protected tools. Anti-sharing is handled at the session level instead, not by profiling your machine.</li></ul><h3><strong>So — back to the comment</strong></h3><p>The commenter was right: developers trust what they can inspect. So here’s my straight answer — <strong>inspect nearly all of it.</strong></p><p>Read the CLI on pub.dev, including the exact signature-verification code that decides whether to trust an artifact. Read my open source apps, like pico_sulteng_flutter, built on the same architecture. Read the pattern docs. Run the before-and-after yourself — that’s the visible proof that actually converts, and you’re right that I should lean into it harder than any feature list.</p><p>The single thing you can’t clone is the maintained generator artifact — and it’s protected <em>because</em> the last time it was fully open, people didn’t build with it. They renamed it and sold it back to the same developers I was trying to help. Locking that one artifact behind an entitlement check is what lets a solo developer keep maintaining the whole thing.</p><p>Transparency and protection aren’t opposites here. I chose to be transparent about everything that earns your trust — the code that runs on your machine, the patterns, the results — and to protect the one thing whose openness only ever benefited resellers.</p><p>That trade felt honest to me. Laid out in full, diagrams and boundaries and all, I hope it feels honest to you too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f561cfa3dff5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an Open-Source E-Commerce Scraper & Analytics Dashboard for Indonesia’s 2026 Economic…]]></title>
            <link>https://medium.com/@ryanaidilp/building-an-open-source-e-commerce-scraper-analytics-dashboard-for-indonesias-2026-economic-f43ad31f8475?source=rss-e720d3034687------2</link>
            <guid isPermaLink="false">https://medium.com/p/f43ad31f8475</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[sensus-ekonomi]]></category>
            <dc:creator><![CDATA[Fajrian Aidil Pratama]]></dc:creator>
            <pubDate>Sun, 05 Apr 2026 23:58:28 GMT</pubDate>
            <atom:updated>2026-04-05T23:58:28.626Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Building an Open-Source E-Commerce Scraper &amp; Analytics Dashboard for Indonesia’s 2026 Economic Census</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Yb01Ue8eqEvEjKixbYGNw.png" /></figure><p><em>How a weekend project to help my father’s office turned into a full-stack data pipeline with Chrome Extension scraping, DuckDB WASM analytics, and MapLibre GL visualization.</em></p><h3><strong>The Problem</strong></h3><p>In May 2026, Indonesia will conduct its national <strong>Sensus Ekonomi</strong> (Economic Census) — a massive nationwide effort to map every business establishment across the archipelago. The central statistics agency (BPS) tasked each regional office head (<strong><em>Kepala BPS Kabupaten</em></strong>) with creating an innovation to help analyze the growing digital commerce landscape.</p><p>My father got the assignment from the heads from one of these regional offices where he work. The challenge? Indonesia’s digital economy is fragmented across <strong>six major platforms</strong>— Tokopedia, Shopee, GrabFood, GoFood, Lazada, and Blibli — each with its own data format, anti-bot protections, and location systems. No single tool existed to collect and cross-analyze merchant data across all of them.</p><p>So, I start with some questions that I think needed answers like:</p><p>- <strong><em>How many digital merchants operate in each regency?</em></strong></p><p>- <strong><em>Which platforms dominate in which areas?</em></strong></p><p>- <strong><em>Are the same merchants listed across multiple platforms?</em></strong></p><p>- <strong><em>What does the merchant density map look like across Central Sulawesi?</em></strong></p><p>Manually visiting each platform and counting merchants? For 13 regencies, 6 platforms, and thousands of merchants — that’s not feasible.</p><p>So I built a tool.</p><p>— -</p><h3><strong>The Architecture</strong></h3><p>The solution has two parts: a <strong>Chrome Extension</strong> that scrapes merchant data with customizable location filters &amp; parameters, and a <strong>Web Dashboard</strong> that synchronizes, stores, and analyzes everything.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wxarchJx1AGEifja_IMsaA.png" /><figcaption>high level architecture of the scrapper</figcaption></figure><p>— -</p><h4><strong>Part 1: The Chrome Extension — Scraping Six Platforms</strong></h4><p><strong>Why a Chrome Extension?</strong></p><p>A traditional server-side scraper would face immediate IP bans and CAPTCHA walls. But a Chrome Extension runs <strong>inside the user’s authenticated browser session</strong>. It sees the same page as a regular user, can handle CAPTCHAs interactively, and respects each platform’s rendering pipeline.</p><p>The extension uses <strong>Manifest V3</strong> with a service worker orchestrating seven content scripts — one per platform. The popup UI is a full React app built with Vite and shadcn/ui, opening in a new tab for a richer experience.</p><p><strong>How Each Platform Gets Scraped</strong></p><p>Each platform required a completely different strategy. Here’s where it got interesting:</p><p><strong>Tokopedia</strong> uses a GraphQL API under the hood, but the search results are rendered as DOM elements with lazy-loading. The content script scrolls the page programmatically (up to 20 attempts with 800ms delays), waits for new shop cards to appear, then extracts merchant data from structured DOM selectors.</p><p><strong>Shopee</strong> was the trickiest. Their class names are obfuscated and rotate frequently — something like <strong><em>.shopee-search-item-result__item</em></strong> one week becomes .<strong><em>stardust-xxx</em></strong> the next. Instead of targeting classes, we use <strong>structural selectors</strong> and URL pattern matching:</p><pre>// Instead of fragile class names:<br>// document.querySelector(&#39;.shopee-search-item-result__item&#39;)<br>// We use URL patterns to identify shop links:<br>const SHOP_URL_PATTERN = /\/shop\/(\d+)/;<br>const PRODUCT_URL_PATTERN = /\/-i\.(\d+)\.(\d+)/;<br>// And extract shop IDs from href attributes<br>const links = document.querySelectorAll(&#39;a[href*=&quot;/shop/&quot;]&#39;);</pre><p><strong>GrabFood</strong> presented the most creative challenge. It’s a Next.js app that embeds GPS coordinates directly into API request payloads. We can’t just change a URL parameter — we need to intercept <strong><em>fetch() </em></strong>calls before they leave the browser.</p><p>The solution uses a <strong>dual-script injection</strong> pattern:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wn1PKizJ9nfakry3m_Bh9w.png" /><figcaption>Data flow Diagram of the Dual-script injection pattern</figcaption></figure><p>The interceptor script runs at <strong><em>document_start </em></strong>in the <strong>MAIN world</strong> (not the isolated content script world), meaning it patches <strong><em>window.fetch</em></strong> before GrabFood’s own JavaScript executes. It reads target coordinates from the URL hash (<strong><em>#se_lat=-0.89&amp;se_lng=119.87)</em></strong> and silently swaps them into every outgoing API request. The content script, running in the ISOLATED world, receives the intercepted merchant data via <strong><em>postMessage</em></strong>.</p><p><strong>Location Filtering: The BPS Region System</strong></p><p>Indonesia’s statistical system uses a hierarchical code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DiyU6NYWJjD-mlztsoUmYA.png" /><figcaption>Indonesian hierarchical code flow of location filtering</figcaption></figure><p>Each platform has a different way of specifying location. Tokopedia uses <strong><em>fcity</em></strong> codes, Shopee uses province-level <strong><em>locations</em></strong>, GrabFood uses GPS coordinates, and GoFood uses city slug URLs. The extension normalizes all of these to BPS region codes by:</p><p>1. Fetching regency data on-demand from the BPS API</p><p>2. Caching it in <strong><em>chrome.storage</em></strong> per province</p><p>3. Fuzzy-matching location text from merchant cards (“Kab. Banggai”, “PALU”) to the official BPS names</p><p>This means the extension stays small (no bundled lookup tables) while handling the messiness of how each platform displays location data.</p><p>— -</p><h4><strong>Part 2: The Web Dashboard — From Raw Data to Insights</strong></h4><p><strong>Data Pipeline: Extension to Parquet</strong></p><p>When the user clicks “Send to Server,” the extension POSTs merchant arrays to the Next.js API. The server deduplicates using a composite key (<strong><em>platform|name|address</em></strong> or <strong><em>platform|sourceUrl</em></strong>) and writes everything to a <strong>Parquet file</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tn7PtUfg-omkxIcNvMoZPg.png" /><figcaption>Data Pipeline from Extension to Parquet</figcaption></figure><p>Why Parquet instead of a traditional database?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y-mGlC2y_Ubh_LPCdwgidA.png" /><figcaption>Decission tree of why I choose parquet</figcaption></figure><p>A single <strong><em>merchants.parquet</em></strong> file stores all our data. The Next.js API serves it as a binary blob, and DuckDB WASM loads it directly in the browser.</p><p><strong>DuckDB WASM: SQL Analytics at Zero Latency</strong></p><p>This is where it gets powerful. Instead of sending queries to a server, we run <strong>DuckDB inside the browser</strong> using WebAssembly. The parquet file gets loaded once, and every subsequent query runs locally with no network latency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XwQCyVn7OqwBKnaJLxPM5Q.png" /><figcaption>Data flow from the parquet to Dashboard</figcaption></figure><p>The dashboard includes a full SQL editor with:</p><ul><li><strong>CodeMirror</strong> with SQL syntax highlighting and One Dark theme</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NJ-F_-w38PRzOM9A2e9_BA.png" /></figure><ul><li><strong>Multi-tab queries</strong> — run up to 10 queries simultaneously</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_6Y7H4iYWJ-A4JREZYeDJw.png" /></figure><ul><li><strong>Sample query library </strong>— pre-built templates for common census analysis</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NBN-Af4MyHSi9WoQ4hO9eA.png" /></figure><ul><li><strong>Export to CSV/Excel</strong> — one click to get results out</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*beTbbls5DipSf2njvgRiPw.png" /></figure><ul><li><strong>Live map updates</strong> — query results automatically update the choropleth map. Merchant points are generated using a <strong>seeded PRNG</strong> (Mulberry32) for deterministic placement within polygon boundaries. Each platform gets its own color, so you can visually see which platforms dominate which areas.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IH_6xoVgiYTvUZdQIJSMGA.png" /></figure><p>Users can write queries like:</p><pre>-- Merchant density by regency (updates the map)<br>SELECT regionCode, regionName, COUNT(*) as merchantCount<br>FROM merchants<br>GROUP BY regionCode, regionName<br>ORDER BY merchantCount DESC<br><br>-- Cross-platform presence<br>SELECT regionName, platform, COUNT(*) as total<br>FROM merchants<br>GROUP BY regionName, platform<br>ORDER BY regionName, total DESC<br><br>-- Filter by platform and see it on the map<br>SELECT * FROM merchants WHERE platform = &#39;gofood&#39;</pre><p><strong>Cross-Platform Merchant Matching</strong></p><p>One of the most valuable features for the census is identifying the <strong>same merchant</strong> listed across multiple platforms. “Warung Makan Ibu Siti” on GoFood might be “RM Ibu Siti” on GrabFood and “Ibu Siti Official Store” on Tokopedia.</p><p>We use <a href="https://www.geeksforgeeks.org/dsa/jaro-and-jaro-winkler-similarity/"><strong>Jaro-Winkler similarity</strong></a> (not simple Levenshtein) because it weighs matching prefixes more heavily — critical for Indonesian business names that often share prefixes like “Toko,” “Warung,” or “RM.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0G8ismiEFnjn78eqsY6M-Q.png" /><figcaption>Matching mechanism used to detect merchant across different platform</figcaption></figure><p>Matching only happens within the same region code to avoid false positives across regencies. The threshold is adjustable (80–95%).</p><p>— -</p><h3><strong>Challenges We Faced</strong></h3><h4><strong>1. The Shopee Login Wall</strong></h4><p>Shopee aggressively detects automated requests. Even with a Chrome Extension running in a real browser, requests without an authenticated session get hit with infinite CAPTCHA loops. The solution was simple but non-obvious: <strong>require the user to be logged into Shopee before scraping</strong>. The content script detects the login state and warns the user if they’re not authenticated.</p><h4><strong>2. GrabFood’s Coordinate Lock</strong></h4><p>GrabFood determines your location from the browser’s geolocation API and embeds it deep into every API request body. You can’t just change a URL parameter. Our <strong><em>document_start</em></strong> fetch interceptor was the result of many failed attempts — we tried overriding <strong><em>navigator.geolocation</em></strong>, modifying request headers, and injecting script tags. The only reliable method was patching <strong><em>window.fetch</em></strong> before GrabFood’s JavaScript bundle loads.</p><h4><strong>3. CAPTCHA Detection Across Platforms</strong></h4><p>Each platform shows CAPTCHAs differently — some use dedicated pages, others overlay modals, and some just silently stop returning data. We implemented a universal CAPTCHA detector using MutationObserver:</p><pre>// Watch for CAPTCHA elements appearing in the DOM<br>const observer = new MutationObserver(() =&gt; {<br>const captchaSelectors = [<br>&#39;[class*=&quot;captcha&quot;]&#39;, &#39;[id*=&quot;captcha&quot;]&#39;,<br>&#39;[class*=&quot;verify&quot;]&#39;, &#39;iframe[src*=&quot;captcha&quot;]&#39;<br>];<br>// If found → pause scraping, notify user, resume on solve<br>});</pre><p>The scraper pauses automatically when a CAPTCHA appears and resumes once the user solves it manually. No automation of CAPTCHA solving — this keeps it ethical and within platform terms.</p><h4><strong>4. DuckDB WASM Quirks</strong></h4><p>DuckDB’s WASM build (v1.33.1-dev) has a peculiar behavior: it resets the <strong><em>max_expression_depth</em></strong> configuration between queries. Complex SQL (like our matching query with nested CASE expressions) would fail silently. The fix was unglamorous but necessary — set <strong><em>max_expression_depth TO 500</em></strong> before every single query execution.</p><h4><strong>5. The “Palu Shows 0 Merchants” Bug</strong></h4><p>Our most confusing bug: after running <strong><em>SELECT * FROM merchants</em></strong>, the Palu regency on the map would show 0 merchants despite having 377. The root cause was a heuristic in our <strong><em>extractMapData()</em></strong> function that tried to auto-detect “count” columns for the choropleth. It was matching <strong><em>productCount</em></strong> (a per-merchant field showing how many products the merchant sells) instead of the aggregated <strong><em>merchantCount</em></strong>. The lesson: be explicit about column semantics, don’t rely on naming heuristics.</p><h4><strong>6. Parquet in Node.js is Painful</strong></h4><p>The JavaScript Parquet ecosystem is… fragmented. <strong><em>parquetjs</em></strong> is abandonware. <strong><em>parquetjs-lite</em></strong> works but is CommonJS-only, which clashes with Next.js’s ESM preferences. <strong><em>hyparquet</em></strong> is browser-only. We ended up using <strong><em>parquetjs-lite</em></strong> on the server for writing and DuckDB WASM for reading — two different libraries for the same format.</p><p>— -</p><h3><strong>Open-Sourcing It</strong></h3><p>After the tool proved useful internally, we decided to open-source it at <a href="https://github.com/IPDS-59/se-merchant-scrapper"><strong>github.com/IPDS-59/se-merchant-scrapper</strong></a> so any BPS regional office in Indonesia (or anyone else) could use it.</p><p>To prepare for open source, we:</p><p>1. <strong>Added a postinstall script</strong> for DuckDB WASM files — they’re 72MB of pre-built binaries that auto-regenerate from npm packages on <strong><em>npm install</em></strong>, so they don’t need to live in the repo</p><p>2. <strong>Wrote comprehensive Indonesian-language documentation</strong> in the README, including setup guides, troubleshooting, and deployment instructions for Netlify/Vercel</p><p>The goal is to give other regional offices a ready-made tool that they can deploy, customize for their province, and use for the census preparation.</p><p>— -</p><h3><strong>Tech Stack Summary</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0HZeY-nQlSgB0R17yR4cWA.png" /></figure><h3><strong>What I Learned</strong></h3><p>1. <strong>Every platform is a unique puzzle.</strong> There’s no universal scraping strategy. Shopee needs structural selectors, GrabFood needs fetch interception, Tokopedia needs scroll automation. Each one required understanding the platform’s rendering architecture.</p><p>2. <strong>Parquet + DuckDB WASM is a killer combo for analytical tools.</strong> Loading data once and running unlimited SQL queries with zero network latency feels like magic. For tools where the dataset fits in browser memory, this pattern eliminates the need for a query server entirely.</p><p>3. <strong>Chrome Extensions are underrated as data collection tools.</strong> They run with the user’s authenticated session, handle CAPTCHAs gracefully, and can persist state across popup open/close cycles. The Manifest V3 service worker architecture takes some getting used to, but it’s robust.</p><p>4. <strong>Build for the person who’ll actually use it.</strong> My father’s team isn’t technical — they need a button that says “Start Scraping” and a map that shows results. The SQL editor is there for power users, but the default experience had to be simple.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f43ad31f8475" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Flutter APK Size Analysis in Pull Requests: A Complete CI/CD Guide]]></title>
            <link>https://medium.com/@ryanaidilp/automating-flutter-apk-size-analysis-in-pull-requests-a-complete-ci-cd-guide-c79fa171d4fe?source=rss-e720d3034687------2</link>
            <guid isPermaLink="false">https://medium.com/p/c79fa171d4fe</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[Fajrian Aidil Pratama]]></dc:creator>
            <pubDate>Sun, 01 Feb 2026 08:26:10 GMT</pubDate>
            <atom:updated>2026-02-01T08:26:10.063Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A2K9C2fmEOEpEUtq" /><figcaption><strong>How we built an automated system to track, compare, and report Flutter APK size changes for every PR using GitHub Actions and Flutter’s built-in size analysis</strong></figcaption></figure><h3><strong>Introduction</strong></h3><p>Mobile app size matters. Every megabyte counts when users are deciding whether to download your app, especially in markets with limited bandwidth. For SDK developers, this is even more critical, your SDK’s footprint directly impacts your users’ apps.</p><p>In this article, I’ll walk you through how I implemented a comprehensive <strong>APK size analysis workflow</strong> for our Flutter SDK. This system automatically builds both the PR and base branch APKs, compares their sizes down to the feature level, and posts detailed reports directly on pull requests.</p><h3><strong>The Challenge</strong></h3><p>As maintainers of the <a href="https://github.com/ryanaidilp/stadata_flutter_sdk">Stadata Flutter SDK</a> — a wrapper for Indonesia’s statistics bureau API — we needed to answer these questions for every PR:</p><p>1. <strong>How much does this change affect the final APK size?</strong></p><p>2. <strong>Which features are contributing most to the size?</strong></p><p>3. <strong>Are we inadvertently adding heavy dependencies?</strong></p><p>4. <strong>Should this PR require additional review due to size impact?</strong></p><p>Manual checks weren’t cutting it. We needed automation.</p><h3><strong>The Solution Architecture</strong></h3><p>Here’s the high-level flow of our APK size analysis workflow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E1iNUHz9PFO8FMxb_IEnOw.png" /></figure><h3><strong>Key Components</strong></h3><h4><strong>1. Flutter’s Built-in Size Analysis</strong></h4><p>The magic starts with Flutter’s <strong><em>— analyze-size</em></strong> flag:</p><pre>flutter build apk - analyze-size - target-platform android-arm64</pre><p>This generates a detailed JSON file (<strong>apk-code-size-analysis_*.json</strong>) containing:</p><p>- <strong>Precompiled Dart code</strong> breakdown by package</p><p>- <strong>AOT (Ahead-of-Time)</strong> compiled code sizes</p><p>- <strong>Native libraries</strong> sizes</p><p>- <strong>Hierarchical package structure</strong> with sizes at each level</p><h4><strong>2. The PR Build Script</strong></h4><pre>#!/bin/bash<br># scripts/ci/build_pr_apk.sh<br># Clean for fresh analysis<br>flutter clean<br># Build with size analysis<br>flutter build apk - analyze-size - target-platform android-arm64<br># Find the generated size JSON<br>SIZE_JSON=$(find &quot;$HOME/.flutter-devtools&quot; \<br>-name &quot;apk-code-size-analysis_*.json&quot; \<br>-type f | sort -V | tail -n 1)<br># Output for GitHub Actions<br>echo &quot;apk_path=build/app/outputs/flutter-apk/app-release.apk&quot; &gt;&gt; $GITHUB_OUTPUT<br>echo &quot;size_json=$SIZE_JSON&quot; &gt;&gt; $GITHUB_OUTPUT</pre><h4><strong>3. Intelligent Caching Strategy</strong></h4><p>Building APKs is slow. We use a smart caching strategy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s7MLZenQPR87mCGJAim6Qg.png" /></figure><p>The workflow first tries to download a cached <strong><em>develop-size-analysis-latest</em></strong> artifact. Only if that fails does it checkout and build the develop branch.</p><h4><strong>4. Multi-Level Size Comparison</strong></h4><p>We compare sizes at three levels:</p><p><strong>Level 1: Total SDK Size</strong></p><pre># scripts/ci/compare_sdk_sizes.sh<br>BASE_SDK_SIZE=$(./calculate_sdk_size.sh &quot;$BASE_JSON&quot;)<br>PR_SDK_SIZE=$(./calculate_sdk_size.sh &quot;$PR_JSON&quot;)<br>SIZE_DIFF=$((PR_SDK_SIZE - BASE_SDK_SIZE))<br>SIZE_DIFF_PCT=$(echo &quot;scale=2; ($SIZE_DIFF * 100) / $BASE_SDK_SIZE&quot; | bc)<br># Threshold: 50KB increase requires approval<br>if [ &quot;$SIZE_DIFF&quot; -gt 51200 ]; then<br>echo &quot;requires_approval=true&quot; &gt;&gt; $GITHUB_OUTPUT<br>fi</pre><p><strong>Level 2: File-Level Changes</strong></p><p>Identify which specific files grew or shrank.</p><p><strong>Level 3: Feature-Level Breakdown</strong></p><p>Our SDK is organized by features (domains, publications, news, etc.). We track each feature’s size contribution:</p><pre># scripts/ci/compare_feature_sizes.sh<br># Output format:<br># | Feature | Base Size | PR Size | Diff | Change |<br># | - - - - - - -| - - - - - -| - - - - -| - - - - -| - - - - |<br># | Domains | 12.5 KB | 13.2 KB | +0.7 KB | +5.6% |<br># | Publications| 8.3 KB | 8.1 KB | -0.2 KB | -2.4% |</pre><h4><strong>5. The Analysis Script</strong></h4><p>The heart of our analysis is <strong><em>analyze_apk_size.sh</em></strong>:</p><pre>#!/bin/bash<br># scripts/analyze_apk_size.sh<br># Parse Flutter&#39;s size analysis JSON<br>PRECOMPILED_SIZE=$(jq -r &#39;.precompiled.sizeInBytes // 0&#39; &quot;$SIZE_JSON&quot;)<br>AOT_SIZE=$(jq -r &#39;.aot.sizeInBytes // 0&#39; &quot;$SIZE_JSON&quot;)<br>NATIVE_SIZE=$(jq -r &#39;.native.sizeInBytes // 0&#39; &quot;$SIZE_JSON&quot;)<br># Find SDK contribution<br>SDK_ENTRY=$(jq -r &#39;<br>.precompiled.children[] |<br>select(.n | contains(&quot;stadata_flutter_sdk&quot;)) |<br>&quot;\(.n)|\(.s)|\(.sInBytes)&quot;<br>&#39; &quot;$SIZE_JSON&quot;)<br># Extract top packages<br>jq -r &#39;.precompiled.children[] | &quot;\(.n)|\(.s)|\(.sInBytes)&quot;&#39; &quot;$SIZE_JSON&quot; \<br>| sort -t&#39;|&#39; -k3 -nr \<br>| head -20</pre><p>This produces a detailed breakdown:</p><pre>## 📊 Size Breakdown by Category<br>### Precompiled Code<br>**Size:** 2.45MB (2,569,216 bytes, 45.2%)<br>| Package | Size | Percentage |<br>| - - - - -| - - - | - - - - - - |<br>| `package:flutter` | 1.2MB | 46.7% |<br>| `package:stadata_flutter_sdk` | 156KB | 6.1% |<br>| `package:dio` | 89KB | 3.5% |</pre><h3><strong>The Final PR Comment</strong></h3><p>Here’s what developers see on their PRs:</p><pre>## 📱 APK Build Ready<br>### 📊 Size Analysis<br>| Metric | Base (develop) | PR | Change |<br>| - - - - | - - - - - - - - | - - -| - - - - |<br>| **Total APK** | 24.5 MB | 24.8 MB | +0.3 MB (+1.2%) |<br>| **SDK Size** | 156 KB | 162 KB | +6 KB (+3.8%) |<br>### 📦 Feature Breakdown<br>| Feature | Base | PR | Change |<br>| - - - - -| - - - | - - -| - - - - |<br>| Dynamic Tables | 0 KB | 45 KB | +45 KB (New) 📈 |<br>| Domains | 12.5 KB | 12.5 KB | 0 KB ➡️ |<br>| Publications | 8.3 KB | 8.1 KB | -0.2 KB 📉 |<br>### 💡 Analysis<br>- New feature added: Dynamic Tables<br>- Overall SDK size within acceptable threshold<br>- ✅ No approval required<br>[📥 Download APK](https://github.com/.../artifacts/...)</pre><h3><strong>Threshold Enforcement</strong></h3><p>We use a 50KB threshold for requiring additional approval:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TFFe-PqHoSBH82Ik2WBCTg.png" /></figure><h3><strong>Conclusion</strong></h3><p>Automated APK size analysis transforms bundle management from an afterthought into a first-class part of your development workflow. Every PR gets:</p><p>- <strong>Immediate feedback</strong> on size impact</p><p>- <strong>Detailed breakdowns</strong> by feature and package</p><p>- <strong>Actionable insights</strong> for optimization</p><p>- <strong>Historical comparison</strong> against the base branch</p><p>The complete implementation is available in my <a href="https://github.com/ryanaidilp/stadata_flutter_sdk">GitHub repository</a>. Feel free to adapt it to your Flutter projects!</p><p><em>What strategies do you use to manage APK size in your Flutter projects? Share in the comments!</em></p><p><em>If you found this helpful, follow for more Flutter DevOps content!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c79fa171d4fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a High-Performance Statistical Dashboard with DuckDB-WASM and Apache Arrow]]></title>
            <link>https://medium.com/@ryanaidilp/building-a-high-performance-statistical-dashboard-with-duckdb-wasm-and-apache-arrow-d6178aeaae6d?source=rss-e720d3034687------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6178aeaae6d</guid>
            <category><![CDATA[duckdb]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Fajrian Aidil Pratama]]></dc:creator>
            <pubDate>Mon, 17 Nov 2025 11:57:28 GMT</pubDate>
            <atom:updated>2025-11-17T12:20:06.643Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LBkXhmqZGmbrcwHvrw6ZmQ.png" /><figcaption>Landing Page of our Dashboard Page</figcaption></figure><h3>Introduction: A Personal Project with Big Performance Goals</h3><p>Last week, while working remotely and accompanying my wife in the hospital during her recovery, she reached out to me for input on a technical assignment from her supervisor at Badan Pusat Statistik (BPS — Indonesia’s Statistics Bureau). The task? To create a responsive dashboard for visualizing key statistical indicators like demographics, poverty rates, inflation, and trade data.</p><p>Since I had prior experience working with the BPS API and she needed a fresh approach, we decided to collaborate — and turned a challenging week into an opportunity to build something impactful, right from the browser.</p><p>What resulted was a fully client-side statistical dashboard powered by DuckDB-WASM and Apache Arrow, with blazing-fast data querying, minimal backend infrastructure, and thoughtful caching. In this article, I walk through the technical design, insights, and learnings from this build — including how modern browser APIs can rival traditional backend solutions.</p><h3><strong>The Problem: A Poorly Designed API</strong></h3><p>BPS offers a public API:<br> 👉 <a href="https://webapi.bps.go.id/documentation/">https://webapi.bps.go.id/documentation/</a></p><p>But working with it feels like decoding a puzzle:</p><ul><li>Nested, cryptic JSON structures</li><li>Poorly defined relationships between keys</li><li>Always returns HTTP 200 (even when nothing exists)</li><li>Slow response time, even for small datasets</li></ul><p>Here’s an example:</p><pre>{<br>  &quot;status&quot;: &quot;OK&quot;,<br>  &quot;data-availability&quot;: &quot;available&quot;,<br>  &quot;data&quot;: [<br>    {<br>      &quot;page&quot;: 1,<br>      &quot;pages&quot;: 3,<br>      &quot;per_page&quot;: 10,<br>      &quot;count&quot;: 10,<br>      &quot;total&quot;: 25<br>    },<br>    [<br>      {<br>        &quot;turvar_id&quot;: 3200,<br>        &quot;turvar&quot;: &quot;DKI Jakarta&quot;,<br>        &quot;group_turvar_id&quot;: 1,<br>        &quot;name_group_turvar&quot;: &quot;Wilayah Provinsi&quot;<br>      },<br>      {<br>        &quot;turvar_id&quot;: 4100,<br>        &quot;turvar&quot;: &quot;Pertanian&quot;,<br>        &quot;group_turvar_id&quot;: 2,<br>        &quot;name_group_turvar&quot;: &quot;Sektor Ekonomi&quot;<br>      }<br>    ]<br>  ]<br>}</pre><p>The dynamic table endpoint is even worse:</p><pre>{<br>  &quot;status&quot;: &quot;OK&quot;,<br>  &quot;data-availability&quot;: &quot;available&quot;,<br>  &quot;var&quot;: [{&quot;val&quot;: 31, &quot;label&quot;: &quot;Jumlah Penduduk&quot;, &quot;unit&quot;: &quot;Jiwa&quot;}],<br>  &quot;turvar&quot;: [{&quot;val&quot;: 0, &quot;label&quot;: &quot;Tidak Ada&quot;}],<br>  &quot;labelvervar&quot;: &quot;Kecamatan&quot;,<br>  &quot;vervar&quot;: [{&quot;val&quot;: 7315, &quot;label&quot;: &quot;Pinrang&quot;}],<br>  &quot;tahun&quot;: [<br>    {&quot;val&quot;: 99, &quot;label&quot;: &quot;1999&quot;},<br>    {&quot;val&quot;: 100, &quot;label&quot;: &quot;2000&quot;}<br>  ],<br>  &quot;turtahun&quot;: [{&quot;val&quot;: 0, &quot;label&quot;: &quot;Tahun&quot;}],<br>  &quot;datacontent&quot;: {<br>    &quot;7315310990&quot;: 308669,<br>    &quot;73153101000&quot;: 311595<br>  }<br>}</pre><p>This API structure, along with slow responses, posed a critical performance challenge, especially if the dashboard needed to feel responsive for users</p><h3>Why Client-side Data Processing Matters: Key Performance Considerations</h3><p>When building a data visualization dashboard, several factors need careful consideration:</p><ul><li><strong>Data transfer size</strong>: How much data needs to be transferred from server to client?</li><li><strong>Frontend data handling</strong>: How do we efficiently process and store data in the browser?</li><li><strong>Display performance</strong>: How do we render complex tables and charts without freezing the UI?</li><li><strong>Interactivity</strong>: Can users filter, sort, and explore data smoothly?</li><li><strong>Resource constraints</strong>: What are our deployment limitations?</li></ul><h3>Building the Stack: Tools and Trade-offs for a Browser-Based Dashboard</h3><h4><strong>Step 1: </strong>Fixing the API With stadata-js</h4><p>To make the BPS API less painful to work with, I created a JavaScript SDK:<br> 👉 <a href="https://www.npmjs.com/package/stadata-js"><strong>stadata-js</strong></a></p><p>This wrapper:</p><ul><li>Normalizes response structure</li><li>Handles API quirks internally</li><li>Makes data access simple and reliable</li></ul><p>PS: I had built a similar tool previously for Flutter — <br> 👉 <a href="https://github.com/ryanaidilp/stadata_flutter_sdk">stadata_flutter_sdk</a></p><h4><strong>Step 2: </strong>Rethinking Data Storage — Enter Apache Arrow &amp; DuckDB-WASM</h4><p>My wife’s supervisor initially suggested scraping all the data and setting up our own database.</p><blockquote>Clone the data via scraping → Put in our database → Build our own queries</blockquote><p>But I thought: why create and maintain a separate database for data that already exists and rarely changes?</p><p>Instead, I explored client-side solutions:</p><h4><strong>Initial consideration: localStorage</strong></h4><ul><li>❌ Can’t perform complex queries</li><li>❌ Complex data structures slow down read/write operations</li><li>❌ 5–10MB size limit</li></ul><h4><strong>Better approach: Apache Arrow IPC + DuckDB-WASM</strong></h4><p>After researching columnar formats, I discovered that <strong>Apache Arrow IPC</strong> is perfect for browser-based analytical workloads. Unlike JSON, Arrow uses a columnar format that’s incredibly efficient for queries.</p><p>Here’s the architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PxxBiMm68NxUixAP3EAupQ.png" /></figure><h4><strong>Data Format Comparison: Why Apache Arrow IPC?</strong></h4><p>When choosing a data format for browser-based analytics, we evaluated several options:</p><h4><strong>Format Comparison Table</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tJkj3tpvyUO0tF1m7Mdtaw.png" /></figure><h4><strong>Real-World Performance: Our Data</strong></h4><p>Let’s compare these formats with actual data from our dashboard (Jumlah Penduduk table, 1,000 rows):</p><p><strong>JSON (Original BPS API format):</strong></p><pre>{<br>  &quot;datacontent&quot;: {<br>    &quot;7315310990&quot;: 308669,<br>    &quot;73153101000&quot;: 311595,<br>    // ... 998 more entries<br>  }<br>}</pre><ul><li><strong>Size</strong>: ~85 KB</li><li><strong>Parse time</strong>: ~15ms</li><li><strong>Query time</strong> (filter + sort): ~120ms (scan all objects)</li><li><strong>Web Worker transfer</strong>: ~8ms (structured clone)</li><li>❌ <strong>Problem</strong>: Must scan every object for filtering</li></ul><p><strong>CSV:</strong></p><pre>kecamatan,tahun,value<br>Pinrang,1999,308669<br>Pinrang,2000,311595</pre><ul><li><strong>Size</strong>: ~42 KB</li><li><strong>Parse time</strong>: ~25ms (split strings)</li><li><strong>Query time</strong> (filter + sort): ~100ms (array operations)</li><li><strong>Web Worker transfer</strong>: ~6ms (structured clone)</li><li>❌ <strong>Problem</strong>: Text parsing overhead, no type information</li></ul><p><strong>Parquet</strong></p><p>Binary columnar format with compression</p><ul><li><strong>Size</strong>: ~18 KB (GZIP compression)</li><li><strong>Parse time</strong>: ~45ms (decompress + parse)</li><li><strong>Query time</strong> (filter + sort): ~12ms (columnar scan)</li><li><strong>Web Worker transfer</strong>: ~5ms (clone ArrayBuffer)</li><li>⚠️ <strong>Trade-off</strong>: Great for storage, slower to read due to decompression</li></ul><p><strong>Apache Arrow IPC (Our Choice):</strong></p><p>Binary columnar format, uncompressed</p><ul><li><strong>Size</strong>: ~35 KB (no compression)</li><li><strong>Parse time</strong>: ~2ms (zero-copy memory mapping)</li><li><strong>Query time</strong> (filter + sort): ~8ms (columnar scan)</li><li><strong>Web Worker transfer</strong>: ~0.5ms (Transferable Object)</li><li>✅ <strong>Winner</strong>: Perfect balance for browser analytics</li></ul><h4><strong>Why Arrow IPC Won</strong></h4><p>Apache Arrow IPC (Inter-Process Communication) format is:</p><ul><li><strong>Columnar</strong>: Like Parquet, but optimized for in-memory processing</li><li><strong>Zero-copy</strong>: Direct memory mapping, no parsing overhead</li><li><strong>Transferable</strong>: Can be passed to Web Workers without cloning (Transferable Object)</li><li><strong>DuckDB-native</strong>: Seamless integration with DuckDB-WASM</li><li><strong>Fast serialization</strong>: No compression overhead, faster than Parquet for frequent read/write</li><li><strong>Type-safe</strong>: Preserves data types (numbers stay numbers, not strings)</li></ul><p><strong>Real-world impact:</strong></p><ul><li><strong>First table load</strong>: 2–3 seconds (API + cache)</li><li><strong>Subsequent loads</strong>: &lt;1 second (Arrow IPC from IndexedDB)</li><li><strong>Filter operations</strong>: &lt;50ms (DuckDB SQL on Arrow data)</li><li><strong>Chart updates</strong>: ❤00ms (Arrow → Web Worker → Chart.js)</li></ul><p>According to <a href="https://duckdb.org/2021/10/29/duckdb-wasm">DuckDB benchmarks</a>, querying with DuckDB-WASM on Arrow data is <strong>10–100x faster</strong> than processing plain JavaScript objects.</p><blockquote><strong>Key insight</strong>: For long-term archival storage where data is rarely accessed, Parquet’s compression wins. But for browser-based analytics where data is loaded once and queried frequently, Arrow IPC’s zero-copy performance is unbeatable.</blockquote><h4><strong>Step 3: </strong>Offloading Computation Using Web Workers</h4><p>Chart/table processing can get heavy, especially with large datasets. To keep the UI responsive, we:</p><ul><li>Offload post-DuckDB query tasks to Web Workers</li><li>Pass Arrow IPC buffers directly (zero-copy transfer)</li><li>Format data (legends, series, column groups) inside workers</li></ul><p><strong>Why this works:</strong> Apache Arrow tables are <strong>Transferable Objects</strong> — no cloning overhead!</p><p><strong>Why Apache Arrow?</strong></p><p>One major concern with Web Workers is the cost of transferring data between main thread and worker thread. Typically, JavaScript objects must be <strong>cloned</strong> when passed to workers, which is expensive for large datasets.</p><p>Apache Arrow solves this elegantly: it’s a <strong>Transferable Object</strong>, meaning we can pass a reference (not a copy) to the worker thread. This dramatically reduces memory usage and transfer time.</p><p>When post-processing completes, results are transferred back to the main thread as buffers using the same zero-copy mechanism.</p><p><strong>Complete Data Processing Flow</strong></p><p>Here’s the end-to-end flow when a user generates a table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o77Yxibx_KicFhHRt3M8AQ.png" /></figure><p><strong>State Management with Pinia</strong></p><p>Even for a “simple” dashboard, state can get complex:</p><ul><li>Filters (variables, years, regions)</li><li>Data loading and caching</li><li>Chart type toggles</li><li>UI preferences</li></ul><p>With <strong>Pinia</strong>, state is modular and clean:</p><ul><li>filtersStore → Selection logic</li><li>dataStore → API/cache loading</li><li>visibilityStore → Table column filters</li><li>uiStore → Panel states &amp; exports</li></ul><h4><strong>Intelligent Caching Strategy</strong></h4><p>A major pain point was the slow API response times. Users shouldn’t have to wait for the same data repeatedly.</p><p><strong>Solution: IndexedDB with Time-To-Live (TTL)</strong></p><p>Every API response is cached in IndexedDB with a timestamp. On subsequent requests, we:</p><p>1. Check if data exists in cache</p><p>2. Verify the data hasn’t expired (based on TTL)</p><p>3. Return cached data if valid, otherwise fetch fresh data</p><p><strong>TTL Configuration:</strong></p><ul><li><strong>Variables, vertical variables, derived variables</strong>: 24 hours (rarely changes)</li><li><strong>Derived periods</strong>: 24 hours</li><li><strong>Dynamic tables</strong>: 6 hours (updated more frequently)</li><li><strong>Strategic indicators</strong>: 30 minutes (near real-time data)</li></ul><p>This strategy provides:</p><ul><li>Fast subsequent visits (&lt;1 second load time)</li><li>Reasonable data freshness</li><li>Reduced server load</li></ul><p><strong>Automatic Metadata Loading</strong></p><p>When a user selects a variable/table, the system automatically loads all related metadata in parallel using Promise.all():</p><ul><li>Vertical variables (table rows)</li><li>Derived variables (data categories)</li><li>Derived periods (months/time breakdowns)</li><li>Periods (years)</li></ul><p>We also filter out meaningless data like single “Tahun” (Year) entries that don’t add value.</p><h3><strong>Production Challenges</strong></h3><h4><strong>Challenge 1: DuckDB Fails in Production Build</strong></h4><p><strong>The Problem:</strong></p><p>DuckDB worked flawlessly in development, but <strong>completely failed in production</strong>. The error: “Table does not exist” — even though the table loaded successfully.</p><p>After hours of debugging, I discovered that `insertArrowTable()` <strong>silently fails in production builds</strong>, likely due to minification or optimization issues.</p><p><strong>The Solution:</strong></p><p>Implement an automatic fallback mechanism:</p><p>1. Attempt to insert data using Arrow format (optimal performance)</p><p>2. Verify the table exists after insertion</p><p>3. If verification fails, fallback to manual SQL INSERT:</p><ul><li>Convert Arrow table to JSON</li><li>Generate batch INSERT statements</li><li>Execute via DuckDB SQL API</li></ul><p>This approach maintains optimal performance when possible, while ensuring reliability through the fallback.</p><h4><strong>Challenge 2: CSP Headers vs DuckDB Workers</strong></h4><p><strong>The Problem:</strong></p><p>Content Security Policy (CSP) headers blocked DuckDB’s web workers. DuckDB-WASM needs to load worker scripts from a CDN using importScripts(), which CSP blocks by default.</p><p>Without DuckDB, the entire dashboard is useless. But removing .htaccess entirely breaks <strong>SPA routing</strong> — direct URL access returns 404.</p><p><strong>The Solution:</strong></p><p>Create a minimal .htaccess configuration.</p><h4><strong>Challenge 3: Cache Corruption</strong></h4><p>Sometimes the IndexedDB cache got corrupted (browser crashes, force quits, etc.), causing the dashboard to crash on load.</p><p><strong>The Solution:</strong></p><p>Implement automatic cache recovery:</p><p>1. Detect “table does not exist” errors in DuckDB queries</p><p>2. Automatically clear corrupted cache</p><p>3. Re-fetch fresh data from API</p><p>4. Gracefully fallback to placeholder data if API fails</p><p>Users now experience seamless operation — no crashes, no error messages.</p><h4><strong>Challenge 4: Shared Hosting Constraints</strong></h4><p>My wife’s office only provided <strong>shared hosting</strong> with these limitations:</p><ul><li>❌ No Node.js backend</li><li>❌ Apache server with limited configuration</li><li>❌ No control over server headers beyond `.htaccess`</li><li>✅ Must support direct URL access for SPA</li></ul><p><strong>The Silver Lining:</strong></p><p>These constraints actually led to a better solution: a <strong>fully client-side application</strong>. No backend server needed — everything runs in the browser (data processing, querying, caching). Perfect for shared hosting!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNXKiziD6W7q0tLsmAAMTQ.png" /><figcaption>UI of the table &amp; chart generator</figcaption></figure><h3><strong>Key Lessons Learned</strong></h3><h4><strong>1. Development ≠ Production</strong></h4><p>Code that works perfectly in development can fail catastrophically in production. <strong>Always test production builds thoroughly</strong> before deployment, especially when using WebAssembly or complex tooling.</p><h4><strong>2. Performance is a Feature</strong></h4><p>Users don’t care about your impressive tech stack — they care about <strong>speed and responsiveness</strong>. Aggressive caching, lazy loading, and web workers made the difference between a sluggish and delightful user experience.</p><h4><strong>3. Browser APIs are Incredibly Powerful</strong></h4><p>We run a <strong>full SQL database</strong> (DuckDB) directly in the browser, query columnar Arrow data efficiently, and handle complex analytical workloads — <strong>all without a backend server</strong>. Modern web APIs have come remarkably far.</p><h4><strong>4. Apache Arrow is a Game Changer</strong></h4><p>Zero-copy data transfer between threads, efficient memory usage, columnar storage format, and native integration with DuckDB. Once you experience Apache Arrow’s performance, there’s no going back to plain JavaScript objects for analytical workloads.</p><h4><strong>5. Security vs Functionality Trade-offs</strong></h4><p>Strict Content Security Policy is important for security, but sometimes pragmatic trade-offs are necessary. Understanding your threat model and use case is crucial for making informed decisions.</p><h4><strong>6. State Management Prevents Technical Debt</strong></h4><p>Even for a “simple” dashboard, proper state management with Pinia saved us from prop-drilling hell, made debugging straightforward, and kept the codebase maintainable as features grew.</p><h4><strong>7. IndexedDB Over localStorage</strong></h4><p>For anything beyond trivial key-value storage, IndexedDB is the right choice. Yes, the API is more complex than localStorage, but libraries like `idb` provide a clean interface while giving you the power of a real database in the browser.</p><h4><strong>8. Constraints Breed Innovation</strong></h4><p>Shared hosting limitations forced us to build a fully client-side solution, which turned out to be <strong>more performant</strong> and <strong>easier to deploy</strong> than a traditional client-server architecture. Sometimes limitations push you toward better designs.</p><h3><strong>Conclusion</strong></h3><p>Building this statistical dashboard was a journey through modern web technologies and architectural patterns. From wrangling poorly designed APIs to optimizing browser-based data processing, every challenge had an elegant solution.</p><h4><strong>Key Takeaways:</strong></h4><ul><li><strong>Client-side analytical processing</strong> is not only viable but often superior with modern tools (DuckDB-WASM, Apache Arrow, Web Workers)</li><li><strong>Intelligent caching strategies</strong> can transform user experience without backend infrastructure</li><li><strong>Production environment testing</strong> is non-negotiable for complex applications</li><li><strong>Performance optimization</strong> requires a holistic approach: network efficiency, processing speed, and rendering performance</li><li><strong>Constraints can lead to better solutions</strong> — sometimes limitations force more elegant architectures</li></ul><p>The dashboard is now live and serving users at BPS Sulawesi Tengah. My wife’s team can visualize complex statistical data efficiently without waiting for slow API responses or wrestling with cryptic data structures.</p><p><strong>🚀 Try it yourself: </strong><a href="https://tes.bpsslteng.id/"><strong>tes.bpssulteng.id</strong></a> (Feel free to test and explore!)</p><p>Mission accomplished! 🎉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6178aeaae6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Decade Later: A Small Note in the Middle of Jakarta’s Traffic]]></title>
            <link>https://medium.com/@ryanaidilp/a-decade-later-a-small-note-in-the-middle-of-jakartas-traffic-7554ad6b1534?source=rss-e720d3034687------2</link>
            <guid isPermaLink="false">https://medium.com/p/7554ad6b1534</guid>
            <category><![CDATA[journaling]]></category>
            <category><![CDATA[reflections]]></category>
            <category><![CDATA[self-reflection]]></category>
            <dc:creator><![CDATA[Fajrian Aidil Pratama]]></dc:creator>
            <pubDate>Sat, 19 Jul 2025 05:38:56 GMT</pubDate>
            <atom:updated>2025-07-19T11:22:21.098Z</atom:updated>
            <content:encoded><![CDATA[<h4>Reflections on growing up, chasing what felt impossible, and learning how to stay human through it all.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cBDWFyB4VNEBRoM-4CqCpA.jpeg" /></figure><p>I’m writing this not for applause, not for sympathy — just for myself.<br>Because lately, my mind feels full. Too full.<br>Of worry, of pressure, of memories I didn’t even know I was still carrying.</p><p>A song played the other night — <em>NINA</em> by .Feast — and I froze at the line:<br><em>“Beda kota, pisah raga, bukan masalahku. Lihat wajahmu di layar, ku tetap bersyukur.”</em><br>It hit me harder than I expected.<br>It reminded me of my dad. Of my wife. Of my two youngest siblings.<br>It reminded me of how far I’ve come, and how far I still feel from peace.</p><p>Sometimes I forget that I’ve been through a lot.<br>That I left my village when I was just a teenager.<br>That I carried hope heavier than my backpack.<br>That I’ve built a life from almost nothing.</p><p>So this is just me, writing things down — chapter by chapter — so I don’t lose them.<br>Because when things get loud in my head, it helps to remember where it all began.</p><h3>Chapter 1: The Noise Never Stops</h3><p>Ten years.</p><p>It’s easy to say it like it’s just a number, but when I really look back — when I trace every late night, every tear I wiped before anyone could see, every leap I forced myself to take even when my legs were shaking — it’s not just time.<br> It’s transformation.</p><p>I’ve been listening to <em>.Feast — NINA</em> a lot lately.<br> There’s a part that hits me right in the chest:</p><blockquote>“Beda kota, pisah raga, bukan masalahku. Lihat wajahmu di layar, ku tetap bersyukur”</blockquote><p>Long-distance has been a recurring theme in my life.<br>From leaving home at 15, to enduring years of LDR in my relationship till now that I marriage, to watching my siblings grow up through tiny screens. I’ve learned how to love people from a distance. I’ve learned how to carry them in my pocket — in pictures, calls, and memories — even when I can’t hold their hands.</p><p>I’ve also grown apart from versions of myself.<br>The insecure boy from a small village.<br>The struggling undergrad who coded through the night because he couldn’t afford failure.<br>The early-career developer, exhausted but proud to send money back home.<br>The newlywed, split by cities, unsure how to balance love and ambition.</p><p>Each version still lives in me, whispering reminders.</p><blockquote>“Tumbuh lebih baik, cari panggilanmu, jadi lebih baik, dibanding diriku…”</blockquote><p>That line.<br>That line makes me think of my two youngest siblings.<br> It makes me think of the child I might raise someday.</p><p>Will I be able to give them a better life?<br>Not just one with more money or stability, but one where they feel safe to dream, to fail, to grow?<br>I don’t know. But every decision I make now is an attempt to say: <em>Yes, I’m trying.</em></p><p>Because I didn’t have much, but I had people who believed in me.<br>And I want to be that person for them.</p><p>This is not just a story of success.<br>This is not a LinkedIn flex.<br>This is a love letter to my past self, and a promise to the people I care about.</p><p>That no matter how far I go, no matter what city I end up in — <br> I will never forget the boy who started this journey,<br> And I will never stop trying to become someone he’d be proud of.</p><h3>Chapter 2: The Whisper That Started It All</h3><p>I was in high school when I first left the small village where I grew up.</p><p>It was the first time I lived apart from my family, the first time I saw a city that stayed awake past 9 PM. I moved to the capital of my hometown — still within the same province, but it felt like a different world.</p><p>I was lucky. I got into one of the top private high schools there. A place where people took school seriously, where students talked about dreams like they were something they could actually reach.</p><p>There was something different about that school. It had ambition in the walls.</p><p>Our seniors would come back and share stories of where life had taken them — ITB, ITS, UI. Big names. Big futures. They showed up in clean shirts and confident voices, telling us how they made it out, how they chased something bigger.</p><p>And I remember sitting in the back, listening. Not saying much.<br>Just… wondering.<br>Could that be me too?</p><p>Until then, the idea of “success” was blurry. I thought it meant having a job and sending money home. But that year, it started to mean something else.</p><p>That was also when I first heard about Gojek.<br>A new kind of company. Something built in Indonesia, for Indonesians, using tech. I didn’t understand everything, but it sounded… exciting.</p><p>And in that environment — surrounded by people smarter than me, more confident than me — I whispered something small to myself:</p><blockquote><em>“Could I work at a place like that one day?”</em></blockquote><p>Just a tiny thought. I never said it out loud.<br>But it stuck with me.</p><p>I started learning about computers, teaching myself bits of code when I could. I didn’t know where it would lead. I just knew it felt like a way forward.</p><p>Back then, everything felt far away.<br>Jakarta, Gojek, even college.</p><p>But I kept the whisper close.</p><p>It’s wild to think how that first step — leaving home for high school — quietly changed everything.<br>It showed me what was possible.</p><p>And once you’ve seen what’s possible, it’s hard to go back to just surviving.</p><h3>Chapter 3: Between Lecture Halls and Hunger Pangs</h3><p>The first year of college was like being dropped into the deep end of the pool — sink or swim.</p><p>I got into a university in a bigger city. Not the most prestigious campus, but it was <em>my</em> stepping stone. My ticket to prove that a village boy like me could stand shoulder to shoulder with anyone else. I was filled with excitement and hope, but I wasn’t ready for the cost — not just the financial one, but the emotional toll of growing up fast and alone.</p><p>I didn’t tell many people this, but there were days I only ate once. Sometimes, I lied to my mom, saying I had dinner, just so she wouldn’t worry. I remember boiling instant noodles and splitting it into two meals. I remember the anxiety of counting coins before deciding whether I could afford a glass of iced tea.</p><p>But I also remember something else: <strong>GRIT</strong>.</p><p>I took freelance jobs just to get by. Late nights were my routine — half studying, half hustling. I taught myself to code from scratch, driven by nothing but YouTube tutorials, curiosity, and survival instinct. I didn’t know then that this would later open the doors to everything I once dreamed of.</p><p>Some nights I cried. Some nights I felt like quitting.<br>But each morning, I chose to rise again — sometimes not because I wanted to, but because I had to.</p><p>That period taught me more than any textbook ever could.<br>How to be resourceful. How to ask for help without shame. How to endure failure, and try again anyway.<br>It built a foundation of humility and hunger that I carry with me to this day.</p><p>And somehow, in the middle of all that chaos, I found meaning.</p><p>There’s a moment I’ll never forget:<br>A message from my younger sibling, saying, “Kak, aku mau kayak kamu nanti.”<br>That one line reminded me why I started this journey in the first place.</p><p>I wasn’t just trying to change my own life — I was trying to rewrite our family’s narrative.</p><p>That thought kept me moving forward.<br>And little by little, it worked.</p><p>By the time I reached the end of university, I wasn’t the same boy who had arrived years before, confused and underfed. I was a man shaped by struggle, sharpened by resilience, and softened by empathy.</p><p>And most importantly, I was finally ready for the next leap.</p><h3>Chapter 4: Jakarta, Distance, and the People I Love</h3><p>Jakarta was never in the plan. At least, not in the way it arrived.</p><p>The city felt alive in a way I had never experienced before. Jakarta wasn’t just big — it was relentless.</p><p>Tall buildings, chaotic traffic, the blur of ambition in every face you passed. I had finally made it to the capital, the land of opportunity.</p><p>But freedom, I learned, came with its own price.</p><p>The salary I received seemed big — until rent, food, transport, and helping my family back home carved it into tiny pieces. I was proud to send money back every month. It felt like I was repaying a debt not of money, but of love. But I never realized how heavy it would feel to be <em>the one everyone depends on</em>.</p><p>I wasn’t chasing prestige. I was chasing something harder to name. Growth? Stability? A version of myself that could finally breathe?</p><p>Jakarta is tough. But life now? Honestly, I can’t lie — it’s also the best version of life I’ve ever lived.</p><p>I still remember the kos-kosan I lived in during college. A room so small I had to move things around just to do my sholat. The bathroom was outside and shared. No proper kitchen, no AC, and the heat could be unbearable. But that was my life, and I had to make it work. I’d cook on a tiny electric stove, save money by eating simple food every day, and often wonder: will I ever get out of this loop?</p><p>Now I wake up in a proper house.<br>There’s a kitchen set.<br>A clean shower.<br>Air conditioner humming softly.<br>A king-size bed I never imagined I’d sleep in.</p><p>What people don’t always tell you is that getting what you wanted — after years of not having it — comes with a strange kind of grief.</p><p>For someone like me, who came from a modest family, “living well” in a city like this means stretching every inch of energy, time, and money.</p><p>You don’t want to just survive, but you also don’t want to live paycheck to paycheck forever. You want to provide. For your partner. For your parents. For your future.</p><p>And it’s hard.</p><p>My dad still can’t get his eye surgery done. His condition hasn’t improved. I haven’t been able to help as much as I want to. Every time I call home, I pretend like things are going fine — but deep down, I know I’m just treading water.</p><p>Since getting married, everything’s been in flux — moving out, moving in, starting a new life, planning the next move. And now I’m back in Jakarta while she’s still finishing up things back home.</p><p>It feels like everything is half-done. Half-started.</p><p>Now, even though I’m overwhelmed sometimes with this Jakarta life — the traffic, the pace, the WFO culture — I can’t deny that I’ve come a long way.</p><p>I should feel proud. Grateful. And I do — most of the time. But some nights I just lie there, listening to the city outside, and miss the sound of home. Not the physical place. But the feeling. The ease of having family close. The comfort of familiarity. The quiet understanding that comes from being seen, without having to explain.</p><p>The hardest part wasn’t the new job or the big city. It was the distance.</p><p>When I was working remotely, I could help my wife with the small, quiet things — <br>Cooking together.<br>Picking her up from work.<br>Doing chores while she rested.<br>Being present, not just providing.</p><p>Now everything feels like a trade.<br>She’s in one place. I’m in another.<br>We’re both growing — but in separate rhythms.<br>We still talk. We still laugh.<br>But sometimes, love feels like scheduling.</p><p>And then there’s my father — getting older and more fragile every time I visit.<br>My siblings — especially the two youngest — looking up to me with eyes full of questions I’m not sure I can answer.</p><p>And again, that’s when the song <em>NINA</em> by .Feast hit me in a way I didn’t expect.<br><em>“Tumbuh lebih baik, cari panggilanmu, jadi lebih baik dibanding diriku.”</em><br>I thought about my siblings.<br>About my future kids.<br>Will they live better lives than mine?<br>Will I be the one to open that door for them?</p><p>Those words echoed in my mind like a blessing and a burden.<br>Because now, it wasn’t just about me. I had younger siblings watching. I had a future child I hadn’t met yet, whose life I was already trying to improve. I was planting trees whose shade I might never sit under.</p><p>And I was okay with that.</p><p>Sometimes I worry that I’m just surviving in a shinier box.<br>That I’ve moved forward, yes — but am I also moving <em>closer</em> to the life I truly want?</p><p>I’ve come a long way from that boy who left the village.<br>But part of him still lives inside me.<br>He still asks the same questions.<br>He still hopes the people he loves will be okay.</p><p>And he still believes that all this — every move, every sacrifice — is worth it, if it means they can grow up with less weight on their shoulders than I had on mine.</p><p>I keep remind myself — this is a phase. A difficult one, but not permanent. I try to focus on what this sacrifice is for. The bigger picture. A better future. Because if I’ve made it from kos-kosan to this life, maybe I can keep walking forward — for myself, for my wife, for my family.</p><h3>Chapter 5: What I Don’t Say on the Video Call</h3><p>We call almost every day.<br>Morning greetings. Quick updates between work. Night check-ins before bed.<br>We try to bridge the distance with routine — and it helps, most days.</p><p>But the truth is: no matter how many times we talk,<br>no screen can hug you back.</p><p>Some nights, I stare at the ceiling and feel the weight in my chest.<br>Not sadness exactly. Just… tired. Worn out in a way that sleep doesn’t fix.</p><p>I want to say it out loud:<br>“I miss having someone to come home to.”<br>“Even with a job I used to dream about, sometimes I still feel lost.”</p><p>But I don’t.<br>Because I know she’s tired too.<br>Because I don’t want to worry anyone.<br>Because as a man, somewhere along the way, I learned to hold it in.</p><p>That’s what we’re taught, right?<br>Be strong.<br>Don’t complain.<br>Man up.<br>Swallow it down.</p><p>So instead, I joke. I smile. I say I’m fine.<br>And maybe I <em>am</em> fine. But also — maybe I’m not.</p><p>Lately, I’ve been thinking…<br>What if strength isn’t about holding it together all the time?<br>What if real strength is being able to say:<br>“I’m not okay right now,”<br>and trusting that it doesn’t make you less of a man?</p><p>Maybe it takes more courage to open up<br>than it does to keep pretending.</p><p>And maybe — just maybe — we all need a little more space<br>to be soft, even in this world that keeps asking us to be hard.</p><h3>Chapter 6: A Decade in the Mirror</h3><p>Some days, I still feel like that kid from the village.</p><p>The one who used to dreaming of a better life.</p><p>The one who started hustling at eight — not because it was fun, but because life didn’t leave much choice.<br>On weekends, I’d walk with my mom to traditional markets, helping her sell virgin coconut oil she made at home. I tried selling things I crafted myself, anything that might earn a few extra coins.<br>In high school, I even delivered gallons of water to help cover daily expenses.</p><p>If you had told me ten years ago where I’d be today, I’m not sure I would’ve believed you.</p><p>Back then, everything felt so uncertain. I was just a kid from a small village, hoping hard work would be enough. I didn’t know the cost of ambition yet. I didn’t know that chasing dreams would sometimes mean sleeping with a racing mind and an empty stomach. I didn’t know that “growing up” would feel like constantly holding back tears you don’t have time to cry.</p><p>But I made it here. Not perfectly, not painlessly — but I made it.</p><p>There’s a version of me in every place I’ve lived:<br>The hopeful boy in high school, watching seniors get into top universities.<br>The broke student in college, eating instant noodles and coding until dawn.<br>The fresh grad in his first real job, trying to look like he belonged.<br>The husband saying goodnight through a screen, faking energy he doesn’t feel.</p><p>Each of those versions carried something forward so the next could walk a bit taller. And now, I look in the mirror and see a man I never imagined — but somehow always hoped to become.</p><p>And still, I’m not done.</p><p>If the past ten years were about survival, I want the next ten to be about presence.<br>Not just achieving, but <em>living</em>.<br>Not just providing, but <em>nurturing</em>.<br>Not just appearing strong, but <em>being honest</em>, even when it’s uncomfortable.</p><p>Because strength isn’t about silence.<br>It’s about showing up again and again — with love, with truth, with the willingness to grow.</p><p>I know the road ahead won’t be smooth. There will be setbacks. Fears I haven’t met yet. Losses I can’t prepare for.</p><p>But I also know this: I’ll keep showing up.<br>For my family.<br>For the boy I used to be.<br>For the man I’m still becoming.</p><p>And maybe, one day, my son or daughter will read this.<br>And they’ll know — Dad didn’t have it all figured out.<br>But he tried.<br>He really tried.</p><h3>Epilogue</h3><p>Sometimes I look back and wonder how that little boy survived it all.</p><p>The one who walked to the market every weekend with his mom, carrying bottles of virgin coconut oil.<br>The one who sold whatever he could — snacks, crafts, even delivered gallons of water — just to get by in high school.<br>The one who left home early, not because he wanted to chase dreams, but because he had to.</p><p>And then I blink, and I’m here.<br>Living in a place I used to only imagine.<br>Working a job that once felt unreachable.<br>Calling someone “wife” — building a life together, even if we’re apart most days.</p><p>Ten years ago, I whispered a dream into the dark.<br>Now I’m living it — sort of.<br>It’s not perfect. It’s not peaceful.<br>But it’s real. And it’s mine.</p><p>So maybe, ten years from now, I’ll be somewhere better.<br>A home with warm lights. A family that laughs at dinner. A job that challenges but doesn’t consume.</p><p>Ten years feel like a blur and a lifetime all at once.<br>So much of it was survival. Hustling. Pushing. Enduring.<br>I spent most of it proving I was enough. That I could carry it all. That I could make everyone proud.</p><p>But lately, I’ve started asking myself: <em>what now?</em><br>If not just working. If not just chasing the next thing.<br>What do I want this next decade to feel like?</p><p>I want to breathe easier.<br>To laugh without guilt.<br>To stop grinding like I’m still that scared kid in the market.</p><p>I want joy. Not just the loud kind, but the quiet, steady one.<br>The kind you feel when you’re home, when you’re whole, when nothing’s missing — even if things aren’t perfect.</p><p>I’m not saying I’ve figured it all out.<br>But I know now I don’t have to carry it alone.<br>And maybe, for the first time, I believe I deserve to rest, too.</p><p>The boy who started all this?<br>He’d be proud.<br>And I think he’d be relieved to know — it’s okay to slow down now.</p><p>I’m still learning.<br>Still healing.<br>Still becoming.</p><p>But for once, hopefully I’m not in a rush.</p><p>I don’t know. But I hope.</p><p>And for now, I’ll keep moving.<br>Even when it’s slow. Even when it’s hard.<br>Even when I don’t know what comes next.</p><p>Because if life could hear me back then… maybe it still does.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7554ad6b1534" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streamlining Flutter Development with Mason and BrickHub]]></title>
            <link>https://medium.com/@ryanaidilp/streamlining-flutter-development-with-mason-and-brickhub-21c5020e9761?source=rss-e720d3034687------2</link>
            <guid isPermaLink="false">https://medium.com/p/21c5020e9761</guid>
            <category><![CDATA[template]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[ui-design]]></category>
            <dc:creator><![CDATA[Fajrian Aidil Pratama]]></dc:creator>
            <pubDate>Sun, 23 Jul 2023 03:01:46 GMT</pubDate>
            <atom:updated>2023-07-23T03:01:46.652Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OyOGPwThBwtHnwWVvKmsvw.jpeg" /></figure><p>Flutter, with its versatility and ease of use, has become a popular choice for app development. As Flutter projects grow in complexity, developers often find themselves writing repetitive code, leading to reduced productivity and maintenance challenges. To overcome these hurdles, two powerful tools have emerged in the Flutter community: Mason and BrickHub. In this article, we will explore how Mason and BrickHub can revolutionize Flutter development by automating code generation and fostering a collaborative ecosystem.</p><h3>Introducing Mason</h3><p>Mason is a code generation tool for Flutter that automates the process of creating boilerplate code, templates, and other artifacts. It simplifies development by reducing repetitive tasks and enforcing consistency across projects. With Mason, developers can define code templates and then easily generate components, classes, and more based on those templates.</p><p>To illustrate its power, let’s consider an example of using Mason to generate the core of a UI Kit package. By utilizing a Mason brick like ui_kit_core, developers can swiftly scaffold the foundational structure of their design system. This includes defining colors, text styles, theming, and utility functions that form the backbone of a consistent and efficient UI design.</p><p>Learn more about ui_kit_core Mason brick: <a href="https://brickhub.dev/bricks/ui_kit_core">UI Kit Core Brick</a></p><h3>Introducing BrickHub</h3><p>BrickHub complements Mason by serving as an online marketplace and repository for sharing and distributing Mason bricks. A “brick” is a collection of code generation templates and assets, empowering developers to share and utilize commonly used code patterns, components, and more. BrickHub fosters a collaborative ecosystem, allowing developers to contribute, discover, and customize bricks for their specific needs.</p><p>Continuing with our UI Kit package example, let’s look at the ui_kit_component brick on BrickHub. This brick is designed to generate individual UI components, such as buttons, cards, and text fields, providing developers with a head start when creating a comprehensive UI Kit package.</p><p>Learn more about ui_kit_component Mason brick: <a href="https://brickhub.dev/bricks/ui_kit_component">UI Kit Component Brick</a></p><h3>Benefits of Mason and BrickHub</h3><p>By leveraging Mason and BrickHub, Flutter developers can unlock a multitude of benefits:</p><p><strong>Enhanced Productivity</strong>: With code generation, developers can generate repetitive code quickly, freeing up time to focus on building features and business logic.</p><p><strong>Consistency and Standards</strong>: Mason ensures that code follows predefined templates and adheres to established design standards, improving code quality and maintainability.</p><p><strong>Reuse and Collaboration</strong>: The shared bricks on BrickHub encourage developers to collaborate and build upon each other’s work, fostering a thriving community of reusable components and best practices.</p><p><strong>Rapid Prototyping</strong>: Developers can rapidly prototype new features and UI components, allowing for faster iteration and feedback.</p><p><strong>Knowledge Exchange</strong>: BrickHub facilitates knowledge exchange among developers, enabling them to learn from and inspire one another.</p><h3>Watch the Full Explanation and Example on YouTube</h3><p>Curious to see Mason and BrickHub in action? Head over to my YouTube channel to watch a full explanation and example of using these powerful tools in Flutter development. I’ll walk you through the process of generating a UI Kit package and demonstrate how to streamline your app development workflow.</p><p>🎥 <a href="https://youtu.be/br8IyHfGHQw">Watch the Full Example on YouTube</a></p><h3>Conclusion</h3><p>Mason and BrickHub are powerful tools that empower Flutter developers to streamline their development workflow and build high-quality applications with ease. By automating code generation and creating a collaborative ecosystem, Mason and BrickHub transform the way developers create, share, and reuse components.</p><p>As the Flutter community continues to grow, we encourage you to explore Mason and BrickHub, contribute to the community by sharing your bricks, and discover how these tools can elevate your Flutter development experience.</p><p>Let’s take our Flutter projects to new heights together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21c5020e9761" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter UI Kit Package Development — Introduction]]></title>
            <link>https://medium.com/@ryanaidilp/flutter-ui-kit-package-development-introduction-9edbd4413dcb?source=rss-e720d3034687------2</link>
            <guid isPermaLink="false">https://medium.com/p/9edbd4413dcb</guid>
            <category><![CDATA[ui-design]]></category>
            <category><![CDATA[package]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[uikit]]></category>
            <dc:creator><![CDATA[Fajrian Aidil Pratama]]></dc:creator>
            <pubDate>Sat, 22 Jul 2023 07:18:40 GMT</pubDate>
            <atom:updated>2023-07-22T07:18:40.870Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter UI Kit Package Development — Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4kX7gKz7U-5y4CPu" /></figure><h3>An Introduction to Flutter UI Kit Package Development</h3><p>Flutter has emerged as a leading framework for developing beautiful and performant cross-platform applications. With its rich set of widgets and powerful rendering engine, Flutter makes it easy to create stunning user interfaces. To further enhance the development process and maintain consistency across projects, developers often turn to UI Kit packages. In this article, we’ll delve into the world of Flutter UI Kit package development, exploring its benefits, best practices, and how to get started.</p><h3>What is a UI Kit Package?</h3><p>In the context of Flutter, a UI Kit package is a collection of reusable components, design patterns, themes, and other elements that form the foundation for building consistent user interfaces. It serves as a toolbox containing all the necessary widgets and styles needed to create a cohesive and visually appealing app.</p><h3>Benefits of Using a UI Kit Package</h3><p><strong>Consistency</strong>: A well-designed UI Kit package ensures consistency in the visual appearance and user experience across different screens and sections of your application.</p><p><strong>Efficiency</strong>: By encapsulating common UI components and styles, UI Kit packages eliminate redundant code and streamline the development process, saving time and effort.</p><p><strong>Modularity</strong>: UI Kit packages promote modular development, allowing you to focus on building features and logic while reusing UI elements across projects.</p><p><strong>Customization</strong>: With a UI Kit package, you can easily customize the look and feel of your app by tweaking the predefined styles and themes.</p><h3>Best Practices for UI Kit Package Development</h3><p><strong>Clear Naming and Organization</strong>: Name your components and assets descriptively, and organize them in a structured manner within the package to facilitate easy access and understanding.</p><p><strong>Thorough Documentation</strong>: Document your UI Kit package thoroughly, providing clear explanations of each component’s purpose, usage, and customization options.</p><p><strong>Responsive Design</strong>: Ensure that your UI Kit components adapt gracefully to different screen sizes and orientations to support a wide range of devices.</p><p><strong>Accessibility</strong>: Design your components with accessibility in mind, making them inclusive and usable for all users, including those with disabilities.</p><p><strong>Testing</strong>: Write comprehensive test cases for your UI Kit components to verify their functionality and maintain reliability.</p><h3>Watch the Full Example on YouTube</h3><p>To see a complete explanation on introduction of Flutter UI Kit Package development, check out Episode 1 of our YouTube video series. We’ll walk you through the entire process, from setting up the project to implementing components and styling. Don’t miss this opportunity to level up your Flutter development skills!</p><p><a href="https://youtu.be/-qO-fn9dMMo">https://youtu.be/-qO-fn9dMMo</a></p><h3>Conclusion</h3><p>Flutter UI Kit packages empower developers to build stunning user interfaces efficiently and consistently. By leveraging the benefits of UI Kit package development and adhering to best practices, you can create reusable and modular components that accelerate your app development process. So, embark on your UI Kit package development journey, share your creations with the Flutter community, and contribute to the ever-growing ecosystem of beautiful and user-friendly apps. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9edbd4413dcb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embarking on a Personal Development Journey: Unveiling the 12 Rules of Life]]></title>
            <link>https://medium.com/@ryanaidilp/embarking-on-a-personal-development-journey-unveiling-the-12-rules-of-life-6bc62b0f1071?source=rss-e720d3034687------2</link>
            <guid isPermaLink="false">https://medium.com/p/6bc62b0f1071</guid>
            <category><![CDATA[books]]></category>
            <category><![CDATA[book-review]]></category>
            <category><![CDATA[jordan-b-peterson]]></category>
            <category><![CDATA[self-development]]></category>
            <category><![CDATA[self-improvement]]></category>
            <dc:creator><![CDATA[Fajrian Aidil Pratama]]></dc:creator>
            <pubDate>Sat, 03 Jun 2023 14:05:00 GMT</pubDate>
            <atom:updated>2023-06-03T14:05:00.241Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qYcg_hCchCzBbWZo" /><figcaption>Photo by <a href="https://unsplash.com/@lazizli?utm_source=medium&amp;utm_medium=referral">Lala Azizli</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the vast landscape of personal growth and self-improvement, the pursuit of wisdom and guidance is a common thread that unites us all. We seek insights, strategies, and philosophies that can illuminate our path towards becoming the best versions of ourselves. Within this ever-expanding realm, I recently found myself captivated by a book that has resonated with millions around the world: “12 Rules for Life” by Jordan Peterson.</p><p>But why Jordan Peterson? Who is he, and what makes his book so compelling? Jordan Peterson is a renowned psychologist, author, and professor whose ideas have sparked meaningful conversations and ignited personal transformations. His unique perspective combines elements of psychology, philosophy, and spirituality, providing a thought-provoking framework for self-discovery and personal development.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*DbSXS4OX-VbxkRspilHr6w.jpeg" /><figcaption>12 Rulse for Life by Jordan B Peterson</figcaption></figure><p>“12 Rules for Life” is Peterson’s magnum opus — a profound guide that outlines twelve fundamental principles to navigate the complexities of existence. With deep insights and captivating anecdotes, Peterson weaves together wisdom from diverse sources, drawing from ancient myths, psychological research, and his own clinical experience. Each rule offers a roadmap for individuals seeking to cultivate resilience, meaning, and purpose in their lives.</p><p>As I contemplated my aspirations for the year 2023, I felt drawn to embark on a transformative journey inspired by Peterson’s work. The idea of dedicating each month to implementing and reflecting upon one of the twelve rules struck a chord within me. I realized that by immersing myself in the practical application of these rules, I could unlock profound personal growth and share my experiences with others on a similar path.</p><p>Through a series of monthly blog posts, I aim to document my expedition, providing a transparent account of my triumphs, struggles, and reflections. By delving into each rule, implementing its principles in my daily life, and synthesizing my thoughts, I hope to uncover valuable insights that can inspire and guide others on their own personal development journeys.</p><p>Join me as we venture together into the realm of “12 Rules for Life,” exploring the profound wisdom contained within its pages. With every passing month, we will delve into a new rule, examine its significance, and unravel its practical implications. We will confront challenges, embrace growth opportunities, and ultimately strive towards creating a more meaningful and fulfilling life.</p><p>As we embark on this transformative odyssey, let us remain open to the possibility of change, receptive to new perspectives, and committed to personal growth. Together, we will navigate the labyrinthine path of self-discovery, illuminating the truths that lie within and forging a brighter future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6bc62b0f1071" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating from GetX: Boosting Flutter App Development Efficiency — Part 3: Dependency Injection]]></title>
            <link>https://medium.com/@ryanaidilp/migrating-from-getx-boosting-flutter-app-development-efficiency-part-3-dependency-injection-50693e8fed2e?source=rss-e720d3034687------2</link>
            <guid isPermaLink="false">https://medium.com/p/50693e8fed2e</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[getx]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <dc:creator><![CDATA[Fajrian Aidil Pratama]]></dc:creator>
            <pubDate>Mon, 22 May 2023 02:01:52 GMT</pubDate>
            <atom:updated>2023-05-22T02:01:52.935Z</atom:updated>
            <content:encoded><![CDATA[<h3>Migrating from GetX: Boosting Flutter App Development Efficiency — Part 3: Dependency Injection</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4GxAhWI86MVbcroJkn3EBw.png" /></figure><h3>Exploring the Power of Dependency Injection: GetIt and Injectable</h3><p>In the previous section, we discussed the benefits of using AutoRoute as a replacement for routing in Flutter applications. Building upon that, we now turn our attention to the realm of dependency injection and explore the power of GetIt and Injectable.</p><p>Dependency injection is a crucial aspect of building scalable and maintainable codebases. While GetX provides a basic form of dependency injection, GetIt and Injectable take it to the next level by offering advanced features and code generation capabilities. In this chapter, I will guide you through the process of migrating from GetX to GetIt and Injectable, showcasing their advantages and demonstrating how they can enhance our development workflow.</p><p>We will begin by installing GetIt and Injectable packages and integrating them into our project. I will walk you through the setup process and show you how to configure your dependencies in a clean and organized manner. With GetIt, we can easily register and resolve dependencies using a simple and intuitive API. We will learn how to define singletons, factories, and lazy dependencies, enabling greater control and flexibility in managing our application’s components.</p><p>Next, we will explore the code generation capabilities of Injectable. By leveraging code generation, Injectable eliminates the need for manual dependency registration, making the process more efficient and error-free. We will witness the power of code generation as we define our dependencies using annotations and generate the necessary code to wire them up automatically. This approach not only reduces boilerplate code but also improves code readability and maintainability.</p><p>Throughout this chapter, I will provide practical examples and share insights gained from my own migration process. We will examine how GetIt and Injectable enhance the modularity, scalability, and testability of our codebase. By adopting these advanced dependency injection techniques, we will experience improved code organization, reduced coupling, and increased flexibility in managing our dependencies.</p><h4>Installation:</h4><p>Proper dependency injection is crucial for maintaining a clean and modular architecture in our Flutter app. It helps manage the dependencies between different components, promotes code reusability, and simplifies the testing process. By leveraging GetIt and Injectable, we can take our dependency injection to the next level and enjoy additional features and flexibility.</p><p>In this section, I will walk you through the installation process of two powerful dependency injection packages for Flutter: GetIt and Injectable. These packages provide advanced features and benefits compared to the traditional dependency injection approach offered by GetX.</p><p>Whether you are starting a new project or looking to enhance your existing app’s architecture, understanding and implementing these powerful dependency injection packages will greatly benefit your development process. So, let’s dive into the installation steps and unlock the full potential of dependency injection in Flutter!</p><h4>Getx</h4><p>Here’s a high-level overview of the steps involved in setting up dependency injection with GetX:</p><ul><li>Install the GetX package: Start by adding the getpackage to your project’s pubspec.yaml file. Run flutter pub get to fetch the package and its dependencies.</li><li>Define your dependencies: Identify the dependencies that your app requires. This could include services, repositories, controllers, or any other objects that need to be accessed throughout your app.</li><li>Create a Service or Repository class: Implement the logic for our dependencies in separate classes. These classes should handle specific functionalities or data operations.</li><li>Set up the dependency injection container: In our app’s entry point, typically the main.dart file, create an instance of Get.put or Get.lazyPut for each dependency. Choose the appropriate method based on your requirements. Get.put registers the dependency as a singleton while Get.lazyPut registers the dependency as a factory. You can also utilize the initialBinding property of GetMaterialApp to initialize dependencies by creating or calling an existing binding class. This ensures that the dependency becomes globally accessible throughout your app. For local dependency injection specific to a module or feature, you can use feature_binding.dart the bindings directory within each module/feature to handle the local dependency injection process.</li></ul><p><strong>Global Injection</strong></p><pre>class BMPRApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return GetMaterialApp(<br>      title: &#39;BMPRApp&#39;,<br>      initialRoute: AppPages.INITIAL,<br>      initialBinding: GlobalBindings(),<br>      transitionDuration: const Duration(milliseconds: 500),<br>      defaultTransition: Transition.rightToLeft,<br>      getPages: AppPages.routes,<br>      home: Root(),<br>      theme: homeTheme,<br>    );<br>  }<br>}</pre><p><strong>Local Injection</strong></p><pre>/// modules/create_documents/bindings/create_document_binding.dart<br>import &#39;package:get/get.dart&#39;;<br><br>import &#39;../controllers/create_document_controller.dart&#39;;<br><br><br><br>class CreateDocumentBinding extends Bindings {<br>  @override<br>  void dependencies() {<br>    Get.lazyPut&lt;CreateDocumentController&gt;(<br>      () =&gt; CreateDocumentController(),<br>    );<br>    Get.lazyPut&lt;ApiProvider&gt;(<br>      () =&gt; ApiProvider(),<br>    );<br>  }<br>}<br><br>/// lib/app/routes/app_routes.dart<br>class AppPages {<br>  AppPages._();<br><br>  static const INITIAL = Routes.SPLASH;<br><br>  static final routes = [<br>    GetPage(<br>      name: _Paths.CREATE_DOCUMENT,<br>      page: () =&gt; CreateDocumentView(),<br>      binding: CreateDocumentBinding(), /// Local Injection of Create Document<br>      transition: Transition.downToUp,<br>    ),<br>  ];<br>}</pre><ul><li>Access the dependencies: Now, we can access the dependencies throughout our app by using Get.find . GetX will handle the lifecycle management and provide us with the appropriate instances.</li></ul><pre>class CreateDocumentController extends GetxController {<br>  late ApiProvider provider;<br><br>  @override<br>  void onInit() {<br>    super.onInit();<br>    provider = Get.find&lt;ApiProvider&gt;(); // Find the injected ApiProvider<br>  }<br>}</pre><p>By following these steps, we can establish a solid foundation for dependency injection using GetX. In the next section, I will introduce you to GetIt and Injectable, which offer advanced features and benefits over traditional GetX dependency injection. We’ll explore their installation process and learn how to leverage them to further enhance our app’s architecture. Let’s get started!</p><h4>GetIt and Injectable</h4><p>To begin our migration journey from GetX to GetIt and Injectable, we need to install the necessary packages and integrate them into our Flutter project. Follow the steps below to get started:</p><ul><li>Open the project’s pubspec.yaml file.</li><li>Add the following dependencies to the pubspec.yaml file:</li></ul><pre>dependencies:<br>  get_it: ^7.2.0<br>  injectable: ^1.5.0<br><br>dev_dependencies:<br>  injectable_generator: ^1.5.0<br>  build_runner: ^2.1.0</pre><ul><li>Save the pubspec.yaml file and run the following command in our project&#39;s root directory to fetch the dependencies:</li></ul><pre>flutter pub get</pre><ul><li>We will be using code generation, so let’s set up the required configuration. Create a new file called service_locator.dart in lib/core/di/ directory</li></ul><pre>import &#39;package:get_it/get_it.dart&#39;;<br>import &#39;package:injectable/injectable.dart&#39;;<br><br>import &#39;service_locator.config.dart&#39;;<br><br>final getIt = GetIt.instance;<br><br>@InjectableInit(<br>  initializerName: r&#39;$initGetIt&#39;,<br>  preferRelativeImports: true,<br>  asExtension: false,<br>)<br>Future&lt;void&gt; configureDependencies() async =&gt; $initGetIt(getIt);</pre><ul><li>Run the following command in our project’s root directory to generate the code :</li></ul><pre># For generating once<br>flutter pub run build_runner build -d<br><br># If you want to watch for change and re-generate whenever there is an udpate<br>flutter pub run build_runner watch</pre><ul><li>This will generate service_locator.config.dart file inside the same directory as our service_locator.dart file.</li><li>Next, initialize the code in our main.dart . Make sure to initialize it before calling therunApp method.</li></ul><pre>WidgetsFlutterBinding.ensureInitialized();<br>await onfigureDependencies();<br>runApp(BMPRApp());</pre><p>That’s it! We have successfully installed the GetIt and Injectable packages and set up the initial configuration. In the next section, I’ll guide you through the setup and usage of GetIt and Injectable, sharing my insights and experience with these powerful dependency injection packages. Let’s dive in and explore their advanced features to enhance your Flutter app’s architecture and maintainability.</p><p><strong>Registering Dependencies</strong></p><p>To register dependencies, we can create separate module files or annotate the file we want to inject. Here’s an example of registering a dependency :</p><ul><li>Register using module</li></ul><pre>@module<br>abstract class RegisterModule {<br><br>  @Named(&#39;btHttpClient&#39;)<br>  HttpClient get btHttpClient =&gt; HttpClient.init(<br>        HttpSetting(baseUrl: ApiEndpoint.baseUrl),<br>      );<br><br>  @Named(&#39;btStorageHttpClient&#39;)<br>  HttpClient get btStorageHttpClient =&gt; HttpClient.init(<br>        HttpSetting(baseUrl: ApiEndpoint.storageBaseUrl),<br>      );<br>}</pre><ul><li>Register using annotation</li></ul><pre>part &#39;bmpr_router.gr.dart&#39;;<br>@AutoRouterConfig(<br> replaceInRouteName: &#39;Page, Route&#39;, <br>)<br>@LazySingleton() // Inject as a singleton <br>class BMPRRouter extends _$BMPRRouter {<br> @override <br> List&lt;AutoRoute&gt; get routes =&gt; [ <br>   AutoRoute(<br>     page: SplashRoute.page, <br>     path: &#39;/&#39;, <br>   ), <br> ];<br>}</pre><p><strong>Generating Dependencies</strong></p><p>To generate the necessary code for dependency injection, run the following command in our project directory:</p><pre>flutter pub run build_runner build</pre><p>This command triggers the code generation process and generates the required files (lib/core/di/service_locator.config.dart)based on the annotations and configurations.</p><p><strong>service_locator.config.dart</strong></p><pre>// GENERATED CODE - DO NOT MODIFY BY HAND<br><br>// **************************************************************************<br>// InjectableConfigGenerator<br>// **************************************************************************<br><br>// ignore_for_file: unnecessary_lambdas<br>// ignore_for_file: lines_longer_than_80_chars<br>// coverage:ignore-file<br><br>// ignore_for_file: no_leading_underscores_for_library_prefixes<br>import &#39;package:get_it/get_it.dart&#39; as _i1;<br>import &#39;package:injectable/injectable.dart&#39; as _i2;<br><br>_i1.GetIt $initGetIt(<br>  _i1.GetIt getIt, {<br>  String? environment,<br>  _i2.EnvironmentFilter? environmentFilter,<br>}) {<br>  final gh = _i2.GetItHelper(<br>    getIt,<br>    environment,<br>    environmentFilter,<br>  );<br>  final registerModule = _$RegisterModule();<br>  gh.factory&lt;_i43.HttpClient&gt;(<br>    () =&gt; registerModule.btHttpClient,<br>    instanceName: &#39;btHttpClient&#39;,<br>  );<br>  gh.factory&lt;_i43.HttpClient&gt;(<br>    () =&gt; registerModule.btStorageHttpClient,<br>    instanceName: &#39;btStorageHttpClient&#39;,<br>  );<br>}</pre><p><strong>Utilizing Dependency Injection</strong></p><p>With the setup complete and the dependencies registered, we can now start utilizing dependency injection in our Flutter project. Here’s an example of how to use GetIt to retrieve a registered dependency:</p><pre>final router = getIt&lt;BMPRRouter&gt;();<br><br>router.push(LoginRoute());</pre><p>In this example, we retrieve an instance of BMPRRouter from the GetIt container using getIt&lt;BMPRRouter&gt;().</p><p>Congratulations! We have successfully set up GetIt and Injectable, registered dependencies, and utilized dependency injection in our Flutter project. The code generation feature provided by these libraries simplifies the setup process and ensures the correctness of our dependencies.</p><h3>Comparison: GetX Dependency Injection vs. GetIt and Injectable</h3><p>When it comes to dependency injection in Flutter, there are multiple options available, each with its own advantages and considerations. In this section, I will compare GetX’s built-in dependency injection with two popular alternatives: GetIt and Injectable.</p><h4>GetX Dependency Injection</h4><p>GetX provides a simple and intuitive way to handle dependency injection within your Flutter application. By using Get.put and Get.lazyPut methods, you can easily register dependencies and manage their lifecycle. Here are some pros and cons of GetX&#39;s dependency injection:</p><p><strong>Pros</strong>:</p><ul><li><strong>Simplicity</strong>: GetX’s dependency injection is straightforward to understand and implement, making it an excellent choice for small to medium-sized projects.</li><li><strong>Integration</strong>: The dependency injection system is tightly integrated with other GetX features such as state management and routing, providing a seamless development experience.</li><li><strong>Global and Local Injection</strong>: GetX allows for both global and local dependency injection, giving you flexibility in managing dependencies at different levels of your application.</li></ul><p><strong>Cons</strong>:</p><ul><li><strong>Lack of Advanced Features</strong>: GetX’s built-in dependency injection may lack some advanced features offered by dedicated dependency injection libraries.</li><li><strong>Limited Scoping</strong>: While GetX supports local injection within modules or features, it may not offer the same level of scoping and separation of concerns as dedicated DI libraries.</li></ul><h4>GetIt and Injectable</h4><p>GetIt and Injectable are popular third-party libraries for dependency injection in Flutter applications. They offer additional features and flexibility compared to GetX’s built-in solution. Here’s a comparison of using GetIt and Injectable:</p><p><strong>Pros</strong>:</p><ul><li><strong>Advanced Features</strong>: GetIt and Injectable provide advanced features like named dependencies, scoping, and asynchronous injection, allowing for more fine-grained control over your dependencies.</li><li><strong>Separation of Concerns</strong>: These libraries promote clear separation of concerns by providing tools to define modules and organize dependencies based on their purpose.</li><li><strong>Code Generation</strong>: GetIt and Injectable leverage code generation to automatically generate the necessary code for dependency injection, reducing manual configuration and potential errors.</li></ul><p><strong>Cons</strong>:</p><ul><li><strong>Learning Curve</strong>: Compared to GetX’s built-in solution, GetIt and Injectable may have a steeper learning curve due to their additional features and concepts.</li><li><strong>Increased Complexity</strong>: The advanced features offered by GetIt and Injectable can add complexity to the dependency injection setup, which might not be necessary for simpler projects.</li></ul><p>In conclusion, both GetX’s built-in dependency injection and third-party libraries like GetIt and Injectable have their own strengths and considerations. GetX is an excellent choice for its simplicity and seamless integration with other GetX features. On the other hand, GetIt and Injectable provide advanced features and more flexibility, making them suitable for larger and more complex projects.</p><p>When deciding on a dependency injection solution, it’s essential to consider the specific needs of your project and weigh the benefits against the potential trade-offs. Regardless of the chosen approach, proper dependency injection will help improve code maintainability, testability, and overall application architecture.</p><p>In the next section, we will explore another powerful process of replacing GetX controllers with BLoC for state management.</p><p>If you’re interested in learning more about GetIt and Injectable, you can find detailed information in their respective documentation on <a href="https://pub.dev/packages/get_it">pub.dev</a> (get_it) and <a href="https://pub.dev/packages/injectable">pub.dev</a> (injectable). These resources will provide you with comprehensive insights and examples to further enhance your understanding of these dependency injection libraries.</p><blockquote>This comparison is based on my personal experience and understanding as a Flutter developer. The choice of a dependency injection library ultimately depends on individual project requirements and preferences.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50693e8fed2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating from GetX: Boosting Flutter App Development Efficiency — Part 2: Routing]]></title>
            <link>https://medium.com/@ryanaidilp/migrating-from-getx-boosting-flutter-app-development-efficiency-part-2-routing-c146a09bc5fa?source=rss-e720d3034687------2</link>
            <guid isPermaLink="false">https://medium.com/p/c146a09bc5fa</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[routing]]></category>
            <category><![CDATA[getx]]></category>
            <category><![CDATA[bloc]]></category>
            <dc:creator><![CDATA[Fajrian Aidil Pratama]]></dc:creator>
            <pubDate>Sun, 21 May 2023 02:01:55 GMT</pubDate>
            <atom:updated>2023-05-21T03:08:43.271Z</atom:updated>
            <content:encoded><![CDATA[<h3>Migrating from GetX: Boosting Flutter App Development Efficiency — Part 2: Routing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4GxAhWI86MVbcroJkn3EBw.png" /></figure><h3>Replacing GetX Routing with AutoRoute: Streamlining Navigation in Your Flutter App</h3><p>In the previous part, we discussed the advantages of migrating from the GetX architecture pattern to the Clean Architecture pattern, which resulted in improved code organization and scalability. Now, let’s dive into another significant aspect of our Flutter app migration journey: replacing GetX routing with AutoRoute.</p><p>Routing is a fundamental part of any app, allowing users to navigate between different screens and components seamlessly. While GetX provided a simple and efficient routing mechanism, AutoRoute offers additional features and benefits that enhance the navigation experience. In this section, we will explore how AutoRoute simplifies routing in Flutter apps and discuss its advantages over the GetX routing approach.</p><p>Let’s get started!</p><h4>Installation:</h4><p>To begin using AutoRoute in your Flutter project, follow these simple steps:</p><ul><li>Open your project’s pubspec.yaml file.</li><li>Under the dependencies and dev_dependencies section, add the following line:</li></ul><pre>dependencies:<br> auto_route: ^[version]<br>dev_dependencies:<br> build_runner: ^[version]<br> auto_route_generator: ^[version]</pre><ul><li>Replace [version] with the desired version of AutoRoute. It is recommended to use the latest stable version.</li><li>Save the file and run the following command in your terminal to fetch the dependencies:</li></ul><pre>flutter pub get</pre><p>With AutoRoute successfully installed, we can now start leveraging its powerful routing capabilities to replace the GetX routing mechanism in our Flutter app.</p><h4>Defining Routes with AutoRoute:</h4><p>In GetX, creating new modules and setting up routing is made easy with the get create page [page_name] command, which handles the generation of the page folder, including its binding, controller, and view files, as well as the routing configuration in the app_pages.dart and app_routes.dart files.</p><p>With AutoRoute, the process is slightly different but equally straightforward. Let’s walk through the steps:</p><ul><li>Start by defining your page using the @RoutePage annotation in your page file. For example:</li></ul><pre>@RoutePage() <br>class LoginPage extends StatelessWidget {<br> //<br>}</pre><ul><li>Next, run the build runner command in your terminal to generate the routing mechanism based on your annotations:</li></ul><pre>flutter packages pub run build_runner build</pre><ul><li>This will generate the necessary files to handle routing for your pages.</li><li>Now, create a configuration class and annotate it with @AutoRouterConfig. This class allows you to customize various settings for AutoRoute. For example, you can specify how routes are generated using the replaceInRouteName property. In my case, I set it to &#39;Page,Route’, which means that a page named LoginPage will generate a corresponding route named LoginRoute.</li></ul><p><strong>bmpr_router.dart</strong></p><pre>part &#39;bmpr_router.gr.dart&#39;;<br>@AutoRouterConfig(<br> replaceInRouteName: &#39;Page, Route&#39;, <br>) <br>class BMPRRouter extends _$BMPRRouter {}</pre><ul><li>Inside the configuration class, override the routes getter, where you will define the list of routes for your app. Here’s an example:</li></ul><pre>part &#39;bmpr_router.gr.dart&#39;;<br>@AutoRouterConfig(<br> replaceInRouteName: &#39;Page, Route&#39;, <br>) <br>class BMPRRouter extends _$BMPRRouter {<br> @override <br> List&lt;AutoRoute&gt; get routes =&gt; [ <br>   AutoRoute(<br>     page: SplashRoute.page, <br>     path: &#39;/&#39;, <br>   ), <br> ];<br>}</pre><ul><li>In this example, we define the SplashRoute as the initial route for the &#39;/&#39; path.</li><li>Repeat the process for every new route that you have.<br>Replace your MaterialApp with MaterialApp.router</li></ul><p><strong>app.dart</strong></p><pre>class BMPRApp extends StatelessWidget {<br>  final bmprRouter = getIt&lt;BMPRRouter&gt;();<br>  BMPRApp({super.key});<br>  @override<br>  Widget build(BuildContext context) =&gt; MaterialApp.router(<br>        title: &#39;Surat BMPR&#39;,<br>        routerDelegate: AutoRouterDelegate(<br>          bmprRouter,<br>          navigatorObservers: () =&gt; [<br>            BMPRRouteObserver(),<br>          ],<br>        ),<br>        routeInformationParser: bmprRouter.defaultRouteParser(),<br>      );<br>}</pre><p>With these steps completed, you have successfully defined your routes using AutoRoute. The build runner will generate the necessary routing code based on your annotations, simplifying the process of setting up routing in your Flutter app.</p><h4>Advantages of Using AutoRoute over GetX for Routing:</h4><p>While GetX provides a convenient way to handle routing in Flutter applications, AutoRoute offers several advantages that make it a compelling choice for managing routes. Here are some key benefits of using AutoRoute:</p><ul><li><strong>Type-Safe Routing</strong></li></ul><p>AutoRoute generates strongly-typed route classes, which means you can avoid dealing with string-based route names and potential typos. With AutoRoute, your routes are represented as classes, ensuring type safety and enabling IDE code completion and navigation.</p><p>In addition to the advantages mentioned above, AutoRoute offers even more powerful features for handling route return values. By specifying the return type in the @RoutePage annotation, you can define the expected return type when navigating to a specific page.</p><p>For example, if you have a page that expects a boolean value as its return type, you can annotate it with @RoutePage&lt;bool&gt;. This allows you to navigate to that page and retrieve a boolean value as the result when the page is dismissed or popped from the navigation stack.</p><pre>var router = getIt&lt;BMPRRouter&gt;();<br>router.pop(true);</pre><p>AutoRoute also supports using custom classes as return types. This means that you can define your own result classes, such as MailDetailResult, and annotate the corresponding page with @RoutePage&lt;MailDetailResult&gt;. This enables you to pass complex data or custom result objects between routes with type safety.</p><p><strong>mail_detail_result.dart</strong></p><pre>class MailDetailResult extends Equatable {<br>    final bool isUpdated;<br>    final MailSaveDestination destination;<br>    const MailDetailResult({<br>        this.isUpdated = false,<br>        required this.destination<br>    });<br>    @override<br>    List &lt;Object&gt; get props =&gt; [isUpdated, destination];<br>}</pre><p><strong>mail_detail_page.dart</strong></p><pre>if (state is MailSaveSuccess) {<br>    var router = getIt &lt;BMPRRouter&gt;();<br>    var result = MailDetailResult(<br>      isUpdated: true, <br>      destination: MailSaveDestination.draft,<br>    );<br>    router.pop(result);<br>}</pre><p><strong>home_page.dart</strong></p><pre>class HomePage extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      body: Button(<br>        onTap: () async {<br>          var result =<br>              await router.push&lt;MailDetailResult&gt;(MailDetailPage(mail: mail));<br><br>          /// Check if the mail is updated<br>          if (result != null &amp;&amp; result.isUpdate) {<br>            /// Show success snackbar and then<br>            /// Navigate to specific page after<br>            /// mail status is updated based on its<br>            /// save destination.<br>            switch (result.destination) {<br>              case MailSaveDestination.draft:<br><br>              /// Navigate to draft<br>            }<br>          }<br>        },<br>      ),<br>    );<br>  }<br>}</pre><p>By leveraging strongly-typed route classes and specifying return types, AutoRoute ensures that your navigation flows are type safe and free from potential errors caused by incorrect return values. This enhances the reliability and maintainability of your Flutter app, making it easier to navigate between pages and handle the returned results.</p><p>Furthermore, the IDE code completion and navigation features provided by AutoRoute enable developers to easily explore and navigate through the available routes, reducing the chances of introducing errors due to typos or incorrect route names.</p><p>Overall, AutoRoute’s support for strongly-typed route classes and customizable return types adds another layer of safety and convenience to your Flutter app’s routing mechanism.</p><ul><li><strong>Annotation-Based Configuration</strong></li></ul><p>AutoRoute utilizes annotations to define routes, reducing boilerplate code and making the routing setup more concise and readable. By simply annotating your page classes with @RoutePage, AutoRoute automatically generates the necessary routing code.</p><ul><li><strong>Flexible Routing Configurations</strong></li></ul><p>AutoRoute provides flexibility in configuring your routes. You can define nested routes, specify route guards for authentication or authorization, handle route transitions, and more. The @AutoRouterConfigannotation allows you to customize various settings according to your app’s specific needs.</p><ul><li><strong>Declarative Routing</strong></li></ul><p>With AutoRoute, you can define your app’s routes declaratively using a builder syntax. This allows you to express complex route structures in a clear and concise manner, making it easier to manage and maintain your app’s navigation flow.</p><ul><li><strong>Route Parameters and Arguments</strong></li></ul><p>AutoRoute simplifies the passing of parameters and arguments between routes. It automatically generates argument classes for your pages, eliminating the need to manually create and manage them. This ensures type safety and reduces potential bugs related to passing arguments between routes.</p><p>In traditional GetX routing, passing arguments or parameters between routes requires manual definition and retrieval. For example, if you want to navigate to a page called MAIL_DETAILand pass a mail object as an argument, you would need to do the following:</p><pre>Get.to(Routes.MAIL_DETAIL, arguments: {<br> &#39;mail&#39;: mail,<br>});</pre><p>Then, in the onInitmethod of the destination page’s controller, you would manually retrieve the argument:</p><pre>mail.value = Get.arguments[&#39;mail&#39;];</pre><p>On the other hand, with AutoRoute, passing arguments becomes much more streamlined. When you have a page that requires an argument, such as ProfileEntity, you can simply define it as a parameter in the page’s constructor:</p><pre>@RoutePage()<br>class ProfilePage extends StatelessWidget {<br> final ProfileEntity profile;<br> ProfilePage({Key? key, required this.profile});<br>}</pre><p>AutoRoute will automatically generate the necessary route file, including an argument class specifically for the ProfilePage:</p><pre>/// generated route for<br>/// [ProfilePage]<br>class ProfileRoute extends PageRouteInfo&lt;ProfileRouteArgs&gt; {<br>  ProfileRoute({<br>    Key? key,<br>    required ProfileEntity profile,<br>    List&lt;PageRouteInfo&gt;? children,<br>  }) : super(<br>          ProfileRoute.name,<br>          args: ProfileRouteArgs(<br>            key: key,<br>            profile: profile,<br>          ),<br>          initialChildren: children,<br>        );<br>  static const String name = &#39;ProfileRoute&#39;;<br>  static const PageInfo&lt;ProfileRouteArgs&gt; page =<br>      PageInfo&lt;ProfileRouteArgs&gt;(name);<br>}<br><br>class ProfileRouteArgs {<br>  const ProfileRouteArgs({<br>    this.key,<br>    required this.profile,<br>  });<br>  final Key? key;<br>  final ProfileEntity profile;<br>  @override<br>  String toString() {<br>    return &#39;ProfileRouteArgs{key: $key, profile: $profile}&#39;;<br>  }<br>}</pre><p>You can then navigate to the ProfilePage while passing the profile argument directly:</p><pre>router.push(ProfileRoute(profile: profile));</pre><p>AutoRoute takes care of type safety and automatically generates the required argument classes, eliminating the need for manual argument management. This not only improves code clarity but also reduces the likelihood of introducing bugs related to passing arguments between routes.</p><p>Overall, AutoRoute simplifies the process of passing parameters and arguments between routes, ensuring type safety and reducing potential errors in your Flutter app’s navigation flow.</p><ul><li><strong>Code Generation and Efficiency</strong></li></ul><p>AutoRoute leverages build-time code generation, which means the routing code is generated during the build process rather than being executed at runtime. This approach results in improved performance and efficiency, as the routing code is already generated and optimized before the app is run.</p><p>By leveraging these advantages, AutoRoute enhances the routing capabilities of your Flutter app, providing a more robust and efficient solution compared to the routing offered by GetX.</p><h4>Conclusion</h4><p>In conclusion, AutoRoute offers numerous advantages and powerful features compared to GetX routing. The generation of strongly-typed route classes enhances type safety and enables IDE code completion and navigation, minimizing the risk of errors and typos. AutoRoute simplifies the passing of parameters and arguments between routes by automatically generating argument classes, eliminating the need for manual management and reducing potential bugs. Additionally, AutoRoute provides advanced features such as route guards, nested routes, and route transitions.</p><p>To explore more about AutoRoute and its capabilities, you can visit the official package documentation <a href="https://pub.dev/packages/auto_route"><strong>here</strong></a>. It provides detailed information on how to leverage AutoRoute’s features to enhance your Flutter app’s routing and navigation.</p><p>In the next part, we will dive into the benefits of using GetIt and Injectable for dependency injection, offering an improved approach compared to the GetX architecture.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c146a09bc5fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>