
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
>
  <channel>
    <atom:link href="http://wwww.shubham-maurya.vercel.app/rss.xml" rel="self" type="application/rss+xml" />
    <title>Shubham Maurya</title>
    <link>https://shubham-maurya.vercel.app</link>
    <description>I transform ideas into interactive reality by coding.</description>
    <image>
      <url>https://shubham-maurya.vercel.app/favicon.svg</url>
      <title>Shubham Maurya</title>
      <link>https://shubham-maurya.vercel.app</link>
      <width>32</width>
      <height>32</height>
    </image>
    
        <item>
          <guid>https://shubham-maurya.vercel.app/flutter-pos-app</guid>
          <title>Flutter POS App</title>
          <description>Building a Modern POS App with Flutter - From Orders to Insights</description>
          <link>https://shubham-maurya.vercel.app/flutter-pos-app</link>
          <pubDate>Thu May 14 2026 00:00:00 GMT+0000 (Coordinated Universal Time)</pubDate>
          <category>Flutter</category><category>Supabase</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/flutter-pos-app">
                  read on the site!
                </a>
              </strong>
            </div>

            <p>Most small cafes and food businesses don&#39;t fail because of bad food - they struggle because of inefficient <strong>operations</strong>.</p>
<p>Manual order tracking, missed entries, inconsistent billing, and lack of insights create friction every single day.</p>
<p>I wanted to solve this.</p>
<p>So I built a <strong>cross-platform POS (Point of Sale) app using Flutter</strong> - focused on speed, simplicity, and real-world usability.</p>
<hr>
<h3 id="the-problem">The Problem</h3>
<p>In many small setups:</p>
<ul>
<li>Orders are tracked manually or loosely</li>
<li>Missed orders = lost revenue</li>
<li>No visibility into daily sales or top items</li>
<li>Billing is inconsistent</li>
<li>Printing is unreliable or unavailable</li>
<li>Apps don&#39;t work across devices (Android, desktop, etc.)</li>
</ul>
<p>What they need is not a &quot;complex ERP system&quot;.</p>
<p>They need:<br>Fast. Simple. Reliable.</p>
<hr>
<h3 id="the-solution">The Solution</h3>
<p>A lightweight POS system that handles:</p>
<ul>
<li>Order creation (with variants)</li>
<li>Billing &amp; receipt printing</li>
<li>Sales tracking</li>
<li>Backdated entries (for missed orders)</li>
<li>Works across multiple platforms</li>
</ul>
<p>Built entirely using <strong>Flutter</strong>, with Supabase as backend</p>
<hr>
<h3 id="core-features">Core Features</h3>
<div style="display: flex;overflow-x:auto;gap:1em">
    <img src="https://shubham-maurya.vercel.app/images/blogs/flutter-pos-app/order-screen.png" alt="Order Screen" width="200" style="border-radius: 0.7rem; margin-inline: auto;" />
    <img src="https://shubham-maurya.vercel.app/images/blogs/flutter-pos-app/order-creation-screen.png" alt="Order Creation Screen" width="200" style="border-radius: 0.7rem; margin-inline: auto;" />
    <img src="https://shubham-maurya.vercel.app/images/blogs/flutter-pos-app/order-creation-variant.png" alt="Order Creation Screen" width="200" style="border-radius: 0.7rem; margin-inline: auto;" />
    <img src="https://shubham-maurya.vercel.app/images/blogs/flutter-pos-app/order-creation-sideitem-added.png" alt="Order Creation Screen" width="200" style="border-radius: 0.7rem; margin-inline: auto;" />
</div>

<h4 id="1-smart-order-management">1. Smart Order Management</h4>
<ul>
<li>Add items quickly with search &amp; suggestions</li>
<li>Support for variants (e.g., Steamed &amp; Fried)</li>
<li>Same item with different variants treated separately</li>
<li>Custom items supported (non-menu entries)</li>
</ul>
<p>This allows flexibility without breaking structure.</p>
<hr>
<h4 id="2-accurate-pricing-engine">2. Accurate Pricing Engine</h4>
<p>Each order item calculates:<br>Total = Quantity x (Base Price + Variant Price Delta)</p>
<p>This ensures:</p>
<ul>
<li>Transparent billing</li>
<li>Correct totals even with customizations</li>
</ul>
<hr>
<h4 id="3-receipt-printing-escpos">3. Receipt Printing (ESC/POS)</h4>
<figure class="w-full h-full object-cover">
    <img src="https://shubham-maurya.vercel.app/images/blogs/flutter-pos-app/receipt-printing.png" alt="Receipt Printing" width="200" style="border-radius: 0.7rem; margin-inline: auto;" />
    <figcaption class="mt-4 text-center text-base text-current">Receipt Printing</figcaption>
</figure>

<p>One of the most importatnt parts of any POS<br>The app supports:</p>
<ul>
<li>Bluetoot / USB printers</li>
<li>58mm / 72mm / 80mm thermal printing</li>
<li>QR-based payments (UPI)</li>
<li>Structured receipts with:<ul>
<li>Items</li>
<li>Variants</li>
<li>Totals</li>
<li>Branding</li>
</ul>
</li>
</ul>
<p>And importantly:<br>Reliable printing with chunked writes (avoiding buffer crashes)</p>
<hr>
<h4 id="4-sales--analytics-dashboard">4. Sales &amp; Analytics Dashboard</h4>
<figure class="w-full h-full object-cover">
    <img src="https://shubham-maurya.vercel.app/images/blogs/flutter-pos-app/analytics-screen.png" alt="Sales Screen" width="200" style="border-radius: 0.7rem; margin-inline: auto;" />
    <figcaption class="mt-4 text-center text-base text-current">Sales Screen</figcaption>
</figure>

<p>Not just order-taking -- decision-making</p>
<p>The app provides:</p>
<ul>
<li>Revenue for selected date range</li>
<li>Total orders</li>
<li>Average order value</li>
<li>Top-selling items</li>
</ul>
<p>This helps answer:<br>What sells the most?<br>What earns the most?</p>
<hr>
<h4 id="5-backdated-orders">5. Backdated Orders</h4>
<p>In real operations:<br>Orders get missed.</p>
<p>So the app allows:</p>
<ul>
<li>Selecting a custom date while creating/editing orders</li>
<li>Logging past entries acurately</li>
</ul>
<p>This is critical for</p>
<ul>
<li>Daily reconciliation</li>
<li>Accounting accuracy</li>
</ul>
<hr>
<h4 id="6-intelligent-search--suggestions">6. Intelligent Search &amp; Suggestions</h4>
<figure class="w-full h-full object-cover">
    <img src="https://shubham-maurya.vercel.app/images/blogs/flutter-pos-app/order-creation-sideitem.png" alt="Order Creation Screen" style="border-radius: 0.7rem;margin-inline:auto;" class="w-full md:w-4/5" decoding="async" />
    <figcaption class="mt-4 text-center text-base text-current">Custom Item search & suggestions</figcaption>
</figure>

<p>Typing: &quot;Cola&quot;<br>Matches: &quot;Coca Cola&quot;<br>With:</p>
<ul>
<li>Highlighted matches</li>
<li>Price autofill</li>
<li>Fast entry workflow</li>
</ul>
<hr>
<h4 id="7-adaptive-ui-speed-first-design">7. Adaptive UI (Speed-first Design)</h4>
<p>Designed for fast interaction:</p>
<ul>
<li>Draggable cart (collapsed -&gt; expanded)</li>
<li>Sticky total bar</li>
<li>Variant selection sheets</li>
<li>Minimal navigation</li>
</ul>
<p>Everything is optimized for:<br>Tap -&gt; Decide -&gt; Complete</p>
<hr>
<h4 id="8-dark-mode--theming">8. Dark Mode &amp; Theming</h4>
<ul>
<li>Fully theme-driven UI</li>
<li>Consistent design system</li>
<li>Works across light/dark modes</li>
</ul>
<hr>
<h4 id="9-accesibility-handling">9. Accesibility Handling</h4>
<p>Instead of breaking layouts on large font sizes:</p>
<ul>
<li>Text scaling is clamped intelligently</li>
<li>Layouts use flexible constraints</li>
<li>Critical UI remains usable</li>
</ul>
<p>Balancing:<br>Accessibility × Usability</p>
<hr>
<h4 id="10-sound--haptics-pos-feedback">10. Sound &amp; Haptics (POS Feedback)</h4>
<figure class="w-full h-full object-cover">
    <img src="https://shubham-maurya.vercel.app/images/blogs/flutter-pos-app/settings-screen.png" alt="Settings Screen" width="200" style="border-radius: 0.7rem; margin-inline: auto;" />
    <figcaption class="mt-4 text-center text-base text-current">Settings screen</figcaption>
