<?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 Asbed B on Medium]]></title>
        <description><![CDATA[Stories by Asbed B on Medium]]></description>
        <link>https://medium.com/@asbedb?source=rss-4c65e73441ec------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*h1RpKvlAlhrdejqW4KT28A.jpeg</url>
            <title>Stories by Asbed B on Medium</title>
            <link>https://medium.com/@asbedb?source=rss-4c65e73441ec------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 16:40:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@asbedb/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[write all the things]]></title>
            <link>https://medium.com/@asbedb/write-all-the-things-d44baf2a145b?source=rss-4c65e73441ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/d44baf2a145b</guid>
            <category><![CDATA[blog]]></category>
            <category><![CDATA[writers-on-writing]]></category>
            <category><![CDATA[writing-tips]]></category>
            <category><![CDATA[personal-growth]]></category>
            <category><![CDATA[personal-development]]></category>
            <dc:creator><![CDATA[Asbed B]]></dc:creator>
            <pubDate>Wed, 28 Oct 2026 21:33:31 GMT</pubDate>
            <atom:updated>2026-10-28T21:41:05.281Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BVFKB3aVmKls6XcDRsqdsQ.jpeg" /></figure><p>As I self-reflect on my writing process, its significance and impact on my life start to become more apparent. But writing, or at least the version of it I take for granted today, wasn’t always easy. The mediums and implements I use are leaps and bounds beyond what a younger me would have imagined, yet the feelings evoked remain the same.</p><p>This article is spurred by the many iterations of my “portfolio website”: how much it has changed, not only in its purpose, design and presentation, but also in how it has changed me and my way of self-expression.</p><h3>where it all started</h3><p><a href="https://www.understood.org/en/articles/writing-skills-what-to-expect-at-different-ages">Writing is a skill we start to develop in our first year on earth, taking about 10 years to become proficient</a>. This tracks with my own experience: I fondly remember being awarded a “pen licence” (<a href="https://www.theguardian.com/australia-news/article/2024/aug/20/the-write-stuff-australian-children-have-to-earn-their-pen-licence-but-is-the-coveted-certificate-on-the-way-out">a classic Australian tradition</a>) in the fourth grade, a milestone in my life to formally acknowledge my writing proficiency and vest upon me the power to wield a BIC 4-colour retractable ballpoint pen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pz0DARMmJbKlMnBqefaj0Q.png" /></figure><p>During my final year at school, our English exam was administered in a two-hour block where students were expected to handwrite 1,000–1,200 words. I still remember the flailing hands with wrists clenched.</p><p>In the subsequent two years, I had already abandoned regular use of a pen, with the computer keyboard taking its place.</p><p>My earliest memory of writing prose with a computer goes back to 1999. There was a small, dimly lit room wedged between classrooms in my suburban public school, where a shared computer could be accessed. The teachers would encourage students to book time to “surf the web” and “learn Microsoft Word”.</p><p>Computers were expensive; not every family had one. If you did, using it as a kid was under the supervision of an adult. Having access to the internet was not common at all. Our household didn’t have the internet for a very long time — dial-up came to our house whilst I was midway through high school, and by the time we finally got a faster connection, I had already become accustomed to picking up the landline to hear whirs and beeps.</p><p>I did play games on the computer (I was occasionally allowed to play a side-scroller like Aladdin on DOS), but if my parents brought home a game, it was almost always an educational one.</p><p>Coming back to the classroom, a friend called Lewis and I were both really into computers, especially computer games. Remember those educational games? One of the ones released in the ’90s (<a href="https://en.wikipedia.org/wiki/Marble_Drop">Marble Drop</a>) was really fun. Our computer studies teacher used it as a carrot to motivate us to finish our “main computer work”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*2-acX80ECQnWQ9OlF0RCnw.png" /></figure><p>An application Lewis and I started to have some fun with was <a href="https://en.wikipedia.org/wiki/Microsoft_FrontPage">Microsoft FrontPage</a>, a relic from a time when making websites was all about having an editor that mimicked what the website actually looked like (What You See Is What You Get, or WYSIWYG).</p><p>Being the gamers we were, our big project for that year involved making a gaming e-zine, a FrontPage-built website with lots of Nintendo characters and game reviews.</p><p>And so… I wrote my first-ever “gaming article”. Not because it was homework or because someone told me to.</p><p>Because I wanted to.</p><p>The game I reviewed was Super Mario 64, and I probably gave it 5 Power Stars out of 5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*YbKijTd22vo_IQ2kpgI-8g.png" /><figcaption>what our website probably looked like</figcaption></figure><p>There’s a reason I recall this so fondly: writing about something I’m passionate about felt good.</p><p>It still does, and it brings me joy.</p><h3>find your muse</h3><p>I once asked my grandfather (Dede) what reading and writing meant to him.</p><p>He told me about how his schooling ended at age 13. He was a good student and wanted to continue; however, like many children growing up in the Middle East in the late ’40s, his circumstances dictated that he drop out and start working. He never expressed regret or bitterness, but his passion for reading and writing would shine when he smiled from his heart talking about his favourite books (he would also get really upset when a friend borrowed one of his books and didn’t return it).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*A0lpFBJznKBkDk1Y8ITaXw.png" /><figcaption>My grandfather in his younger years.</figcaption></figure><p>In his later years, he would spend hours upon hours writing about everything in his life: long-form handwritten scribbles in our native tongue (Armenian). Private, philosophical, and a rare insight into a slice of history.</p><p>There are many stories like my grandfather’s out there, too many to count, and whilst the clichéd proverb “the pen is mightier than the sword” might bubble up, in a way the pen became my grandfather’s sword. It was by his side, making him feel safe through the trials and tribulations of being the primary breadwinner at 13 years old. It supported him through his conscription years, gave him security through marriage, having children, emigrating and having grandchildren, and finally, it was his familiar comfort before his rest.</p><h3>just be yourself</h3><p>I spent fifteen years in tech sales. If I were to average two slide-deck presentations across thirty-two working weeks a year, I would be nearing 960 presentations. Needless to say, that’s a long history of presenting and talking to an audience.</p><p>It was dry, repetitive, professional and ultimately cookie-cutter.</p><p>As confident as I am at “synergising” and “circling back”, if I were to drop my guard and show my true colours, a very different side of me would emerge: the nerdy, passionate and tangential me — a side that, when I sheepishly put out there, didn’t resonate with many (at least not in the settings or circles I tried).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*LTV-RhzqTMVWrQShBmXHTA.png" /></figure><p>It’s tiring. I still sometimes catch myself putting on a face. Part of it is the fear of rejection; sometimes I’m just trying to fit in; most of the time it’s feeling misunderstood.</p><p>Don’t get me wrong: a genuine interest in others is a wonderful thing, and I wholeheartedly embrace a passionate conversation, yet I often find myself in that odd spot of being hesitant — whether it’s because of the vulnerable position I’m put in by being the real me, or the internal monologue that comes with realising the planet, can sometimes be a lonely place when you have niche interests.</p><p>Hesitation holds back progress.</p><p>It took fifteen years and close to a thousand PowerPoint presentations to get to a point where I could easily throw slides together fifteen minutes before a meeting and present (not joking — it happened many times). Why shouldn’t I put the same amount of effort into something far more important?</p><p>So that’s what I’ve been slowly chipping away at: talking about myself in an honest way and writing about the things I find interesting, with every small step more decisive than the last.</p><p>My portfolio attempts have been a mirror of this journey of sorts — take a moment to reflect with me, if you please.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I9O72-VZOj9OA7IuducvbA.png" /><figcaption>My first attempt at a portfolio website</figcaption></figure><p>In my very first portfolio design, the corporate me was still very much the “identity”. It’s a story for another time, but I was at a critical junction in life. There was change in the air, but the hesitant me still hadn’t fully embraced my inner voice. I also saw a portfolio as a “means to a job” and hadn’t explored many other avenues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5l32V3vyWKZLnkC_AbNKfQ.png" /><figcaption>whilst I never used this design, I spent a lot of time on it</figcaption></figure><p>Around the same time, I had started looking for my tribe. Online communities have always been a big part of my life — gaming, forums and chat rooms all have long threads running back to my early years. It’s interesting to look back at this: I was starting to discover tech interest groups through an online messaging app called Discord, and it looks like the inner me wanted to display some of the joy in finding common interest groups. The language is still very much corporate-coded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S6CEBKu7DBQU_w84JZOY2g.gif" /><figcaption>well, this is interesting now!</figcaption></figure><p>By the next attempt, I was starting to feel a little more comfortable with myself. I had now been part of these online communities for nearly a year, and the idea that more people like me exist in the world brought me comfort. I started attending local meetups (free pizza and drinks — what’s not to like?), and that kid who made a website with Lewis was back. Windows XP took up a massive chunk of my life, and this was a homage to that kid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h_Zy5fo8TOjdh_5fkTJC_w.png" /></figure><p>Whilst the homage is still <a href="https://asbedb.github.io/windowsxphtml/">up as a demo</a>, something interesting started to emerge.</p><p>That feeling of writing because it feels good started to bubble back up. I started to hear my own voice, and I wanted to make sure it was mine.</p><p>Furious editing followed — going over points repeatedly, saying things out loud — and the biggest realisation came through this process: <strong>this is my website.</strong></p><p>It’s my corner of the internet, and I don’t need to hide. If that means super-long articles about colour science, or about how I looked into some weird McDonald’s Flash game from the ’90s, so be it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VAxYw3Xr-HSy4Y-O-C65uw.png" /></figure><p>I’ve found a calming quality in being decisive. It takes practice and sometimes a bit of courage. My current portfolio is special to me. Yes, it looks nice, but it’s also a nod to how far I’ve come, both technically and personally, in the last two years.</p><p>But I also built it for others to use. I made it a platform in the hope that other technical people would have a medium to share their true voices and join me in practising. It’s called <a href="https://melan.asbedb.dev/">Melan</a>, which in Western Armenian means both “ink” and “pen”, and it’s dedicated to my grandfather, who often wrote with his <em>melan</em> in a corner of the room before blogging was even a thing.</p><h3>fun side note</h3><p><em>As a fun side note on the topic of pens and swords:</em></p><p>There are no sovereign countries that feature a pen or writing implement on their national flag.</p><p>Seven sovereign countries (Saudi Arabia, Sri Lanka, Oman, Guatemala, Angola, Iran and Malta) have decided the sword is mightier than the pen. Flags (and I use the term loosely) tied to physical places that feature pens or writing implements are extremely rare — the two I managed to find were:</p><ul><li><a href="https://en.wikipedia.org/wiki/Coat_of_arms_of_Armenia">The Armenian coat of arms (coincidental, I promise).</a></li><li><a href="https://en.wikipedia.org/wiki/Juana_D%C3%ADaz,_Puerto_Rico">Juana Díaz (municipality of Puerto Rico)</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d44baf2a145b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Replacing GitHub Actions with a Tiny Desktop]]></title>
            <link>https://medium.com/@asbedb/replacing-github-actions-with-a-tiny-desktop-0c10e410307f?source=rss-4c65e73441ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/0c10e410307f</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[homelab]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Asbed B]]></dc:creator>
            <pubDate>Sun, 27 Sep 2026 13:12:22 GMT</pubDate>
            <atom:updated>2026-09-27T13:12:22.211Z</atom:updated>
            <content:encoded><![CDATA[<p>Earlier this year I launched <a href="https://scapedle.com/">Scapedle</a>, a daily word guessing game themed around the popular video game Old School RuneScape. If you are interested you can <a href="https://asbedb.dev/musings/scapedle-game/">read all about it here</a>.</p><p>A key element to this project involves rotating a daily word every 24 hours — to address this functionality an automated rebuild and subsequent deploy would need to occur every day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sAJkst7Re8-QascAYRuMQw.png" /></figure><p>Originally I administered this process through GitHub Actions using the public free runners, initially this was fairly reliable. However as I came to learn there were a few drawbacks to this approach.</p><ol><li><strong>Waiting in a queue</strong> — GitHub free runners are a shared resource, this means on particularly busy days you could be waiting up to 8 hours to run your actions.</li><li><strong>GitHub has off days</strong> — If you’ve been paying attention, you’ll know the AI boom has GitHub, like everyone else, struggling to keep up with scale. You can check out the <a href="https://mrshu.github.io/github-statuses/">“real status page”</a> for some metrics.</li><li><strong>Nothing is free forever</strong> — Free services are great, but anything that could start charging at scale or be deprecated deserves a plan B.</li></ol><p>This write-up covers moving the build and deploy process off GitHub infrastructure onto my home lab (minus hosting the website itself).</p><p><a href="https://asbedb.dev/musings/tiny-homelab-git-runner/"><strong>If you would like to read a developer friendly version of this article click here.</strong></a></p><h3>Current State</h3><p>The daily-deploy.yml file handled the scheduled build and deployment of the application. The below snippet is only a high level summary but gives you the idea of the steps involved.</p><pre>name: Deploy OSRS Guessing Game<br>on:<br>    schedule:<br>        - cron: &#39;30 13 * * *&#39;<br>    push:<br>        branches: [&#39;main&#39;]<br>jobs:<br>    build_and_deploy:<br>        runs-on: ubuntu-latest<br>        steps:<br>            - name: Checkout<br>            - name: Install pnpm<br>            - name: Setup Node<br>            - name: Install dependencies<br>            - name: Build<br>            - name: Setup Pages<br>            - name: Upload artifact<br>            - name: Deploy to GitHub Pages</pre><p>These steps used pre-built <a href="https://github.com/features/actions">GitHub Actions</a>, providing less overhead in managing infrastructure and tooling — in turn you give up some of the freedoms that come with owning the “supply chain”.</p><p>I also want to point out the schedule on my cron is in UTC 30 13 * * * which is 23:30 AEST (Australian Eastern Standard Time), this was updated multiple times to try and predict when I would get a free runner at precisely midnight with no success. Some days it was 10 minutes off, most of the time it was an hour to eight hours late.</p><p>Notifications were managed via daily-notification.yml (see below):</p><pre>name: Daily Notifications<br>on:<br>    workflow_run:<br>        workflows: [&#39;Deploy OSRS Guessing Game&#39;]<br>        types: [completed]<br>jobs:<br>    on-success:<br>        runs-on: ubuntu-latest<br>        # conditional<br>        steps:<br>            - name: Send Success Message<br>              run: |<br>                  curl -H &quot;Content-Type: application/json&quot; \<br>                       -d &#39;{<br>                         &quot;username&quot;: &quot;Scapedle Announcer&quot;,<br>                         &quot;content&quot;: &quot;🗓️ **A new daily Scapedle is live!** \nCheck it out here: https://scapedle.com&quot;<br>                       }&#39; \<br>                       ${{ secrets.DAILY_WEBHOOK }}</pre><p>This curls content to a Discord webhook sending a message in relevant channels. Looking back, this should have been integrated into the daily-deploy.yml. Calling a new resource just to curl is not ideal. My approach also had a &quot;bug&quot; where a non-daily rebuild would trigger the same notification.</p><p>This is something I will be addressing in the new approach.</p><h3>Home Lab</h3><p>If you have trepidation around tinkering with a home lab, I’m here to tell you <em>it’s not that deep</em>. I too once sat on the outskirts occasionally peeking in and then one day I finally picked up that old tiny desktop and gave it some new life.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*4zOC5B_Nsc0ZuHoeJD-y6w.png" /></figure><p>Currently “the hulk” is powering a network-wide adblocker, a Docker host and a cronjob orchestrator, and it’s barely breaks a sweat doing it! It’s also playing a leading role in helping develop me develop <a href="https://github.com/asbedb/proxaform">Proxaform</a>, an open-source orchestration tool for provisioning and tearing down Proxmox LXC container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3RopZvW2h6INWnCEg40RTg.png" /></figure><p>Before getting into my setup, it’s worth noting — the outlined technical foundation shouldn’t really change much, however the implementation can wildly vary depending on your application, home lab and stages in your build and deployment pipeline.</p><p>I decided to containerise my build and notification tasks into a single Docker image, scheduled to run every 24 hours. Bundling notifications into this process also addresses the bug noted earlier and streamlines the tasks into a single container.</p><p>As I have other applications that benefit from having a Docker runner and scheduled cronjobs, I split the tasks into two VMs. Additionally, I found <a href="https://github.com/alseambusher/crontab-ui">Crontab-UI</a>, a simple Node.js web interface for managing cronjobs on the host server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ACbSgRu61BzANeO2tZ37Uw.png" /></figure><p>docker_node Runs Docker; executes jobs dispatched from Crontab-UI crontab_node Runs Crontab-UI server; schedules, manages and dispatches jobs</p><p>And of course the full Ansible playbook to set up a similar workflow is also released as part of my Proxaform project — <a href="https://github.com/asbedb/proxaform/tree/main/playbooks/coding/crontab_ui_docker_runner">you can find more technical details and the code here</a>.</p><p><em>Note: The above approach can just as easily be replicated on a local machine using Docker (or Docker Desktop on Windows). If you are curious just give it a go!</em></p><h3>A new daily deployer</h3><p>The previous section laid out the foundation, now I needed it to work for my specific application. Below is a high level diagram of how all the pieces fit together.</p><pre>┌──────────────────────── Proxmox ────────────────────────┐<br>│                                                         │<br>│  ┌─────────────────────┐        ┌─────────────────────┐ │<br>│  │ VM  : crontab_node  │        │ VM  : docker_node   │ │<br>│  │                     │  SSH   │                     │ │<br>│  │ Crontab-UI          │ ─────► │ Docker Engine       │ │<br>│  │ schedules jobs      │  jobs  │ Fetch/Build/Notify  │ │<br>│  └─────────────────────┘        └──────────┬──────────┘ │<br>│                                            │            │<br>└────────────────────────────────────────────┼────────────┘<br>                                             │  Push to gh-pages branch<br>                                             ▼<br>                                  ┌─────────────────────┐<br>                                  │ GitHub Pages        │<br>                                  │ scapedle.com        │<br>                                  └─────────────────────┘</pre><h3>Dockerfile</h3><p>The easiest place to start was the Docker image. I wanted a small footprint ensuring a quick build and shut down. Being my first time seriously writing a Dockerfile, the syntax and file structure were very easy to pick up, I don&#39;t think it&#39;s far-fetched to compare it to a yml file with stepped instructions (but for containers).</p><p>The below Dockerfile goes through the following steps:</p><ol><li>Latest version of Node.js Alpine Linux image from Docker Hub — Alpine was chosen for being small in used disk size, and memory usage making it perfect for an ephemeral workload.</li><li>Ensures the image has the right tools — bash, git, certs, curl.</li><li>Sets the package manager to pnpm.</li><li>Ensures the directories used as part of the build are created and available.</li><li>Makes the deploy script executable and gives the node user ownership of the working directories.</li><li>Ensures the scripts are running as a non-root user called node.</li><li>Enables CI mode keeping pnpm non-interactive.</li><li>Executes deploy.sh with the daily flag.</li></ol><pre>FROM node:current-alpine3.23<br>RUN apk add --no-cache bash git ca-certificates curl util-linux tzdata<br>RUN npm install -g pnpm@11.1.2<br>RUN mkdir -p /work /state /pnpm-store &amp;&amp; chown node:node /work /state /pnpm-store<br>COPY --chmod=755 scripts/deploy.sh /usr/local/bin/deploy<br><br>USER node<br>WORKDIR /work<br>ENV TZ=Australia/Sydney \<br>	CI=true<br><br>ENTRYPOINT [&quot;deploy&quot;]<br>CMD [&quot;daily&quot;]</pre><h3>Shell Script</h3><p>deploy.sh now does the heavy lifting - <a href="https://github.com/asbedb/Scapedle/blob/main/scripts/deploy.sh">you can review the script in full here</a>. In summary the script will:</p><ol><li>Check if the build action comes with a daily flag as this is how our “New Daily Word” notification is now triggered as opposed to a new build out of cycle.</li><li>Manage our authentication (I will cover secrets shortly) to GitHub.</li><li>Build our application taking into account already running builds and gracefully failing if a build is already in flight.</li><li>Set a commit message with each build taking note of the date and time.</li><li>Fire off relevant webhook notifications depending on the type of build triggered.</li></ol><h3>Secrets</h3><p>The final bridge was managing secrets and authentication — for this, a trusty .env file has now been employed and referenced in the shell script (and .gitignored).</p><p>See an example below:</p><pre># Fine-grained PAT scoped to this repo only, with &quot;Contents: Read and write&quot;.<br>GH_TOKEN=<br>GH_REPO=asbedb/Scapedle<br># Optional overrides<br># SOURCE_BRANCH=main<br># DEPLOY_BRANCH=gh-pages<br># SITE_URL=https://scapedle.com<br># GIT_AUTHOR_NAME=Scapedle Deploy<br># GIT_AUTHOR_EMAIL=deploy@scapedle.com<br># Discord webhooks (leave blank to disable)<br>DISCORD_WEBHOOK=<br>DAILY_WEBHOOK=</pre><p>The variables and comments should make it fairly self-explanatory. I will stress it’s important to apply the principle of least privilege to the access token for the repository. For this one it’s limited to the project and Read/Write only.</p><h3>Cronjob</h3><p>As I said before my cronjob might wildly vary from how you may want to approach this — but to keep this piece consistent I will share my setup. Keep in mind my workflow includes SSH’ing into the Docker host before executing the command.</p><p>I’ll also plug a <a href="https://github.com/asbedb/proxaform/tree/main/playbooks/maintenance/sync_time">small playbook I wrote</a> to set the time zone across my Proxmox cluster, along with some <a href="https://github.com/asbedb/proxaform/tree/main/roles/common">common roles</a> for keeping clocks in sync via NTP. If you’re doing the same, make sure your VM’s time zone is set, so @daily fires at local midnight.</p><pre>@daily ssh -i /var/lib/&lt;app&gt;/.ssh/&lt;key&gt; -o BatchMode=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=/var/lib/&lt;app&gt;/.ssh/known_hosts docker-runner@&lt;IP&gt; &#39;set -e; REPO=/opt/scapedle; [ -d &quot;$REPO/.git&quot; ] || git clone -q https://github.com/asbedb/Scapedle.git &quot;$REPO&quot;; cd &quot;$REPO&quot;; git fetch -q origin; git reset -q --hard origin/main; docker compose run --rm -T --build builder daily&#39;</pre><p>If you wanted to just do it directly on the host you could also elect to use a cron runner that supports time zones like CRON_TZ and do a command like this. The second cron is an example of checking every five minutes for new commits and rebuilding without sending the daily notification.</p><pre>CRON_TZ=Australia/Sydney<br>1 0 * * *   cd /opt/scapedle &amp;&amp; docker compose run --rm builder daily      &gt;&gt; /var/log/scapedle.log 2&gt;&amp;1<br>*/5 * * * * cd /opt/scapedle &amp;&amp; docker compose run --rm builder if-changed &gt;&gt; /var/log/scapedle.log 2&gt;&amp;1</pre><p>In case others decide to fork and make their own “wordles” and want to adopt something similar <a href="https://github.com/asbedb/Scapedle/tree/main/deploy">I’ve included scheduling options</a> in the Scapedle repo (including making the daily deployer a systemd service) - as mentioned, same foundation, different ways of doing things.</p><h3>Conclusion</h3><p>With all the pieces in place, changes staged and merged I nervously waited for my first scheduled job at midnight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*7c23Tb8brXY95rYB6mH4Bw.png" /></figure><p>Seeing the Discord notifications pop up and a new daily word brought with it relief. Another fun weekend tech project for the (desktop on the) shelf 🙃.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0c10e410307f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Untangling bureaucracy by creating a RAG Chatbot]]></title>
            <link>https://medium.com/@asbedb/untangling-bureaucracy-by-creating-a-rag-chatbot-eb292db21d51?source=rss-4c65e73441ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb292db21d51</guid>
            <category><![CDATA[government]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Asbed B]]></dc:creator>
            <pubDate>Fri, 25 Sep 2026 07:38:03 GMT</pubDate>
            <atom:updated>2026-09-25T07:38:03.402Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>The views and material below are purely my own and do not represent an authority or body of any sort, all output and information should be clarified and not taken as advice or an official stance</strong></p><p>It’s was <a href="https://www.apsprofessions.gov.au/resources/innovation-hub/innovation-month-2025-risk-resolve-results">innovation month</a> across the Australian Public Sector, as part of the festivities a challenge was set to “build a bureaucrat bot”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Z1PMhNRN4l53jPEO_jp-qA.png" /></figure><p>I thought it apt to give the challenge a “fair shake of the sauce bottle” . It was a good excuse for me to dive into something new and untested, maybe learn a thing or two along the way. I wanted to summarise the journey — not necessarily in my usual deep dive technical style, but approachable enough to get an idea, with some relevant links to code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qx19ZZRj46p4eQ1eb2knYw.png" /></figure><p>If you want to poke at it yourself, the <a href="https://github.com/polycy-bot">repo’s here</a> with a <a href="https://polycy-bot.netlify.app/">live demo here</a> and if you spot something I’ve done badly (very possible), I’d love to hear about it.</p><p>And a summary of what the bot does below (excuse my artistry.😊)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*ub2J58DlAwVRCIL61o5gWw.png" /></figure><p><a href="https://asbedb.dev/musings/innovation-month-2026/">If you prefer to read this article in a developer friendly format you can find an alternative link for this post on my website here.</a></p><h3>Challenge</h3><p>Innovation month similar to a hackathon is a good way to platform and provide opportunity to showcase — <em>dare I say it</em> — innovation in delivering smarter outcomes in what I’m going to coin “good public service”. With the theme “Ready or not” the primary focus this year is around harnessing the capabilities of AI (in all forms) without losing sight of the goals aforementioned. The “Build a Bureaucrat Bot” event took this theme and provided a tangible category for all to participate.</p><blockquote><em>“Can you build a helpful bot for a real public service problem? Use generative AI to create an interactive bot that helps public servants, senior leaders or citizens. No coding experience needed — no-code, low-code and prompt-based builds are welcome.”</em></blockquote><p>In addition the bot could sit in primarily one of the below categories.</p><ol><li><strong>The Chief AI Officers Aide</strong>: Tools that support strategic decision-making, adoption planning, governance, maturity assessment, prioritisation, risk framing or executive briefings</li><li><strong>The Workday Wingmate:</strong> Drafting, planning, summarising, navigating internal guidance, preparing meetings, improving correspondence, supporting teams, or making routine work less painful</li><li><strong>The Cobber Bot:</strong> Citizen-facing or public-facing ideas that make services, obligations, forms, decisions, entitlements or processes easier to understand and engage with.</li><li><strong>The Complexity Tamer:</strong> Tools for policy, research, modelling, simulation, evidence synthesis, system mapping, scenario testing or making trade-offs more visible</li><li><strong>The AI Trailblazer:</strong> Move from curiosity to responsible practice: identifying opportunities, designing experiments, working through risks, building confidence, planning implementation, or scaling what works</li></ol><h3>Approach</h3><p><strong>The Complexity Tamer</strong> category instantly lit up for me. Untangling bureaucracy can be an art form, particularly when trying to administer and uphold laws.The immediate scenario which came to mind was navigating <a href="https://www.ato.gov.au/about-ato/ato-advice-and-guidance/ato-guidance-products/law-administration-practice-statements">Law Administration Practice Statements</a> (PS LAs).</p><p>A PS LA is an article that provides direction to Public Service workers on approaches to take when performing duties which involve the Superannuation and Tax laws being administered. Whilst the PS LAs themselves are not law or public ruling, they are used to help undertake technical direction in various matters. This “abstraction” layer above the law, certainly is in the category of taming complexity — but there were a few “bottle necks” in analysing a practice statement that I wanted to try and test.</p><ol><li>The abstraction of law means that the language or legal ease is still going to be present in the directions provided — how can this become more accessible to someone less technical.</li><li>Drawing parallels between articles is currently difficult unless directly referenced in the statement itself — In some scenarios there may be multiple PS LAs covering various technical topics — “GST Rulings” can appear across three PS LAs with two of them withdrawn.</li><li>Searching and using the PS LAs as reference is currently relegated to a public facing website with the content being in HTML/Static Web — it works, but outside of reading the PS LAs themselves you would need additional uplift to use the data in other environments.</li></ol><h3>The Idea</h3><p>My idea was to implement a retrieval augmented generation tool (RAG) to quickly sift through PS LAs based on a user’s prompt and provide a highly tailored response to the user. I’ll try and provide a simple step by step example of a RAG assisted result.</p><ol><li>User prompts tool in simple language to try and gather information on making a technical decision.</li><li>Prior to our call going to our preferred generative model we ensure that our prompt is searched against a database of information housing all of our PS LA knowledge.</li><li>If a PS LA is found its crafted into a <strong>context payload</strong>.</li><li>The personality of our model is heavily guarded — it can <strong>only</strong> talk about PS LAs, it is given strict instructions to <strong>use the context provided</strong> and any request outside of PS LAs is rebuffed.</li><li>We stuff the <strong>context</strong> between our guard rails (<strong>prompt stuffing</strong>) and tell the model this is its <strong>primary subject</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LtghhrhZ0TGCq-E1hLOXMw.png" /></figure><p>And there you have it — a retrieved piece of information has augmented our prompt and resulted in a pointed generation!</p><p>Initially, I was imagining a Saturday and Sunday at best to build, test and deploy — leaving me plenty of time to write this piece. How wrong I was (apologies for any grammar or spelling mistakes in advance 🙃).</p><h3>The Plan</h3><p>The project is broken into two repositories — the ingestion engine and the presentation layer or “front end”.</p><p>For this project to show promise it was important to fine tune both — not only were they reliant on each other but also each in its own right drastically changed the user experience outcomes.</p><p>Ensuring good data stewardship is going to dictate the success of outcomes — and to some degree this holds true for any technology program in the not too distant future. I will go through and break out both the ingestion pipeline and front end into interesting challenges and learnings, however, if you want to review the full code its open source and <a href="https://github.com/polycy-bot">available on GitHub here</a>.</p><p>Below is an outline of the initial ingestion flowing into a full stack interactive web interface.</p><pre>Website with PS LA content (Public Facing Website)<br>                           │<br>                           ▼<br>             ┌───────────────────────────┐<br>             │ Ingestion Engine Pipeline │<br>             │  • Converts HTML to MD    │<br>             │  • Parses metadata        │<br>             │  • Sanitizes URLs/Dates   │<br>             └─────────────┬─────────────┘<br>                           │<br>                           ▼<br>			 [ knowledge.json ] (DB Artifact)<br>                           │<br>                           ▼<br>             ┌───────────────────────────┐<br>             │     SvelteKit Backend     │<br>             │  (api/library/server.ts)  │<br>             │                           │<br>             │   ┌───────────────────┐   │<br>             │   │  • Context Search │   │<br>             │   │  • Filter Stops   │   │<br>             │   │  • Score Relevance│   │<br>             │   │  • Stuff Prompt   │   │<br>             │   └─────────┬─────────┘   │<br>             └─────────────┼─────────────┘<br>                           │ <br>		 [API Payload] (Stuffed Prompt to Model)<br>                           │<br>                           ▼<br>             ┌───────────────────────────┐<br>             │    SvelteKit Frontend     │<br>             │                           │<br>             │  ┌─────────────────────┐  │<br>             │  │  uiState.svelte.ts  │  │ (Global UI state)<br>             │  └──────────┬──────────┘  │<br>             │             │             │<br>             │  ┌──────────▼──────────┐  │<br>             │  │ • Display Chats     │  │<br>             │  │ • Search DB/Context │  │<br>             │  │ • Prompt            │  │<br>             │  │ • Detail &amp; timeline │  │<br>             │  └─────────────────────┘  │<br>             └───────────────────────────┘</pre><h3>Ingestion</h3><p>Ingestion has been broken down into a few parts — I want to thank whoever built and maintaned the website housing PS LAs, there are some key patterns I relied on throughout the ingestion phase and without them, I don’t think I would have finished this project in time.</p><h3>Crawling</h3><p>Each PS LA has a unique URL, lets take one as an example:</p><p><a href="https://www.ato.gov.au/law/view/document?docid=PSR/PS19981/NAT/ATO/00001.">https://www.ato.gov.au/law/view/document?docid=PSR/PS19981/NAT/ATO/00001.</a></p><p>Removing the static parts of the URL we can review only this section:</p><p>PS{year}{sequence}/NAT/ATO/00001.</p><p>Rather then copy pasting each URL my first automation was to build a quick request resolver to go through a range of years to scan valid links within that year. If you are interested in the code you can <a href="https://github.com/polycy-bot/ingestion-engine/blob/main/utilities/url_builder.py">review it here</a>.</p><p>For each successfully resolved URL it was appended to a text document called verified_urls.txt in the /data folder.</p><p>A few things I learnt from this feature:</p><ul><li>Not all websites expect a friendly header to let the web administrator know what your crawler is doing (I’m assuming some Cloudflare technology trend) just rejected my requests when I had something along the lines of Crawler-Innovation-Month in my header. <em>Sorry admin.</em></li><li>Graceful delays and timeouts help reduce gaps in the data hammering a request isn’t the most efficient way to gather and validate evidence.</li><li>Reliable patterns make for good automation — and allow not only for an easier approach to administration but also for external parties to integrate and extend your product.</li></ul><h3>Scraping</h3><p>I am of the firm belief that one of the top sought after skills in the next 5–10 years will be centred around the ability to write good documentation, in addition to being able to write it in markdown.</p><p>Generative models are good at this, yet when it comes to articles that are extremely nuanced or not in the public domain — it’s on us to build that layer to help get to outcomes faster.</p><p>Scraping a website isn’t ground breaking — however — translating a website from HTML markup to markdown is where it gets interesting. Thankfully the web administrators once again were gracious enough to clearly mark the PS LA webpage with easy to understand id’s tied to the various markup elements. It was on me to translate those elements into a markdown format — <a href="https://github.com/polycy-bot/ingestion-engine/blob/main/utilities/psla_parser.py">the python utility responsible for this can be reviewed here.</a></p><p>Doing this during ingestion made sense, we could have reserved it for the front end however that also complicates the prompt stuffing — LLM’s are a lot better at understanding markdown as context then they are HTML.</p><p>During this parsing stage I created a key value data structure to return which would be appended to a .json file. The return object looks like this:</p><pre>return {<br>        &quot;doc_id&quot;: doc_id,<br>        &quot;title&quot;: title,<br>        &quot;category&quot;: category,<br>        &quot;raw_text_content&quot;: markdown_content,<br>        &quot;revision_history&quot;: revision_history,<br>    }</pre><p>Learnings from this feature:</p><ul><li>Stripping elements and cleaning the ingestion data was critical — we didn’t need images, contact details or scripts. Purely the content relevant to the task</li><li>By preserving the HTML in its markdown equivalent presenting this back in a front end was much easier to manage. i.e. a title denoted with # was easy to render as a &lt;h1&gt; using a markdown parser.</li><li>Breaking up the parsed data into metadata attributes allowed us to create faster searches across documents (and expand out capability to include other sources in the future).</li></ul><h3>Persistence/Storing</h3><p>Finally should there be no data ingested, the application will create and store the results in two files, one which houses all the valid URLs, and one which will be the main source of truth artifact to our full stack web app (knowledge.json).</p><p>I built a persistence service to check if the files existed and only run the service if they didn’t. This was primarily to rapidly test but also not recrawl URLs if I had a fully valid list and only wanted to update the database with new tags/content.</p><h3>The Application</h3><p>With the ingestion engine reliably producing knowledge.json, the other half of the problem was giving that data somewhere to live that didn&#39;t feel like reading a legal document with extra steps. I decided to go back to my tried and tested friend <a href="https://svelte.dev/docs/kit/introduction">SvelteKit</a> - if you are interested in my feelings about it you can <a href="https://asbedb.dev/musings/scapedle-game/#sveltekit">read more here</a>.</p><p>Similar to my reasonings for that project I wanted to have a quick and easy way to deliver both front and back end without splitting infrastructure and inflating cost.</p><p>The front end has two main responsibilities, I won’t go into the technical detail of the UI implementation as this post is more focussed on the “RAG” side of things however it provides the user with.</p><ol><li>A way to communicate to the chatbot through a common chat interface</li><li>A way to browse all of the context available, and, prompt based on a PS LA as a starting point to a conversation.</li></ol><h3>Models</h3><p>For the generative engine I did test both a local model using llama 3.1 4B and Google Gemini’s cloud model. I ended up choosing Gemini as it’s free and one less hosting problem to consider — that said the system is fully capable of slotting in and out models. Currently the hosted version is using gemini-3.1-flash-lite which I found perfect for a tech demo.</p><h3>Context Search</h3><p>Once knowledge.json existed, the job of the backend was fairly simple to <em>state</em> and much less simple to get right: take whatever a user typed, work out which PS LA (if any) it&#39;s actually about, and only then let the model open its mouth. I&#39;ll admit up front - there&#39;s no embedding model or vector database sitting behind this thing. getContextByKeyword is doing keyword scoring, plain and simple.</p><p>Every document in the knowledge base gets a score based on a handful of signals:</p><ul><li>Does the raw query appear verbatim in the text (+10).</li><li>Does it appear in the title or doc ID (+20).</li><li>Word-by-word matches against title, doc ID and body content at smaller weights.</li></ul><p>There’s a small bit of nuance in there for our PS LA 1998/1 style references specifically - if a query word contains a slash and matches the doc ID (think someone pasting in PS 1998/1 or similar), it gets bumped harder than a generic word match, because that&#39;s about as close to a direct citation as a user is going to give us.</p><p>Anything that doesn’t clear a minimum match ratio (at least a quarter of the query’s meaningful words showing up somewhere relevant) or a minimum score gets discarded, and I only ever pass the top three scoring matches through to the model.</p><p>Stop words get filtered out before any of this even starts, otherwise “what does the ATO say about GST” would spend most of its scoring budget matching “the” and “about” against every document in the library. We don’t want to score these words as they are just part of common lexicon and will appear everywhere.</p><p>The <a href="https://github.com/polycy-bot/polycy-fe/tree/main/src/routes/api/chat">/api/chat</a> is home to this functionality, specifically context.ts doing the scoring and searching.</p><p>Learnings from this feature:</p><ul><li>Keyword scoring is unglamorous but it’s transparent — I can look at any result and explain in one sentence why it scored the way it did.</li><li>The slash-matching quirk exists purely because of how PS LAs are referenced in the wild (1998/1, 2011/27, etc.) - a generic RAG implementation wouldn&#39;t have thought to weight that, but knowing your data&#39;s shape earns you these small wins.</li><li>Capping at three matches was a deliberate guardrail on context size as much as anything else — Gemini doesn’t need six PS LAs shoved into a system prompt to answer a question about GST rulings, and neither does the person asking it.</li></ul><h3>Prompt Stuffing</h3><p>The personality of the agent is fine tuned in <a href="https://github.com/polycy-bot/polycy-fe/blob/main/src/routes/api/chat/policyAssistant.ts">this file</a>. Here you can see its personality and instructions. I wrote a custom function which takes whatever came back from the context search and does one of two things.</p><ol><li>If nothing matched, the model gets AGENT_INSTRUCTIONS plus a POLICY_NOT_FOUND_GAURDRAIL block which tells it, in no uncertain terms, that it doesn&#39;t get to freelance an answer about tax law from its own training data.</li><li>If something did match, it gets AGENT_INSTRUCTIONS plus POLICY_FOUND_INSTRUCTION, followed by every matched document wrapped in its own clearly delimited block - source link, doc reference number, title, and the full markdown content, separated by a run of equals signs so the model has an unambiguous way of telling one PS LA from another when more than one comes back.</li></ol><p>This is the “prompt stuffing” I mentioned earlier made real — the model’s personality and its subject matter are being assembled fresh on every single request, out of instructions I control and content that’s been vetted by the scoring step above.</p><p>Learnings from this feature:</p><ul><li>Separating “found” and “not found” instructions turned out to matter more than I expected. Early on I was using one instruction set and telling the model to “use context if provided” — it would occasionally still have a go at answering from general knowledge when nothing matched. Splitting the guardrail language into its own explicit branch closed that gap.</li><li>Labelling each context block with a document reference number (#1, #2, #3) rather than just dumping raw text back to back gave the model something concrete to cite back to the user, which matters a lot when someone&#39;s asking about a topic that spans a withdrawn PS LA and its replacement.</li></ul><h3>Model Calls</h3><p>+server.ts is the thin layer that actually talks to Gemini - and deliberately thin. It pulls the API key, validates the incoming message array, pulls the last user message out as the query, and hands it to getContextByKeyword. From there it&#39;s mostly plumbing: build the system instruction, reshape the conversation history into the user/model roles Gemini expects (SvelteKit and the frontend are happy calling it &quot;assistant&quot;, Gemini is not), and open a streaming connection with generateContentStream.</p><p>The response comes back chunk by chunk through a ReadableStream, which gets piped straight to the client as plain text rather than waiting for the full generation to finish - useful for anything constrained to an edge runtime, and it&#39;s the difference between a user staring at a blank screen for a few seconds versus watching an answer arrive. One small addition I was glad I made early: an x-context-retrieved header on the response, set to whether any PS LA actually matched. It&#39;s a cheap way for the frontend to know, before it&#39;s even parsed a word of the streamed answer, whether it&#39;s looking at a grounded response or a guardrail refusal.</p><h3>Library Endpoint</h3><p>Sitting alongside all of this is /api/library, a much simpler read-only endpoint that just flattens the entire knowledge base into an array - id, title, category, content, source URL and revision history per document. This is what lets the frontend browse the full PS LA library independently of any chat interaction, which turned out to matter once I started thinking about the &quot;detail &amp; timeline&quot; view - being able to look at a PS LAs revision history directly, without needing to have asked the chatbot a question first.</p><h3>Wrapping Up</h3><p>I thought a “Saturday and Sunday” session would be all it took, here we are finishing this piece 2 days before the deadline, which is probably the most honest lesson from Innovation Month: taming complexity is itself complex.</p><p>If you want to poke at it yourself, the <a href="https://github.com/polycy-bot">repo’s here</a> with a <a href="https://polycy-bot.netlify.app/">live demo here</a> and if you spot something I’ve done badly (very possible, see grammar disclaimer above), I’d love to hear about it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb292db21d51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decompiling a McNugget]]></title>
            <link>https://medium.com/@asbedb/decompiling-a-mcnugget-d6bec5360cac?source=rss-4c65e73441ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6bec5360cac</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[retro-gaming]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[macromedia-director]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Asbed B]]></dc:creator>
            <pubDate>Tue, 22 Sep 2026 13:22:18 GMT</pubDate>
            <atom:updated>2026-09-22T22:13:40.805Z</atom:updated>
            <content:encoded><![CDATA[<p>For some reason a lot of the weekend projects I decide to embark on also double as an excuse to get nostalgic. This past weekend another one of these extremely niche never to be revisited projects took place.</p><p>Growing up it was a rare treat for me to see the shimmer of golden arches — envious of kids who had regular visits after Saturday soccer. I had the blessing and curse of growing up in the family restaurant, effectively rendering all fast food as a scam.</p><p>I did on occasion, get to visit the golden arches (after a lot of begging) as a treat — and on one fateful afternoon in 1999 a visit netted me my very own copy of a McDonalds PC Game. “Mission to McDONALDLAND” (Yes that’s how it’s spelled on the cover art.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*pW4EScBRT-Iv2kZeAckKUA.png" /></figure><p>If you would like to see this article formatted from a technical perspective with images and code blocks head on over to:</p><p><a href="https://asbedb.dev/musings/decompiling-a-mcnugget/#results">https://asbedb.dev/musings/decompiling-a-mcnugget/</a></p><h3>Mission to McDONALDLAND</h3><p>Released in 1999 as a promotional game in Australia and New Zealand, “Mission to McDONALDLAND” is a point-and-click computer game released for Windows 3.1 and Windows 95. In the game, Ronald McDonald helps an alien named Astor whose spaceship crashes and shatters into pieces after hitting a space dinosaur.</p><p>The project as I came to learn was made with Macromedia Shockwave. Playing this game today on a modern PC would require either a virtual machine emulating hardware of yonder or some sort of modern way to “play old games” — like using an emulator.</p><p>I had for a long time wanted to start looking into some basic techniques around what it would take to reverse engineer parts of a game and modify/recreate its logic. So I opted to go down a harder path of “recreating the game with original assets for the modern web” — <em>please don’t ask why.</em></p><p><a href="https://www.youtube.com/watch?v=8pFpgC2AB80">If you want to see the full game in action you can check out this YouTube video.</a></p><h3>Who made this game?</h3><p>The development story and people involved were largely abstracted away, but through a little research (and some artefacts we’ll get to later), I was able to ascertain at least two organisations involved in putting it all together.</p><p>Quoin Technologies and Hardlight Interactive — both companies have since been deregistered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xyLEV1wEkh930NFhMSpjWQ.png" /></figure><p><a href="https://web.archive.org/web/20090919180033/http://www.hardlight.com.au///page?pg=22&amp;stypen=html">I did manage to actually find Hardlight Interactive’s website using the wayback machine!</a></p><p><em>I also found some developer names in the raw decompiled files (Windows File System remnants with folder paths). I won’t publish those for obvious reasons.</em></p><h3>Files and Folders</h3><p>After acquiring the ISO through a preservation project I first looked into the file structure inside the disc. There were some familiar relics: setup.exe, AUTORUN.INF, and an executable called McLand.exe.</p><p>There were three other file extensions to review. The most common file in the main directory of the ISO had the .dxr extension.</p><p>DXR Files are protected, non-editable and uncompressed interactive multimedia files. If any of my readers are old enough you might remember the Shockwave Player and Macromedia (the company which started Flash and was later acquired by Adobe). These files were created in a tool called Macromedia Director.</p><p>The second file type was in a folder called Xtras and had the .X32 extension.</p><p>My research suggested this was part of the Macromedia Director suite. The files in this folder are essentially plugins that are meant to load at runtime to add functionality to a Macromedia Director project.</p><p>Finally there was a .ini file, a file type still common to describe configuration of software.</p><h3>File Content</h3><h3>McLand.ini</h3><p>I started with the lowest hanging fruit. McLand.ini; this is the config file - within it I was able to validate the project was made with Macromedia Director (6 to be precise). As the original settings instructions were left in, it was easy to decipher and establish a few key points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*1w2_hbiS7EaZh6HDKO4prw.png" /></figure><ol><li>The file name would be &lt;ProjectorName&gt;.ini this means that the projector for this project is McLand.</li><li>This file is only distributed if the defaults are changed — therefore there was some modification to make the project work.</li><li>All of settings are originally commented out in this file so there was an effort to remove the ; character denoting a comment.</li></ol><p>And here are those settings which have been commented out (in order):</p><pre>[Graphics]<br>Wing = 1<br>; 1: Use WinG graphics accelerator software. This requires<br>;    certain system files to be installed. Projector size and memory<br>;    usage may increase. See the documentation for details.<br> <br>[Palette]<br>Animation=1<br>; 1: allows director to take control of the palette for fast palette effects and transitions.<br> <br>[Sound]<br>; There&#39;s a fair bit here to list but TLDR - Sound Card Specific + default settings for changing the quality.</pre><p>My first take (or learning) — getting sound right in the 90’s (even using something like Shockwave) was very involved. Makes you appreciate how far we have come being able to simply wire up things like playing sound in the browser today.</p><h3>DXR Files</h3><p>A while back I did do the picoCTF challenge in PowerShell (<a href="https://asbedb.dev/musings/disko-1/">see write up here</a>) so I naturally gravitated towards trying to get string content in the files as a starting point.</p><p>I took LANDING.dxr as a candidate and ran the below command.</p><pre>Get-Content -Path &quot;LANDING.dxr&quot; | Select-String -Pattern &#39;[\x20-\x7E]{4,}&#39; | ForEach-Object { $_.Matches.Value</pre><p>and the results looked a little something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CkjYKqfu7c5XuARglLnLqA.png" /></figure><p>Notice anything? <em>cough</em> read it backwards <em>cough</em> — Apparently when a director file is saved on a “little-endian” intel processor (like Windows Machines), these chunk names and data types are written backwards.</p><p>So values like eerf represent free as in a free space chunk.</p><p>Some more examples below:</p><ul><li>dns/snd Sound Data</li><li>knuj/junk Filler/Junk data chunk</li><li>muht/thum Thumbnail preview image</li></ul><p><a href="https://nosamu.medium.com/a-tour-of-the-adobe-director-file-format-e375d1e063c0">I came across a great write up from nosamu and their conversation with Anthony Kleine (AKA Tomysshadow) talking about the Adobe Director File Format.</a></p><p>I highly recommend reading it if you want to deep dive further into how director files are compiled — I also didn’t realise that both Anthony Kleine and nosamu would again be featured later on in my workflow (watch this space!)</p><p>Continuing through the string content there was indeed some legible text as well!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*7pY3hVltxyoJ2b3IacX8aQ.png" /></figure><p>Through this chunk of text (specifically on this LANDING.dxr file) there are hints to a FONTMAP.txt file used to support fonts cross platform, I also found some <a href="https://en.wikipedia.org/wiki/Lingo&lt;em&gt;(programming&lt;/em&gt;language)">Lingo Script</a> which looks a little like this (in chunks):</p><pre>LsCM:<br>Internal<br>RtSAC<br>  go frame 105 of movie &quot;MCDON&quot;<br>tSAC^<br>on mouseUp<br>  go to (the frame +1)<br>on exitFrame<br>  if soundBusy(1) then go the frame<br>  else go to (the frame +1)<br>end if<br>on getBehaviorDescription<br>return<br>// more code</pre><p>Neat! There’s actually some programming logic without needing a full-blown decompiler!</p><p>Maybe I can write a bash script that can sift through and make a copy of these files as a starting point only taking the logic chunks.</p><p>As an experiment I wanted to check if a few more files followed this logic with a starting chunk of LsCM so I put together a bash proof of concept:</p><pre>strings -n 3 LANDING.dxr | \<br>awk &#39;/LsCM/{found=1} found&#39; | \<br>grep -E &#39;^\s*(-- [A-Za-z0-9]|on [a-zA-Z]|go |if |else|end|return|puppet|play |set |put )&#39; | \<br>grep -v -E &#39;(--[A-Z]{2}|[\%\&amp;\*\,\=\/]{2,})&#39;</pre><ol><li>Strings with a min length of 3 to get rid of a lot of chunks</li><li>awk returns every line from the first line containing LsCM to the end of the file.</li><li>Finally the two grep commands look for patterns aligned to lingo script operators and retain indentation where applicable.</li></ol><p>And would you believe it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wNjt6HL4lrazvhGa5tT57w.png" /></figure><p>That actually looks like code — fine tuning it further into a shell script I made it look into all .dxr files creating a .txt version making it easier for me to plan my next steps.</p><pre>#!/usr/bin/env bash<br>#<br># extract_dxr.sh<br># Scans the current directory for .dxr files and extracts plausible<br># Lingo script text from each into ./decompiled/&lt;name&gt;.txt<br>set -uo pipefail<br>OUTDIR=&quot;decompiled&quot;<br>mkdir -p &quot;$OUTDIR&quot;<br># Count how many .dxr files we find (nullglob avoids errors if none exist)<br>shopt -s nullglob<br>dxr_files=( *.dxr *.DXR )<br>shopt -u nullglob<br>if [ ${#dxr_files[@]} -eq 0 ]; then<br>    echo &quot;No .dxr files found in the current directory.&quot;<br>    exit 0<br>fi<br>echo &quot;Found ${#dxr_files[@]} .dxr file(s). Extracting to &#39;${OUTDIR}/&#39;...&quot;<br>echo<br>for f in &quot;${dxr_files[@]}&quot;; do<br>    # Skip if somehow not a regular file<br>    [ -f &quot;$f&quot; ] || continue<br>    base=&quot;$(basename &quot;$f&quot;)&quot;<br>    name=&quot;${base%.*}&quot;<br>    outfile=&quot;${OUTDIR}/${name}.txt&quot;<br>    echo &quot;Processing: $f -&gt; $outfile&quot;<br>    strings -n 3 &quot;$f&quot; | \<br>        awk &#39;/LsCM/{found=1} found&#39; | \<br>        grep -E &#39;^\s*(-- [A-Za-z0-9]|on [a-zA-Z]|go |if |else|end|return|puppet|play |set |put )&#39; | \<br>        grep -v -E &#39;(--[A-Z]{2}|[%&amp;*,=/]{2,})&#39; \<br>        &gt; &quot;$outfile&quot;<br>    # Report if nothing came out (empty result), since grep chains can silently produce nothing<br>    if [ ! -s &quot;$outfile&quot; ]; then<br>        echo &quot;  (warning: no matching lines extracted -- output file is empty)&quot;<br>    fi<br>done<br>echo<br>echo &quot;Done. Extracted files are in &#39;${OUTDIR}/&#39;.&quot;</pre><p>I am convinced the second thing running the world after Excel is shell scripts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*5ju4jaUiV__m0ExJkPV9YA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*VsvRkkUNvEKdUir8LG5O5g.png" /></figure><p>So there’s some programming logic extracted — (not that it’s of any use at this stage). But I have some legible text for additional analysis. For example in MCMARS.dxr I found some code that suggests that I can roll some dice and if it lands on 6 an animation called &quot;hiphop&quot; is triggered.</p><p>I could continue down the path of manually reviewing each line and mapping chunks however I have 48 hours and the efforts are purely for fun — so I decided to look into tools to help speed the process along.</p><h3>ProjectorRays</h3><p>I’m not the first person to try and decompile a shockwave game nor will I be the last, so when I saw there was already an open source project called <a href="https://github.com/ProjectorRays/ProjectorRays">ProjectorRays</a> maintained by some awesome 90s loving software enthusiasts. I thought it would be a good start.</p><p>When I first read the Windows instructions I was honestly confused. Apparently you just drag the folder housing all your .DXR files <strong>onto the</strong> .exe and it should work!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*yV5ODqEohYXeDiCSk_Ry-g.png" /></figure><p>It did! I’m not sure what to do with them just yet <em>but I’ll pop them in a folder for now.</em></p><h3>Director Cast Ripper</h3><p>We now need some glorious assets — remember nosamu from earlier? <a href="https://github.com/n0samu/DirectorCastRipper">Turns out they have an awesome tool/repository</a> that is built <strong>with</strong> Director made to rip cast files from DIRs. Basically all the assets for our game!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*_Tg_Tb5aTY-tM57zuPJkGg.png" /></figure><p>Thanks nosamu! I now actually have sound, art assets and some lingo script!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*pj10H2szleU4DrnoIJxmTA.png" /></figure><h3>Make Me McDonalds — Make No Mistakes</h3><p>At this point I’m starting to get curious if the building blocks are enough for an agentic workflow. I am not too fussed at how this thing turns out — just curious. I believe I have covered most of the major building blocks for a remake of this classic all that’s left is to put some thought into a CLAUDE.md.</p><p><strong>Model Used:</strong> Sonnet 4.5 <strong>Plan:</strong> Standard $30 Monthly Pro Plan <strong>Token Usage:</strong> Comfortably within daily limit ~60% daily usage.</p><p>The design I settled on.</p><ol><li>This is a behavioural port, not looking to emulate Shockwave — I am implementing a clean, modern, statically-typed interpretation to run in a browser.</li><li>Decompilation and extraction has been completed and checked into a folder called /source/ broken out into subfolders based on category (dir, exports and lingo ) these are from the previous manual steps to get some information on the structure and assets used in the project - the tools/methodology used to gather this data is specifically mentioned in design and instructions.</li><li>An established principle of dealing with the port is for the agent to create a domain glossary mapping a Director/Lingo concept to a Web/TS Equivalent. For each Movie/Cast object the agent should write documentation under lingo-notes and score-notes as a markdown file creating a proof point of what the original scenes intent was prior to trying to port the behaviours to TypeScript.</li></ol><p>And the guiding principles.</p><ol><li><strong>Read before you port.</strong> Never hand-translate Lingo to TypeScript line-by-line.</li><li><strong>Preserve behaviour, not syntax.</strong> repeat with i = 1 to 10 becomes an idiomatic for loop, not a manual Lingo-shaped loop construct.</li><li><strong>One source of truth per asset.</strong> Never copy or rename a file out of /source/exports/ into /src/ and map it through a manifest so asset lineage back to the original cast member stays traceable.</li><li><strong>No silent format guessing.</strong> If a cast member’s export under /source/exports/ is missing, corrupted, or looks wrong (proprietary compression artifacts, unsupported ink effect, exotic Xtra with no exported equivalent), stop and flag it in /docs/score-notes/ rather than approximating silently. List unresolved members and issues in a running KNOWN_GAPS.md at repo root.</li><li><strong>Keep the engine generic, keep movies specific.</strong> Anything reusable across movies (rendering, asset loading, event dispatch, timeline stepping) belongs in src/engine/. Movie-specific logic belongs in src/movies/&lt;movie-name&gt;/.</li><li><strong>Strict TypeScript.</strong> strict: true, no any for ported Lingo values — define proper union/interface types for cast member data and sprite state.</li><li><strong>Deterministic frame stepping.</strong> The engine should support both real-time playback and a fixed-step “advance one frame” mode, since the latter is essential for diffing against the original movie frame-by-frame.</li></ol><h3>Did it make no mistakes?</h3><p>My interactions with the agent were kept fairly minimal — After initial review a determination was made to start with a simple scene — “MCThrow”.</p><p>In this scene the main character throws hamburgers at Grimace whilst they are bouncing on a trampoline. The scene starts paused with the voice over explaining the game and then proceeds to the main game loop of throwing burgers at Grimace — there is some sort of an “arch” to the throw as you send burgers flying. For every burger that lands on Grimace — he chomps and you get a point.</p><h3>The Good</h3><p>Remembering our workflow from earlier — particularly the design decision to make a “domain glossary”. The notes produced stemming from this decision gave me insight into the conversion process which might have otherwise been lost.</p><p>I picked up how much value this could provide in reviewing any generated content. It also served as a way to quickly refine certain elements using the “port language” reducing the requirement of sifting through the codebase and readjusting context.</p><p>A basic tree output of the MCThrow scenes lingo notes shows how many cast objects went into producing the final product.</p><pre>└───MCthrow<br>1.md<br>10audioobject.md<br>11_bt.md<br>13btnnorm.md<br>14btnanim.md<br>15_AstorObj.md<br>16_SuitObj.md<br>17_nuker.md<br>18_ObjectUtils.md<br>19StubObject.md<br>2.md<br>20Old_mouse_Rolloverstuff.md<br>21_JumperObj.md<br>22_thrower.md<br>23Screen1Functions.md<br>24Screen2Functions.md<br>28soundIntro.md<br>30_LockTo.md<br>35.md<br>3_Utilities.md<br>4_chanhand.md<br>5_ObjectHandlers.md<br>79_AN.md<br>8Graphicobject.md<br>9_AnimatedCast.md</pre><p>Picking at random the lingo notes for the 28<em>sound</em>intro object this is what one of these markdown files looks like:</p><pre># Cast member 28 — &quot;sound Intro&quot; (script)<br> <br>Source: `source/exports/MCthrow/28sound Intro.ls`. `PlaySnd(castmem)`: plays a sound on channel 2 and busy-waits (`repeat while soundBusy(2)`) until it finishes. Used by `1.ls` for the movie-open sting and by `24Screen2 Functions.ls`&#39;s `ReturnToWorld` for the outro. Port as a small `await`-style helper (`await playSound(...)`) in the audio engine module rather than a literal busy-wait loop.</pre><p>Each “scene” (by the same design principle) has its own score-notes/&lt;SCENE_NAME&gt;.md file - this file serves as a summary of what the Scene is meant to do, its status and, the approach taken to reconstruct to the original concept.</p><p>An interesting behaviour was picked up from the “Guiding Principles” for the agent which also made its way into each scene’s score notes in the form of a scene specific “Known gaps” section. The directive I believe spurred this on is below.</p><blockquote>List unresolved members and issues in a running KNOWN_GAPS.md at repo root.</blockquote><p>For example the McTHROW scene had the below appended to the end of its score notes.</p><pre>## Known gaps for this movie<br> <br>- No score/frame timeline — see root `KNOWN_GAPS.md`.<br>- Cast member &quot;backflip&quot; (referenced in `112.ls`) missing from `Members.csv` — see root `KNOWN_GAPS.md`.<br>- `CODE` shared cast not yet inventoried — flag if a needed behavior can&#39;t be found in the Internal cast during implementation.</pre><h3>The cool, but maybe not so good?</h3><p>Well — It did what I asked, but was it worth it?</p><p>I think for this project and its general unimportant “toy nature” — it was fun. But if I were to seriously consider recreating this to be a modern type safe behavioural port — I would not have approached it in the same way, there is an argument to say I could have refined and spent more time on the prompts, structure of the rip, skills, tests etc. But that wasn’t really the point here — If you watch a video of the game being played, you could probably whip up an MVP by hand in an hour or so.</p><p>What it did do, that I found cool at least — is it faithfully recreated a behavioural port and it also respected the rule of using the original assets and mapping a manifest accordingly.</p><p>Let’s have a look at the src/ for the recreation:</p><pre>├───engine<br>│ │ assets.ts<br>│ │ GameLoop.ts<br>│ │ SoundManager.ts<br>│ │ Sprite.ts<br>│ │ Stage.ts<br>│ │<br>│ └───**tests**<br>│ fakes.ts<br>│<br>└───movies<br>└───MCthrow<br>│ assets-manifest.ts<br>│ Jumper.ts<br>│ main.ts<br>│ MCthrow.ts<br>│ Screen1.ts<br>│ Thrower.ts<br>│<br>└───**tests**<br>Jumper.test.ts<br>Thrower.test.ts</pre><p>I found the recreation of behaviours unique to the Director/Shockwave ecosystem in typescript to be “fun” but also redundant if you were to just use the features/hacky ways to provide the same feeling.</p><p>As an example a fully implemented sound manager SoundManager.ts that could have probably just been reserved for the Browsers in build sound APIs.</p><pre>/**<br> * What movie/behavior code actually needs from sound playback -- extracted<br> * so tests can supply a lightweight fake instead of a real `SoundManager`<br> * (which needs a real `AudioContext`). Movie classes should depend on thi<br> * interface, not the concrete `SoundManager`.<br> */<br> <br>export interface SoundPlayer {<br>    play(channel: number, buffer: AudioBuffer, onEnded?: () =&gt; void): void<br>    stop(channel: number): void<br>    isBusy(channel: number): boolean<br>}<br>/**<br> * Lingo: numbered sound channels (`puppetSound(channel, member)`,<br> * `soundBusy(channel)`, `puppetSound(channel, 0)` to stop). Only one clip<br> * plays per channel at a time; starting a new one on the same channel cuts<br> * off whatever was already playing there.<br> */<br>export class SoundManager implements SoundPlayer {<br>    private sources = new Map&lt;number, AudioBufferSourceNode&gt;()<br>    constructor(<br>        private audioContext: AudioContext<br>    ) {} /** Lingo: `puppetSound(channel, buffer)` */<br>    play(channel: number, buffer: AudioBuffer, onEnded?: () =&gt; void): void {<br>        this.stop(channel)<br>        const source = this.audioContext.createBufferSource()<br>        source.buffer = buffer<br>        source.connect(this.audioContext.destination)<br>        source.onended = () =&gt; {<br>            if (this.sources.get(channel) === source)<br>                this.sources.delete(channel)<br>            onEnded?.()<br>        }<br>        source.start()<br>        this.sources.set(channel, source)<br>    } /** Lingo: `puppetSound(channel, 0)` */<br>    stop(channel: number): void {<br>        const existing = this.sources.get(channel)<br>        if (existing) {<br>            existing.onended = null<br>            existing.stop()<br>            this.sources.delete(channel)<br>        }<br>    } /** Lingo: `soundBusy(channel)` */<br>    isBusy(channel: number): boolean {<br>        return this.sources.has(channel)<br>    }<br>}</pre><p>This was probably my biggest “not so good” takeaway — I still think it’s fun and “cool”.</p><h3>Results</h3><p>By the end of this process I managed to put together three “scenes” — the one which ended up being the most accurate to the original would be “McThrow”, coincidentally the one which had more refinement and manual intervention. The other two scenes were the hub and “McMars” both of which are nowhere near what the original looks like.</p><p>I suspect that’s just due to more ground work being required in the decompile steps alongside additional manual interventions and refinement.</p><p>Anywho, enjoy some videos and snippets below linked on my blog here -&gt; <a href="https://asbedb.dev/musings/decompiling-a-mcnugget/#results">https://asbedb.dev/musings/decompiling-a-mcnugget/#results</a></p><h3>Final Thoughts</h3><p>I took away some good learnings around agentic workflows doing something trivial and unnecessary to most people.</p><p>More importantly I got to relive being a green alien in 1999 chomping on a McNugget as an annual treat.</p><p>I don’t know which lesson is more valuable here — all I know is I had fun doing it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6bec5360cac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[So I made my own Wordle based on RuneScape]]></title>
            <link>https://medium.com/@asbedb/so-i-made-my-own-wordle-based-on-runescape-ae5d5accda9c?source=rss-4c65e73441ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae5d5accda9c</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Asbed B]]></dc:creator>
            <pubDate>Wed, 22 Apr 2026 14:19:32 GMT</pubDate>
            <atom:updated>2026-04-22T14:19:32.784Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OLUGd5oyjVJboVNoDK3Lww.png" /></figure><p>When my friends asked how easy it would be to make a version of Wordle based on characters, items and quests from the popular game <a href="https://oldschool.runescape.com/">RuneScape</a>. My initial answer was “It should be easy!”, I didn’t expect the architecture decisions, algorithm optimisation, and insight into trade-offs it would provide. Whilst it was a shorter fun little project, there are a few pearls worth sharing in case you too want to make your own Wordle.</p><p>If you already know what RuneScape and Wordle is and you want to get straight into it — head on down to the Scapedle title</p><p>If you want to play the game you can check it out at <a href="https://scapedle.com/">Scapedle.com</a></p><p>This project is open to contributions and has been released fully open source under a GPL 2.0 license — <a href="https://github.com/asbedb/Scapedle">you can find the repository and contributing guide here</a>.</p><p>For the write up directly on my blog see below!<br><a href="https://asbedb.dev/musings/scapedle-game/">https://asbedb.dev/musings/scapedle-game/</a></p><h3>What is Wordle</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NiA0X6ALv_HC0XdqUDhX_A.png" /></figure><p>Wordle is a guessing game in which you have to guess a five letter word in five guesses, each guess will provide you hints by displaying letters in three colours/shades.</p><ol><li>Darker grey when they aren’t present in the word</li><li>Orange if they are present in the word but not in the correct spot</li><li>Green if they are present and in the correct spot</li></ol><h3>What is RuneScape</h3><p>Released in 2001 RuneScape is a fantasy massively multiplayer online (MMO) game with a unique art style, point and click controls and a large (still growing) player base. When I began to look into the number of items in the game it was estimated to be close to 17,000 (that’s a lot of words!)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*AR-TmAyVvC4MN1IWjJuKhg.png" /></figure><h3>Scapedle</h3><p>So now we mush Wordle and RuneScape’s characters, quests and items together and you have a word guessing game called <a href="https://scapedle.com/">Scapedle</a>! There are a few minor differences to note.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*flseIjTS7_36irJY0yLsRQ.png" /></figure><ul><li>Scapedle doesn’t have a five letter restriction, there are even multiple words to guess, due to this added difficulty ceiling there is an emoji hint to assist users.</li><li>Some words are unique to the world of RuneScape so having prior knowledge of the game is also essential.</li><li>Finally in addition to the emoji hints a user can “give up” one guess for an extra hint in the form of text.</li></ul><h3>The Architecture</h3><p>At a high level a typical game of Wordle is comprised of the following functions and features.</p><ol><li><strong>Word of the day</strong> — a word is chosen after a nominated time period, these words seem to have a method around being chosen as they generally have a unique word number when being shared as solved.</li><li><strong>Dictionary</strong> — when users guess words there is a dictionary lookup ensuring the word being guessed is in the English language.</li><li><strong>Stateful</strong> — a game of Wordle can be played all day, a user can walk away and close the app/website and come back to play it.</li><li><strong>Mobile Friendly</strong> — generally Wordle users are playing on a mobile device, it’s a fun little time passer and gets on average ~5–10 minutes screentime per day. The UI should be intuitive and touch friendly.</li></ol><p>The architecture and design phase actually came to be the most surprising and fulfilling part of this project. I wanted to “think like the team behind Wordle”, a team that supports an estimated 10–14.5 million active players per day. This meant making choices that allowed for scale, flexibility, automation, integrity (anti-cheat) and accuracy. In hindsight I am extremely happy I approached it this way as choices were easier to make when you are constrained.</p><h3>SvelteKit</h3><p>After careful consideration and pre-empting the work required for processes like “generating a daily word” and “managing user and game state”. I settled on <a href="https://svelte.dev/">SvelteKit</a>.</p><p>I wanted a framework that could fill the role of both client and server side logic, but also stay within the realms of reasonable performance for a simple single page application. My experience with frameworks like NextJS left me with an impression that choosing it would be “overkill” for this project. The routing and SSR features whilst great for larger, more complex applications, would bring with it a performance hit for a simple word guessing game.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*4x562fvqLzoG61my47yfpw.png" /></figure><p>Svelte was a great choice for this particular project and here’s why:</p><ul><li><strong>Global State management for Game and Player</strong> — I can just use runes to manage things across multiple components without having to worry about prop drilling</li><li><strong>Simple HTML</strong> — I just wanted the UI to work Svelte has a similar feel to Astro where it leans into the HTML feeling like HTML!</li><li><strong>Dynamic file-based routing</strong> — The routes of the API are defined by the file structures in codebase making it easier to manage functions.</li><li><strong>On build server functions</strong> — Every rebuild of the static site required an automation of word processing to happen, Svelte type safe load functions provide a neat interface to manage this.</li></ul><h3>Theming and Design</h3><p>I also needed to ensure theming and design was on brand to invoke that nostalgic RuneScape feeling, I found the <a href="https://osrs.design/">OSRS Design System by milkbar designs</a> as a great reference point helping keep colours, fonts and components consistent across my project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wdu9KdQFPu_TCXhIz96lXg.png" /></figure><p>Using tailwind 4 theme syntax, declarations means that the color property will be available across text, backgrounds and more. (see snippet below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Bxs6VNEFesQiPkNWpCsHw.png" /></figure><h3>Scaling</h3><p>There are two ways to check a users input against the correct answer. We either ship the answer in the client and test against it or we host the answer on a server and use some sort of middleware to check if the encrypted guess matches the encrypted answer. Shipping it with the client comes at the cost of making it way easier to cheat, and hosting it with a server comes at the cost of added infrastructure, complexity and management.</p><p>I decided to keep the word of the day a client side feature and focussed on making it harder to cheat (It’s impossible to stop cheating client side).</p><p>This decision also means that theoretically the load of 14.5 million active users playing has significantly reduced as the majority of compute is client side. Sure bandwidth is a concern but the over the wire requirements are not as taxing as 14.5 million API requests to a back end.</p><h3>Wordlist</h3><p>Originally the wordlist was built with some help from those beautiful guessing machines we have come to love. The file houses an array of objects and within each object we have a itemName, emojiHint and wordHint. I am currently in the process of refining this list and pushing updates per skill.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZCVVWDRBO6LmN9bpy5GzNA.png" /></figure><p>Nothing particularly groundbreaking here, just a simple structure to help house all of our words!</p><h3>Routing</h3><p>The fun part of choosing a word comes from utilising Svelte file based routing system to dynamically load words from this list on every re-build (more to come in automation).</p><p>Within the src folder which houses all of the logic that builds up the application, by nominating a routes folder you effectively tell Svelte to build pages based on folders and files.</p><p>As an example, If there was a folder called src/routes/lumbridge and within that there’s a file called +page.svelte. After building the website a user navigating to scapedle.com/lumbridge (not a real link), would be greeted with the content in that route. In addition to this a route can also have a +page.server.js or +page.server.ts this is telling Svelte router that the load function for this particularly page can only run on the server and not the client.</p><p>I am only shipping the daily word, hint and emojis to the client — I do not want the entire wordlist. The idea was to house the wordlist in a dedicated src/server (this route is a dedicated back end/build route) folder which tells Svelte to never include that in the client and access it through a server load function in +page.server.ts!</p><h3>Daily Word</h3><p>I needed a consistent way to seed the word, it needed to be random, within the constraints of the wordlist and seeded in a way that ties back to the date — the daily word number should correlate and be seeded with the date.</p><p>The wordlist itself has some sequential structure based on RuneScape’s skills so going in order would mean a user would experience a theme of words grouped together if we went through the list in order.</p><p>Unlike a Math.random() function in which every generated result would be unpredictable. I needed a helper that could take a seed and return consistent results. I came to realise these are called “Pseudo Random Number Generators” (PRNG).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q4wULNidAeKuBDSxFeWY1w.png" /></figure><p>The helper above is called a <a href="https://github.com/cprosche/mulberry32">Mulberry32</a>, the linked Stack Overflow article in the GitHub repository has many more examples of PRNGs to consider. I decided to go with Mulberry32 due to its speed since the PRNG was required once per build. With that I used the date of build as a seed to get consistent results!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oPH5XeJZrORPjNiRJiCaSA.png" /></figure><p><strong>Notes:</strong></p><ul><li>All words are stripped of special characters like -, &#39;, + and ( and converted to upper case to ensure any inconsistent names in the wordlist are able to be guessed fairly.</li><li>The return statement is cut off on purpose; you can find full code on GitHub below is for illustrative purposes only.</li><li>Australian time zone is hardcoded to AEST (Australia/Sydney) to ensure consistent daily word rotation aligned with my local schedule.</li></ul><h3>Anti-cheat</h3><p>In game development, the more you serve via the client, the more you relinquish control over anti-cheat opening an application up to memory manipulation and cheating. I guess it’s not that different in web — looking at functions such as secure authentication and encryption, these rely on appropriate methods in middleware and back end.</p><p>So you decided to ship the answer for your game with the game client, what next?</p><p>Well we need to make it harder for Hackerman to find the answer! Not impossible, just harder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FKTMgZJpKZVydt0QIy1NUQ.png" /></figure><p>I’ll be honest, beyond simple encoding, if someone is willing to make the effort to cheat and decode the word, <em>that’s fine</em>. Funnily enough for a long time Wordle also did the same thing and worked on an honour policy. These days I’m not too sure, essentially the simple things to do here is to ensure the returned objects key isn’t too obvious in suggesting the answer lies there and to wrap the word itself in a btoa() method which encodes the answer as a <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa">Base64 ASCII string from a Binary string. </a>. This provides basic obfuscation but isn’t true encryption—anyone inspecting the code can decode it trivially.</p><h3>Dictionary</h3><p>The leetcode grind actually came in useful for this feature. I needed to create a dictionary of words which were derived from the initial wordlist, this included words which were specific to RuneScape, you wouldn’t find Guthix or Saradomin in the English lexicon.</p><p>I committed to client side which meant no fancy third party services or APIs deciding to instantiate a dynamic dictionary during build time which shipped with the client. The initial build is O(n) as we would iterate through every word in our wordlist, the lookups are O(1) on average as we are effectively building a HashMap that takes into account the length of a word and the word itself!</p><p>Here’s the dictionary code in action! I was also able to integrate a nice little UI feature that showed how many guessable words are available by tracking the word count when building the dictionary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OOUQWyMbpQv2SFGwm804RA.png" /></figure><h3>Svelte Runes</h3><p>After the server pushed to the client the following items:</p><ul><li>Encoded word of the day</li><li>Emoji hint</li><li>Word hint</li><li>Word number</li><li>Dictionary</li><li>Word count (to render on the UI number of words available to guess)</li></ul><p>The functional logic of the game needed to be mapped. Inadvertently Svelte has this concept of Runes (what a coincidence!).</p><p><strong><em>What are runes?</em></strong></p><blockquote><em>Runes are symbols that you use in </em><em>.svelte and </em><em>.svelte.js / </em><em>.svelte.ts files to control the Svelte compiler. If you think of Svelte as a language, runes are part of the syntax — they are </em>keywords<em>.</em></blockquote><p><a href="https://svelte.dev/docs/svelte/what-are-runes"><em>Source</em></a></p><p>Svelte provides a few of these runes for consideration — if you are familiar with reactive web UI libraries some of the terminology will be familiar.</p><ul><li>$state - a rune which holds a variable data store which can be used to trigger re-renders, the UI reacts to this component as an example a state that holds a count could start at 0.</li><li>$derived- a rune which will conditionally update based on a $state rune within your component, as an example a component may always be $state + 2 so we can derive it accordingly.</li><li>$effect - A function which runs when a $state updates.</li><li>$props - Inputs to a component including it’s children</li></ul><p>There’s a lot of additional nuance but at a high level these are the main runes to consider.</p><h3>Global State</h3><p><strong><em>Disclaimer: The next section outlines a file placed in stores folder — this should not be confused with Svelte global stores prior to Svelte 5 — I only realised the naming convention may cause confusion after the fact and will refactor to remove doubts in future.</em></strong></p><p>In a svelte project the lib folder within your src, is a unique path.</p><blockquote><em>lib contains your library code (utilities and components), which can be imported via the </em><a href="https://svelte.dev/docs/kit/$lib"><em>$lib</em></a><em> alias, or packaged up for distribution using </em><a href="https://svelte.dev/docs/kit/packaging"><em>svelte-package</em></a></blockquote><p>Within this folder there are a few additional paths that are unique like server, outside of this you are free to manage and build out your structure in an easy to read and manageable format.</p><p>For the game state this looked a little something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vu6-ml0sDYGz9w3iwymJFQ.png" /></figure><p>The above in summary works on:</p><ul><li>Setting up types for ExternalData and GameStateType</li><li>Instantiating a rawData object to manipulate.</li><li>Exporting functions to get our solution and gameData values</li><li>Exporting our gameState object</li><li>Exporting an initialisation function initStore that checks if a new word has been loaded prior to resetting the game state.</li></ul><p>With the state loaded in our lib this allowed me to call the same consistent state no matter how deeply nested my folders were - this is crucial as I needed to track.</p><ul><li>Guesses</li><li>Prompt usage</li><li>Letters in word/out of word already guessed</li><li>The word of the day, emojis and the dictionary</li></ul><p>You can view the component code in more detail on the GitHub however here is a small example of how this came to be used in the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fi-ICPnvtoaL2-y9g5oZqA.png" /></figure><p>In the script tag we import the gameData and gameState - note the path points to $lib, this means no drilling and mental math is required and the state is persistent across our shared components and page.</p><p>This also means pushing up changes across multiple components becomes much easier.</p><h3>GitHub Pages + Daily Runner</h3><p>The last piece to the puzzle was automating the publishing of the page with updates, whether it be a daily word or a new feature being merged. As the project is being managed through GitHub it made sense to stay within the ecosystem. The project is open source meaning other developers can contribute or fork the repository to build their own versions.</p><p>The way I solved this challenge was by hosting the main branch on <a href="https://pages.github.com/">GitHub Pages</a> with a workflow file that automates a rebuild every 24 hours and on successful merge of pull requests to the main branch.</p><h3>Managing the Game Loop</h3><p>As the game state is now an accessible rune across all components, managing that state is the main task at hand with various functions. I am going to provide a quick fire insight into this with links to the full code for the curious.</p><h3>Local Storage</h3><p>Early on I elected to utilise local storage as a means to track progress on the word of the day, a simple yet effective browser API that lets us manage an otherwise overly complicated feature if we wanted a persistent user state via a database.</p><p>The local storage holds the bare minimum required for a user to come back and check in/make extra guesses until the game is up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H31pmBpHwjqM44HeqsrTCA.png" /></figure><p>The cliff notes:</p><ul><li>On initial mount/render of site the client checks against local storage to see if a new word is being guessed data.wordNumber === gameData.wordNumber - if it’s new removeItem is invoked and the $effect will instantiate a blank object for the new word.</li><li>An effect runs when making a guess, using a hint or starting a game. The primary purpose of this effect is to update guesses in local storage.</li><li>Svelte has an advanced feature called <a href="https://svelte.dev/docs/kit/snapshots">snapshots</a> this allows us to de-proxy the state stored in local storage which can help remove issues around serialisation.</li></ul><h3>Starting the game</h3><p>The gameboard is initialised and the user is greeted with a “Start Quest” button, this was a strategic choice as “input jacking” with a hidden input is generally frowned upon with mobile browsers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*0mXBNlwp4C5cXsjjttll2w.png" /></figure><p>Both Scapedle and Wordle provide the user an option to use normal onscreen keyboards (or physical on pc) to input guesses. I wanted the same feeling on mobile. I resorted to using a start button that tells the browser to focus on this hidden input and in turn brings up the onscreen keyboard!</p><p>This in turn also helps with initialising our local storage (used to track progress on the daily word) by putting the game in a playing state.</p><h3>Making a Guess</h3><p>Once the user makes a guess using the onscreen keyboard or the presented letter blocks that guess is checked against the word of the day. Each guess is updated in our gameState.guesses array and those entries are used on the keyboard component to provide user feedback on if the letter has been exhausted in the word (green), present but not in correct place (orange) or not in word at all (darker shade on keyboard).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*fDC52LXguoRliYz0GrKccA.png" /></figure><p>There are a few techniques I used here that turned out to be really useful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-90SgfTl-Ucu3yDqxGHOyw.png" /></figure><ul><li>The word of the day is broken into parts (split by spaces) this in turn is used when making a guess to check a single string against the dictionary because we can split the guess into parts — that’s how the valid words are identified (we even slide a window here!).</li><li>All special characters have been stripped to make this logic easier to follow.</li><li>The currentGuess is tracked and that’s how we determine if the user even has an option to “attempt to guess”. If the currentGuess doesn’t match the full word length then we don’t even attempt to look at the dictionary.</li><li>A special global constant is used if the user elects to use a “hint” that will remove one guess completely and hold it in memory as such (this comes handy when sharing results).</li><li>Finally once all guesses are exhausted or the correct word is guessed the game ends with a screen showing the word of the day and a share option.</li><li>a triggerInvalidEffect() function is dedicated to give the user a little flashup of red text letting them know the word they have guessed is not currently in the dictionary of words available to guess.</li></ul><h3>Winning or Losing</h3><p>Winning or losing a game of Scapedle looks a little like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*shLI-YWZnC13d5p2-jWpNQ.png" /></figure><p>Naturally the global state tracking our games progress is utilised to match our guesses to the word of the day and effectively return a win/lose/still playing result.</p><p>This is actually a fairly simple if statement being run as an $effect</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TpuBmIkZg2wbhWsTNk3VcA.png" /></figure><p>by tracking our status - we can lock the gameboard, show modals or allow additional guesses making it very easy to manage the UI. The modal in the pictured screenshot renders conditionally when a user is no longer in a playing state, taking into account the win/loss position of the board. From there a share results option is presented - these are fun little emoji messages used to help spread the game and challenge friends!</p><p>Scapedles looks a little something like this.</p><p>Scapedle — An OSRS Guessing Game<br>Todays Word #111–3/5</p><p>🟨🟨⬛⬛🟨🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩<br>🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟨⬛<br>🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩</p><p>Play at: <a href="https://scapedle.com/">https://scapedle.com/</a></p><p>With the code looking like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ohywJKGoL2KB-b6tyM7yVQ.png" /></figure><p>Essentially a simple map of characters in each valid guess to represent its corresponding return in the original guess with a line break at the end of the word length.</p><h3>Wrap it up</h3><p>Building Scapedle taught me that “easy” projects often hide the most interesting challenges. What seemed like a simple Wordle clone turned into a whole lot more.</p><p>The best part? It’s all open source. Fork the <a href="https://github.com/asbedb/Scapedle">repository</a>, build your own variant, or just come play at <a href="https://scapedle.com/">Scapedle.com</a>.</p><p>Whether you’re here for RuneScape nostalgia or insights, I hope you found something useful in this breakdown. Now go guess that word — you’ve got this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae5d5accda9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[sRGB to HSV — Science or Magic?]]></title>
            <link>https://medium.com/@asbedb/srgb-to-hsv-science-or-magic-f154852a94fe?source=rss-4c65e73441ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/f154852a94fe</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Asbed B]]></dc:creator>
            <pubDate>Sat, 31 Jan 2026 05:44:32 GMT</pubDate>
            <atom:updated>2026-01-31T05:44:32.833Z</atom:updated>
            <content:encoded><![CDATA[<h3>sRGB to HSV — Science or Magic?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*iXA5ijT4XthgnLzjB7CehQ.png" /></figure><p>Recently, I was automating colour generation for a theme engine, which sparked a question</p><p><strong><em>“Why do I instinctively lean towards a HSV Colour picker when trying to pick a colour on my computer?”</em></strong></p><p>Investigating a little further into the “why” of how computers work, brings me immense joy. By the end of this piece, I hope to provide insight into what helped me understand colour space, colour transformations and what they can represent in digital form.</p><p>If you would like to see this article with supported code blocks and formatting alongside more articles check out my site below:</p><p><a href="https://asbedb.dev/musings/rgb-to-hsv/">sRGB to HSV - Science or Magic?</a></p><h3>The Brief</h3><p>From a programming standpoint, the problem I was looking to solve was fairly simple.</p><p>This is the high level summary:</p><ol><li>Take seed colours (Primary, Secondary, Tertiary, Neutral and Semantic).</li><li>Ensure the colour set has an isDark flag to help deal with contrast and shades for a “Dark Mode” colour scheme.</li><li>Generate shades of each colour and label 100,300,500,700,900 with 100 being the lightest and 900 being the darkest (if you use tailwindcss this might already be familiar to you).</li><li>Compile our colours into a list of variables to be imported at the parent level of a CSS file (example `-primary-100: #222222;).</li></ol><p>And my intuition immediately lead to:</p><ol><li>Obtain our seed colour hex codes.</li><li>Convert to a HSV value.</li><li>Have a set of standard transforms based on the colour scheme flag (isDark so we can apply the right contrast ratios).</li><li>Apply transforms and reconvert to hex with results ready to append.</li></ol><p>The reason for my intuition came from having played with HSV values (in a visual tool like a colour picker) in the past. I already knew they were the right choice for this exercise, I had just never looked into why.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*ZMJBBukfo6Z_DwwtOB8ocA.png" /><figcaption><em>Source: </em><a href="https://m2.material.io/design/color/the-color-system.html#tools-for-picking-colors"><em>Material Design: Tools for Picking Colour</em></a></figcaption></figure><p>But before I do that we need to cover some of the introductory content to this space. If you want to jump straight into the meat and bones feel free to skip ahead to <a href="https://asbedb.dev/musings/rgb-to-hsv/#the-rgb-colour-model">The RGB Colour Model</a>.</p><h3>Colour is Sensed and Perceived</h3><p>Colour is the translation of light sensed by the human eye and perceived by the brain.</p><p>Colour literature has roots dating as far back as 322 BCE (<a href="https://en.wikipedia.org/wiki/On_Colors">Aristotle’s — On Colours</a>). Many of the concepts and standards we will come to discuss are tied to Isaac Newton’s <a href="https://hti.osu.edu/sites/hti.osu.edu/files/Sir-Isaac-Newton_Letter-Theory-Light-Colors.pdf">extensive work on colour theory</a> stating that white light is composed of a spectrum of colours, and colour is not intrinsic to objects, but rather arises from the way an object reflects or absorbs different wavelength.</p><p>Newton also discovered that sunlight is composed of 7 primary colours which are visible when passed through a prism: Red, Orange, Yellow, Green, Blue, Indigo and Violet. (fun fact: Newton added Indigo to ensure the 7 colours were aligned to musical notes Do, Re, Mi, Fa, Sol, La, Ti)</p><p>An average healthy human eye can see around <strong>100 million different colours.</strong></p><p>This is due to the three cone cell types (photoreceptors) found in the retina which can process ~100 different colour shades, amounting to ~one million combinations.</p><p><em>Fun Fact:</em> The same biological factors can be observed in the animal kingdom, with the number of cone cells being varied. As an example some species of fish are considered to have <a href="https://en.wikipedia.org/wiki/Double_cone_(biology)">double cones</a> where as others might have <a href="https://en.wikipedia.org/wiki/Tetrachromacy">four cones</a>. The result of less or more cell types changes the way colours are perceived.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*GGAoXjXHv9QATMhVWOiWOg.png" /><figcaption><em>Source:</em> <a href="https://www.aao.org/image.axd?id=7de23d7d-7d22-4c72-81ed-292dc01cfbcf&amp;t=636422014777200000">American Academy of Ophthalmology</a></figcaption></figure><p>The human eye has light-detecting neurons in the retina (rods and cones) that convert light into electrical signals for vision. The rods handle dim light and black/white vision and the cones are responsible for colour and sharp daytime vision. The human eye can perceive more variations in warmer colours rather than cooler ones due to a higher mix of cones that process longer light wavelengths (reds). These cone cells are classed as L, M and S (Long, Medium and Short)</p><p>The estimated split of cone cells in a human eye are:</p><ul><li>60% Red Sensing <em>L</em> (these cones technically peak in the yellow-green part of the spectrum)</li><li>30% Green Sensing <em>M</em></li><li>10% Blue Sensing <em>S</em></li></ul><p>Variations in this make up means a different perception of colour with a deficiency being considered a root cause of <a href="https://en.wikipedia.org/wiki/Color_blindness">colour blindness</a>.</p><p>In summary the process looks like this:</p><ol><li>Light hits photopigments in the photoreceptors outer segment</li><li>The absorption starts a biochemical chain reaction (transduction)</li><li>This changes the cell’s membrane potential and creates an electrical signal</li><li>The signal is passed along through cells to the optic nerve and then brain</li></ol><p>With this some of the biology out of the way lets dive a little more into computers and colour. Because our perception is so tied to these biological quirks — like our heightened sensitivity to green and red — computer programmers needed a way to translate the ‘sensing’ into reproducible data. This is where standards come in.</p><h3>Standards, Standards, Standards</h3><p>In doing my research an article I discovered had three poignant quotes that are worth repeating (as I am a fledging in this space and can see the depths to which this topic can lead).</p><blockquote><em>CIE colorimetry isn’t even half the story of colour science, it’s a tiny piece of the huge puzzle of human perception and engineering that is colour science. Don’t confuse understanding it with understanding colour perception.</em></blockquote><blockquote><em>Colorimetry is essentially linear algebra, human perception is much more complex. CIE colorimetry isn’t the whole story of colorimetry. It’s the modern standard but the theoretical work was done by James Maxwell in the 1850s.</em></blockquote><blockquote><em>Differentiating theoretical colorimetry from the CIE’s implementation of it will be a milestone in your understanding. I recommend : </em><a href="https://mitpress.mit.edu/books/color-science"><em>Jan Koenderink’s Color For the Sciences</em></a></blockquote><p><em>Source</em>: <a href="https://medium.com/hipster-color-science/a-beginners-guide-to-colorimetry-401f1830b65a">A Beginner’s Guide to (CIE) Colorimetry</a></p><p>The CIE (Commission internationale de l’éclairage) an over 100 year old organisation is the peak body providing a forum, developing international uniform standards and cooperating with interwoven fields related to the following categories (within the context of light and colour):</p><ul><li>Light</li><li>Lighting</li><li>Photobiology</li><li>Vision and Colour</li><li>Image Technology</li><li>Measurement</li></ul><p>Specifically around Image Technology they focus on bridging the gap between how we can make printed and display images match what we see. This includes methods, measurements and quantifiable ways of processing analogue or digital reproductions of colour.</p><h3>CIE 1931 Colour system</h3><p>The CIE 1931 Chromaticity Diagram (below) <strong><em>“represents”</em></strong> the full gamut of human colour perception. Funnily enough depending on how the chart is presented you are also going to be limited by the colour space that it was rendered in (more on this shortly). It is a mathematical model and is a <strong><em>“static idealisation”</em></strong> i.e. what is theorised to be the colour vision of a normal human.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*cjY62DF2OE4_GeJbMNhdcQ.png" /></figure><p>The diagram has a few elements to consider:</p><ul><li>The outer curved boundary is the <em>spectral (or monochromatic) locus</em> — it represents the physical measurement of light oscillation represented in wavelengths.</li><li>The bottom of the chart omits this outer boundary (The purple line) These colours don’t exist as a single wavelength in nature; they are only “sensations” created by our brain when it receives both short (blue) and long (red) wavelengths simultaneously.</li><li>The diagram adopts colour names from the <a href="https://en.wikipedia.org/wiki/Munsell_color_system">Munsell colour system</a>.</li><li>The solid curved line with dots through the middle (<a href="https://en.wikipedia.org/wiki/Planckian_locus">Planckian locus</a>) is the path an <a href="https://en.wikipedia.org/wiki/Black-body_radiation">incandescent black body</a> would take in this colour space as its temperature changes. (Think the colour of heat).</li><li>Near the centre of the curve (denoted as either D65 or Point E) is usually known as the “white point” or a “defined white”.</li><li>And just above the x-axis those temperatures on the locus are represented in Kelvin.</li></ul><h3>Colour Spaces, what’s that about?</h3><p>A colour space is a digital device translation tool or dictionary used to define how colours are coded and organized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3KwOrf95PpZxYXSfo0oRVg.png" /></figure><p>Below I’ve summarised a few colour spaces to help give an understanding on how different output devices may display colour.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*UUgOWbsP4h8BF5ReJxgd8Q.png" /><figcaption>Table from my website as medium still doesn’t suppor this formatting :)</figcaption></figure><h3>The RGB Colour Model</h3><p>The RGB Colour model is considered an <a href="https://en.wikipedia.org/wiki/Additive_color"><em>additive colour model</em></a> in which the combination of red, green and blue primary colours of light are added together to reproduce a broad array of colours. The RGB model is for sensing, representation and display of images in electronic systems. The model aligns to our perception of colours (Trichromacy).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*NZIxLxo0gJrXXQ2V57t8OQ.png" /><figcaption><em>Source: </em><a href="https://www.figma.com/resource-library/what-is-rgb/"><em>Figma’s article “What is RGB”</em></a></figcaption></figure><p>To form a colour we superimpose three light beams (red, green and blue) either by, emission from black, or reflection from white. Each beam is labelled a component of that colour. The reason the RGB space is considered additive is because if light beams of differing colour (frequency) are superposed in space, their light spectra adds up, resulting in total spectrum.</p><p>To map a RGB triplet the component values are treated as positive <a href="https://en.wikipedia.org/wiki/Cartesian_coordinate_system">Cartesian coordinates </a>with a double value clamped between 0 and 1. If you could visualize a cube holding the bounds of the colour space a point with an X (Red), Y (Blue) and Z (green) “coordinate” will represent a colour (more on this shortly).</p><p>With this geometric representation additional computations can be applied such as colour similarity by mapping the distance between two given RGB colours.</p><h3>sRGB Colour Space (and Transfer Function)</h3><p>On November 5, 1996 Michael Stokes (Hewlett-Packard), Matthew Anderson (Microsoft), Srinivasan Chandrasekar (Microsoft) and Ricardo Motta (Hewlett-Packard) submitted a joint proposal to the W3C titled <a href="https://www.w3.org/Graphics/Color/sRGB.html">A Standard Default Color Space for the Internet — sRGB</a>.</p><p>Jointly written by HP and Microsoft the paper plays an instrumental role in shaping how we sense colour on computers today.</p><p>The tech industry was facing a challenge. Hardware, applications and output devices were all displaying colour information with different standards applied. High end users who needed precision had access to hardware and software which supported a wider gamut whilst lower end entry level devices would be limited in support for such colour spaces. If the problem wasn’t addressed there would be a considerable effort required to maintain the colour display ecosystem.</p><p>To address this, the paper put forward a standardised colour space (Standard RGB or sRGB) with the intention to:</p><ul><li>Improve colour fidelity in the desktop environment</li><li>Create a uniform standard for software development</li><li>Confidently communicate colours with minimal overhead</li></ul><p>Essentially sRGB is a communication ruleset, a “lingua franca” (common language), made possible by constant parameters adopted to create a common colour language.</p><p>To achieve this there are a couple of important factors to consider:</p><h3>Colorimetric RGB</h3><p>sRGB uses precise standardised definition of anchor colours, specifically the Rec.709 values for Red, Green Blue and White (D65). The reason REC.709 was chosen was because it matched the phosphors used in the consumer CRT monitor and Television set of the 1990’s ensuring backwards compatibility.</p><h3>Gamma (Transfer Function)</h3><p>The proposal provides a a bridged target of gamma suitable for most devices and breaks up the requirement into various subsets.</p><ul><li><strong>Viewing Gamma </strong>— Computed Gamma we want to obtain</li><li><strong>Camera Gamma </strong>— Derived characteristic from the image sensors standard transfer function.</li><li><strong>CRT Gamma </strong>— The gamma of the physical CRT (display).</li><li><strong>LUT Gamma </strong>— The gamma of the frame buffer lookup table</li><li><strong>Display Gamma </strong>— Computed downstream “display system” gamma</li></ul><p>The four specific numbers the proposal settles on</p><ol><li><strong>1.125</strong> — <strong>Target</strong> Viewing Gamma (The desired boost for dim environments)</li><li><strong>11.9561.9561​</strong> — Rec.709 Power Function (The mathematical behaviour of the 709 transfer function)</li><li><strong>2.5</strong> — Physical CRT Gamma (Baseline characteristic for CRT displays in the 90’s)</li><li><strong>2.2</strong> — The magic number or “New Standard” proposed as the ideal target for the <strong>sRGB Display Gamma</strong></li></ol><p>To simplify further:</p><ul><li>1.125 is our <strong>goal</strong></li><li>11.9561.9561​ is a <strong>constraint</strong> of Rec.709</li><li>2.2 is used to <strong>bridge</strong> our gap</li></ul><p>The solution results in the simple formula:</p><p>1.1247=2.2∗11.9561.1247=2.2∗1.9561​ (This rounded would resolve to 1.125 our target viewing gamma)</p><p>The reasoning behind 1.125 is clearly laid out in the proposal and well beyond the scope of what we are discussing here, in simpler terms they understood the colour space would be used in a multitude of environments which still required images to look correct and not washed out.</p><h3>Definition</h3><p>The final piece I will touch on at a high level is definition. The key components that were defined as <strong><em>standard</em></strong>:</p><ul><li><strong>The Standard Observer:</strong> While based on the <strong>CIE 1931 Standard Observer</strong>, the sRGB proposal specifically optimised for the “average” human’s response to the phosphors of a CRT monitor. It effectively turned a biological variable into a mathematical constant.</li><li><strong>Reference Viewing Environment:</strong> This defined the “room” the observer is in, assuming a dimly lit office and a specific <strong>D50</strong> ambient white point. This is why the 1.1251.125 viewing gamma was necessary (to compensate for the “darker” office surroundings).</li><li><strong>The sRGB Gamut:</strong> This is the “triangle” of colours within the CIE 1931 space. Any colour falling outside this triangle is considered “out of gamut” for sRGB and must be re-mapped.</li><li><strong>Render Intent:</strong> The inclusion of render-intent was a forward-thinking attempt to handle those “out of gamut” colours. It instructed the browser on how to squeeze a wide-gamut image (like a professional photograph) into the smaller sRGB space without losing detail in the highlights or shadows.</li></ul><h3>Some Cube Code</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nX7cxUYzaMr7T86e.png" /><figcaption>Source: <a href="https://developer.mozilla.org/en-US/docs/Glossary/RGB">MDN</a></figcaption></figure><p>To visualise the sRGB transformation think of a cube (see above) and now in code (below):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DCi55mFn4HPQyN5Xs7GJ2A.png" /></figure><p>Mapping in increments of 0.1 an 11x11x11 cube which would equate to 1331 unique combinations. Whilst this works for a cube with a single factor of consideration, It is not taking into account the nature of our above pictured cube having corners starting at Red, Green, Blue, White, Magenta and Black.</p><p>True sRGB works in 8-bit space providing over 16.7 million unique combinations and takes into account the tracking of index in relation to each other.</p><p>256×256×256=2563=16,777,216256×256×256=2563=16,777,216</p><p>(don’t run the below code it generates over 50 million entries)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C7L2Z9xOspjdja9njRYbog.png" /></figure><p>The above “cube code” with the additional parameter in mind, return coordinates to the value of 25632563.</p><p>The axis of the cube is represented as such:</p><ul><li><strong>X-axis = Red (R)</strong></li><li><strong>Y-axis = Green (G)</strong></li><li><strong>Z-axis = Blue (B)</strong></li></ul><p>Charting the colour cube is as simple as plugging in our coordinates and setting sail — see some example coordinates below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*Xj7108pyEpYUVFsz1AuqgA.png" /><figcaption>Source: My website because again — medium please tables.</figcaption></figure><p>An important distinction I needed to wrap my head around:</p><p><strong><em>The mapping of the colour space (setting the coordinates) is linear, the issue is the adjustment of colour.</em></strong></p><p>Remember all that stuff about gamma? Now that the coordinates are mapped I found that the relationship between coordinates and gamma to be <em>non-linear</em>. This was the main reason why the sRGB transformation was not suitable for my computed colour scheme exercise (I’ll show a visual example shortly).</p><p>When you adjust only the Red, Green or Blue sliders on an sRGB colour picker the results do not necessarily meet expectation.</p><p><em>Side note: There is so much more to explore around gamma specifically, maybe another time.</em></p><h3>Vector Manipulation</h3><p>If it wasn’t already implied the combination of vectors in an additive fashion allow for us to come up with a colour. As an example adding <strong>Pure Red</strong> and <strong>Pure Green</strong> should give us <strong>Yellow</strong>.</p><p>[1,0,0]+[0,1,0]=[1,1,0][1,0,0]+[0,1,0]=[1,1,0]</p><p>As it was aptly put by Troy from <a href="https://hg2dc.com/2019/03/23/question-1/">hg2dc</a></p><blockquote><em>What the F$%k Happens When We Change an RGB Slider Value?</em></blockquote><blockquote><strong><em>You are increasing or decreasing the emission intensity of one of the three RGB lights</em></strong></blockquote><p>The transformation lends itself to great precision providing a very large number of combinations, however, the intuitive expectations become difficult to meet.</p><p>As an example let’s take <strong>Red</strong> [1,0,0][1,0,0] If we wanted to make this a “Deeper Red” programmatically we would need to have either reviewed and memorised the coordinates of the red we are seeking or manipulated our RGB values and reviewed incrementally until we were happy this could land us at [0.9098,0.0353,0.0353][0.9098,0.0353,0.0353] (a slightly darker red).</p><p>Even with clamped helper values in the RGB space we would still need to manipulate our green and blue values to find the output we desire.</p><p>Because of the biological quirks ([discussed earlier](#Colour is a Sensation)) — like our heightened sensitivity to Green — moving a coordinate by 0.1 on the Green axis “feels” much more dramatic than a 0.1 move on the Blue axis.</p><p>This “overhead” in managing our perception and sense is why It is harder to apply a programmatic approach to computed Themes in the sRGB space. That’s why I needed to look at alternatives like HSV and HSL.</p><h3>HSV and HSL</h3><p>HSV and HSL comes from the desire to have a natural system in which it’s easier to adjust a colour scheme, providing more intuitive functions familiar to the standard observer (humans). The transformations are inspired from art where a base colour (hue) is picked adding white (tint), black (shade), or grey (tone/saturation).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yrZME8IMYCwrQG87QrcfPA.png" /><figcaption><em>Source: </em><a href="https://en.wikipedia.org/wiki/HSL_and_HSV"><em>Wikipedia Article on HSV and HSL</em></a></figcaption></figure><p>sRGB is hardware-focussed valuing precision, where as HSL/HSV accommodates human intuition. The transformations for HSL/HSV are implemented by mapping cartesian RGB values into a <a href="https://en.wikipedia.org/wiki/Cylindrical_coordinate_system">cylindrical co-ordinate system</a>.</p><p>To apply the transformation (assuming RGB values are normalized to the range [0,1][0,1]) a pre-calculation determines the peak and floor of each RGB triplet with:</p><ul><li>M=max(R,G,B)M=max(R,G,B)</li><li>m=min(R,G,B)m=min(R,G,B)</li><li>C=M−mC=M−m (This is the <strong>Chroma</strong> , or the distance from the neutral grey axis)</li></ul><p>We use the above values in both Value and Saturation so it’s important to remember them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*SnecvbFy_e2dNmGV1XoNLg.gif" /><figcaption><em>Source: </em><a href="https://en.wikipedia.org/wiki/HSL_and_HSV"><em>Wikipedia Article on HSV and HSL</em></a></figcaption></figure><p>Visualising the cylinder with a colour space mapped to it (like below) — HSL and HSV provide a transformation option where specific choices for Lightness (or Brightness in the case of HSV), Hue and Saturation become special cases, unified by adjustable parameters — also known as a parametric framework.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VE_v87bT7IHtcnt_puzQTQ.png" /><figcaption><em>Source: </em><a href="https://en.wikipedia.org/wiki/HSL_and_HSV"><em>Wikipedia Article on HSV and HSL</em></a></figcaption></figure><p>I will try to summarise Hue, Saturation and Value (or lightness/intensity) in its transformative context. I did note through a lot of my readings that definition for these terms is going to have variance based on context — so keep that in mind when exploring other areas.</p><h3>Hue</h3><p><strong>TLDR: Hue is an angle on our unwrapped colour cylinder normalised to 360°360° to represent a perceived colour.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aw7Hy2ePC3iR3asmULz7zw.png" /><figcaption><em>Source: </em><a href="https://en.wikipedia.org/wiki/Hue"><em>Wikipedia Article on Hue</em></a></figcaption></figure><p>I came to find this particular definition from <a href="https://books.google.com.au/books/about/Color_Appearance_Models.html?id=8_TxzK2B-5MC">Color Appearance Models by Mark D. Fairchild</a> as a great starting point for my understanding of hue.</p><blockquote><em>Hue — Attribute of a visual sensation according to which an area appears to be similar to one of the perceived colors; red, yellow, green and blue or to a combination of two of them.</em></blockquote><p>In a HSV/HSL model both hue and chroma are parameters which when applied navigate our coordinates with different effect.</p><p>To have a reference for hue first the RGB cube tilted with the black vertex on the bottom is projected to a hexagonal shape.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*qIEpHgDd6HY8BR1mrJMcDw.png" /></figure><p>Each projected vertex which constitutes points between edges in our hexagon become the anchor vectors with the definition of hue being roughly the angle of the vector to a point in the projection, with red at 0°</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LjTR7B6azq9BpCp3BrE3Mw.png" /></figure><p>As such Hue is the angular component and is typically measured in degrees. As an example from the above image a yellow hue would sit at roughly 60°60° — if H is less then 0 then it would add 360°360° to normalise it.</p><h3>Saturation</h3><p><strong>TLDR: In HSV saturation is simply the chroma CC divide by the maximum value MM.</strong></p><blockquote>Saturation<em> is the “colourfulness of an area judged in proportion to its brightness” (17–1136)</em></blockquote><p>Source <a href="https://munsell.com/color-blog/difference-chroma-saturation/">The Difference Between Chroma and Saturation</a>*</p><p>The math behind the generalised saturation functions is certainly a little above my paygrade however I will try to keep it simple.</p><p>Saturation is traditionally calculated at the length of a vector L(c)L(c) (calculation varied based on weightings — see lightness below) divided by the length of the extension of this vector to the surface of the RGB cube. Dependant on the brightness function creating a parametric system which allows us to keep a <em>conic</em> or <em>bi-conic</em> form of transformation space, intimately utilises brightness functions and takes into account specific co-ordinates on the brightness slope. Those poitns are then used in a calculation to divide our length accordingly.</p><h3>Brightness or Lightness Value (ft. Intensity)</h3><p><strong>TLDR: In HSV = Value = Max of RGB Triplet — the below gives more detail and insight and can be skipped if it’s not of interest.</strong></p><p>HSL, HSV and HSI all use a form of luminous intensity ( L(c)L(c) ) as a subjective measure of brightness — this is derived from the <a href="https://www.sciencedirect.com/science/article/abs/pii/S1049965283710199">Generalized Lightness Hue and Saturation (GLHS) colour model</a>.</p><p>The equation below provides insight into how the brightness is calculated:</p><ul><li>Assuming c as a colour [R,G,B][R,G,B] value.</li><li>wminwmin​, wmidwmid​ and wmaxwmax​ as user set weights (generally 0 or 1)</li><li>min(c)min(c) represents the minimum value amongst the [R,G,B][R,G,B] values</li><li>mid(c)mid(c) represents the median of the [R,G,B][R,G,B] values</li><li>max(c)max(c) represents the maximum value amongst the [R,G,B][R,G,B]</li><li>Finally a few constraints — wmax&gt;0wmax​&gt;0</li><li>and wmin+wmid+wmax=1.wmin​+wmid​+wmax​=1.</li></ul><p>L(c)=wmin⋅min(c)+wmid⋅mid(c)+wmax⋅max(c)L(c)=wmin​⋅min(c)+wmid​⋅mid(c)+wmax​⋅max(c)</p><p>Specific values of the weights give the brightness functions used by the common cylindrical colour spaces:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*hLTZic4oIpH5ZyS1RO63zw.png" /><figcaption>Source: My shiny site that supports tables and LaTeX :)</figcaption></figure><h3>Why HSV?</h3><p>So now that the RGB space is clearly laid out, we need to consider colour matching in a very basic sense, if my theme engine was to take some seed colours for Primary, Secondary, Tertiary and Neutral how do I expand this system with multiple derivative shades in a formulaic fashion.</p><p>Lets take hex code #4287f5 as our seed colour - RGB 66, 135, 245</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/233/1*I94VjU5AsmfqSS5ewK3CrA.png" /></figure><p>And here is a subjectively lighter shade of blue #7cadfc - RGB 124, 173, 252</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*py_56N0pOhnimDe9yCUALw.png" /></figure><p>As the nature of travelling between colours (adjusting gamma) in sRGB is non linear there is no defined step change across all three vectors that will yield a consistent results. If we were to take the above logic then a stepped change of [+58,−11,+7][+58,−11,+7] across our vectors should have a similar result on a green colour. Lets try it!</p><p>Here is our green seed hex #30d42a - RGB 48, 212, 42</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/1*M4KBrgdP1ujFAR7Wul-_1Q.png" /></figure><p>Here if we apply the same modifiers to our RGB coordinates we map to RGB 106, 201, 49 which results in hex #6ac931 In comparison to our blue shade variant the green looks washed out and “not quite right”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*2kLrLeo_URLGAYOcUODJ6w.png" /></figure><p>You may also notice that the green variation feels different compared to blue. This is because the standard observer (human being) has an uneven sensitivity across the spectrum: we are most sensitive to changes in <strong>Green</strong>, followed by <strong>Red</strong>, and least sensitive to <strong>Blue</strong>. This is why a fixed mathematical shift in RGB results in wildly different perceptual shifts depending on the starting colour.</p><p>To demonstrate this point I will pick two seed colours and apply the same step change of [+58,−11,+7][+58,−11,+7] four times and put them side by side for comparison. (The top is the seed colour picked at random).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*H6sJP0maeOkQI7P185wiCg.png" /></figure><p>The results tend to feel washed out, and the uniform intuitive option will not resonate across a swatch.</p><p>Now let’s apply the same exercise in the HSV space. First and foremost we are not going to play with Hue or Saturation only Value (Brightness Factor!).</p><p>Now one thing I didn’t mention is this project is being done in Java (sorry in advance) so the code here is going to be a bit verbose but should be easy to follow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9VXq4UGO2KFnDztaWaIbWQ.png" /></figure><p>By applying a standardised multiplier to our base colours brightness we get some interesting results! lets take our colours we used in our sRGB approach and apply the same multipliers:</p><p>Lets take our original purple hex #FF1BB4 in our function the 1.0 or “500” shade is considered the centre and the results show a noticeable difference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*vTNw735vEbGY8NM3mQv6qQ.png" /></figure><p>and now the same with the #FF714E coral orange.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*07oVF7TC2l8MB13WI3oUog.png" /></figure><p>The immediate uniformity in shade application and the effect of having a parameter that gives us consistent results becomes apparent!</p><h3>Conclusion</h3><p>This was a really long way of saying if you want to automate theming a parametric system like HSV/HSL or HSI and now the new standards in CSS like <a href="https://evilmartians.com/chronicles/oklch-in-css-why-quit-rgb-hsl">OKCLH</a> (which supports a wider gamut of colours in the p3 space) are going to allow for you to have consistent automated results.</p><p>Until next time!</p><h3>Reading Sources</h3><ul><li><a href="https://books.google.com.au/books/about/Color_Appearance_Models.html?id=8_TxzK2B-5MC">Color Appearance Models — Mark D. Fairchild</a></li><li><a href="https://www.sciencedirect.com/science/article/abs/pii/S1049965283710199">GLHS: A Generalized Lightness, Hue, and Saturation Color Model Levkowitz H. Herman G.T.</a></li><li><a href="https://www.researchgate.net/publication/228977873_The_taming_of_the_hue_saturation_and_brightness_colour_space">The taming of the hue, saturation and brightness colour space — Alan Hanbury</a></li><li><a href="https://chrisbrejon.com/cg-cinematography/chapter-1-color-management/">Color Management — Chris Brejon</a></li><li><a href="https://medium.com/hipster-color-science/a-beginners-guide-to-colorimetry-401f1830b65a">Beginners Guide to Colorimetry — Chandler Abraham</a></li><li><a href="https://hg2dc.com/">Hitchhikers Guide to Digital Colour</a></li><li><a href="https://www.pantone.com/articles/color-fundamentals/how-do-we-see-color">How do we see color? — Pantone</a></li><li><a href="https://files.cie.co.at/CIE_Brochure_July_2022.pdf">CIE Informational Brochure</a></li><li><a href="https://www.w3.org/Graphics/Color/sRGB.html">A Standard Default Color Space for the Internet — sRGB — Microsoft and HP</a></li><li><a href="https://en.wikipedia.org/wiki/CIE_1931_color_space">CIE 1931 Color Space — Wikipedia</a></li><li><a href="https://en.wikipedia.org/wiki/HSL_and_HSV">HSV and HSL — Wikipedia</a>*</li><li><a href="https://www.aao.org/eye-health/anatomy/photoreceptors">Photoreceptors — American Academy of Ophthalmology</a></li><li><a href="https://munsell.com/color-blog/difference-chroma-saturation/">Difference Between Chroma</a></li><li><a href="https://www.figma.com/color-palette-generator/">Figma Colour Palette Generator</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f154852a94fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Root and run NodeJS on a Pixel 3XL]]></title>
            <link>https://medium.com/@asbedb/root-and-run-nodejs-on-a-pixel-3xl-1416c6e4e6e3?source=rss-4c65e73441ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/1416c6e4e6e3</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Asbed B]]></dc:creator>
            <pubDate>Sun, 28 Dec 2025 02:23:39 GMT</pubDate>
            <atom:updated>2025-12-28T02:23:39.193Z</atom:updated>
            <content:encoded><![CDATA[<p><em>For editable code blocks and better formatting</em><strong><em> </em></strong><a href="https://asbedb.dev/musings/smort-phone/"><strong><em>head to my website</em></strong></a><em> as medium seems to break on mobile when presented with a code block alongside minimal markdown support.</em></p><blockquote><strong><em>Like what you are reading? Check out my </em></strong><a href="https://www.linkedin.com/in/asbed/"><strong><em>LinkedIn</em></strong></a><strong><em> and </em></strong><a href="https://github.com/asbedb"><strong><em>GitHub</em></strong></a><strong><em> for more!</em></strong></blockquote><blockquote><em>Hello there, I’m Asbed! I put myself on a path to develop my software engineering skills, I use this space to share updates and learning’s on things I find interesting along the way.</em></blockquote><blockquote><em>Please note, I don’t claim to be an expert, nor do I pretend what I share is best practice. This is merely a space to see perspective and collaborate.</em></blockquote><blockquote><strong><em>If you enjoy what I do, consider supporting me on Ko-fi! Every little bit means the world! </em></strong><a href="https://ko-fi.com/asbedb"><strong><em>https://ko-fi.com/asbedb</em></strong></a></blockquote><h3>TLDR</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NyQXhCNzdNOhfdIlYjUAgA.png" /></figure><p>This is a high level guide on some fun I had with an old Google Pixel 3xl with the following goals in mind.</p><ol><li>De-google and run a Linux distro</li><li>Glorious SSH</li><li>Install and run a developer environment</li><li>Potentially host and access services from another device through incoming connections</li></ol><p>If you want to skip the why, and learn more about the how, feel free to go straight to the LineageOS Title</p><h3>Lets go!</h3><p>We recently hit spring (supposedly) which means its that time of the year to clean out the tech closets. After a lifetime of advocating to reduce “tech debt”, I always find it funny opening my closet to find decades of technology just sitting there dormant. Like warriors of past the closet doubles as hall of fallen heroes, each with it’s own tale of conquest and heroism from a simpler time.</p><p>So as one does, I come back to clean this space every few months and each time a new seemingly simple, but usually complicated, idea pops into my mind. Things like <strong><em>“I wonder if I can run RAID across 5 old laptop hard drives?”</em></strong> or <strong><em>“I should build a cyberdeck out of all these extra parts”</em></strong>. To be fair, one of these ideas resulted in installing Arch on an old ThinkPad — a decision I am extremely happy with. (I use Arch btw).</p><p>So this time when the cogs started to turn there were two things in the back of my mind that really helped speed things along.</p><p>The first was the concept of ownership as opposed to being a hostage. Whilst this isn’t a piece dedicated to that, and many before me have done it justice the crux of it came down to.</p><ol><li>Right to repair</li><li>Freedom to modify for personal use</li><li>Unrestricted access to features</li></ol><p>The second came from an odd place.</p><p>Long time content creator recently turned 10x engineer PewDiePie has gone on an interesting journey building fun projects and solving tech problems. He has, probably like me, opened the tech closet and gazed upon the titans of past thinking of giving them purpose once more. One project that stood out was <a href="https://youtu.be/u_Lxkt50xOg?si=y5hEvKN6EC8RKpFT">self hosting using a Steam deck</a>.</p><p>So with an optimistic glimmer in my eye and my gaze affixed on a retired Google Pixel 3xl from 2018, I set forth to conquer what I thought would be a few simple milestones.</p><ol><li>De-google and run a Linux distro on my Pixel 3xl</li><li>Glorious SSH</li><li>Install and run a developer environment</li><li>Potentially host and access services from another device through incoming connections</li></ol><h3>LineageOS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*KW8Na2xA0oKF9S1xHksWTg.jpeg" /></figure><p>The first step was to “unshackled the Google from Google” a task that was surprisingly accessible. I know its easy to pick at issues with big tech companies — but for what its worth, at least there’s a way to do this with relative ease.</p><p>I thoroughly enjoyed this process because it was reminiscent of installing an operating system back in the “good old days”. A time where taking careful note of hardware compatibility and kernels could be the difference between a short simple process or hours of troubleshooting.</p><p>So after some research I found there weren’t many choices for my relic and the best suited one would be <a href="https://lineageos.org/">LineageOS</a> an android distribution that has an impressive amount of <a href="https://wiki.lineageos.org/devices/">devices</a> it supports.</p><p>This isn’t going to be a step by step guide on how to install LineageOS as the documentation does a good job in explaining the process there are however key things when tinkering with an android phone that were critical to installing LineageOS and subsequently rooting the phone. These being Android Developer Options, Android Debug Bridge (adb) and Fastboot.</p><h3>Android Developer Options</h3><p>To access and run debugging via a USB Cable the phone required Android developer options enabled. To enable this</p><ol><li>Go to the phones Settings</li><li>PressAbout Phone</li><li>Tap the Build Number seven times</li><li>Enter your pin or password if prompted.</li></ol><p>You can then find the Developer Options menu in your main settings, often under System. This menu will be crucial to enabling USB Debugging which will be used through out the process.</p><h3>Android Debug Bridge (ADB) and Fastboot</h3><p>As part of installing LineageOS the process will require you to reboot into a bootloader by using a command line interface. ADB is a command line tool which allows you to communicate with the device and perform a number of privileged actions after enabling developer access.</p><p>If you have used Android Studio or an Android SDK chances are you already have adb installed to check this you can run the <em>a</em>db version command in your preferred command line interface. The communication between PC and Phone is usually done over a USB cable, but Wi-Fi connections are also supported.</p><p>Using fastboot (if your device supports it) should simply involve rebooting to fastboot mode. While in fastboot mode, you can type fastboot devices to verify that your device is being detected</p><p>To run adb and fastboot you will need to consider your OS and <a href="https://wiki.lineageos.org/adb_fastboot_guide#installing-adb-and-fastboot">follow the instructions here</a></p><h3>Su (magisk)</h3><p>Even after installing LineageOS there still will be an issue when trying to run processes or commands requiring elevated privileges. Simply put without rooting the device the su command is non existent. To do this you <a href="https://topjohnwu.github.io/Magisk/install.html">can follow along here</a></p><p>The shortened guide below.</p><ol><li><a href="https://github.com/topjohnwu/Magisk/releases/latest">Download and install the Magisk</a> mobile app</li><li>Within the app get a copy of <strong>one</strong> of the following images boot.img, init_boot.img or recovery.img. (If you don’t see either of these see the detailed instruction linked in the first paragraph for more details).</li><li>Copy the boot/init_boot/&lt;recovery_image.img&gt; to your phone</li><li>Press install in the <strong>Magisk</strong> section (not the app section).</li><li>Choose <strong>Select and Patch a File</strong> followed by your recovery image.</li><li>Once installation is done copy your new img file via adb. (Your device might have a different folder structure instead of sdcard) <strong>Warning</strong>: <em>Never download and use a random </em><em>img file online - always patch your own file to avoid any security or configuration issues.</em></li><li>Reboot phone into recovery mode using adb -d reboot bootloader</li><li>Use fastboot and point your device to your new image (take note of boot type based on your img file type) and then turn on your phone.</li><li>Launch the Magisk app and select Direct Install followed by another reboot</li><li>The phone should now be rooted successfully.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*xyae801Atk04zrb8hx1syA.jpeg" /></figure><h3>F-Droid and Termux</h3><p>Now that we have a free and opensource operating system we also need a catalogue of free and opensource applications available for the android platform, and that’s exactly what <a href="https://f-droid.org/en/">F-Droid</a> does. Installation of F-Droid is fairly simple you navigate to the main page on the phone hit the big download button and install via the APK.</p><p>Going back to our goal of SSH and emulating Linux the first step was to ensure we had a terminal we could play with. I decided to go with <a href="https://f-droid.org/en/packages/com.termux/">Termux</a> as it provides an extensive Linux package collection. Heck you could even compile code with gcc and clang.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*blyKAaa-yV5bEsrWboi3OQ.jpeg" /></figure><p>Now the old Pixel 3XL not only is running a brand new de-Googled OS but it also has a nice terminal emulator waiting for root access. All that’s left is to ensure we allow for Termux to have said access as a super user.</p><ol><li>Open Termux</li><li>run the su command (inside Termux on the phone)</li><li>Grant access via Magisk app (approve prompts on your phone)</li><li>execute the adb shell on your PC - whilst the phone is plugged into your pc (this is akin to having a direct wired connection to your terminal)</li><li>type in su within the adb shell terminal on your pc and then <strong>approve/verify</strong> the access <strong>on the phone.</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*WuE_R9kvsuy717FJB8XL4A.jpeg" /></figure><h3>Glorious SSH</h3><p>Alas, the last step is to provide remote SSH access (at this stage via local network). Now that we have an elevated terminal and can technically access it straight from our PC via a USB cable it becomes no different to a regular Linux process! You can elect to do this via adb shell or directly on the phone via Termux</p><ol><li>Open Termux / or adb shell</li><li>Run the command pkg upgrade &amp;&amp; pkg update</li><li>Run the command pkg install openssh</li><li>Set a SSH password using the passwd command</li><li>Run the sshd command to start the SSH daemon</li><li>Check your phones local IP address using the ifconfig command</li><li>Check your terminal username using the whoami command (this needs to be done on Termux directly on the phone)</li></ol><p>(Optional but recommended) With this setup if the device goes to sleep it will automatically sever the SSH connection — you can stop this behaviour by running the command termux-wake-lock in Termux on the phone.</p><p>This stops your device from going into “deep sleep” ensuring access even if the screen is “asleep”.</p><p>So by now you should have:</p><ul><li>Phones Local IP</li><li>Termux Username</li><li>SSH Password</li></ul><p>The final check is ensuring you can SSH into the phone to do this open up your favourite CLI which can of course provide you with glorious SSH and type in the following:</p><p>ssh -p 8022 &lt;username&gt;@&lt;phone_IP_Address&gt;</p><p>If everything has been done correctly you should be greeted with something similar to the below image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*eMqcGxm3rVGZwn3vK2kd8A.png" /></figure><h3>proot-distro</h3><p>Termux provides a package called <a href="https://github.com/termux/proot-distro">proot-distro</a> which takes care of managing Linux distributions inside Termux. You can install this utility by executing.</p><p>pkg install proot-distro</p><p>By using proot we open the device up to so much more fun! In my example I went with ubuntu - this was as simple as executing the following commands:</p><ol><li>proot-distro install ubuntu</li><li>proot-distro login ubuntu</li></ol><p>Proot supports the following distros:</p><ul><li>Alpine Linux (edge)</li><li>Arch Linux / Arch Linux 32 / Arch Linux ARM</li><li>Debian (stable)</li><li>Fedora 35</li><li>Manjaro AArch64</li><li>OpenSUSE (Tumbleweed)</li><li>Ubuntu (22.04)</li><li>Void Linux</li></ul><h3>hey look, my phone now runs a dev environment</h3><p>So this was my last goal really, could I run a node server and access it on my local network. Sadly I was able to only get it half done.</p><p>There were a few reasons for this but let me start by providing a quick overview on the Node and NPM experience .I took a bit of a different route to get it running because we needed to ensure all the binaries were available a luxury that you overlook when using a desktop OS.</p><p>Below you will find the commands in order, I also opted to use Node Version Manager (NVM) to make it easier to manage multiple node packages in the future.</p><ol><li>apt update &amp;&amp; apt upgrade</li><li>apt install nodejs npm build-essential</li><li>apt install curl -y</li><li>curl -o- <a href="https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh">https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh</a> | bash</li><li>source ~/.bashrc</li><li>nvm — version</li><li>nvm install — lts</li><li>nvm use — lts</li></ol><p><em>Magic</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*g2c2N830z8siOPKSo923PA.png" /></figure><p>With what I have just demonstrated you can imagine the amount of possibilities that open up, I have seen people turn old phones into a bunch of things including a mobile pen testing tool running Kali Linux.</p><p>Here’s an Astro site running locally as an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*BxyVZJoQG90YTbUi5FwhWA.png" /></figure><p>Sadly there was one thing I didn’t account for.</p><h3>Nobody escapes the Google</h3><p>Just when I thought I was out Google pulled me right back in. Compared to it’s fruit variety the freedom is unmatched however there was still some restriction I had not accounted for. The NIC is extremely locked down in most mobile phones (for good reason!) that certainly is no different in the case of the pixel.</p><p>After trying almost every option to fix the error A system error occurred: uv_interface_addresses returned Unknown system error 13 (Unknown system error 13). I staggered off to lick my wounds - Whilst I think there still might be a way for me to beat the final challenge - perhaps it’s a tale for another day.</p><p>In retrospect the issue stems from permissions as the libuv library tries to call the function os.networkInterfaces(). This function triggers an Access denied on modern Android (11+) as querying network interface details are restricted.</p><p>This was a fun exercise and it has given me something to do with an otherwise dormant relic of the past. I would always recommend finding ways to give old tech a new purpose — you may even surprise yourself with the results.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1416c6e4e6e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Developing a webOS — Part One]]></title>
            <link>https://medium.com/@asbedb/developing-a-webos-part-one-02253291ced6?source=rss-4c65e73441ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/02253291ced6</guid>
            <category><![CDATA[operating-systems]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[object-oriented]]></category>
            <dc:creator><![CDATA[Asbed B]]></dc:creator>
            <pubDate>Sun, 17 Aug 2025 01:45:40 GMT</pubDate>
            <atom:updated>2025-12-28T02:03:44.647Z</atom:updated>
            <content:encoded><![CDATA[<h3>Developing angOS— Part One</h3><p><em>For editable code blocks and better formatting</em><strong><em> </em></strong><a href="https://docs.asbedb.com/projects/angos/angos---part-one/"><strong><em>head to my docs page</em></strong></a><em> as medium seems to break on mobile when presented with a code block alongside minimal markdown support.</em></p><blockquote><strong><em>Like what you are reading? Check out my </em></strong><a href="https://www.linkedin.com/in/asbed/"><strong><em>LinkedIn</em></strong></a><strong><em> and </em></strong><a href="https://github.com/asbedb"><strong><em>GitHub</em></strong></a><strong><em> for more!</em></strong></blockquote><blockquote><em>Hello there, I’m Asbed! In the month of August 2024, I put myself on a path to develop my software engineering skills, I use this space to share updates and learning&#39;s on things I find interesting along the way.</em></blockquote><blockquote><em>Please note, I don’t claim to be an expert, nor do I pretend what I share is best practice. This is merely a space to see perspective and collaborate.</em></blockquote><blockquote><strong><em>If you enjoy what I do, consider supporting me on Ko-fi! Every little bit means the world! </em></strong><a href="https://ko-fi.com/asbedb"><strong><em>https://ko-fi.com/asbedb</em></strong></a></blockquote><p>My earliest memory of a Windows PC dates back to when I was 5. The information age had started to pick up steam and Microsoft was sporting it’s latest operating system, Windows 95 — a powerhouse for business, connectivity and leisure marketed as a must-have tool for the modern family. My parents who were operating a small business and raising a young family at the time certainly thought so and bought home the Compaq Presario 4160, a technological marvel for its time. This machine not only served me throughout most of my adolescent life, but also sparked a joy for technology that would be lifelong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*yntfylU0gsJCzmMpmyoE-A.jpeg" /><figcaption>Credit: <a href="https://www.retroprops.com.au/product/compaq-presario-4160-windows-95/">https://www.retroprops.com.au/product/compaq-presario-4160-windows-95/</a></figcaption></figure><p>I reference this because even at that young age, wanting to understand the ins and outs of my machine and how all the software operated was something that excited me. That’s why I recently decided to go deeper and attempt to simulate an operating system using a modern web language — these projects are often described as webOS projects and are generally used to learn and grow as a developers.</p><p>This project has been very rewarding for me, it has taught me a great deal on how larger teams make various decisions. For those who are at an intermediate level and looking to branch from one type of development to another (in my case it was web to Systems/OS) — these sorts of projects are a great way to think outside the box.</p><h3>Conception</h3><p>At the end of June 2025 I came across whispers that the Windows 11 Start Menu was built with <a href="https://winaero.com/windows-11-start-menu-revealed-as-resource-heavy-react-native-app-sparks-performance-concerns/">React Native</a> . After further research, it seemed to be some casual “clickbait” that surfaced every few months and nothing of note (the Start Menu itself is <a href="https://www.youtube.com/watch?v=kMJNEFHj8b8&amp;t=287s">built with C++ and XAML</a> with the recommendations feature using React Native). It was a nice little rabbit hole at the time however it did spark a small proof of concept which would later turn into an exciting project for me.</p><p>Growing up in the mid-90s early 2000s, the nostalgia of older Microsoft operating systems notably 95, 98 and XP brings me joy, reminiscing about aero icons and MSN Messenger dings after school I set myself a goal of visually recreating a Windows XP desktop environment in React — not the hardest front end styling exercise but one I came to enjoy.</p><p>It was around this time that my curiosity and current learning topics started to mingle — I had recently started reading <a href="https://www.amazon.com.au/Clean-Architecture-Craftsmans-Software-Structure/dp/0134494164">Clean Architecture</a> by Robert C. Martin (Uncle Bob), alongside working through some course-ware from <a href="https://www.coursera.org/learn/algorithms-part1">Princeton around Data Structures and Algorithms</a> which was taught in Java. Putting the two together I had fully bought into the OO paradigm and was itching to practice my knowledge and theory — as I started crafting my UI design, my systems thinking mindset set in — It was then I asked myself some fundamental questions.</p><ul><li>“How does Windows get to the front end?”</li><li>“Is Windows different to other operating systems in how it achieves this?”</li><li>“How do we manage themes, preferences, start menu applications and other users?”</li></ul><p>The more I asked these questions the more I realised this project was going to go beyond the scope of just a front end recreation.</p><h3>New Goals</h3><p>I had made a decision to turn this small project into a “learning companion” giving me a higher level understanding of core components that go into an Operating System, to keep it simple it would be written in a language I am currently familiar and comfortable in (TypeScript). I wanted the project to push me to think outside of the box with my current language whilst introducing me to concepts found in different development practices (Kernel Development, Drivers, Firmware, OS etc. ).</p><p>I first needed to set myself some rules — after careful consideration these were the main ones.</p><ol><li>Pick a reference architecture.</li><li>Choose a Paradigm.</li><li>Stick to <a href="https://en.wikipedia.org/wiki/SOLID">SOLID principles</a> .</li><li>Modularity and expansion prioritised in design and structure.</li><li>Constrain realism to limitations of language and tools we are building in.</li><li>Be open to changing these rules if it meets the goals of simulating our reference architecture.</li></ol><h3>Opinionated Early</h3><p>These rules resulted in some early decisions. I first elected to align with the <a href="https://en.wikipedia.org/wiki/Object-oriented_programming">Object Oriented Paradigm</a> for this project, this would mean some changes to frameworks and structure (more on that shortly). I also decided to choose the <a href="https://en.wikipedia.org/wiki/Architecture_of_Windows_NT">NT Architecture</a> as my reference architecture considering I was already working on a Windows front end.</p><p>Some other “standards” I set for myself.</p><ul><li>kebab-case naming convention with dot separators to identify our files with ease etc: <strong>example-file.class.ts</strong></li><li>Separation of concerns including modularised <strong>type.ts</strong> and <strong>const.ts</strong></li><li>Test driven development to milestone major functionality implementations with unit testing methodology.</li></ul><p>I believe the above to be more foundational, I also realised the more important decisions were paradigm and reference architecture which helped shape and grow these standards organically.</p><p>In addition I chose some technologies to assist with the developer experience — the main ones being <strong>jest</strong>, <strong>prettier</strong>, <strong>tailwind</strong>, <strong>angular</strong>, <strong>ts-jest</strong> and <strong>jsdom</strong>.</p><ul><li><strong>jest</strong> with <strong>js-dom</strong>: Is the main testing suite being used as it allows for both functional unit tests and DOM related output validation.</li><li><strong>prettier</strong>: Is used to ensure consistent formatting across our files.</li><li><strong>tailwind</strong>: Is a utility class based CSS library allowing for us to have simple inline styling across our html components</li><li><strong>angular</strong>: is an OO front end framework which we will discuss in more detail in the next section.</li></ul><h3>Functional vs OO</h3><p>I had done a considerable amount of work making a functional front end using <strong>vite</strong>. I had built a replica of the Windows XP taskbar which visually matched the old Start Menu. I had even built multiple themes being served through a <strong>contextProvider</strong>, originally the vision was to allow for users to make their own themes to replicate other popular operating systems — the only issue, <strong>vite</strong> and <strong>React</strong> (whilst no issue mixing in OO principles `after all everything is an object in javascript`) are primarily better suited to the functional paradigm.</p><p>I had my first decision to make — one that I now believe to be the right one.</p><p>I elected to port my project in full to <a href="https://angular.dev/">Angular</a>. This was a great experience overall and my approach helped speed things up, if you are ever looking to port a project from one framework to another — my suggestion is to speak in the language of the Framework you are familiar with to an LLM (my current choice is Gemini for “pair programming” purposes) — I’m not suggesting the responses are gospel however, questions like.</p><p>“What is the React <strong>useState</strong> equivalent in the Angular framework?”</p><p>Helped speed up finding the right reference materials for me to learn the basics of the framework. Other more nuanced techniques were reserved to reading documentation and self research.</p><h3>An example of change</h3><p>Here I want to show how different the two frameworks are, let’s take the Windows XP Start Menu (see reference picture from my frontend).</p><figure><img alt="Screenshot of start menu from front end" src="https://cdn-images-1.medium.com/max/697/1*xzggOw7ctZQqoF0we7X_Uw.png" /><figcaption>The current look of the start menu from front end.</figcaption></figure><p>The original functional component code (<strong>vite</strong>) looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kSNvgojcpDWacn8de0Nddw.png" /><figcaption>vite StartMenu.tsx code block</figcaption></figure><p>And the ported object oriented component (<strong>Angular</strong>) looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PiybbZzrRr0hdU7vBT-DaA.png" /><figcaption>Angular StartMenu.ts code block</figcaption></figure><p>Two completely different approaches ultimately leading to the same rendered component — I had moved from <strong>useContext</strong> to <strong>inject</strong> (and <strong>compute</strong>); <strong>props</strong> to <strong>@decorators</strong>; <strong>state</strong> to <strong>signals</strong> and of course was now returning classes instead of functions.</p><p>Whilst the conscious choice to port to Angular was made early this wasn’t necessarily due to one framework being better then the other. It aligned more to those opinions and rules I had set — in particular adhering to an OOP approach upfront.</p><h3>Starting at the Hardware</h3><p>A computer is made up of components, those components put together make it compute. So how do we simulate those components without losing focus on the overall project and its learning outcomes. My first task was to validate a configuration with some simulated core hardware components.</p><h3>CPU</h3><p>During my initial research I made a decision to forgo simulating a CPU at this stage — I made this decision as I saw the task as one that would consume a significant amount of early stage development that could cause the project to lose focus and fail to meet its initial learning goals..</p><p>Should I have included CPU I would need to consider, threading, concurrency, logic gate functionality, orchestrating kernel executions and much more. My approach was simple, allow for the structure to “plugin” a CPU at a later date and for now continue with the main goals.</p><h3>Storage, RAM and GPU</h3><p>Memory from a functionality perspective is fairly simple with the two main functions being read and write. (technically it is storing and releasing but for now let’s relegate to read and write).</p><p>Accessing memory has no linearity, allowing for non-sequential reads and writes to ensure fast access. As this is a simulation we were not going to get into the granularity of control logic, address decoders (at least in detail) or multiplexers. The function of our various memory modules was to meet and address a few points.</p><ul><li>A way to simulate and limit concurrent running processes</li><li>Abstracted pointers to Hexadecimal values (<strong>Uint8Array</strong> was used for this).</li><li>Simple read and write that could eventually be accessed through our win32API (More on this in part two of this article in the near future).</li></ul><p>The first technical decision made was to limit the simulated storage parameters to be kilobytes (kb/*1024) noting I would scale this up in the front end environments for rendering/visual purposes. The reason was due to the constraints for object creation lengths in JavaScript. Having a <strong>Uint8Array</strong> with a length that equated to the amount of bytes in a GB would not be acceptable or even required for this project.</p><p>As mentioned I made a choice of a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array"><strong>Uint8Array</strong></a> to represent our “address decoder” (using the term very loosely) because it supports working with arbitrary binary data. Should I decide to dip my toes into WASM and decoding binary data then we have a good typed array to support this in the future!</p><p>I also decided to not implement GDI level simulation which meant limiting the GPU to memory functionality, this means that both the GPU and RAM classes would be identical for now separated in name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2bT5G9QmOJJ_XfH_YEOAWw.png" /><figcaption>ram.class.ts code block</figcaption></figure><h3>Storage Devices</h3><p>Whilst the storage device would also take the same functions a small addition was added to the constructor to ensure I could adapt the class to have different type properties. I did this by using a <strong>StorageType</strong> export. I was also initially considering how to check “port compatibility” and this structure would help me address that across components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lpNdJgTQaH9PzKEba0ngiQ.png" /><figcaption>storage/types.ts code block</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GYneyEMpvxuEJ6e0muitzw.png" /><figcaption>storage-device.class.ts code block</figcaption></figure><h3>Motherboard</h3><p>The motherboard serves as a I/O board that verifies if its slots are occupied with valid devices and returns a class with “what’s plugged in”. I decided to use custom interfaces to construct types that would ensure the compatibility of certain slot types.</p><p>This approach allows me to come back to this module and expand on the idea in the future. For now the <strong>pcieOne</strong> and <strong>pcieTwo</strong> ports as per <strong>pcConstructorProperties</strong> take a <strong>pcieSlotConfig</strong> type which would offer us with either a null value (nothing plugged in) or an interface that’s <strong>gpu</strong> or <strong>storage</strong>. The idea here is fairly straight forward. The motherboard can ultimately have anything plugged in but at a minimum it needs GPU, Storage and RAM to be a valid construction of a motherboard otherwise returning a <strong>configurationError</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hht_37NZrQ7zi8u1fC87Bw.png" /><figcaption>motherboard/types.ts code block</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hYCQxaJqKpGruVclTKc_bw.png" /><figcaption>motherboard.class.ts code block</figcaption></figure><h3>Firmware</h3><p>I introduced the concept of firmware when I was separating concerns related to verifying an option ROM and the master boot record. In a normal scenario an operating system would initially be installed off external boot media with a valid boot signatures however in this scenario our simulation would assume that the operating system was “pre-installed” and these installation steps had been completed. I made a choice to relegate the master boot record to a “firmware” function, this would allow for us to create different signatures, should we make a Linux inspired OS in the future we could dynamically load a Linux MBR onto a Storage device.</p><h3>Storage Firmware (Master Boot Record)</h3><p>To create the master boot record the approach I took wasn’t dissimilar to how it would work in a real operating system. The first step was to set some variables.</p><p><strong>diskSectorSize</strong> — This would be the smallest size allocated for each sector, similar to a real device we chose 512 as the smallest divisible number.</p><p><strong>pointerVariables</strong> — These variables are the memory addresses reserved to identify characteristics of the the boot record we have:</p><ul><li><strong>446</strong>: Pointer which returns if partition is Active or Inactive.</li><li><strong>450</strong>: Partition type (NTFS, FAT etc.)</li><li><strong>510</strong> and <strong>511</strong>: These pointers are reserved to let the BIOS know if the partition has a boot signature.</li><li><strong>328</strong> and <strong>329</strong>: For the simulation I reserved pointer 328 and 329 to be our OS Signature, in a real operating system unreserved bytes in the MBR would store the bootloader software. As I was going straight into kernel mode depending on signature found I simplified the logic to match — it also means we can make different operating systems without needing to build a bootloader for each one.</li></ul><p><strong>partitionVariables</strong>: To accompany the above memory addresses the partition variables are set into two categories.</p><ul><li>Storage Specific — File Type, Active/Inactive</li><li>OS Specific — Boot Signature Values, OS Signature Values (For our simulation we only have the Windows ones for now.)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sZelnPBIKyc-FU4WmlGb_w.png" /><figcaption>storage/const.ts code block</figcaption></figure><p>With the values set now it was time to translate this to a class structure — I opted to take four variables for the constructor as captured by the types file:</p><ul><li><strong>partitionType</strong>: a simple union type that would translate different file-system types.</li><li><strong>sectorSize</strong>: a number representing the number of bytes per sector.</li><li><strong>osSingatureOne</strong> and <strong>osSignatureTwo</strong>: our unique system implemented to invoke the correct operating system from BIOS.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dlf0k4v-y4-KvGSjCliiEA.png" /><figcaption>storage/types.ts code block</figcaption></figure><p>Finally I combined the variables and put together the <strong>MasterBootRecord</strong> class which when constructed would return a <strong>Uint8Array</strong> which could then be directly written into the previous <strong>StorageDevice</strong> class.</p><p>The class when constructed would first ensure the constructor arguments were within to our original architecture specifications (512 byte length, active partition, valid OS signature and valid file-system type). Once checks are complete it sets the <strong>this.masterBootRecord</strong> property to the typed array with our crucial pointers having the correct corresponding data.</p><p>I also included a <strong>validateMasterBootRecord</strong> function which would return <strong>true</strong> if all our specifications were met else returning false.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z39EBUNJ2E-0si3s0kJ-gA.png" /><figcaption>master-boot-record.class.ts code block</figcaption></figure><p>Finally we can create a custom <strong>const</strong> for a “Windows” master boot record (if you haven’t noticed yet my simulated OS working title is <strong>Bindows XD</strong>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K-Z_Uh2NlJmeYNul6MYGmg.png" /><figcaption>windows-master-boot-record.ts</figcaption></figure><h3>GPU Firmware (Option ROM)</h3><p>Now that I have explained the logic behind how pointers and data is set when dealing with storage — I can expand on the GPU’s role. For now I have decided to use `Angular` as a “Graphical Device Interface Service” rather then building something custom to simulate the OS GDI Layer. There is however a crucial role a GPU can play in the boot process — mainly housing the option ROM functionality.</p><p>An option ROM allows you to use basic peripherals prior to your device loading an operating system (as an example display and Input support when configuring your BIOS). Like a Master Boot Record, an Option Rom also has a unique signature noted by the first two bytes accessed on the devices onboard storage. For our simulation the GPU houses the option ROM and the option ROM’s function is merely to be validated during POST (nothing more at this stage). This means I can come back later and expand on this idea should I decide to expand on the BIOS functionality or work on a GDI service/expand the GPU’s role and functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HO9uMeQu_DeE5R37J7Hh4Q.png" /><figcaption>firwmare/gpu/const.ts code block</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pznN8MJJUY_21YTMNxs4mQ.png" /><figcaption>option-rom.class.ts code block</figcaption></figure><h3>Assembled PC</h3><p>Now we have our building blocks to build a PC ready to be inspected by a BIOS function. Below is what all the parts together look like. First I created a type interface which allocated compatibility for each slot available in a fully constructed PC</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A_kCZQd4kAPCpowKW8zY9w.png" /><figcaption>pc-builds/types.ts code block</figcaption></figure><p>Following this a helper function was created to return a default system spec — for now this is functional. I will move this to a class at a later stage with the ability to choose multiple builds for testing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c6coQTlX9W6Pbs8n_IYbnw.png" /><figcaption>pc-builds.ts code block</figcaption></figure><p>As you can see the RAM, GPU, Storage, Option ROM and Windows MBR classes are instantiated. A validation of the option ROM and MBR then allocate and write memory to storage and GPU. Resulting in the return of a constructed PC via the <strong>MotherBoard</strong> class.</p><h3>Unit Testing Examples</h3><p>I mentioned earlier following a test driven development model for each of these components iterating on functionality by building to pass tests. This methodology has not only been useful in accounting for edge cases early but it has also been an invaluable tool when I refactored code or separated concerns helping me rapidly find variables/changes that may have causes chain reactions across my project where there were joint dependencies. Below I have included some simulated hardware tests as an example. I have made it a a point to go back and ensure these tests are updated to reduce any burdens caused by refactoring at a later stage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*17qbmFCa1630_-ZUVnmncQ.png" /><figcaption>gpu.test.ts code block</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*foKiOFap0VgqlQW_b1PuXg.png" /><figcaption>motherboard.test.ts code block</figcaption></figure><h3>BIOS</h3><p>At this stage I felt ready to start tackling the BIOS — at a high level my plan was to:</p><ol><li>Take an assembled PC in its constructor</li><li>Detect components in PC at a BIOS level.</li><li>Conduct a Power on Self Test (POST) to ensure the PC would boot</li><li>Check and validate a boot signature and option ROM signature</li><li>Invoke an interrupt (19h) to boot into Kernel</li></ol><h3>Class Properties and Constructor</h3><p>The BIOS class would mirror the motherboard when it comes to slot properties alongside a few tracking variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d3ERkNN9mcCQ82yA_m0NZw.png" /><figcaption>class variables excerpt</figcaption></figure><p>The two <strong>public</strong> properties would be the <strong>eventLog</strong> and <strong>postResults</strong> with the rest being reserved for the internal state of the class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JsRlRSq-1Mo4DIsnKC5E4w.png" /><figcaption>BIOS Class Constructor</figcaption></figure><p>The constructor takes an assembled PC, runs a <strong>detectDevices</strong> function followed by a <strong>postResults</strong> (Power on Self Test), if the POST fails it returns an error, if it passes it invokes Interrupt 19h (further explained below).</p><p>Not much commentary required for the <strong>detectDevice</strong> Function; it simply translates the slots that are occupied from our <strong>assembledPC</strong> to the private BIOS variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-CVQBnhE7obwAq6j65i54g.png" /><figcaption>detect devices function</figcaption></figure><h3>BIOS Event Logging</h3><p>I included a utility function to track BIOS level events. The intent is to take an event object to lift up to the Kernel (and eventually Event Manager). For now the function takes the arguments of a <strong>message</strong> and <strong>isError</strong>. Pushing to our public <strong>Array&lt;string&gt;</strong> typed <strong>eventLog</strong> a message entry.</p><p>When the function is called a new <strong>Date</strong> object with the current system time is broken into a string representation of <strong>hours</strong>, <strong>minutes</strong> and <strong>seconds</strong>, padding the start with two zeros to create a time stamp. We then concatenate our time-stamp with the event message to update our event log entry. The <strong>isError</strong> is used to display our message in the DOM as either a <strong>console.error</strong> or <strong>console.log</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pfZHTUi1TkB7qsNjdUcUMQ.png" /><figcaption>BIOS Event Logging Function</figcaption></figure><h3>Power on Self Test (POST)</h3><p>The Power on Self Test is responsible for verifying if the hardware is “functioning”. The function is `private` to the class and starts with an <strong>updateEventLog</strong> function call.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vm9SApIN8DPjK79PTyaJ-A.png" /><figcaption>POST Initialisiation</figcaption></figure><p>For the simulation the POST begins with a <strong>overallPostPassed</strong> boolean set to <strong>true</strong>, I also created a variable for <strong>atLeastOneGPUFound</strong> and <strong>atLeastOneBootDriveFound</strong>. Whilst technically both of these flags are not required for an actual POST function. I went with integrating these two “checks” into the POST to simulate a verifying an option ROM and bootloader. Should I decide to research bootloaders in the future I can easily create a class that sits between our BIOS and Kernel that can act as an additional interface.</p><p>Setting some constants helped maintain modularity when testing various slot without having to repeat code. Using the structure of an object entry inside an array I set up <strong>storageSupporingSlots</strong>, <strong>gpuSupportingSlots</strong> and <strong>ramSupportingSlots</strong>.</p><p>I also accounted for scenarios where a <strong>GPU</strong> or a <strong>StorageDevice</strong> could be using a PCIE slot by using typescripts <strong>instanceof</strong> type check to determine, and return, the matching class ensuring edge cases were covered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g-gBN8kOSahF1KFQsdEEgg.png" /><figcaption>POST Supporting Slot constants</figcaption></figure><h3>RAM Testing</h3><p>I was now able to construct a *for* loop that would take the array and run the right battery of tests based on “slot type” (this pattern is repeated for GPU and Storage). As the class slot properties are constructed with either null or a valid object the property would be mirrored for <strong>slotInfo.device</strong> reducing operations and only testing on slots that are “occupied”.</p><p>For RAM a <strong>postTestMemory</strong> is first called returning a <strong>boolean</strong> value followed by adding to the <strong>totalMemory</strong> of the BIOS class alongside an update to the <strong>overallPostPassed</strong> based on a combination of the existing <strong>boolean</strong> and <strong>ramTestPassed</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JzPJY9Mjv10FO3pGDwL7Uw.png" /><figcaption>POST RAM testing for loop</figcaption></figure><p>The <strong>postTestMemory</strong> function is used in both *for* loops for <strong>ramSupportingSlots</strong> and <strong>storageSupporingSlots</strong>. It initially logs an event message followed by a <strong>isFunctioning</strong> check. Once complete it ensures the memory modules available memory is above `0` before returning `true` for the test being passed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l7JdpTDarl2YKsXS1_A6RQ.png" /><figcaption>postTestMemory Function</figcaption></figure><p><strong>isFunctioning</strong> is purely decorative — we don’t really need this in typescript. We are just simulating that the slot is powered and returning a 1 or a 0 basically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P-ynFN4UGcay2uXpIRi2pA.png" /><figcaption>isFunctioning function</figcaption></figure><h3>GPU Testing</h3><p>Again the *for* loop cycles through <strong>gpuSupporingSlots</strong> this time calling the <strong>postTestGPU</strong> function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2XrCdYzvOXzwMmSE62dXaQ.png" /><figcaption>GPU Testing for loop</figcaption></figure><p>As relayed earlier to reduce complexity around deploying a full bootloader the POST relies on a GPU not only being loaded but also including a valid option rom signature within its first two bytes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SIvylrJCu3m4r2RUBtvg4Q.png" /><figcaption>postTestGPU function</figcaption></figure><h3>Storage Testing</h3><p>The final *for* loop cycle continues with the same tests on storage with an additional check to add devices to a <strong>bootTable</strong> if the check returns true on a <strong>bootSignature</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q6KYGB5nl2uBY3t8-Og_iw.png" /><figcaption>Storage for loop</figcaption></figure><p>and the <strong>checkbootSignature</strong> function similar to our GPU check returns true if the MBR sectors last two bytes return a boot signature (`0x55, 0xaa`).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5MpihgpC2ZFrrXYhs-c3bA.png" /><figcaption>checkBootSignature function</figcaption></figure><h3>Finalising POST</h3><p>The last step in POST is a <strong>boolean</strong> return with a final update to our event log assuming all the tests have passed. This marks the conclusion of the POST function with our `Interrupt19h` being called next in the constructor should POST be successful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KliFQ72N8zQI16GiVwPoUg.png" /><figcaption>finalising POST</figcaption></figure><h3>Interrupts</h3><p>Currently the only Interrupt I have implemented in <strong>19h</strong>. Interrupt calls are invoked by operating systems and application programs as an interface to firmware. For our example we are using the <strong>19h</strong> call to load our “bootloader”. As mentioned earlier as we are going straight from BIOS to Kernel our <strong>19h</strong> call in this example will instantiate a new Kernel object. Using a <strong>switch case</strong> I have set the foundation for future interrupts with relevant event logging and comments as a reminder of the functionality of each call.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CMqkAWYApdKnrSx8zEXxQQ.png" /><figcaption>interrupt function</figcaption></figure><p>Finally the <strong>interrupt19h</strong> function will check the OS Signature and return a new kernel object accordingly (The return has not been implemented yet). This structure allows for me to create support for other operating systems in the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7p28-G9ZzXc8F5ulKkNc0Q.png" /><figcaption>interrupt19h function</figcaption></figure><h3>Conclusion and Next Phase</h3><p>I hope you enjoyed part one of my journey so far. This project has helped me really think outside the box, it has driven me to change and adapt things to match a paradigm and constraints. At this stage I am working on a NT Architecture kernel splitting objects and functionality between User and Executive mode with various services which will make up the core of the operating system being orchestrated accordingly. In part two (once I finish most of the kernel level structure and code) I will provide a lot more insight into the NT Architecture and the challenges I faced implementing my simulated approach.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=02253291ced6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Router, Vite and JWT Authentication]]></title>
            <link>https://medium.com/@asbedb/react-router-vite-and-jwt-authentication-9abf049c3f32?source=rss-4c65e73441ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/9abf049c3f32</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-router]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Asbed B]]></dc:creator>
            <pubDate>Tue, 18 Mar 2025 07:00:20 GMT</pubDate>
            <atom:updated>2025-03-21T13:35:31.610Z</atom:updated>
            <content:encoded><![CDATA[<p>This is meant to act as a summary and reference for implementing React Router with hashed authentication in your Vite project. The article reference project is made as a Single User Login using an .env file as basis to store credentials. It can be modified for multiple use cases.</p><h3><strong>**UPDATE**</strong> Medium breaks this article on mobile due to code blocks. For editable code blocks head to my docs page.</h3><p><em>For an editable code block </em><a href="https://docs.asbedb.com/articles/tech/reactrouterdom/"><em>head to my docs page</em></a><em> as medium seems to break on mobile when presented with a code block.</em></p><blockquote><strong>Like what you are reading? Check out my </strong><a href="https://www.linkedin.com/in/asbed/"><strong>LinkedIn</strong></a><strong> and </strong><a href="https://github.com/asbedb"><strong>GitHub</strong></a><strong> for more!</strong></blockquote><blockquote>Hello there, I’m Asbed! In the month of August 2024, I put myself on a path to develop my software engineering skills, I use this space to share updates and learnings on things I find interesting along the way.</blockquote><blockquote>Please note, I don’t claim to be an expert, nor do I pretend what I share is best practice. This is merely a space to see perspective and collaborate.</blockquote><blockquote><strong>If you enjoy what I do, consider supporting me on Ko-fi! Every little bit means the world! </strong><a href="https://ko-fi.com/asbedb"><strong>https://ko-fi.com/asbedb</strong></a></blockquote><h3>What is React Router?</h3><p>Well according to React Router themselves.</p><blockquote><em>React Router is a multi-strategy router for React bridging the gap from React 18 to React 19. You can use it maximally as a React framework or as minimally as you want. </em><a href="https://reactrouter.com/home"><em>Source</em></a></blockquote><p>The site goes on to explain there are three modes available. For the purposes of this exercise we are primarily focused on declarative components.</p><p>I recommend reading the <a href="https://reactrouter.com/start/modes">full documentation on React Router</a> should additional requirements pop up.</p><h3>Important Lessons</h3><p>As part of this exercise, the most important lesson to remember is the delineation between client and server. As we are using stored credentials, any interaction with those credentials needs to:</p><ol><li>Ensure that the communication of those credentials is encrypted.</li><li>Those credentials are not validated or exposed at a client level.</li><li>Restrict access to the sever when it comes to matters related to credentials is critical.</li></ol><h3>Prerequisites</h3><p>This article assumes you are familiar with Node, React, and have deployed a Vite project as the basis for your web application. The code provided is written in TypeScript.</p><h3>File Setup</h3><p>Below are the main files we will be working with in your pre installed Vite folder structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*ysFfo2cIwN6NPe6palWprQ.png" /></figure><h3>Dependencies</h3><p>The following dependencies are used in this project across both client and server (break down to follow):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*n844ZAgO99HK3H5T4_YGcQ.png" /></figure><h4>Client</h4><p><strong>These modules should be targeting your Vite project folder, ensure relevant</strong> package.json <strong>folders are updated with the correct dependencies.</strong></p><p>The below NPM command’s can be utilised to install relevant dependencies client side:</p><p><strong>Vite</strong> To create a new Vite project with React and TypeScript template:</p><p><strong><em>npm</em></strong><em> create vite@latest &lt;</em><strong><em>YOUR_PROJECT_NAME</em></strong><em>&gt; — — template react-ts</em></p><p><strong>react-dom</strong> To install react-dom:</p><p><strong><em>npm</em></strong><em> install react-dom</em></p><p><strong>react-router-dom</strong> To install react-router-dom (for routing):</p><p><strong><em>npm</em></strong><em> install react-dom</em></p><h3>Server</h3><p><strong>These modules should be targeting your</strong> server <strong>folder, to have a separate set of modules within your Vite project structure it is recommended to run the</strong> npm init -y <strong>command in your server&#39;s root directory prior to executing additional install commands.</strong></p><p>The below NPM command’s can be utilised to install relevant dependencies server side:</p><p><strong>dotenv</strong> To install dotenv (hold our server side secrets):</p><p><strong><em>npm</em></strong><em> install dotenv</em></p><p><strong>cors</strong> To install cors (allows for cross origin traffic filterting on our server):</p><p><strong><em>npm</em></strong><em> install cors</em></p><p><strong>express</strong> To install express (to host our server):</p><p><strong><em>npm</em></strong><em> install express</em></p><p><strong>jose</strong> To install jose (JWT utility):</p><p><strong><em>npm</em></strong><em> install jose</em></p><h3>Summary</h3><ol><li><strong>Client Dependencies</strong>: Make sure you’re installing the relevant modules (vite, react-dom, and react-router-dom) in the /src folder of your Vite project.</li><li><strong>Server Dependencies</strong>: Use npm init -y to initialize a package.json in your /server folder. Then, install the necessary server-side modules (dotenv, cors, express, and jose) there.</li><li><strong>Environment Configuration</strong>: Ensure that your .env file is placed in the /server folder for storing sensitive information like SECRET_KEY and other configuration details.</li></ol><h3>Server Configuration</h3><h3>/server/.env</h3><p>The user management side of things will be extremely simple, whilst a more complex system can be applied to manage multiple users authenticating. This article will focus on a single-user login using an .env file. The methodology applied is still very relevant as we are managing an Authenticated user with local storage authentication and routing accordingly. The same logic can be applied to a validated SQL Row as an example.</p><p>If you are unfamiliar with .env files and the significant role they may play in your application, I would recommend <a href="https://medium.com/@sujathamudadla1213/what-is-the-use-of-env-8d6b3eb94843">reading this article</a> alongside doing some additional research.</p><p>Below is an example .env file to examine:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*9KJXEKHQwo8I21ATvM0lvw.png" /></figure><p>We have three variables being stored: a username, password and secret which our application will interface with to verify a successful login.</p><h3>server/server.js</h3><p>Let’s dive into our server.js code:</p><p>The comment’s should provide a high level insight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xowj-1qAflYENdkG3_wzgg.png" /></figure><h4>/api/login</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*udxq9-QKHp_Ow3r6_q_9Cw.png" /></figure><p>Below is a break down of the above code:</p><p><strong>Defining the Login Route</strong>:</p><ul><li>A POST request is set up at the /api/login endpoint to handle login requests.</li></ul><p><strong>Request Body Validation</strong>:</p><ul><li>The incoming request body is de structured to extract username and password.</li><li>These are compared with the ADMIN_USERNAME and ADMIN_PASSWORD environment variables, effectively checking credentials for a single user login.</li></ul><p><strong>JWT Token Creation</strong>:</p><ul><li>If the credentials match, a JWT (JSON Web Token) is created using the username as the payload.</li><li>The token is signed using the HS256 algorithm, with the SECRET_KEY encoded to ensure secure hashing.</li></ul><p><strong>Token Metadata</strong>:</p><ul><li>The token is configured with:</li><li>setIssuedAt(): Marks the time the token was issued.</li><li>setExpirationTime(‘1h’): Sets the token to expire after one hour.</li><li>setProtectedHeader({ alg: ‘HS256’ }): Specifies the signing algorithm used.</li></ul><p><strong>Returning the Token</strong>:</p><ul><li>The generated JWT token is returned to the client in the response as a token object.</li><li>This token is then used for authenticating subsequent requests via middleware to access protected routes.</li></ul><h4>verifyToken</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hizwKpxbq4UqaH0vKAKFFA.png" /></figure><p>Below is a break down of the above code:</p><p><strong>Extracting the Token from the Authorization Header</strong>:</p><ul><li>The middle ware first checks the Authorization header and splits it by spaces. Typically, the header will have the format Bearer &lt;token&gt;, so we extract the token portion after the space.</li></ul><p><strong>Checking if the Token Exists</strong>:</p><ul><li>We ensure that the token exists. If it’s missing or null, the middle ware responds with a 403 Forbidden status and an error message saying &quot;No token provided.&quot;</li></ul><p><strong>Verifying the Token’s Validity</strong>:</p><ul><li>The token is then verified using jwtVerify function, which checks the token against the SECRET_KEY. If the token is valid and the signature matches, the middleware allows the request to proceed by calling next().</li></ul><p><strong>Error Handling</strong>:</p><ul><li>If there’s any issue with the token (e.g., invalid, expired, or tampered with), an error is thrown and caught returning a status of 401 Unauthorized denying access to the requested resource.</li></ul><h3>Summary</h3><p>At this point, we have a server with endpoints capable of handling authentication via JWT tokens. The client can request a token by providing valid credentials, and the server will issue a signed JWT. Subsequent requests to protected routes will require the token for access, ensuring that only authenticated users can reach sensitive endpoints.</p><h3>Client</h3><h3>App.tsx</h3><p>The App.tsx file serves as a &quot;gateway&quot; to the different routes available in your application. Traditionally, this file contains the core logic for how a user can navigate to various features of your app. For the purposes of this article, we will implement exactly that. As suggested by the file structure, our three main landing pages will be the Home Page, Login Page, and Dashboard Page.</p><p>Let’s have a look at the file and break it down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9fqbIhnlMdlFUDin4IS1aA.png" /></figure><h4>Import Statements</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zZMn-J5QfoSzetgXojBnHA.png" /></figure><p>Here we are doing three main imports:</p><p><strong>Global CSS</strong>: The App.css file for styling, which is standard in Vite&#39;s React TypeScript setup.</p><p><strong>React Router Components</strong>: We import Router, Routes, and Route from react-router-dom to enable routing functionality in the application.</p><p><strong>Custom Components</strong>: We import the Home, Login, and Dashboard components from the components folder to render the respective pages.</p><p><em>ProtectedRoutes: This is a custom utility component that handles protecting certain routes, ensuring only authenticated users can access them.</em></p><h4>Understanding BrowserRouter</h4><p>Router</p><p>The &lt;Router&gt;is the parent element for our &lt;Routes&gt;, aligning location context (Determining the URL Path). It is a declarative element that can either be a StaticRouter (used for server-side rendering) or a BrowserRouter (used for client-side rendering). In this case, we have declared our router to be a BrowserRouter, as Vite is optimised for client-side rendering.</p><p>Routes</p><p>The &lt;Routes&gt; component serves as the parent container that holds all of our &lt;Route&gt; logic. It allows the &lt;Router&gt; to match the current URL and render the appropriate components based on the matching route.</p><p>Route</p><p>All of our customisation will be done at this level. The &lt;Route&gt; is pointing our router to its final destination through the path property, returning the correct component based on the element property.</p><h4>JSX Return</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*owitDcDeIhuTkO1FupzQ8w.png" /></figure><p>Here’s a breakdown of the App.tsx JSX return:</p><ul><li><strong>Router Component</strong>: The &lt;Router&gt; wraps all of the routes to provide routing functionality based on the URL.</li><li><strong>Routes Component</strong>: Inside the &lt;Router&gt;, the &lt;Routes&gt; component holds all the &lt;Route&gt; definitions.</li></ul><p><strong>Paths and Components</strong>:</p><ul><li><strong>Home Page</strong>: The first route (&lt;Route path=&quot;/&quot; element={&lt;Home /&gt;} /&gt;) corresponds to the root URL (/). When a user visits the root path, the Home component is rendered.</li><li><strong>Login Page</strong>: The second route (&lt;Route path=&quot;/admin&quot; element={&lt;Login /&gt;} /&gt;) is for the login page. It matches the /admin path and renders the Login component.</li><li><strong>Dashboard Page (Protected)</strong>: The third route (&lt;Route path=&quot;/admin/dashboard&quot; element={&lt;Dashboard /&gt;} /&gt;) is nested inside a ProtectedRoutes wrapper. This ensures that only authenticated users can access the dashboard page at /admin/dashboard.</li></ul><p><strong>ProtectedRoutes Component:</strong></p><p>The ProtectedRoutes component is used to wrap the routes that require authentication. This ensures that only authenticated users can access the /admin/dashboard route. If the user is not authenticated, they will be redirected to the login page or shown an appropriate error message.</p><h4>Summary</h4><p>The App.tsx file is responsible for setting up routing in our application. It uses React Router’s BrowserRouter, Routes, and Route components to render different views based on the current URL:</p><ul><li><strong>Home</strong>: Accessible via the root URL (/).</li><li><strong>Login</strong>: Available at /admin.</li><li><strong>Dashboard</strong>: A protected route at /admin/dashboard that requires authentication.</li></ul><h3>/utils/ProtectedRoutes.tsx</h3><p>The ProtectedRoutes.tsx component acts as a wrapper for routes that require authentication. It checks if the user has a valid authorization token before allowing access to the child routes inside it. If the token is not valid or missing, the user is redirected to the login page.</p><p>Let’s have a look at the file and break it down:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*akKmC28IEi4PR0uQOygkuQ.png" /></figure><h4>Import Statements</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eRtCHzc6lzSSQthrwDBbSA.png" /></figure><p>We are not introduced to two new imports from react-router-dom:</p><ol><li><strong>useNavigate</strong>: The useNavigate function sends a navigation request when triggered, as of writing this article this is the preferred method of navigation suggested by React Router.</li><li><strong>Outlet</strong>: The Outlet element returns nested Routes of the parent component.</li></ol><h4>ProtectedRoutes() function</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gvXH4DAPm1o0Qh5qv-auOw.png" /></figure><p>Below is a break down of the above code:</p><p><strong>Setting Token and Navigation Variables</strong>:</p><ul><li>The function will be relying on a locally stored token from localStorage to determine the users authorisation status.</li><li>The function needs a navigate variable to trigger useNavigate</li></ul><p><strong>Token Validation</strong>:</p><ul><li>The useEffect hook is responsible for the validation based on changes to token or navigate</li><li>We ensure that the token exists prior to validation attempts.</li><li>The function then try’s the ap/protected endpoint where we have written our token verification function server side.</li><li>Should the signatures match and the token is deemed valid the router allows for children via the &lt;Outlet/&gt; to be rendered</li></ul><p><strong>Error Handling</strong>:</p><ul><li>If there’s any issue with the token (e.g., invalid, expired, or tampered with), an error is thrown any instance of the local token is deleted and the user is returned to the unprotected /admin page.</li></ul><h3>Dashboard Login and Home:</h3><p>The Dashboard and Home components are quite open-ended. You can include whatever JSX you are comfortable with. The only suggestion I would make is including a &lt;button&gt; component (or something similar) in the Dashboard to allow the user to log out.</p><h3>/components/Login.tsx</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nqPZc5WYQnFxyHsiK2Rz1Q.png" /></figure><p>The above code should now be familiar and fairly easy to follow. If you have worked with React Query (Tanstack) before or any other API try/catch style requests, then it is clear we are pinging our API endpoint and validating a login form, returning a local storage item.</p><h3>/components/Dashboard.tsx</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BbI61CSKzRcIpcBlak8w3A.png" /></figure><p>As previously mentioned, including a handleLogout function will allow the user to return to a logged-out state. Here, you can see we are removing the authentication token from local storage, causing the user to be returned to an unauthenticated state.</p><h3>Conclusion</h3><p>Overall, this was a great exercise with a lot to learn about how routing works. It taught me some great techniques in dealing with the security of communicating credentials and has given me some topics to research further. I’m excited to see where this journey leads me next.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9abf049c3f32" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What I Learned Deploying NGINX Proxy Manager]]></title>
            <link>https://medium.com/@asbedb/what-i-learned-deploying-nginx-proxy-manager-f47271d230d6?source=rss-4c65e73441ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/f47271d230d6</guid>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[hosting]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[proxy-server]]></category>
            <category><![CDATA[servers]]></category>
            <dc:creator><![CDATA[Asbed B]]></dc:creator>
            <pubDate>Fri, 28 Feb 2025 07:03:16 GMT</pubDate>
            <atom:updated>2026-09-25T07:40:59.447Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TQffesxe8x26WWTK.jpg" /><figcaption>image credit: <a href="https://www.blackvoid.club/nginx-proxy-manager/">https://www.blackvoid.club/nginx-proxy-manager/</a></figcaption></figure><p>It was a beautiful morning in Melbourne. I had just gotten up preparing for my day. Today’s task was continuing a front end Vite project and reviewing some content on Data Structures and Algorithms (so, hot right now). When suddenly, a notification from one of my learning adjacent communities, unfurled a chain of events eventuating to the deployment of NGINX Proxy Manager.</p><p>Along the journey there were a few moments oh which I felt were worthy to share, not only for those who are discovering the technology for the first time, but for myself also, a place to come back and reference should I need to revise.</p><p>Before we start with the basics — throughout this process, Cloudflare as an organisation really stood out for me. It was my first time interacting with their products and I have to say kudos where kudos is due.</p><p>I am sure there are some valid criticisms out there, however based on my personal use case, there were stark contrasts compared to the alternatives.</p><p>In addition, they do a tremendous job in providing documentation and education on networking related topics (a page taken out of the book of Cisco no doubt.)</p><h3><strong>What is a proxy server?</strong></h3><p>The below image is a great representation of how a proxy server helps collate and add services related to traffic flowing out of a private network.</p><p>As an example, this could be a school using web filtering to block access to content, an anonymiser to protect the identity of a user, or even a tool to help circumvent institutional browsing restrictions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*l50G4rLKn5AUtObNpC8ucg.png" /><figcaption>Image Source: <a href="https://www.cloudflare.com/en-au/learning/cdn/glossary/reverse-proxy/">https://www.cloudflare.com/en-au/learning/cdn/glossary/reverse-proxy/</a></figcaption></figure><blockquote>“A forward proxy, often called a proxy, proxy server, or web proxy, is a server that sits in front of a group of client machines. When those computers make requests to sites and services on the Internet, the proxy server intercepts those requests and then communicates with web servers on behalf of those clients, like a middleman.” — <a href="https://www.cloudflare.com/en-au/learning/cdn/glossary/reverse-proxy/">Source</a></blockquote><h3><strong>What is a reverse proxy?</strong></h3><p>As you may have guessed, a reverse proxy sits in front of web servers and controls how client requests reach them, rather than controlling outbound client traffic like a forward proxy. (the two are not mutually exclusive and can work in tandem).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*EVb9U3-rBLhpY9qo9IKxLg.png" /><figcaption>Image Source: <a href="https://www.cloudflare.com/en-au/learning/cdn/glossary/reverse-proxy/">https://www.cloudflare.com/en-au/learning/cdn/glossary/reverse-proxy/</a></figcaption></figure><blockquote>“A reverse proxy is a server that sits in front of web servers and forwards client (e.g. web browser) requests to those web servers “ – <a href="https://www.cloudflare.com/en-au/learning/cdn/glossary/reverse-proxy/">Source</a></blockquote><h3><strong>Why have a reverse proxy can’t you just link directly to a server?</strong></h3><p>Reverse proxies are typically implemented to help increase security, performance, and reliability. Yes, you can link directly to a server however this practice comes with many risks including (and not limited to) making it easier for threat actors seek holes in your server’s security.</p><h3><strong>NGINX</strong></h3><p>As the title of this article suggests we are primarily looking at NGINX Proxy Manager — NGINX (Pronounced Engine X [or<em> Ehn Jinx if you are cool like me and mispronounce GIF as well]</em>). Is one of the many unsung heroes of web, helping serve you web content since 2004.</p><p>Whilst most of us browse the internet with a Windows device. A lot of the servers are running on open-source Linux based applications and operating systems. <br> <br>One thing I do want to note, which is important to understanding the nature of proxy managers and effectively can be applied to any application, a mantra I regularly chant for software I’m developing, implementing or running.</p><blockquote><em>“Use the right tool for the right job”</em></blockquote><p>NGINX Proxy Manager is primarily used for web proxy filtering and web traffic. It is not a tool to manage proxies into non web traffic servers (gaming servers as an example) — There are other ways to achieve that.</p><p>NGINX is a collection of web server applications which includes reverse proxy, load balancing, caching and HTTPS. Like most things popular and open-source, it has a <a href="https://github.com/nginx/nginx">passionate community of contributors</a> maintaining and managing the repository inspiring over 7,000 forks (potential offshoots) and over 26,000 stars (the GitHub term for likes). It also serves as the core to the NGINX Proxy Manager.</p><h3><strong>What are the prerequisites (loosely).</strong></h3><p>There are a few ways to approach the next steps — so I won’t go into detail, rather I will provide guidance and general advice on how it may work for you.<br> <br> 1. <strong>Hardware — </strong>As the images in the introduction suggest, whether it’s in the public cloud or you are self-hosting. To set up a proxy server effectively you need a minimum of two servers. One acting as your reverse proxy device and one that is hosting your web services/applications. You can technically utilise the same server to run a proxy manager and web apps however this will detract from the security benefits provided.</p><p><strong>2. The ability to run Linux on the hardware.</strong><br> <br><strong> 3.</strong> <strong>Some understanding of Docker technology</strong> — will go a long way in simplifying this process. My deployment utilised Docker to deploy a container running NGINX Proxy Manager which had the service up and running in no time. (<a href="https://docs.docker.com/get-started/docker-overview/">See docker documentation</a> if you are unsure on what Docker) <br> <br><strong> 4.</strong> <strong>A domain</strong> — that will act as the address to your server.</p><p><strong>5.</strong> <strong>Some (Not necessarily in depth) networking knowledge</strong> — At a minimum understanding what purpose IP Addresses, Ports and Firewalls serve and how you could configure those particularly on your host machine. <br> <br><strong>6.</strong> <strong>If you are self-hosting</strong> — policies you should implement on your host when it comes to tunnelling to your proxy server along side firewall rules, this is very important in managing what is exposed to the rest of your network.</p><h3><strong>How I implemented the stack to work for me.</strong></h3><p>Again the reason I have titled this section this way is because everyone’s configurations will differ slightly, in my scenario I was hosting my proxy manager on a VPS (Virtual Private Server) and pointing it to another VPS. More commonly the manager is used to tunnel to a server that is self-hosted to ensure host IP is obfuscated reducing risk to an administrator’s home network.</p><h3><strong>Virtual Private Server</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Idn6sYgRD4aNeCmhGK15iA.png" /><figcaption>Screenshot of the Binary Lane Website</figcaption></figure><p>The first thing I needed was a VPS. This wasn’t my first time requiring such a service and as I am running a developer environment where things aren’t necessarily going to be permanent, I decided to use a great Australian service provider I have used in the past called <a href="https://www.binarylane.com.au/">BinaryLane</a>.</p><p>With some of the VPS options starting at $4 a month it’s just a no brainer to me. I’m sure there’s plenty out there this just comes down to personal choice and what features are important for you. As a side note the proxy manager on it’s own has very minimal hardware requirements and can even run on a Raspberry Pi.</p><h3><strong>Docker</strong></h3><p>Once our Ubuntu server was up and running in the cloud, we immediately had the option to remotely connect and work on it just like you would a virtual or local server. I ran your regular Linux upgrade, install get commands to ensure everything was up to date and proceeded to<a href="https://docs.docker.com/engine/install/ubuntu/"> install docker</a> as it would be the primary method to install/manage/maintain and deploy images for me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*df41KRU8SyfdLrEv5s24LA.png" /><figcaption>A screenshot of Docker Documenation</figcaption></figure><p>From here there are multiple routes available — for those more experienced with Docker following the <a href="https://nginxproxymanager.com/setup/">installation guide for NGINX Proxy Manager</a> should be self-explanatory . That said there is a more guided approach available if the task is daunting.</p><p>I know there are plenty of CLI (Command Line Interface) enthusiasts out there that despise the idea of a Graphical User Interface (NeoVIM advocacy intensifies) thankfully there are also developers who understand humans can also process things in layouts and interfaces and sometimes (hear me out), it makes it easier for us to complete/achieve things if they are laid out a certain way.</p><h3><strong>Portainer</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*XDgJAoXhAR29xsHvwIydWA.png" /><figcaption>Screenshot of Portainer</figcaption></figure><p>Portainer is a tool/Docker application (with a free option available) allowing you to manage/visualise and deploy docker containers through a Web GUI, you deploy it as a docker app and proceed to browse to your <strong>serverip:port</strong> to complete the setup. From there you can run the rest of your docker experience through the browser with minimal CLI interaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*wIZf1p74dJq8O8NrP2uzRg.png" /><figcaption>Screenshot of Portainer Settings Where App templates can be found</figcaption></figure><p>One of the handy features Portainer brings to the table is the integration of application templates (App Templates) making deploying your containers a breeze. Communities maintain and share beneficial templates, typically as JSON files on GitHub, allowing others to use them.</p><p>For my deployment I used the <a href="https://github.com/novaspirit/pi-hosted">pi-hosted</a> template which can be found <a href="https://raw.githubusercontent.com/pi-hosted/pi-hosted/master/template/portainer-v2-amd64.json">here</a>, depending on the version of NGINX Proxy Manager you seek, there may be a need for a different application template that includes your version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*s0WHQ209a6Ah_-twv-GIuQ.png" /><figcaption>Screenshot of NGINX Proxy Manager v2 with Sqlite in App Templates</figcaption></figure><h3>Odd Portainer Issue</h3><p><em>Side Note: </em>As with a lot of things which are free and highly customisable I hit an “odd” issue here — depending on when you are reading this either this method is outdated, or the issue has been resolved.</p><p>That said using the above JSON (and in general any other JSON I tried) I found that there was a visual glitch which re renders my search results rather than letting me proceed with the deployment of the container — the band aid solution to this is. <br> <br><strong>1.</strong> Ensure your search results are correct, and your required container is displayed.<br><strong>2.</strong> Go back to your app settings and modify your JSON address slightly (I just changed v2 to v3). <em>This technically is not a real file from what I have gathered it removes the polling to render the app list.</em> <br><strong>3.</strong> Return to your search results and you should be able to click through to deploy container.</p><h3><strong>Final Menu for Deployment</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*SLN5v0me3MBR4YvYaQPI0Q.png" /><figcaption>Screenshot of a Container Ready to install in Portainer</figcaption></figure><p>From here you are free to deploy the proxy manager accordingly — ensure to select the correct network when deploying. By default, the container is deployed to ports 443, 80 and 81.</p><h3><strong>Finalising NGINX Proxy Manager Installation</strong></h3><p>You will now have access to your NGINX Proxy Manager through a Web GUI on port 81 (if you are using default ports). Your initial login will be set to the default of<br> <br> Email: <a href="/service/mailto:admin@example.com">admin@example.com</a><br> password: changeme</p><p>The first login will prompt you to change these settings immediately.</p><h3><strong>Domain Management (Cloudflare)</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*pzckbV7k8YEt8Om1g8fDdg.png" /><figcaption>Image Source: cloudflare.com</figcaption></figure><p>Here is where our path’s may split — My scenario required me to take some additional steps to move my name servers to Cloudflare yours could be different.</p><p>If for some reason you are having trouble with your domain name service provider, whether it’s revoked access to API’s (issue I had) or something else. The good news is Cloudflare at its free tier gives you everything you need to do this step.</p><p>The domain itself is of course going to be pointed to your proxy manager. The Domain Name System (DNS) layer provided is critical to ensuring you can resolve to these services with a layer of security through the browser (Secure Sockets Layer — SSL). <em>Yes I know it’s TLS now, trying to keep it simple.</em><br> <br>NGINX Proxy Manager creates and authorises these SSL certificates through a service called Let’s Encrypt and if your DNS provider allows it, you can automatically update those certificates without the need to manually intervene. This would be through an application programming interface (API) managed by the provider. <br> <br> Why automate? — for arguments sake let’s say your domain is foo.com, browsing to this page resolves to a basic home page running on a standard web server you are hosting.</p><p>You decide to run another web server for your blog but now you need an address to point to that server. <br> <br> If the environment is setup correctly you will have the ability to make browsing to multiple routes predictable utilising an automated system that creates subdomains (blog.foo.com as an example), generates SSL certificates and manages those for the life of the configuration — steps that would be extremely tedious to manage on a regular basis as your infrastructure/services grow and change.</p><h3><strong>So, what did I do with Cloudflare?</strong></h3><p>As mentioned, I quickly realised I needed to move my nameservers to Cloudflare as I had an issue with the original provider revoking access to API’s (needed for certificate automation). <br> <br>I made an account, selected the free tier and used an automated service to transfer the existing DNS records across. In my scenario I needed to update the name servers to Cloudflare for the transfer to take place. (the wizard they provide is self-explanatory). <br> <br>From here there are two DNS Records I was primarily interested in — again this may be different for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*rpXmP8y7yubSWW5KqVP8tg.png" /><figcaption>A screenshot of the cloudflare DNS Record Management System</figcaption></figure><p><strong>A Record —</strong> A stands for Address and is the most fundamental type of DNS it contains the IP address of a given domain. example, if you pull the DNS records of cloudflare.com, the A record currently returns an IP address of 104.17.210.9 (Note: A records only hold IPV4 Addresses for IPV6 you need AAAA).</p><p><strong>CNAME Record — </strong>CNAME stands for canonical name in short these are used as an alias and commonly provided as a record for a sub domain. <br> <br><strong>Additional note in DNS records to consider</strong> — naming conventions utilise the <strong>*</strong> character as a wildcard helping route anything that might be utilised as input in place. In the below example we use the wildcard to cover sub domains. <br> <br> I have put together a table further explaining how this can be implemented:<br> <br> <strong><em>Example Domain:</em></strong><em> foo.com</em></p><p><em>With the below DNS Records including the wildcard for the second CNAME.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0QOJKM7R5nSbDkYIXbKAwQ.png" /><figcaption>Example DNS Table</figcaption></figure><p><em>We would reroute any s</em><strong><em>ubdomain.foo.com</em></strong><em> alongside the </em><strong><em>foo.com</em></strong><em> domain itself to the IP</em><strong><em> Address of our reverse proxy server</em></strong><em> thus having all traffic to that address now managed by our reverse proxy server.</em></p><h3><strong>Quick Side Rant (API Related)</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*VCtm56jz8edxK9yv.jpg" /><figcaption>Image Source: <a href="https://www.behance.net/gallery/10500093/Dinosaur-Car-Named-Dinobeelte">https://www.behance.net/gallery/10500093/Dinosaur-Car-Named-Dinobeelte</a></figcaption></figure><p>One of the things I have become a lot more appreciative of is organisations that don’t maximise their profits at the cost of those who make their products more desirable. I’ll give you an example. <br> <br> Let’s make up a fictitious car make and model for this analogy. The <em>Hundord Raploster</em> — (why not) — and let’s say the <em>Raploster </em>on launch had an average at best reception. <br> <br> One day, a group of clever engineers realised that the <em>Raploster </em>had a system or mechanism that if modified, could save the average consumer half a tank of fuel every week. They build this system — believe in a philosophy that allows everyone to have access to this great technology and push it out there for people to improve on modify and use.<br> <br> <em>Hundord </em>in it’s great wisdom sees a potential to maximise profits, the next iteration of the car now has a padlock on the mechanism that allows for you to implement this modification, They advise <em>Raploster</em> owners that the padlock can only be unlocked with a key magically provided by <em>Hundord </em>(With the payments usually being a subscription model in which <em>Hundlord </em>can change the padlock and make you pay more for different tiers of padlock keys!).<br> <br> I think the analogy should resonate with now — simply put, don’t alienate a community of enthusiasts who make your product better for small profit gains. These communites grow demand, trust and market presence. Alienating them means losing sales as they will go straight to your competitor and give them the free hype and expertise.</p><p>On that note…</p><h3><strong>Cloudflare API (and Certbot)</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*alw4tszmsFaxRzdsiDl6mg.png" /><figcaption>Screenshot of the Cloudflare API Menu</figcaption></figure><p>Yes, the Cloudflare API is available to use on the free tier. It’s super simple to setup and through a few clicks you can get your API key. You can also segregate your keys to ensure interfaces are only accessible to the zones you have approved should you have multiple zones being managed.</p><p>This will serve as the interface between your proxy server and Cloudflare.</p><h3><strong>NGINX Proxy Manager</strong></h3><p><strong><em>A quick reminder before we continue: </em></strong>As mentioned the reverse proxy method is one of many ways to add a security layer between your server and client. <strong>It does not replace other techniques</strong> such as firewall management and traffic segregation, a robust security strategy must always be considered on the host itself — food for thought when you have nodes publicly accessible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*r98FVl4oTf9SZWjpwRu1JA.png" /><figcaption>Screenshot of the NGINX Proxy manager homepage</figcaption></figure><p>And with that lets return to NGINX Proxy Manager ready to finalise our routes. This journey is near its completion and if you have made it this far the good news is the last few steps are simple.</p><p>This is in no way an in-depth guide to the dashboard or the various options available, my use case was a simple redirect. That said, there are plenty of features you can explore outside of this context highly useful for different scenarios.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*xLzj7pwEB1ygB-uo_HFzIg.png" /><figcaption>Screenshot of NGINX Proxy Manager SSL Certificates Page</figcaption></figure><p>The first step to take was to ensure we had SSL Certifications set up with Let’s Encrypt alongside a valid connection to our Cloudflare API — by now we have a key and all relevant details ready to go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*thvFR5EzllRy7y76Bq7P-w.png" /><figcaption>Screenshot for adding Encryption Certificates</figcaption></figure><p>The menu presented asks for your domains, a valid email alongside your DNS provider (in our case Cloudflare). For the domain field it is important to include both <strong>base domain (foo.com) </strong>along with your <strong>wildcard domain (*.foo.com)</strong> you must <strong>press enter</strong> after typing <strong>each domain.</strong></p><p>I will say the UI experience is not overly intuitive the first time you use it, so these small mistakes are likely to happen.</p><p>Once you have completed this step and everything is green on your dashboard. You can now navigate to your base domain, and it should return a <strong>congratulations</strong> page with a valid SSL certificate.</p><p>The contents of this page do acknowledge that the domain points to a proxy server. This might not be something you want to advertise, thankfully within the dashboard you can change the default site through the settings tab — if setup correctly any non-routed sub domain would redirect to this default site. <br> <br> Now that certifications are checked off we are ready to route some hosts!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*6aWQ0EYhPEMVk8TFrZPi_Q.png" /><figcaption>Screenshot of proxy host popup</figcaption></figure><p>Head on over to your Hosts Tab&gt;Proxy Hosts and hit the Add Proxy Host button — from here you can assign the following settings:</p><p><strong>· A domain or subdomain</strong> — for example blog.foo.com (don’t forget to hit enter).</p><p><strong>· The forward hostname</strong> — Address to your hosted server.</p><p><strong>· Scheme of your host </strong>— HTTP or HTTPS.</p><p><strong>· Security Settings </strong>provided through NGINX Proxy Manager around exploits and websockets.</p><p><strong>· Access Lists</strong> — Restrict who can access the host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*a_hMSJ6q5417hDhLoVBfyg.png" /></figure><p>Additionally SSL is important to configure (found in the pop up upper tabs) to avoid browser presented errors — Here you can assign your generated SSL certificate to your domain/subdomain<br> <br><strong> </strong>🎉<strong>And with that final step completed and the save button clicked, your host should now have a reverse proxy address that can be accessed in accordance with how you have set it up!</strong>🎉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f47271d230d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>