</figure>

<ul>
<li>Click sound on item add</li>
<li>Success / error feedback</li>
<li>Low-latency playback for rapid taps</li>
</ul>
<p>This creates a responsive, tactile experience</p>
<hr>
<h3 id="multi-platform-by-design">Multi-Platform by Design</h3>
<p>Built with Flutter, the app runs on:</p>
<ul>
<li>Android, iOS (primary POS device)</li>
<li>Linux, Windows (desktop POS setup)</li>
<li>Web</li>
</ul>
<p>This enables:<br>Same codebase -&gt; multiple environments</p>
<p>Perfect for growing businesses</p>
<hr>
<h3 id="tech-stack">Tech Stack</h3>
<ul>
<li>Flutter -&gt; UI + cross-platform</li>
<li>Supabase (Postgres) -&gt; backedn + RPC</li>
<li>ESC/POS printing -&gt; hardware integration</li>
<li>Hive -&gt; local caching</li>
<li>Custom design system -&gt; consistent UI</li>
</ul>
<hr>
<h3 id="key-engineering-decisions">Key Engineering Decisions</h3>
<h4 id="1-rpc-driven-backend">1. RPC-driven backend</h4>
<p>Complex operations (orders + variants) handled in Postgres:<br>Fewer API calls<br>Better performance<br>Cleaner client code</p>
<h4 id="2-variant-first-data-model">2. Variant-first data model</h4>
<p>Instead of duplicating items:<br>Menu Item + Variant Groups + Options<br>-&gt; flexible and scalable</p>
<h4 id="3-chunked-printing">3. Chunked printing</h4>
<p>Avoids:<br>Bluetooth buffer overflow crashes<br>-&gt; stable printing experience</p>
<h4 id="4-controlled-text-scaling">4. Controlled text scaling</h4>
<p>Prevents:<br>Broken layouts on high font sizes<br>-&gt; production-ready UI</p>
<hr>
<h3 id="what-this-app-solves">What This App Solves</h3>
<p>At its core:<br>It removes friction from daily operations</p>
<ul>
<li>Faster billing</li>
<li>Fewer missed orders</li>
<li>Better visibility into sales</li>
<li>Reliable printing</li>
<li>Works across devices</li>
</ul>
<hr>
<h3 id="whats-next">What&#39;s Next</h3>
<p>Possible future improvements:</p>
<ul>
<li>Sales charts (daily / weekly trends)</li>
<li>Category-wise analytics</li>
<li>Export reports (PDF / CSV)</li>
<li>Inventory tracking</li>
<li>Multi-user roles</li>
</ul>
<hr>
<p>This project started as a simple POS tool.<br>But it evolved into: A complete operational system for small food businesses<br>The focus was never just features -<br>It was:<br>Speed, reliability, and real-world usability.</p>
<p>If you&#39;re building something similar or exploring Flutter for production apps, I&#39;d love to hear your thoughts.</p>

          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/blogs/flutter-pos-app/cover.png"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/blogs/flutter-pos-app/cover.png"/>
        </item>
      
        <item>
          <guid>https://shubham-maurya.vercel.app/hot-reloading-with-c</guid>
          <title>Hot Reloading with C</title>
          <description>How to add hot reloading in a C project</description>
          <link>https://shubham-maurya.vercel.app/hot-reloading-with-c</link>
          <pubDate>Sat May 11 2024 00:00:00 GMT+0000 (Coordinated Universal Time)</pubDate>
          <category>C</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/hot-reloading-with-c">
                  read on the site!
                </a>
              </strong>
            </div>

            <p>Hot reloading refers to the process of updating code or resources in a running application without requiring a full restart. This is particularly useful during development or in situations where continuous uptime is crucial.<br>It allows developers to make changes to their code or assets (such as images, config files) while the application is running, and see those changes reflected immediately without having to restart the application.</p>
<p>When we think of hot reloading we usually think of a dynamic, interpreted programming language like JavaScript or Python.<br>But we can also achieve hot reloading in C using <strong>Dynamic Link Libraries (DLLs)</strong></p>
<p>Dynamic Link Libraries (DLLs) are commonly to provide reusable code that can be shared across multiple applications. One of the advantages of DLLs is their ability to be dynamically loaded and unloaded by programs, which enables features like hot reloading.</p>
<p>Here&#39;s how hot reloading typically works:</p>
<ul>
<li>Trigger: A trigger is something that causes the reload. It can be a key-event or changes in a file.</li>
<li>Pre-Reload: It is used to store the state before the reloading.</li>
<li>Post-Reload: Post-reload is called after the reload.</li>
</ul>
<p>Let&#39;s implement this in C
Starting with a <code>main.c</code> file let&#39;s write a basic hello world program.</p>
<pre><code class="language-c">~filename main.c
#include &lt;stdio.h&gt;

int main (void)
{
  printf(&quot;Hello World\n&quot;);
  return 0;
}
</code></pre>
<p>Now we can start implementing module which consists of two files:</p>
<ul>
<li>module.h - declarations which will be included in the main file</li>
<li>module.c - definitions of the functions defined in module.h header file</li>
</ul>
<pre><code class="language-c">~filename module.h
#ifndef MODULE_H_
#define MODULE_H_

void (*module_init)(void) = NULL;
void *(*module_pre_reload)(void) = NULL;
void (*module_post_reload)(void *) = NULL;
void (*module_update)(void) = NULL;

#endif // MODULE_H_
</code></pre>
<p>Lots of <code>void</code> in this file but we are just declaring the function signature as pointer so that it can be included in the <code>main.c</code> file.</p>
<p>Now let&#39;s define these functions in <code>module.c</code> file.</p>
<pre><code class="language-c">~filename module.c
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;assert.h&gt;

// Defining a struct state that has to be persisted
typedef struct {
  char *name;
} State;

// Declaring a static state variable
static State *state = NULL;

void module_init (void)
{
  // Allocating memory for storing state on heap
  state = malloc(sizeof(*state));
  assert(state != NULL);
  memset(state, 0, sizeof(*state));

  // Setting initial value of state
  state-&gt;name = &quot;World&quot;;
}

void *module_pre_reload (void) { return state; }

void module_post_reload (void *previous_state) { state = previous_state; }

void module_update (void) {
  printf(&quot;Hello %s\n&quot;, state-&gt;name);
}
</code></pre>
<p>Creating a simple shell file for easily compiling these files.</p>
<pre><code class="language-sh">~filename build.sh
#!/bin/bash

# For compiling the module as .so
clang -Wall -Wextra -ggdb -fPIC -shared -o libmodule.so module.c

# For compiling the main program
clang -Wall -Wextra -ggdb -o main main.c
</code></pre>
<p>The <code>-fPIC</code> and <code>-shared</code> options are used with clang to generate position-independent code (PIC) and create a shared object library (.so)</p>
<p>Executing this script in shell will compile and generate libmodule.so file (Same as DLL on Windows)</p>
<blockquote>
<p>Remember to also give execute permisson to build.sh to be able to execute the script.</p>
</blockquote>
<p>Next we include the <code>module.h</code> file in <code>main.c</code> and functions defined in <code>dlfcn.h</code> file to use the generated libmodule.so file.</p>
<pre><code class="language-c">~filename main.c

// The dlfcn.h contains function to interact with Dynamic linking library
#include &lt;dlfcn.h&gt;
// Including the header file
#include &quot;module.h&quot;

// Path to the generated libmodule.so file
const char* libmodule_path = &quot;./libmodule.so&quot;;
// Pointer for storing the module
void *libmodule = NULL;

bool initialize_libmodule (void)
{
  if (libmodule != NULL) {
    dlclose(libmodule);
  }

  // Opening the dynamic source object
  libmodule = dlopen(libmodule_path, RTLD_NOW);

  if (libmodule == NULL)
    return false;

  // Using the dlsym function which returns the address where the
  // symbol (function in this case) is stored in memory
  module_init = dlsym(libmodule, &quot;module_init&quot;);
  if (module_init == NULL)
    return false;

  module_pre_reload = dlsym(libmodule, &quot;module_pre_reload&quot;);
  if (module_pre_reload == NULL)
    return false;

  module_post_reload = dlsym(libmodule, &quot;module_post_reload&quot;);
  if (module_post_reload == NULL)
    return false;

  module_update = dlsym(libmodule, &quot;module_update&quot;);
  if (module_update == NULL)
    return false;

  return true;
}

void reload_libmodule (void)
{
  // Storing the previous state before unloading the module
  void *previous_state = module_pre_reload();
  initialize_libmodule();
  module_post_reload(previous_state);
}

int main (void)
{
  if (!initialize_libmodule()) {
    fprintf(stderr, &quot;Error: %s\n&quot;, dlerror());
    return 1;
  }

  module_init();
  char ch;
  while (1) {
    module_update();

    printf(&quot;Press &#39;q&#39; to quit | &#39;r&#39; to reload\n&quot;);
    scanf(&quot;%c&quot;, &amp;ch);

    if (ch == &#39;q&#39;) break;

    // Using keypress &#39;r&#39; to trigger a reload
    if (ch == &#39;r&#39;) {
      reload_libmodule();
    }
  }
}
</code></pre>
<p>Now compile the main program using the <code>build.sh</code> script and running it we get</p>
<pre><code>&gt; ./main
Hello World
Press &#39;q&#39; to quit | &#39;r&#39; to reload
</code></pre>
<p>Now we can easily udpate the state in <code>module.c</code> and see the updates reflected without the need to re-compile the main program.</p>
<pre><code class="language-c">~filename module.c
void module_init (void)
{
  // Updating the state
  state-&gt;name = &quot;Link&quot;;
}
</code></pre>
<p>Now we just need to compile <code>module.c</code> file to re-generate <code>libmodule.so</code><br>we do this in another terminal since we don&#39;t have to close the running main program. We can use the <code>./build.sh</code> script to compile.<br>Once compiled we can just enter <code>r</code> in the main program and we can see the name in the state changes.</p>
<pre><code>&gt; ./main
Hello World
Press &#39;q&#39; to quit | &#39;r&#39; to reload
Hello Link
Press &#39;q&#39; to quit | &#39;r&#39; to reload
</code></pre>
<blockquote>
<p>Here we are using the &#39;r&#39; keypress to trigger a reload for simplicity, however we can also trigger reload automatically whenever a change is detected just like in build tools like vite or other development tools.</p>
</blockquote>
<ul>
<li><input disabled="" type="checkbox"> Add link to Github gist that dynamically builds without key triggers</li>
</ul>
<hr>
<h3 id="hot-reloading-demo-with-raylib">Hot reloading demo with Raylib</h3>
<video controls muted loading="lazy">
  <source src="/videos/blogs/hot-reloading-with-c/raylib-test.mp4" type="video/mp4">
  <source src="/videos/blogs/hot-reloading-with-c/raylib-test.webm" type="video/webm">
  Your browser does not support the video tag.
</video>

          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/blogs/hot-reloading-with-c/cover.png"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/blogs/hot-reloading-with-c/cover.png"/>
        </item>
      
        <item>
          <guid>https://shubham-maurya.vercel.app/rust-web-compiling-browser-webassembly</guid>
          <title>Rust to Web: Compiling for Browser with WebAssembly</title>
          <description>Learn how to compile Rust for the browser and unlock a new level of performance and efficiency in your web projects.</description>
          <link>https://shubham-maurya.vercel.app/rust-web-compiling-browser-webassembly</link>
          <pubDate>Tue Mar 12 2024 05:10:58 GMT+0000 (Coordinated Universal Time)</pubDate>
          <category>Rust</category><category>wasm</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/rust-web-compiling-browser-webassembly">
                  read on the site!
                </a>
              </strong>
            </div>

            <p>WebAssembly (Wasm), is a binary instruction format that serves as a portable compilation target for high-level programming languages such as C, C++ or Rust. It is designed to be a low-level virtual machine that runs code at near-native speed in web browsers.<br>WebAssembly is commonly used to enable the execution of performance-critical tasks, allowing web applications to run complex algorithms with improved efficiency.</p>
<p>One of key goals of WebAssembly is to provide a universal and efficient platform for running code on the web, making it easier for developers to write performance-sensitive components for web applications. It allows languages other than JavaScript to be used in the browser, opening up new possibilites for web development.</p>
<p>In order to compile Rust to wasm we first need to install <a href="https://rustwasm.github.io/wasm-pack/">wasm-pack</a>.<br>wasm-pack is a tool that makes it easier to integrate Rust code into web projects. It streamlines the process of building, bundling, and publishing Rust and WebAssembly code for the web.</p>
<p>We can install wasm-pack using the following command.</p>
<pre><code class="language-shell">cargo install wasm-pack
</code></pre>
<p>Follow this <a href="https://rustwasm.github.io/wasm-pack/installer/">link</a> for more info and other methods to install wasm-pack.</p>
<p>For now we can try to create a small wasm module that calculates fibonacci sequence in wasm.
Let&#39;s create a new rust project using cargo.</p>
<pre><code class="language-shell">cargo init fibonnaci-wasm
</code></pre>
<p>This creates a binary crate.<br>Next up we need to add <code>wasm-bindgen</code> and add following changes in <code>Cargo.toml</code> file.</p>
<pre><code class="language-toml">~filename Cargo.toml
# ---
[lib]
name = &quot;lib&quot;
crate-type = [&quot;cdylib&quot;, &quot;rlib&quot;]

[dependencies]
wasm-bindgen = &quot;0.2.92&quot;
# ---
</code></pre>
<p><code>wasm-bindgen</code> package allows us to use <code>#[wasm-bindgen]</code> macro which generates the necessary glue code to enable seamless interaction between Rust code compiled to Wasm and JavaScript code in web applications. It provides a convenient way to handle data types, function calls, and other interactions between Rust and JavaScript.</p>
<p>In addition to adding <code>wasm-bindgen</code>, we also defined the lib type as <code>&quot;cdylib&quot;</code> which stands for <strong>C Dynamic Library</strong> and, it indicates the compiled output should be a dynamic library that can be linked with other languages. For WebAssembly target it means to create a <code>*.wasm</code> file without a start function.<br>We also have to specify the <code>name</code> of lib since we cannot have the same name for binary and lib. The name for lib can be anything.<br>Also since we created a binary package, we have to add a lib.rs file in <em>`/src/lib.rs`</em>.</p>
<p>Now we can just build the project, which will download all the packages and compile them.</p>
<pre><code class="language-shell">cargo build
</code></pre>
<p>Let&#39;s write a function which prints fibonacci sequence till a count.</p>
<pre><code class="language-rust">~filename lib.rs
pub fn fibonacci(count: i32) {
    let mut a = 0;
    let mut b = 1;
    let mut c = a + b;

    println!(&quot;{}&quot;, a);
    for _ in 1..count {
        println!(&quot;{}&quot;, c);
        c = a + b;
        a = b;
        b = c;
    }
}
</code></pre>
<p>and use this function in main.rs</p>
<pre><code class="language-rust">~filename main.rs
use lib::fibonacci;

fn main() {
    let count = 10;
    println!(&quot;Fibonacci sequence till: {}&quot;, count);
    fibonacci(count);
}
</code></pre>
<p>This will print the fibonacci sequence until 10 digits.<br>Now let&#39;s compile this code to wasm. We need to add following lines in <code>lib.rs</code>.</p>
<pre><code class="language-rust">~filename lib.rs
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn fibonacci(count: i32) {
    // Implementation
}
</code></pre>
<p>We can now use wasm-pack for building wasm modules.</p>
<pre><code class="language-shell">wasm-pack build --target web --out-dir web
</code></pre>
<p><code>--target</code> - flag allows us to run directly in browser without needing a bundler like webpack.<br><code>--out-dir web</code> - specifies to output the files in <code>web</code> directory, default directory is <code>pkg</code></p>
<pre><code>- web
  |- .gitignore
  |- lib_bg.wasm
  |- lib_bg.wasm.d.ts
  |- lib.d.ts
  |- lib.js
  \- package.json
</code></pre>
<p><em>lib_bg.wasm</em> - The compiled wasm module.<br><em>lib_bg.wasm.d.ts</em> - Declarations and exports from lib<em>bg.wasm<br>_lib.js</em> - Exports js interop functions that can be used to instantiate and call wasm.<br><em>lib.d.ts</em> - Declarations for lib.js</p>
<p>Let&#39;s add an html file <em>index.html</em> in the web directory and use the exported fibonacci function.</p>
<pre><code class="language-html">~filename index.html
&lt;!doctype html&gt;
&lt;html lang=&quot;en&quot;&gt;
    &lt;!--&gt; Include head and meta tags &lt;/!--&gt;
    &lt;body&gt;
        &lt;script type=&quot;module&quot;&gt;
            import init, { fibonacci } from &#39;./lib.js&#39;;

            let wasm;
            async function run() {
                wasm = await init();
                console.log(wasm);
                fibonacci(10);
            }

            run();
        &lt;/script&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>
<blockquote>
<p>Make sure to set the script type as module.</p>
</blockquote>
<p>Opening this file in browser and looking at the console window we can see that wasm object is being logged in console. It includes <code>memory</code> and reference to <code>fibonacci</code> function. However we can notice that the fibonacci sequence was not logged into console.</p>
<p><img src="https://shubham-maurya.vercel.app/images/blogs/rust-to-wasm-compiling/output-pre-implementation.png" alt="Output pre-implementation" title="Fibonacci sequence is not logged"></p>
<p>That is because we use the <code>println!()</code> in rust which does not log into browser console.<br>So in order to log output to console we will have to call JavaScript function from Rust.</p>
<p>First we will create a wrapper function which is reponsible for logging to console.</p>
<pre><code class="language-rust">~filename lib.rs
// function definitions to be implemented by other platforms
#[cfg(target_arch = &quot;wasm32&quot;)]
#[wasm_bindgen(module = &quot;/web/log.js&quot;)]
extern &quot;C&quot; {
    fn platform_log(message: &amp;str);
}

// Native rust implementation
#[cfg(not(target_arch = &quot;wasm32&quot;))]
fn platform_log(message: &amp;str) {
    println!(&quot;{message}&quot;);
}

pub fn fibonacci(count: i32) {
    let mut a = 0;
    let mut b = 1;
    let mut c = a + b;

    platform_log(format!(&quot;{}&quot;, a).as_str());
    for _ in 1..count {
        platform_log(format!(&quot;{}&quot;, c).as_str());
        c = a + b;
        a = b;
        b = c;
    }
}
</code></pre>
<p>Here we defined a <code>platform_log</code> function which is declared twice. Once inside an <code>extern</code> block .<br>The second declaration is native rust and will be called when building and running the binary.</p>
<p>The first declaration is inside an <code>extern</code> block.<br>It means that this is foreign function and the has to be implemented for specific platforms during the linking stage.<br>We use the <code>#[cfg(target_arch = &quot;wasm32&quot;)]</code> to include this extern block only when the target_arch = wasm32. Meaning this declaration block is only included when the target-arch is set to wasm32 which happens when we are compiling to wasm.<br>Next we use <code>#[wasm_bindgen]</code> to include this function in compiled wasm file. we also have an argument <code>module = &quot;/path&quot;</code> which defines the path to a file containing the implementation of the functions in extern block.</p>
<p>The second declaration is the native rust implementation. This is called when we compile and run the native rust binary.
And we use the <code>#[cfg(not(target_arch = &quot;wasm32&quot;))]</code> to only include this when building a binary package and not in wasm module.</p>
<p>We also have to implement the <code>platform_log function</code> in JavaScript, so we create a file in <code>/web</code> directory which just wraps the <code>console.log()</code> function in JavaScript.<br>Make sure to export the functions</p>
<pre><code class="language-javascript">~filename log.js
export function platform_log(message) {
    console.log(message)
}
</code></pre>
<p>And we are done with the implementation. Now build again using wasm-pack and we can see that the fibonacci sequence is logged to the console.</p>
<p>Output on the Web -</p>
<p><img src="https://shubham-maurya.vercel.app/images/blogs/rust-to-wasm-compiling/output-pre-implementation.png" alt="Fibonacci sequence logged to console from wasm" title="Fibonacci sequence logged to console from wasm"></p>
<p>And native -</p>
<p><img src="https://shubham-maurya.vercel.app/images/blogs/rust-to-wasm-compiling/output-native.png" alt="&#39;Fibonacci sequence logged to console&#39;" title="Fibonacci sequence logged to console"></p>
<p>And that&#39;s how we compile Rust to Wasm and use it browser on a webpage.<br>Here&#39;s something more interesting I made using this workflow <a href="https://shubham13m.github.io/boids?show-controls=true&bg-color=#0B192F&boid-color=#19D645">boids</a></p>

          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/blogs/rust-to-wasm-compiling/rust-wasm-cover.png"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/blogs/rust-to-wasm-compiling/rust-wasm-cover.png"/>
        </item>
      
        <item>
          <guid>https://shubham-maurya.vercel.app/opensource-contribution</guid>
          <title>Opensource Contribution</title>
          <description>A guide to open source contribution</description>
          <link>https://shubham-maurya.vercel.app/opensource-contribution</link>
          <pubDate>Tue Nov 14 2023 09:13:33 GMT+0000 (Coordinated Universal Time)</pubDate>
          
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/opensource-contribution">
                  read on the site!
                </a>
              </strong>
            </div>

            <p>This is a guide to get started with Opensource contribution on Git. In order to contribute to a repository on Git we first have to create a fork of the repository in our personal Git space.</p>
<p>The project that I will work on is a Chat application. I will work on adding the functionality to support rendering links and opening the URL in another tab, currently it just renders it as a text.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vht17fd217dhn5szh74w.png" alt="Fork git repo" title="Forking the repo"></p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dw8li0n1sab9lvcstssl.png" alt="Naming the repo" title="Naming the repo"></p>
<blockquote>
<p>The name of the repo doesn&#39;t have to be the same as the original repo</p>
</blockquote>
<p>After creating a fork we can clone the repo. I am cloning the repo using SSH.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kyzevuvj3xrz1h0zj04w.png" alt="Cloning the repo" title="Cloning the repo"></p>
<p>Next we have to add another remote to the cloned repo. This remote is the repo URL of the original author of the repo. Using this remote we can sync the cloned repo to the latest changes. I have used the HTTPs URL in this case as I only have read access to this repo.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bro5t9txna1w3l0y0q2z.png" alt="Adding remote to the original repo" title="Adding remote to the original repo"></p>
<blockquote>
<p>Usually I will just name it same as the author&#39;s name</p>
</blockquote>
<p>We can check if adding the remote was successful using</p>
<pre><code class="language-shell">git remote -v
</code></pre>
<p>Next up we can just pull from the original repo, just to get the latest changes if any before continuing. It is a good idea to stay up to date with the original repo to prevent possibility of merge conflicts.</p>
<p>In order to work on a new feature create a new branch and add the changes and updates in this branch, commit and then push the changes.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iu6crtffgpr6x00tdigo.png" alt="Creating a new branch" title="Creating a new branch"></p>
<p>These changes are only going to be pushed on the forked repo in our workspace as we don&#39;t have the write access to the original repo anyways.</p>
<p>After working on the feature and pushing to the forked repo we can send a pull request to the original repo, adding a descriptive message to the changes made.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uum0i6wkp64zr1eo7n52.png" alt="Creating a pull request" title="Creating a pull request to te original repo"></p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4z2g7zmyv5mrd0567hwi.png" alt="Leaving a descriptive change log for the author" title="Leaving a descriptive change log for the author"></p>
<p>The author can then review the changes, and merge the pull request.
That&#39;s the basic of contributing to a repository on Github, Gitlab or any other VCs.
Make sure to also go through the licensing of the repositories.</p>

          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/blogs/opensource-contribution/Open-source-contribution-cover.png"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/blogs/opensource-contribution/Open-source-contribution-cover.png"/>
        </item>
      
        <item>
          <guid>https://shubham-maurya.vercel.app/elevate-development-workflow-typescript</guid>
          <title>Elevate Your Development Workflow with TypeScript</title>
          <description>Introduction to Typescript in Development</description>
          <link>https://shubham-maurya.vercel.app/elevate-development-workflow-typescript</link>
          <pubDate>Mon Sep 18 2023 09:09:10 GMT+0000 (Coordinated Universal Time)</pubDate>
          <category>TypeScript</category><category>Productivity</category><category>Beginners</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/elevate-development-workflow-typescript">
                  read on the site!
                </a>
              </strong>
            </div>

            <p>Recently I have been working on a short project trying out Next.js
And I have setup the project with TypeScript.
Here&#39;s a gist of what the project is -
Users can create, share forms, and get responses on the form.</p>
<p>I have a page for creating forms which is wrapped in a React Context that stores the state of the form.</p>
<p>This is the interface of the state of a form.
The form consists of a unique <em>id</em>, <em>title</em>, <em>description</em> and an array of <em>questions</em>.</p>
<pre><code class="language-typescript">~filename types.ts
interface CreateFormState {
    id: string;
    title: string;
    description: string;
    questions: Question[];
}
</code></pre>
<p><strong>Question</strong> is defined as a type consisting of fields - <em>id</em>, <em>title</em> and <em>answerType</em>.</p>
<pre><code class="language-typescript">type Question = {
    id: string;
    title?: string;
    answerType: AnswerType;
};
</code></pre>
<blockquote>
<p>The type of Question is a bit more complex than this as I also have to keep track of the state of answers<br>for example the options of the checkbox/radio the user inputs</p>
</blockquote>
<p><strong>AnswerType</strong> is type that defines what type of response the question can accept. Depending on the selected answerType a different input component is rendered.<br>A normal input for short-answer, a list of checkboxes for checkbox-answer, and so on.</p>
<pre><code class="language-typescript">type AnswerType 
    = &#39;short-answer&#39; 
    | &#39;long-answer&#39; 
    | &#39;radio-answer&#39; 
    | &#39;checkbox-answer&#39;;
</code></pre>
<hr>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rj2jv3x1zl1q3tmtz1y2.png" alt="Question with short answer" title="Question with short answer"></p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dud8x6xe951jmyfmwxjx.png" alt="Question with checkboxes" title="Question with check boxes"></p>
<hr>
<p>The data is stored using the useReducer hook from React.</p>
<pre><code class="language-typescript">const [formData, dispatchFormData] = useReducer(formDataReducer, initialFormState);
</code></pre>
<p>Here is the reducer function which specifies how the state gets updated.</p>
<pre><code class="language-typescript">function formDataReducer(state: CreateFormState, action: CreateFormAction): CreateFormState {
    const { type, payload } = action;
    switch (type) {
        case CreateFormActionKind.UPDATE_TITLE:
            return {
                ...state,
                title: payload
            };
        case CreateFormActionKind.UPDATE_DESCRIPTION:
            return {
                ...state,
                description: payload
            };
        default:
            return state;
    }
}
</code></pre>
<blockquote>
<p>[Note]: Not all actions are present in this code snippet.</p>
</blockquote>
<p>This is where the TypeScript&#39;s type-checking is really helpful. As I can define the type of actions the reducer function can accept and the type of payload that needs be sent when calling the function.</p>
<p>Here are the type of actions that can be performed on the create form state. This is defined as a TypeScript <strong>Enum</strong>.<br>These actions define updating the title and description of the form respectively.</p>
<pre><code class="language-typescript">enum CreateFormActionKind {
    UPDATE_TITLE = &#39;UPDATE_TITLE&#39;,
    UPDATE_DESCRIPTION = &#39;UPDATE_DESCRIPTION&#39;
}
</code></pre>
<p>Here is the action defining the type of the payload as <em>string</em> when we are updating the title or the description of the question.</p>
<pre><code class="language-typescript">type CreateFormAction = {
    type: CreateFormActionKind;
    payload: string;
};
</code></pre>
<p>Let&#39;s add another action for adding a new question to the <em>questions</em> array of the create form state. For that we need to add a new entry in the <strong>CreateFormActionKind</strong> enum.</p>
<pre><code class="language-typescript">enum CreateFormActionKind {
    UPDATE_TITLE = &#39;UPDATE_TITLE&#39;,
    UPDATE_DESCRIPTION = &#39;UPDATE_DESCRIPTION&#39;,
    ADD_QUESTION = &#39;ADD_QUESTION&#39;
}
</code></pre>
<p>And now let&#39;s handle this action in the reducer function.</p>
<pre><code class="language-typescript">function formDataReducer(
  state: CreateFormState,
  action: CreateFormAction
): CreateFormState {
  const { type, payload } = action;
  switch (type) {
    ...
    case CreateFormActionKind.ADD_QUESTION:
      return {
        ...state,
        questions: [...state.questions, payload],
      };
    ...
  }
}
</code></pre>
<p>But adding this action in the function causes error. Since the type of <em>payload</em> is defined as string in the <strong>CreateFormAction</strong> and we are trying to push that to the questions array which is of type <strong>Question</strong>.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ef3hldnjnr9txq09mt2.png" alt="TypeScript error because payload is defined as a string" title="TypeScript error because payload is defined as a string"></p>
<p>To fix this we will have to modify the <em>CreateFormAction</em> a bit.</p>
<pre><code class="language-typescript">type CreateFormAction =
    | {
            type: CreateFormActionKind.UPDATE_TITLE | CreateFormActionKind.UPDATE_DESCRIPTION;
            payload: string;
      }
    | {
            type: CreateFormActionKind.ADD_QUESTION;
            payload: Question;
      };
</code></pre>
<p>We defined CreateFormAction as Union of types so if -</p>
<ul>
<li>ActionKind is UPDATE_TITLE or UPDATE_DESCRIPTION then the type of payload should be <strong>string</strong>.</li>
<li>ActionKind is ADD_QUESTION then the type of payload should be <strong>Question</strong> and we will have to pass a Question object to the function.</li>
</ul>
<p>And now we should be able to use this action for adding new questions. If we try to call this dispatch function in another component we will know the actions that can be performed on the state, the associated type of payload that the action accepts and we also get the Intellisense and auto-completion if we use an IDE with LSP.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l6uz6ljim3cca1rs1sc8.png" alt="Trying to pass string as the payload with action ADD_QUESTION" title="Trying to pass string as payload ADD_QUESTION"></p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4y4ijyobl3w4vbrmmnpx.png" alt="Intellisense and autocompletion with TypeScript" title="Intellisense and auto-completion with TypeScript"></p>
<h4 id="using-this-we-can-add-more-actions-for">Using this we can add more actions for:</h4>
<ul>
<li>Updating the title of the question</li>
<li>Deleting a question from array</li>
<li>Sorting the questions</li>
<li>Changing the type of the answer for a question.</li>
<li>and more...</li>
</ul>
<p>This may feel like typing extra for defining types, but it helps in narrowing the weird things that may happen during the runtime. Because JavaScript is just a weird language.</p>
<p>So yeah that&#39;s how TypeScript makes development easier and accelerates developer productivity.</p>

          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/blogs/elevate-your-development-workflow-with-typescript/cover.png"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/blogs/elevate-your-development-workflow-with-typescript/cover.png"/>
        </item>
      
        <item>
          <guid>https://shubham-maurya.vercel.app/vim-navigation-basics</guid>
          <title>Vim 'navigation' basics</title>
          <description>Learn the basics of navigating with VIM</description>
          <link>https://shubham-maurya.vercel.app/vim-navigation-basics</link>
          <pubDate>Sun Sep 10 2023 00:00:00 GMT+0000 (Coordinated Universal Time)</pubDate>
          
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/vim-navigation-basics">
                  read on the site!
                </a>
              </strong>
            </div>

            <p>Learning Vim navigation can be a valuable skill for programmers, writers, and anyone who frequently works with text. It offers a unique approach to editing and navigating text that can significantly improve your productivity and efficiency.</p>
<p>After learning just the basics of Vim navigation it will allow you to navigate, edit, and perform commands with unparalleled speed, effortlessly moving through code or text.</p>
<p>You will be able to navigate and edit without constantly moving your hands away from the keyboard just to select a word or a whole paragraph.</p>
<hr>
<blockquote>
<p>I started to explore ways to easily navigate using a keyboard only when my dad brought a laptop that had a broken touchpad.
So I looked for ways to -</p>
<ol>
<li>Open/close windows,</li>
<li>Navigate by holding the <code>Ctrl</code>, <code>Home</code>, <code>End</code>,. etc keys</li>
<li>Learning commands to start apps or shutdown.</li>
</ol>
</blockquote>
<hr>
<p>Alright to get started you can either install Vim in your operating system or you can just use an extension in Vs code which could be a good starting point Also you won&#39;t have to worry about how to exit Vim since you can just close Vs code directly.</p>
<blockquote>
<p>Installation of the Vim plugin</p>
</blockquote>
<video controls muted>
  <source src="https://github.com/ShUbHaM13M/vim-navigation-basics/raw/master/resources/installing-vim-extension.webm" type="video/webm">
</video>

<p>Opening a new file now you will notice the cursor is changed
And if you look at the status bar at the bottom you will notice <strong>-- Normal --</strong> indicating that you are currently in the normal mode
It is the default mode of Vim.
It allows you to navigate the text, copy/cut/paste characters, words, and lines, but also roll-back actions, and so on.</p>
<blockquote>
<p>Normal mode cursor</p>
</blockquote>
<p><img src="https://raw.githubusercontent.com/ShUbHaM13M/vim-navigation-basics/master/resources/vim-normal-cursor.webp" alt="Normal mode cursor in Vim"></p>
<blockquote>
<p>The status bar in Vs code indicating the current mode</p>
</blockquote>
<p><img src="https://raw.githubusercontent.com/ShUbHaM13M/vim-navigation-basics/master/resources/vim-normal-mode.webp" alt="Status bar indicating the current mode of Vim"></p>
<hr>
<h3 id="basic-navigation">Basic Navigation</h3>
<p>You can use the keys:</p>
<ul>
<li><code>h</code> to move left.</li>
<li><code>j</code> to move up.</li>
<li><code>k</code> to move down.</li>
<li><code>l</code> to move right.</li>
</ul>
<p>These key presses can be combined with numbers so</p>
<ul>
<li><code>5j</code> will move the cursor 5 lines down.</li>
<li><code>13l</code> will move the cursor 13 characters to the left.</li>
</ul>
<p>Navigating around the file using these keys might feel weird at first, but once you get a hang of it you will be able to navigate much quicker.</p>
<blockquote>
<p>Navigating in Vscode using the Vim key-bindings</p>
</blockquote>
<video controls muted>
  <source src="https://github.com/ShUbHaM13M/vim-navigation-basics/raw/master/resources/navigating-editing-file-with-vim.webm" type="video/webm">
</video>

<h4 id="some-other-key-bindings-that-make-navigating-easier">Some other key bindings that make navigating easier.</h4>
<ul>
<li><code>w</code> - Jump by the start of words</li>
<li><code>W</code> - Jump by the start of words ignoring punctuations <strong>.</strong> <strong>;</strong>.., etc</li>
<li><code>e</code> - Jump to the end of words</li>
<li><code>E</code> - Jump to the end of words ignoring punctuations <strong>.</strong> <strong>;</strong>.., etc</li>
<li><code>b</code> - Jump backward by words</li>
<li><code>B</code> - Jump backward by words ignoring punctuations <strong>.</strong> <strong>;</strong>.., etc</li>
</ul>
<blockquote>
<p>Again these keystrokes can be preceded by a number so
<code>2w</code> would jump two words ahead.</p>
</blockquote>
<hr>
<h4 id="a-bit-advanced">A Bit Advanced</h4>
<ul>
<li><code>0</code> - Jump to the start of the line</li>
<li><code>$</code> - Jump to the end of the line</li>
<li><code>G</code> - Go to the bottom of the file.</li>
<li><code>gg</code> - Go to the top of the file.</li>
<li><code>Ctrl + d</code> - move down half a page.</li>
<li><code>Ctrl + u</code> - move up half a page.</li>
<li><code>: {num} Enter</code> - Go to that line number in the document.</li>
</ul>
<hr>
<p>If you accidentally go into <strong>Insert</strong> mode while having fun navigating the file using these newly learned powers, then just press <code>Esc</code> to go back to <strong>Normal</strong></p>
<p>That covers the basics of navigation using Vim. It may take a few days to get used to this new way of going through your files without using a mouse but it will make your workflow more productive and efficient.</p>

          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/blogs/vim-navigation-basics/Vim-navigation-basics-cover.png"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/blogs/vim-navigation-basics/Vim-navigation-basics-cover.png"/>
        </item>
      
    
        <item>
          <guid>https://shubham-maurya.vercel.app/project/tunes</guid>
          <title>Tunes - Music player</title>
          <description>Tunes a music player app made with Flutter</description>
          <link>https://shubham-maurya.vercel.app/project/tunes</link>
          <category>Flutter</category><category>Design</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/project/tunes">
                  read on the site!
                </a>
              </strong>
            </div>

            <h2 id="tunes---music-player">Tunes - Music Player</h2>
<p>Tunes is a music player app made using <a href="https://flutter.dev">Flutter</a>.</p>
<p>It allows you to browse, play, pause, shuffle and loop music stored locally on your device.<br>This project was created to learn flutter when it was first released and compare it with existing tool that I used at the time for multi-platform app development - <a href="https://reactnative.dev">React Native</a>.</p>
<p>It uses the following packages :-<br><a href="https://pub.dev/packages/on_audio_query">on_audio_query</a>: To query audios/songs metdata from device storage.<br><a href="https://pub.dev/packages/on_audio_query">just_audio</a>: A feature rich audio player supporting multiple platforms.<br><a href="https://pub.dev/packages/shared_preferences">shared_preferences</a>: To store user preferences locally.</p>
<p>The design of Tunes is also inspired by the then design trend <em>Glassmorphism</em>. During the time of development of Tunes there was not an easy way to achieve glassmorphic effects in React Native, since it uses native device element as opposed to Flutter which uses a canvas to render things on the screen.</p>
<p>Instead of relying on the platform&#39;s native widgets, Flutter has its own set of widgets and a custom rendering engine.</p>
<p><a href="https://docs.flutter.dev/resources/architectural-overview">Flutter architectural overview</a> shows the high-level overview of architecture of Flutter.</p>
<p>But in short, Flutter uses the Skia graphics engine to perform the actual painting on the screen. Skia is a 2D graphics library that provides a set of low-level drawing primitives. Flutter uses Skia to draw the graphics for each render object onto the screen. This allows us to add filter or other decoration to any element during rendering.</p>
<p>In order to achieve the glass effect on a widget, I created a custom stateless widget that wraps child in a container with the glass effect.
Here&#39;s a small snippet of dart code that shows how it works -</p>
<pre><code class="language-dart">~filename /lib/widgets/glass.dart
import &#39;dart:ui&#39;;
import &#39;package:flutter/material.dart&#39;;

class Glass extends StatelessWidget {
  final Widget child;
  final double blurAmount;
  final Color backgroundColor;

  const Glass({
    key? key,
    required this.child,
    this.blurAmount = 14,
    this.backgroundColor = Colors.black,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: BackdropFilter(
        filter: ImageFilter.blur(sigmaX: blurAmount, sigmaY: blurAmount),
        child: child,
      )
    )
  }
}
</code></pre>
<p>The project is open source. I haven&#39;t maintained it since a long time. And since this was my first flutter project the way the code is structured might not be the most scalable and efficient. But still I use this app from time to time to listen to music on my phone.</p>
<p>TODOs:</p>
<ul>
<li><input disabled="" type="checkbox"> Put links to android build apks.</li>
<li><input disabled="" type="checkbox"> Can&#39;t build for iOS</li>
</ul>

          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/projects/tunes/tunes_home.png"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/projects/tunes/tunes_home.png"/>
        </item>
        
        <item>
          <guid>https://shubham-maurya.vercel.app/project/tic-tac-toe</guid>
          <title>Tic-Tac-Toe</title>
          <description>Multiplayer Tic-Tac-Toe with Svelte, Koa, Socket.io</description>
          <link>https://shubham-maurya.vercel.app/project/tic-tac-toe</link>
          <category>Svelte</category><category>Socket.io</category><category>KoaJs</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/project/tic-tac-toe">
                  read on the site!
                </a>
              </strong>
            </div>

            <h3 id="tic-tac-toe">Tic-Tac-Toe</h3>
<p>A Tic-Tac-Toe multiplayer game made using <strong>Svelte</strong> for the frontend and <strong>Koa</strong>, <strong>Socket.io</strong> for the backend.</p>
<p>The Svelte frontend is used for creating/joining a room.</p>
<p><img src="https://shubham-maurya.vercel.app/images/projects/tic-tac-toe/create-room.png" alt="Creating a new room" title="Creating a new room."></p>
<p>User can join a room or if the room does not exists a new room will be created.<br>The user will than be taken to a waiting area or lobby where the server will wait for another player to join in the same room.</p>
<p><img src="https://shubham-maurya.vercel.app/images/projects/tic-tac-toe/room-connected.png" alt="Lobby" title="Lobby, waiting for another player to join the room."></p>
<p>Once two players are joined in the same the game will begin after a countdown and the users will be taken to the tic-tac-toe board.</p>
<p><img src="https://shubham-maurya.vercel.app/images/projects/tic-tac-toe/game-room.png" alt="Game room" title="Game room."></p>
<p>Here the user can play the game during their turn and wait for the opponent&#39;s turn.<br>The player who hosted the room is <em>X</em> and the player who joined the room is <em>O</em>.<br>User turns are highlighted for the opponent when they hover on a particular cell of the board.</p>
<p>Once there are no more moves left or a user wins the game. The game will be over and input to the board is also disabled.</p>
<p><img src="https://shubham-maurya.vercel.app/images/projects/tic-tac-toe/game-over.png" alt="X wins the game" title="Player 1 (X) won the game"></p>
<p>All the realtime communication such as room creation, joining, player moves and winning/losing are handled by socket.io events and there are no REST APIs used for communication.
Many rooms can be created simultaneously, but only 2 players can be in a room together and play the game (Its a two player game..)</p>
<p>Initially I only wanted to work on the game without any multiplayer functionality, but later decided to extend it further and introduce a system of rooms and realtime connectivity.</p>
<p><strong>TODOs</strong></p>
<ul>
<li><input disabled="" type="checkbox"> An action to restart the game when the game is over</li>
<li><input disabled="" type="checkbox"> Display the user details and win-lose in the UI</li>
<li><input disabled="" type="checkbox"> Allowing users to make a room public or private during the creation of room.</li>
<li><input disabled="" type="checkbox"> Listing public rooms on the homepage so anyone can join the room if there are less than 2 players.</li>
</ul>

          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/projects/tic-tac-toe/cover.png"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/projects/tic-tac-toe/cover.png"/>
        </item>
        
        <item>
          <guid>https://shubham-maurya.vercel.app/project/stories-io-story-app</guid>
          <title>Stories.io - Story App</title>
          <description>Stories.io is a React Native app that connect with an expressjs server, allows users to browse, create, change and delete their stories stores on a mongoDb database. Users can like and comments on other user's stories and also set their stories as private</description>
          <link>https://shubham-maurya.vercel.app/project/stories-io-story-app</link>
          <category>React Native</category><category>MongoDb</category><category>ExpressJS</category><category>Design</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/project/stories-io-story-app">
                  read on the site!
                </a>
              </strong>
            </div>

            <p>Stories.io was the first React project that I made while learning React.js</p>
<ul>
<li>React</li>
<li>MongoDb</li>
<li>Nodejs</li>
<li>Design</li>
</ul>

          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/projects/stories-io/stories-io-home.png"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/projects/stories-io/stories-io-home.png"/>
        </item>
        
        <item>
          <guid>https://shubham-maurya.vercel.app/project/project-m</guid>
          <title>Project M - Project Management</title>
          <description>A Project Management app with Kanban board, made with Reactjs and Firebase.</description>
          <link>https://shubham-maurya.vercel.app/project/project-m</link>
          <category>React</category><category>TailwindCSS</category><category>Firebase</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/project/project-m">
                  read on the site!
                </a>
              </strong>
            </div>

            
          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/projects/project-m/project_m_login.png"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/projects/project-m/project_m_login.png"/>
        </item>
        
        <item>
          <guid>https://shubham-maurya.vercel.app/project/pomidoras</guid>
          <title>Pomidoras</title>
          <description>Pomidoras is a simple pomodoro timer application built using the Raylib library and Clay Layout library.</description>
          <link>https://shubham-maurya.vercel.app/project/pomidoras</link>
          <category>C</category><category>Raylib</category><category>Clay</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/project/pomidoras">
                  read on the site!
                </a>
              </strong>
            </div>

            <p><strong>Pomidoras</strong> is a lightweight Pomodoro timer application implemented in C, built with the Raylib graphics library and the Clay Layout library for UI layout. It provides a clean, focused interface for managing work and break intervals using the Pomodoro Technique.</p>
<h2 id="what-it-does">What it does</h2>
<ul>
<li>Start, pause, and skip Pomodoro work sessions and short/long breaks.</li>
<li>Audible/visual notification when a session completes.</li>
<li>Simple settings to adjust durations for work, short break, and long break.</li>
<li>Minimal, distraction-free UI optimized for quick task cycles.</li>
</ul>
<h2 id="why-i-built-it">Why I built it</h2>
<ul>
<li>To create a compact desktop timer focused on performance and simplicity.</li>
<li>To learn Raylib for graphics and Clay for declarative layout in C.</li>
</ul>
<h2 id="implementation-highlights">Implementation highlights</h2>
<ul>
<li>Event loop: Single-threaded main loop using Raylib for frame updates and input polling; timers implemented with high-resolution time functions to keep timing accurate even when rendering load varies.</li>
<li>UI structure: Clay Layout manages containers and spacing, enabling responsive placement of controls and timer visuals with minimal layout code.</li>
<li>State management: Small state machine tracks modes (Work, Short Break, Long Break), session counts, and paused/running state to determine transitions and long-break scheduling.</li>
<li>Audio/notifications: Short beep or system notification on session end using Raylib audio playback; and platform-specific notifications.</li>
<li>Configuration persistence: User settings are persisted in Pomidoras’ own simple settings format, so preferences (durations, theme) are saved across sessions.</li>
<li>Cross-compilation: Project is set up to cross-compile to Windows using MinGW, enabling easy generation of Windows binaries from Linux/macOS build environments.</li>
</ul>
<h2 id="project-structure">Project structure</h2>
<p>pomidoras/<br>├── src/<br>│   ├── main.c<br>│   ├── platform_notification.c<br>│   ├── pomidorash.h<br>│   ├── resources/<br>│   └── screens/<br>├── Makefile<br>├── include/<br>└── README.md</p>

          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/projects/pomidoras/pomidoras.png"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/projects/pomidoras/pomidoras.png"/>
        </item>
        
        <item>
          <guid>https://shubham-maurya.vercel.app/project/plexus-dictionary</guid>
          <title>Plexus Dictionary</title>
          <description>Plexus Dictionary - A Dictionary web app made with Svelte - Sapper. Just a dictionary app, might also give an image or an emoji matching the word entered. Can also change the theme or the font of the app.</description>
          <link>https://shubham-maurya.vercel.app/project/plexus-dictionary</link>
          <category>Svelte</category><category>Sapper</category><category>API</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/project/plexus-dictionary">
                  read on the site!
                </a>
              </strong>
            </div>

            
          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/projects/plexus-dictionary/plexus_splash.jpg"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/projects/plexus-dictionary/plexus_splash.jpg"/>
        </item>
        
        <item>
          <guid>https://shubham-maurya.vercel.app/project/multiplayer-pong</guid>
          <title>Multiplayer Pong</title>
          <description>A Multiplayer game made using the pygame library of python which connects to the server using Socket.</description>
          <link>https://shubham-maurya.vercel.app/project/multiplayer-pong</link>
          <category>Python</category><category>Pygame</category><category>Socket</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/project/multiplayer-pong">
                  read on the site!
                </a>
              </strong>
            </div>

            <h3 id="multiplayer-pong">Multiplayer Pong</h3>
<ul>
<li><input disabled="" type="checkbox"> TODO: Push latest changes to Github</li>
</ul>
<p>Its Pong but multiplayer.<br>It uses pygame for managing window and rendering. And uses UDP sockets for synchronizing data between clients</p>

          ]]></content:encoded>
          
          
        </item>
        
        <item>
          <guid>https://shubham-maurya.vercel.app/project/maze-generator</guid>
          <title>Maze Generator</title>
          <description>Random Maze Generator generates a random maze using the backtracing algorithm</description>
          <link>https://shubham-maurya.vercel.app/project/maze-generator</link>
          <category>Python</category><category>Pygame</category><category>Algorithm</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/project/maze-generator">
                  read on the site!
                </a>
              </strong>
            </div>

            
          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/projects/maze-generator/random_maze_generator.png"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/projects/maze-generator/random_maze_generator.png"/>
        </item>
        
        <item>
          <guid>https://shubham-maurya.vercel.app/project/frecipe</guid>
          <title>Frecipe - Recipe API</title>
          <description>Frecipe is free recipe API which serves recipe from a database.</description>
          <link>https://shubham-maurya.vercel.app/project/frecipe</link>
          <category>Python</category><category>MongoDb</category><category>API</category><category>FastAPI</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/project/frecipe">
                  read on the site!
                </a>
              </strong>
            </div>

            <p>Frecipe is a free recipe API which serves recipes from a database and makes them accessible via HTTP APIs.
Currently it has more than 9500+ recipes. An API Token is required to be able to make requests.<br>Frecipe uses <a href="https://fastapi.tiangolo.com">FastAPI</a> - A modern, fast (high-performance), web framework for building APIs.<br>It also uses mongoDb for storing registered users and tokens, and all the recipes.</p>
<blockquote>
<p>All the recipes in the database of frecipe were scraped from a website using a python script.</p>
</blockquote>
<p>Frecipe has two public routes:</p>
<ol>
<li>/get_recipes - returns a paginated list of all the recipes.</li>
<li>/get_recipe_by_slug - returns a matching recipe by the recipe slug.</li>
</ol>
<p>To access this routes the <code>Authorization</code> header must be set.
The user needs to register to get a token in mail which can be used to access the APIs. When the user registers a mail with the token is sent to them. The mail is sent using a custom smpt script written using smtplib.<br>The requests are rate limited (5 requests/minute). To track the rate at which user is accessing the APIs, there token is used.
There are many validations on the server side to ensure that the token is valid. A user can also not generate multiple tokens using the same email.</p>
<p>All the requests are asynchronous using the async features of the python programming lanuage, which makes it really fast and responsive.</p>
<p>Frecipe was up and running on heroku, until the hobby account of heroku was closed.</p>

          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/projects/frecipe/frecipe_home.png"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/projects/frecipe/frecipe_home.png"/>
        </item>
        
        <item>
          <guid>https://shubham-maurya.vercel.app/project/chatr</guid>
          <title>Chatr. - Chat App</title>
          <description>Chatr. is a PWA made using Reactjs with Snowpack, TailwindCSS. The backend is made using Nodejs - Express, MongoDb and Socket.io The users can connect with any other user either by the username or the user_id. The email of the registered users are also verified.</description>
          <link>https://shubham-maurya.vercel.app/project/chatr</link>
          <category>React</category><category>TailwindCSS</category><category>MongoDb</category><category>Socket.io</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/project/chatr">
                  read on the site!
                </a>
              </strong>
            </div>

            <h3 id="chatr---chat-app">Chatr - Chat App</h3>
<p>Chatr is a chat app made with Reactjs, TailwindCSS and Socket.io</p>
<p>It has an express server that uses socket.io to connect and interact with the users
Users can use an their Facebook, Google account to register which uses Passportjs and OAuth
or they can use an Email account to register which sends an email containing a verification link using nodemailer to verify the user. The user data and chat history is stored in a mongoDb instance</p>
<p>The user can then add contacts by adding the unique id of other user
or sharing the user id to other users.
Once both users add each other they will show up in each other&#39;s contact list and their online status.
The users can then chat in a private chatroom.<br>The updates in the chat room such as user typing or sending, recieving messages are real-time since they are both connected to the same room using socket. This approach is very scalable as using this approach we can have a room with not just two users but multiple users creating a group.
Since the user data and chat history is stored in a mongoDb instance, thery are persisted across user sessions.</p>
<p>Chatr is a <a href="https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps">PWA</a> which means it can be installed on the device like an app and will show up at homescreen. One of the things that I would like to implement is a notification feature, so when the user receives a message a notification will be sent if the user is not active.<br>In order to achieve this I think something like the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API">Notifications API</a> can be used.</p>
<p>The active status of the user is tracked when the user opens the PWA or visits the website. The following code does the job to do so -</p>
<pre><code class="language-javascript">~filename /controller/socket.js
// Initializing socket
const io = socket(server, { cors });
// Listening to active socket connections
io.on(&#39;connection&#39;, async (socket) =&gt; {
    // ---
    // Authorization of connected socket and getting the id

    socket.join(id);
    // Getting user from mongoDb database
    const user = await getUserById(id);
    user.isActive = true; // setting user&#39;s active state to true
    user.save();
    sendUserStatusChange(user, true); // Sending a socket event to all the users
});

async function sendUserStatusChange(user, state) {
    const contacts = await getAllContacts(user);
    for (const contact of contacts) {
        socket.broadcast.to(contact._id.toString()).emit(&#39;state-changed&#39;, {
            user_id: user._id,
            state
        });
    }
}
</code></pre>
<p>The <code>&#39;state-changed&#39;</code> event is then listened on the client side and it renders the state accordingly.</p>
<p>Chatr uses somewhat of an MVC pattern. It does not uses ejs templates for html, but instead uses React.js for user pages.
The <em>/web</em> folder is another project which was bootstrapped using <a href="https://www.snowpack.dev/">Snowpack</a> - a lightning fast frontend build tool which is not maintained anymore. It was a thing before vite but it much was faster and better than webpack.<br>If I start working on this project again I will probably change the build tool to vite.</p>
<blockquote>
<p>The backend of this website was hosted on a hobby account of heroku and does not work anymore. But you can still clone the project and use it in anyways.</p>
</blockquote>

          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/projects/chatr/chatr_chat_screen.jpg"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/projects/chatr/chatr_chat_screen.jpg"/>
        </item>
        
        <item>
          <guid>https://shubham-maurya.vercel.app/project/boids</guid>
          <title>Boids</title>
          <description>Boid Simulation in rust and wasm</description>
          <link>https://shubham-maurya.vercel.app/project/boids</link>
          <category>Rust</category><category>wasm</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/project/boids">
                  read on the site!
                </a>
              </strong>
            </div>

            <iframe
    style="border: none; border-radius: 12px; pointer-events: none"
  id="boid"
  title="Boid simulation running on web"
    height="400"
    allow="fullscreen"
  src="https://shubham13m.github.io/boids?bg-color=#0B192F&boid-color=#19D645">
</iframe>

<p><strong>Boids</strong> refers to a computer simulation that models the flocking behaviour of birds. It was developed in 1986 by Craig Reynolds. The term &quot;boids&quot; is derived from a combination of &quot;bird&quot; and &quot;oid&quot;. The purpose of the simulation is to demonstrate how simple rules followed by individual entities can lead to complex and realistic-looking group behaviours.</p>
<p>In the boids simulation, each simulated boid, or bird, follows three basic rules:</p>
<ol>
<li>Separation: Boids avoid crowding together and maintain a minimum distance from their neighbors to prevent collisions.</li>
<li>Alignment: Boids align their direction with the average direction of their neighbors, contributing to a cohesive group movement.</li>
<li>Cohesion: Boids move toward the average position of their neighbors, promoting group unity.</li>
</ol>
<p>These three rules, when applied to a large number of individual entities, result in realistic flocking behaviour that mimics the movement of birds in nature. The boids simulation has been widely used in computer graphics, artificial intelligence, and game development to create life-like animations and behaviours for group of entities, not just limited to birds.</p>
<p>I will be writing a blog soon going over the implementation and how i compiled it to <a href="https://webassembly.org/">wasm</a>.<br>For now here&#39;s the <a href="https://github.com/ShUbHaM13M/boids">Github link</a><br>And a link to deployed version - <a href="https://shubham13m.github.io/boids?show-controls=true&bg-color=#0B192F&boid-color=#19D645">boids</a></p>
<p>References:<br><a href="https://en.wikipedia.org/wiki/Boids">wikipedia</a><br><a href="https://vanhunteradams.com/Pico/Animal_Movement/Boids-algorithm.html">vanhunteradams.com</a></p>
<p>Todos:</p>
<ul>
<li><input disabled="" type="checkbox"> Add Readme</li>
</ul>

          ]]></content:encoded>
          
          
        </item>
        
        <item>
          <guid>https://shubham-maurya.vercel.app/project/a-path-finding</guid>
          <title>A* Path Finding</title>
          <description>A* Pathfinder algorithm finds the shortest path between two cell (points)</description>
          <link>https://shubham-maurya.vercel.app/project/a-path-finding</link>
          <category>Python</category><category>Pygame</category><category>Algorithm</category>
          <content:encoded><![CDATA[
            <div style="margin: 50px 0; font-style: italic;">
              If anything looks wrong,
              <strong>
                <a href="https://shubham-maurya.vercel.app/project/a-path-finding">
                  read on the site!
                </a>
              </strong>
            </div>

            <h3 id="a-path-finding">A* Path Finding</h3>
<p>A* is a graph traversal and pathfinding algorithm.
It is widely used in Computer Science and Aritifical Intelligence.
It is designed to find the shortest path from a starting point to an end point in a graph, considering both the cost of reaching the goal and an estimated heuristic cost from the current node to the goal.<br>The algorithm maintains a priority queue to explore nodes in order of their total estimated cost, which is the sum of the actual cost from the start to the current node (g-value) and the estimated cost from the current node to the goal (h-value). A* selects nodes from the priority queue, explores their neighbors, and updates the cost estimates accordingly. The process continues until the goal is reached or the entire graph is explored.</p>
<p>This program is a visualization of the A* algorithm in action on a 2d grid.
It uses pygame a game library for python which uses SDL APIs for screen and graphics.<br>You can set a start point anywhere on the grid using <code>Shift + Left Mouse</code><br>and an end point using <code>CTRL + Left Mouse</code><br>using left mouse click without any modifier keys you can create walls<br>right clicking on the wall removes them.<br>And then press <code>Space</code> to start the visualization.</p>
<p>The Algorithm will find the shortest path after going through some iterations. It does not consider diagonal movements altought its not difficult to implement.</p>
<p>This is an old project made when i was first learning graphics programming using pygame.
it does not follow any conventions hence everything is in a single file. But the code is relatively easy to traverse and understand.</p>

          ]]></content:encoded>
          <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://shubham-maurya.vercel.app/images/projects/a-star-pathfinder/a_star_pathfinder.png"/>
          <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" url="https://shubham-maurya.vercel.app/images/projects/a-star-pathfinder/a_star_pathfinder.png"/>
        </item>
        
  </channel>
</rss>