<?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"><channel><title><![CDATA[CodeChef-VIT]]></title><description><![CDATA[CodeChef-VIT]]></description><link>https://blogs.codechefvit.com</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 16:42:56 GMT</lastBuildDate><atom:link href="https://blogs.codechefvit.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[CLUEMINATI 3.0 : Unfolding The Tech In The Realms Of Hell and Earth
]]></title><description><![CDATA[Clueminati 3.0: Explore how CodeChef-VIT built a scalable real-time treasure hunt using Next.js, MongoDB and JWT for 700+ participants.]]></description><link>https://blogs.codechefvit.com/clueminati-3-0</link><guid isPermaLink="true">https://blogs.codechefvit.com/clueminati-3-0</guid><category><![CDATA[tech ]]></category><category><![CDATA[app]]></category><category><![CDATA[app development]]></category><category><![CDATA[Next.js]]></category><category><![CDATA[webdev]]></category><category><![CDATA[PWA]]></category><dc:creator><![CDATA[Sanjana Shyamsundar]]></dc:creator><pubDate>Fri, 04 Sep 2026 07:55:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/68ed5c7d36c0fefbce90d417/f2aa99e4-6321-489d-bf5c-687a19127c57.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>It was the night before launch. Everything was tested. Everything was ready. Or so we thought. After all, the stakes were very high this time.</p>
<p>Clueminati 3.0 was a fully immersive, tech-driven treasure hunt with over 700+ participants that brought the thrill of puzzles, maps, and strategic decisions to life. It was a chaotic, beautiful mashup of cardio, decryption and pure adrenaline. The team at CodeChef-VIT crafted this entire experience, centralized around a custom-built web app that seamlessly bridged participants and the club members into one system.</p>
<p><strong>Clueminati</strong> 3.0 revolved around the theme of Hell and Earth. Each team of 3-5 players had to split up.</p>
<p><strong>Hell</strong>: Trapped indoors. Their job was to play a customized game built by CodeChef-VIT, as an attempt to break free.</p>
<p><strong>Earth</strong>: The outdoor runners.They had to sprint across the massive campus, finding physical stations, scanning QR codes, and solving riddles while trying not to pass out.</p>
<p>Here’s a behind the scenes of how we engineered our web app’s frontend to control the pace of play and the strategic decisions made in the backend’s tactical room to turn them into an epic matchday experience for the participants.</p>
<h2>The View From The Stands - Building the frontend between the two realms</h2>
<p>To control the midfield traffic of hundreds of concurrent users, we subbed in <code>Next.js 16</code>. Our main aim was to just render pages while maintaining formation. We used a global <code>RoundContext</code> which stores the current round’s state (such as timer, round number, questions, player status, etc.) as our playmaker, passing data between the backend and the client with custom hooks. This kept the visual timers ticking in perfect harmony across every device, ensuring no one could blame latency for losing the match.</p>
<p>We used <strong>Tailwind CSS</strong> for styling to maintain consistent responsiveness across devices. <strong>Axios</strong> managed the passing game, delivering API requests with precision. But in a match this intense, players slip up. That’s where <code>localStorage</code> came in as our goalkeeper. It managed the credentials for our various squads (Hell, Earth, and Core members) and ensured session persistence. If a player accidentally refreshed the page there was no foul, no penalty. They picked up exactly where they left off, keeping the momentum alive.</p>
<h3>Onboarding Flow: The Pre-Match build up from the Ticket Gate to the Home and Away Ends</h3>
<p>The entry point to the app was a clean login page, where participants authenticated using their registered email and password. When a captain formed a new team, the frontend sent a pass (a <strong>POST request</strong>) to the backend, which generated a unique team ID and code. This code was later converted into a QR code using the <code>qrcode.react</code> library and displayed it on the team’s profile page. Throughout the game, the core members acting as referees would scan the QR to blow the whistle and assign the next set of questions.</p>
<p>With the squad assembled, it was time to set the tactical formation. Players had to choose their position: selecting the indoor role redirected the user to a specifically designed game to escape hell. The outdoor wingers, on the other hand, unlocked the full pitch view, complete with station maps, question feeds, the live league table or leaderboard, ready to sprint for more points.</p>
<h3>The Build-Up Play : Kickoff, Scans, and Screamers</h3>
<p>All the pre-match prep ultimately led to kickoff. When a squad pressed high up the pitch and reached a station, a core member (acting as the referee) would scan the team’s QR code. This signaled the backend to generate a specific question based on logic we’ll break down later.</p>
<p>To receive the pass, the team used the app’s built-in scanner, implemented via <code>react-qr-reader</code>, to scan the station's code. A clean scan meant a perfect first touch, and the question instantly appeared on screen. At this stage, the interface was all about the final touch. Faced with the question, the user had the ball at their feet with two clear options: commit to the finish (Submit) or lay it off to keep the momentum going (Skip).</p>
<p>Hitting "Submit" fired a <strong>POST request</strong> straight at the backend. We used <strong>Toast notifications</strong> as our instant VAR check. A correct answer triggered a green notification, a goal !! Toast notifications made the feedback experience feel instant and rewarding.</p>
<h3>Manager Mode: Admin Tools and Live Standings</h3>
<p>While the players were sprinting, the Core Members were in the Technical Area. We built them a dedicated UI, allowing them to generate questions on demand and even toggle the match difficulty for the second round. This meant the entire officiating loop, identifying the squad, blowing the whistle, and assigning the play, could be executed in seconds. This dashboard was the ultimate sideline management tool, preventing stoppage time delays and keeping the match flowing seamlessly.</p>
<p>The app featured a leaderboard displaying the top 10 teams, turning every refresh into a battle for a spot at the top of the table. We also gave every team access to the submission history, where they could review their points tally, thereby providing them an easy way to track their progress and strategize during the competition.</p>
<h3>Tactical Awareness &amp; The Golden Goal</h3>
<p>To ensure our wingers didn't get caught in the offside trap of the massive campus, the app featured a dedicated tactical board, a map of the campus with all stations clearly marked. We didn’t want them getting lost in a system that makes no sense, but we didn't just show them the field, we played the perfect long ball. We embedded a button that linked directly to Google Maps coordinates. This lightweight method ensured smooth navigation without adding extra dependencies or API calls.</p>
<h3><strong>Extra Time : The Additional Phase of Play</strong></h3>
<p>The gameplay shifted from possession to a high-stakes puzzle. Here is when just scoring sufficient points wasn’t enough and the goal difference came to play. Answering specific questions unlocked a hidden letter, which the frontend tracked in the state like a manager counting subs on the touchline. As the clock ticked down, teams had to assemble these letters into a final defensive splitting cipher. Entering this code into the final input field was the Winning Goal, validating the win in the backend and blowing the final whistle on their campaign.</p>
<p>While the frontend was playing on the surface, the backend was playing a high line defense against a counterattack of numerous concurrent requests. It’s time to leave the pitch, head down the tunnel, and inspect the tactical room that turns raw, chaotic data into a proper game plan.</p>
<h2>The View From The Tactical Room : Building The Backend</h2>
<p>Managing a real-time treasure hunt for 700+ participants isn't your typical CRUD app. When teams are racing between physical stations, scanning QR codes, and competing for live rankings, every API call matters. This is the story of how we built the Clueminati 2025 backend using Next.js API routes, MongoDB, and JWT authentication-complete with near-disasters and last-minute saves.</p>
<img src="https://cdn.hashnode.com/uploads/covers/68ed5c7d36c0fefbce90d417/f2ae706a-4bcd-488b-8476-ad9f62c8b45a.png" alt="" style="display:block;margin:0 auto" />

<p><strong>Core Collections:</strong> Users, Teams (scores + progress), Questions (bank with difficulties), Stations (QR locations), GameStat (global round timestamps) The Security Protocol - Authentication Done Right Before writing a single line of code, we went into full pre-season training mode on JWT. Tutorials, docs, edge cases, everything. That upfront investment paid off (like/the way) a well-drilled backline always does. Zero JWT related bugs throughout the entire run.</p>
<p>Before writing code, we spent days learning JWT thoroughly through tutorials. This upfront investment paid off-we had zero JWT-related bugs throughout development.</p>
<p>Development and production behave differently. Never hardcode security settings.</p>
<h3>The touchline substitution : Email Catastrophe (and Recovery)</h3>
<p>We planned to send login credentials to 700+ participants using three Gmail accounts with round-robin distribution. Testing went perfectly. Then came launch night, and the match turned on us.</p>
<p><strong>The disaster:</strong> Mid-send, one email account got flagged by Gmail's security. The referee pulled out a red card we never saw coming. Result? 200 participants never received credentials before the 8 AM event started. Just three weeks before, we were arguing over a simple question: do we leave the signup endpoint up after pre-registration ends?</p>
<p><strong>Board:</strong> "Send the emails by tonight."</p>
<p><strong>Junior Core:</strong> "Script is up and running. Let's meet tomorrow morning everyone."</p>
<p><em>Next Morning:</em> "Two of the emails crashed, bring up the plan B"</p>
<p>That “Plan B” became our salvation. The 200 affected participants registered on-the-spot without crashes thanks to the distributed load. Those who still faced issues were helped by our support desks up-front. External services will fail, always have a Plan B. Listen to your team's concerns about edge cases. Redundancy isn't paranoia, it's wisdom.</p>
<h3>The Perfect Formation : Game Logic that actually works!!</h3>
<p>Question Assignment: No Duplicates, No Sharing Two rules governed the question assignment, and both were non-negotiable. No team gets duplicate questions within a round, and no two teams have the same question simultaneously. The second rule was our offside trap, cutting off any chance of cheating without anyone noticing.</p>
<img src="https://cdn.hashnode.com/uploads/covers/68ed5c7d36c0fefbce90d417/59dd3c83-4f71-4493-9f1b-68e3515fd78b.png" alt="" style="display:block;margin:0 auto" />

<h3>The top spot mentality : Our Leaderboard Philosophy</h3>
<p>We made a call that felt like a controversial choice: show rankings (#1, #2, #3) but hide actual scores. Why? The reasoning was simple- Seeing a 200-point gap demoralizes teams. They stop pressing. They accept the result before the final whistle. So by hiding the gap, everyone fought until the end. Teams ranked #8 didn't know they were only 50 points behind #3. As a result, the competition stayed fierce. Sometimes the best technical decision is to hide information, not expose it.</p>
<h3>Schema Evolution</h3>
<p>Database schemas evolved constantly as the tournament’s demands shifted. A Question model gained a difficulty field to balance out the points and places. Meanwhile, the team split scoring into indoorScore and outdoorScore to satisfy business logic separation and data modeling constraints. The rule was simple: notify the entire dev team before any schema change. No one finds out mid-match that the formation shifted without them.</p>
<h3>Testing with Senior Devs</h3>
<p>Our senior developers attacked our APIs looking for edge cases like they were trying to knock us out of the tournament</p>
<ul>
<li><p>Joining a team mid-question assignment</p>
</li>
<li><p>Leaving a team while holding an active question</p>
</li>
<li><p>Rapid-fire requests to test race conditions.</p>
</li>
</ul>
<p>Most bugs were caught pre-deployment. By kickoff, there was nowhere to hide. Recruit your sneakiest developers for QA. They'll find the exploits you never imagined.</p>
<h3>The Final Whistle</h3>
<p><em><strong>700+ participants. Two rounds. Zero downtime. Clean sheet.</strong></em></p>
<p>The email mishap taught us humility. Our seniors taught us resilience. The fallback signup system was the substitute that won us the match when the starting eleven couldn’t. Participants raced across campus, solved riddles, scanned QR codes, and competed fiercely. The backend held its line through rapid question submissions, instant score updates, and concurrent team management without breaking a sweat. Not a single goal conceded.</p>
<p>Key Takeaways</p>
<ol>
<li><p>Learn your tools thoroughly before kickoff.</p>
</li>
<li><p>JWT mastery prevents auth bugs. Always have a Plan B warming up on the touchline. Fallback signup saved 200 users.</p>
</li>
<li><p>External services will fail. Email, APIs, everything. Plan for it.</p>
</li>
<li><p>Seek mentorship during crises. Senior devs turn panic into learning.</p>
</li>
<li><p>Product decisions matter. Hiding score gaps kept competition alive till the end.</p>
</li>
<li><p>Communicate schema changes. Team sync prevents bugs.</p>
</li>
<li><p>Test with sneakiest developers. They'll find exploits you never imagined.</p>
</li>
<li><p>Simplicity scales. Atomic operations beat transactions when possible.</p>
</li>
<li><p>Redundancy isn't paranoia. It's the difference between lifting the trophy and watching from the stands.</p>
</li>
</ol>
<h2>Summary</h2>
<p>Built a real-time treasure hunt backend for 700+ concurrent users using <strong>Next.js</strong> API routes, <strong>MongoDB</strong>, and <strong>JWT</strong>. Survived an email provider failure that blocked 200 registrations because we had a substitute ready on the touchline. Learned to never trust external services, measure performance before optimizing, and listen to experienced developers. Two rounds. Zero downtime. Countless lessons about production systems, team communication, and the value of defensive architecture. Want to explore the codebase? Check out our <a href="https://github.com/CodeChefVIT/clueminati-2025">GitHub repository</a> and see how we handled these challenges in practice.</p>
]]></content:encoded></item><item><title><![CDATA[The FFCS-inator Build Story]]></title><description><![CDATA[Built for VIT, FFCS-inator is a precision 2D timetable generator that instantly crunches faculty and subject priorities for over 30,000 active users.]]></description><link>https://blogs.codechefvit.com/the-ffcs-inator-build-story</link><guid isPermaLink="true">https://blogs.codechefvit.com/the-ffcs-inator-build-story</guid><category><![CDATA[FFCS]]></category><category><![CDATA[VITVellore]]></category><category><![CDATA[codechefvit]]></category><category><![CDATA[ffcsinator]]></category><category><![CDATA[Next.js]]></category><category><![CDATA[projects]]></category><dc:creator><![CDATA[Ishan Jindal]]></dc:creator><pubDate>Sat, 25 Apr 2026 16:05:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1759406734455/950095ae-bc04-4716-a827-817d69db7416.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In many universities around the world, students enjoy some form of control over their academic schedules - choosing courses, picking professors, and tailoring class times to fit their needs. This flexibility exists in different flavors: modular bidding systems in places like NUS, open registration in US colleges, or slot-based scheduling in IITs and BITS. At VIT, this concept takes shape as the <strong>Fully Flexible Credit System (FFCS)</strong>, an ambitious platform that promises students the freedom to hand-craft their timetables, selecting subjects, faculty, and time slots with surgical precision. In theory, it’s a dream - your semester, your way. In practice, it can feel like a gladiator arena disguised as a website. The moment registration opens, thousands of students rush in, racing against crashing servers, vanishing slots, and the crushing realization that your “perfect timetable” might be gone before you even log in. It’s flexibility… wrapped in chaos.</p>
<p>Plenty of FFCS helper tools have popped up over the years - slot viewers, faculty rating sheets, even basic timetable generators - but none truly tackled the core challenge. The dream is simple: every student getting the faculty they actually want, without hours of trial-and-error. That’s the harmony we imagined. So, we built something far more ambitious - a <strong>2D priority-based timetable combination generator</strong> made specifically for VIT’s FFCS. By weighing both faculty preferences and subject-priority together, it can produce the most optimal schedules in an instant. FFCS-inator is a precision instrument.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755016059560/d3ac7e06-ba0e-462a-8084-cd5ddd475dab.png" alt="" style="display:block;margin:0 auto" />

<h2>Here is the build story of the platform that got you closer to your semester goals…</h2>
<h3>…and reached 30,000+ active users on campus!</h3>
<p>About a year ago, this started as an obsession with recreating an actual, to-the-scale timetable. The one on VTOP (the VIT ERP Portal) was simply not cutting it. It felt clunky, hard to visualize, and made the reader do most of the heavy lifting just to figure out where they needed to be. It was a UI disaster.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754957211051/994a5ce9-5188-42ea-a24c-9b0ebd5711f1.png" alt="" style="display:block;margin:0 auto" />

<p><em>(Figure: Timetable, as shown on VTOP) Notice how it has 4 axes for time, and barely any sizing consistency. Even the time axes contradict each other at multiple points.</em></p>
<p>All classes start or end at time gaps multiple of 10 minutes. This pattern is recurring because of the nature of timetable slots, and their division between theory and lab slots. We used it to our advantage to work on early prototypes.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754957492558/e1b47e30-5b4b-4976-a8d1-974b54a2772a.png" alt="" style="display:block;margin:0 auto" />

<p><em>(Figure: Early prototype timetable) This has quantized time windows, and every small unit cell is 10 minutes long. Theory classes: 5 units wide. Lab classes: 10 units wide. (50 and 100 minutes respectively)</em></p>
<p>Through rigorous trial-error process and crowdsourcing, we landed on the final layout, which is the most robust way to showcase timetable data. Necessary improvements that have been made include one unified time axis, with <strong>clear indication</strong> after every 10-minute interval, where classes run from 8:00 am to 7:20 pm daily, along with clear separation between theory and lab classes. There was only <strong>one limitation:</strong> public was accustomed to the old, messy table format.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754958287495/f817d026-0037-4936-b0a9-358572d209b7.png" alt="" style="display:block;margin:0 auto" />

<p><em>(Figure: Final Layout) Easy on the eyes, Good for presenting data in digestible form.</em></p>
<p>This to-the-scale prototype seemed very promising, so further brainstorming led us to come to the decision that this would go perfectly with the <strong>FFCS-inator project</strong>, which was already in very early stages of ideation by this time.</p>
<h3>Phase-1: Let’s talk about features</h3>
<p>The main idea behind <strong>FFCS-inator</strong> was to build a one-stop platform that does the necessary thing which no other platform has ever done: <strong>Clash-Checked Combinations</strong>. Only faculties and subjects change each semester, the slots don’t. Sounds like an opportunity. With the information we have about the slots, we can easily map theory and lab slots together or against each-other based on if they clash or are mutually inclusive. Hardcoding the clash-map was the easy part. From a user’s perspective, they simply want the information they need in a clear and straightforward manner, without any unnecessary clutter or fuss. The <strong>WYSIWYG</strong> (What You See Is What You Get) interface makes this possible by eliminating all unwanted information and maintaining a clean, user-friendly experience.</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755016130904/7532d818-09e9-4872-a7b9-2dfa46556050.png" alt="" style="display:block;margin:0 auto" />

<p>We wanted the user to be able to not only use the platform but enjoy it as an <strong>intuitive web experience</strong> that <strong>responds intelligently</strong> to every action. Users should be able to <strong>save</strong> a particular timetable from all the combinations, <strong>share</strong> it with friends, or <strong>generate</strong> a comprehensive <strong>report</strong>. Saved timetables needed a separate space where their <strong>visibility</strong> could be set to <strong>private or public</strong>, based on user preference.</p>
<h3>Phase-2: Design Time!</h3>
<p>The first and most important step is to know your audience. In our case, the audience was students at our university, all of them between 18 and 22 years of age, belonging to the new generation, and highly tech-first individuals. Given this, the <strong>neubrutalist design style</strong> was the most fitting choice - it reflects boldness, authenticity, and a raw, digital-first aesthetic that resonates with the tastes of a visually dynamic, tech-savvy audience.</p>
<p><strong>Vibe’s the word</strong>. Because there is nothing better than a beautifully put together bouquet of solid-shadowed, rounded-cornered boxes with vibrant looks and bold fonts that directly speak to you through the screen.</p>
<p><strong>Unfortunately</strong>, we had to <strong>exclude mobile devices</strong> from the platform's operation because the <strong>small screens</strong> were not suitable for the numerous actions and buttons required to use the platform effectively</p>
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755015881747/882ea0e1-6789-4a13-a546-5481ff9f887b.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6861959d2446075675a11dfb/dcd5679d-b3b1-4a13-a406-ff880bec91b4.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6861959d2446075675a11dfb/0b9deeb3-febd-4ace-a66c-5b78f6af7aa9.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755013862062/8ea0db9d-79b7-4142-aebc-a97ae0b20409.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755015471528/516e73ef-b206-499a-8a36-f9073082126d.png" alt="" style="display:block;margin:0 auto" />

<p><em>“Good Design, Development &amp; Production practices teach us that the best app is the one that often goes unnoticed - not because it is uninteresting, but because it does its task so well that a user doesn’t even need to bother thinking about it.”</em></p>
<h3>Phase-3: Data Procurement</h3>
<p>A helper script enabled us to scrape the faculty and subject allotment data in clean, structured format for each department of each school, which was manually mapped and plugged in the software for ready-to-go processing and timetable generation.</p>
<p>Basic principle of its working is that the VTOP portal is secured behind the authentication, and each student belongs to a School (CS/IT/Civil/Mech/etc.) and further categorized into one department out of various departments from each school, so the subjects allotted to each student may differ to some extent.</p>
<p>Curriculum for each course is further divided into groups, like FC (Foundation Core), DC (Discipline Core), DE (Discipline Elective), OE (Open Elective), etc. Few groups are common to all students across the campus, few are common to only students in and school, and few groups are unique for each department.</p>
<p>Now when a student logs in, they can only see the subjects allotted to their department and school, so with help of few friends here and there, all from different branches, we were able to gather the static data of allotted faculties and subjects right on time for FFCS.</p>
<h3>Phase-4: Development &amp; The Engine Under the Hood</h3>
<p>Let’s talk about the actual engineering. Assume an average student completes somewhere between 23 to 27 credits worth of courses each semester, and each course is about 3.5 credits-per-course on average. That means 7-8 courses per semester. Then, students have a choice of faculty for each course from the list of allotted faculties.</p>
<p><em>"If I select one faculty for each course, and keep 2 more as backup option, I will have potentially more than 5,000 possible combinations of faculties and subject."</em> Very hard to sort through manually, no? And wait, then there is the issue of slot clash, the fear of dropping a mandatory course because its lab slot clashed with your core theory!</p>
<p>If we used a standard recursive algorithm to find valid timetables, your browser tab would instantly freeze, crash, and burn before you even released the mouse click. We needed something surgical, fast, and highly optimized that could run entirely client-side.</p>
<p>To solve this, I designed the novel <strong>non-recursive partial-product based 2D-priority algorithm</strong>.</p>
<pre><code class="language-typescript">ALGORITHM: PartialProductTimetableGenerator

INPUT:  courses[]          — list of course objects with slots, faculties, types
        discardClashes     — bool: prune clashing combos or carry partial?

OUTPUT: { result: timetable[][], clashes: string | null }

───────────────────────────

PHASE 1 — NORMALISE
  candidates ← []
  for each course in courses:
    options ← []
    if course.type is 'th' or 'lab':
      for each (slot, faculty) in course:
        options.push({ code, name, slot, faculty })

    else if course.type is 'both':
      for each (slot, faculty) in course:
        for each labSlot in faculty.labSlots:
          options.push({ code: th__lab, slot: thSlot__labSlot, faculty })

    candidates.push(options)

───────────────────────────

PHASE 2 — PARTIAL-PRODUCT EXPANSION
  accumulator ← [ [] ]        ← seed: one empty timetable
  clashGroups ← {}            ← slot → set of conflicting (course, faculty) pairs
  seenPairs   ← {}            ← dedup set for clash messages

  for each option_list in candidates:
    next ← []

    for each partial in accumulator:
      occupied ← expand(partial)   ← all slots + their clashMap aliases

      for each candidate in option_list:
        cSlots ← expand(candidate.slot)

        if cSlots ∩ occupied = ∅:                     ← NO CLASH
          next.push([...partial, candidate])

        else if not discardClashes:                    ← SOFT MODE
          next.push([...partial])                      ← carry partial as-is

        else:                                          ← HARD MODE + RECORD
          for each (a, b) in partial × {candidate}:
            clashing_slot ← first slot in expand(a) ∩ expand(b)
            if (a.faculty, b.faculty) not in seenPairs:
              seenPairs.add(pair)
              clashGroups[clashing_slot].add(a.faculty + " for " + a.course)
              clashGroups[clashing_slot].add(b.faculty + " for " + b.course)

    accumulator ← next          ← replace — O(1) swap, not append

───────────────────────────

PHASE 3 — FINALISE
  result ← breakClubbed(accumulator)   ← split "A1__L1" → discrete slots

  if result = [] and clashGroups ≠ {}:
    clashMessage ← format clashGroups into human-readable conflict report

  return { result, clashes: clashMessage | null }

───────────────────────────

HELPER: expand(slotString | partial)
  split on '+' and '__'
  for each raw slot:
    include slot itself
    include clashMap[slot] aliases     ← handles VIT's slot equivalences
  return flat deduplicated set
</code></pre>
<p>Instead of generating every possible combination and <em>then</em> checking for clashes (which is computationally heavy and inefficient), the algorithm uses a partial-product approach. It evaluates courses iteratively, cross-referencing slots in real-time. If Subject A's lab (L1) clashes with Subject B's theory (A1), that entire branch of combinations is instantly pruned from the matrix. Hence, we don't have to worry about any recursion or memory leaks, and it keeps the DOM buttery smooth.</p>
<p>Wait that's just one-dimensional checking; wasn't it supposed to be a "2D Priority Algorithm"? Of course it is! The engine mathematically weighs both the priority of the <em>Subject</em> (e.g., you desperately need this mandatory core course) and the priority of the <em>faculty</em> (e.g., you really, really want that specific professor).</p>
<img src="https://cdn.hashnode.com/uploads/covers/6861959d2446075675a11dfb/6517ac2d-f02f-42c8-ad7c-bbabf98d1472.png" alt="" style="display:block;margin:0 auto" />

<p>This culminated in the ultimate feature: the <strong>"All Subjects Mode"</strong>. By leveraging our optimized algorithm, the engine can crunch massive permutation trees and hunt down the perfect combination where <em>every single one</em> of your selected subjects fits flawlessly into the grid without a single clash. It manages all of this complex state using heavily fortified TypeScript models and Context (<code>TimeTableContext.tsx</code>), ensuring that no matter how messy VIT's course catalog gets, the app’s logic remains strictly typed and unbreakable.</p>
<p><strong>Table1 : Architectural Component Analysis</strong></p>
<table style="min-width:100px"><colgroup><col style="min-width:25px"></col><col style="min-width:25px"></col><col style="min-width:25px"></col><col style="min-width:25px"></col></colgroup><tbody><tr><td><p><strong>Component</strong></p></td><td><p><strong>Technology</strong></p></td><td><p><strong>Primary Function</strong></p></td><td><p><strong>Justification for FFCS Domain</strong></p></td></tr><tr><td><p><strong>Frontend Framework</strong></p></td><td><p>Next.js (React)</p></td><td><p>UI Rendering &amp; Routing</p></td><td><p>Enables SSR for fast load times of large faculty lists; simplifies API integration.</p></td></tr><tr><td><p><strong>Language</strong></p></td><td><p>TypeScript</p></td><td><p>Logic &amp; State Management</p></td><td><p>Enforces type safety across complex, nested academic data structures; prevents runtime errors.</p></td></tr><tr><td><p><strong>Styling Engine</strong></p></td><td><p>Tailwind CSS</p></td><td><p>Visual Presentation</p></td><td><p>Facilitates complex grid layouts for timetables; ensures mobile responsiveness.</p></td></tr><tr><td><p><strong>Database</strong></p></td><td><p>MongoDB</p></td><td><p>Saved Timetable Storage</p></td><td><p>To store the timetables saved by users post-login, and maintaining the share-IDs &amp; visibility status</p></td></tr><tr><td><p><strong>Export Engine</strong></p></td><td><p>pdfmake / ExcelJS</p></td><td><p>Data Portability</p></td><td><p>Allows client-side generation of schedule files, reducing server load and enabling offline access.</p></td></tr></tbody></table>

<p><strong>Table 2: Algorithmic Complexity Profile</strong></p>
<table style="min-width:100px"><colgroup><col style="min-width:25px"></col><col style="min-width:25px"></col><col style="min-width:25px"></col><col style="min-width:25px"></col></colgroup><tbody><tr><td><p><strong>Operation</strong></p></td><td><p><strong>Implementation Strategy</strong></p></td><td><p><strong>Time Complexity</strong></p></td><td><p><strong>Notes</strong></p></td></tr><tr><td><p><strong>Clash Check</strong></p></td><td><p>Hash Map / Conflict Matrix lookup</p></td><td><p>O(1)</p></td><td><p>Constant time lookup is essential for real-time UI feedback.</p></td></tr><tr><td><p><strong>Search/Filter</strong></p></td><td><p>Client-side array filtering</p></td><td><p>O(N)</p></td><td><p>N = Total Faculty. fast enough for N &lt; 10000 in modern JS engines.</p></td></tr><tr><td><p><strong>Timetable Gen</strong></p></td><td><p>Depth-First Search with Pruning</p></td><td><p>O(B^D)</p></td><td><p>Exponential worst-case but strictly bounded by small D (number of subjects ~6-7).</p></td></tr><tr><td><p><strong>Grid Rendering</strong></p></td><td><p>Direct Index Mapping</p></td><td><p>O(C)</p></td><td><p>C = Selected Courses. Rendering is linear to user selection</p></td></tr></tbody></table>

<h3>Phase-5: Furthermore...</h3>
<p>Well, you generated timetables, now what? Up till here was only half the story. You can not only generate priority-based clash-free timetables, ...but you can also <em>(drumroll...)</em> Save, Share and Download them!</p>
<p>Users can download a whole report, which helps them take informed decisions during actual course registration. A simple tabular report is generated in PDF form that you can save on your desktop and take a printout. Further explanation is useless, see this screenshot instead:</p>
<img src="https://cdn.hashnode.com/uploads/covers/6861959d2446075675a11dfb/8cb92fd6-02c9-49f5-99db-766c1ba5a860.png" alt="" style="display:block;margin:0 auto" />

<p><em>(Example of a generated report with priority-ordered data of selected courses and faculties, alongside clear indication of clashes, if any)</em></p>
<p>Logins are boring, for both - users and developers. They take away precious time of your life. Which is why, login (OAuth) with Google (VIT Student ID) has only been made required for features like saving and sharing a timetable combination. If a user really likes a specific timetable out of the roster, they can seamlessly save it by authenticating themselves with official university ID, and simply giving the timetable a name, like say, "Too Optimistic Morning Theory".</p>
<img src="https://cdn.hashnode.com/uploads/covers/6861959d2446075675a11dfb/e381252e-5934-42de-8125-40c960f21072.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6861959d2446075675a11dfb/59b9db09-e47e-4687-b582-87f72d8b2268.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6861959d2446075675a11dfb/725d28a0-d1c3-448f-9bac-363739502404.png" alt="" style="display:block;margin:0 auto" />

<p>Moreover, all saved timetables can be shared with anyone (does not need login to view a shared timetable) by flipping a switch and setting a saved timetable from PRIVATE to PUBLIC. All this was made possible with the help of DB integration powered by MongoDB and a lot of coffee.</p>
<h2>Aftermath</h2>
<p>The project was completed in June 2025 after two whole weeks of sleep-deprivation. It gained 10k users in just 3 days, and another 20k over next 5 months, since course registration only happens twice a year. Analytics also show that average engagement time was around 3 minutes. Meaning - we were able to cut down the FFCS planning time by about 85%, indicating a big population shift from manual planning to smart planning for course registration.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6861959d2446075675a11dfb/9212c12e-3ab4-45b9-95a3-728a65126df6.png" alt="" style="display:block;margin:0 auto" />

<p>I am most <strong>definitely missing a lot of things</strong> to add and a lot of challenges we faced while making this happen, along with many itty-bitty things that can be potentially improved in the future.</p>
<h2>Gratitude</h2>
<img src="https://cdn.hashnode.com/uploads/covers/6861959d2446075675a11dfb/9d158d02-e76d-4b1c-9dc7-282931673738.png" alt="" style="display:block;margin:0 auto" />

<p>Special thanks to Dr. Doofenshmirtz for inspiring us come up with this creative name, "FFCS-inator"</p>
<h3>Oh, did I forget to mention?</h3>
<img src="https://cdn.hashnode.com/uploads/covers/6861959d2446075675a11dfb/a4489cda-5878-4f75-8286-7bf3b39ad993.jpg" alt="" style="display:block;margin:0 auto" />

<p><em>Sept 15, 2025: Honored with the "Best Club Project" Award during the Engineer's Day Ceremony at VIT Vellore</em></p>
<p>It was really fun (and equally exhausting) to work on this project, but the final results were definitely worth the effort.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6861959d2446075675a11dfb/05f130ae-5c3c-4669-a86a-9fc984053f8b.png" alt="" style="display:block;margin:0 auto" />

<p>I thank my seniors and juniors who helped with any part of the process in making this idea come alive, I thank my team who tolerated me through the weeks of literally sleepless dev cycles, and most importantly I thank all the users, who made this a big success. I also thank Beyoncé.</p>
<p>And thank YOU if you read it all till the end :)</p>
]]></content:encoded></item><item><title><![CDATA[Racing Against Time: How We Built a Fair, Server-Synchronized Contest Timer at Scale]]></title><description><![CDATA[A behind-the-scenes look at building a Redis-backed, server-synchronized contest timer, scalable worker architecture, and race-ready backend]]></description><link>https://blogs.codechefvit.com/pitlane-to-production-p3</link><guid isPermaLink="true">https://blogs.codechefvit.com/pitlane-to-production-p3</guid><category><![CDATA[Server clock]]></category><category><![CDATA[timer]]></category><category><![CDATA[Docker]]></category><category><![CDATA[horizontal scaling]]></category><dc:creator><![CDATA[Atharva Neena Sharma]]></dc:creator><pubDate>Sat, 28 Feb 2026 17:00:00 GMT</pubDate><enclosure url="https://cloudmate-test.s3.us-east-1.amazonaws.com/uploads/covers/68c5c4b06ed6622c853fdb4a/770d3253-dcca-46d2-9bc0-1714155fba94.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Lights Out, And Away We Go (Again)</h2>
<p>By the time Sunday rolls around in a Grand Prix weekend, the garages are quiet, the setup is locked in, and nobody is allowed to touch anything unless it’s absolutely necessary. That’s exactly where we were with the backend in Part 3 of From Pit Lane to Production. Practice was done, qualifying had set the grid, and now it was race day. This was the phase where systems had to work flawlessly, not because they were flashy, but because if they failed, everyone would notice. That too while screaming.</p>
<h2>It’s About Time (Literally)</h2>
<p>Every race needs a clock. Not a “my laptop says so” clock. A single, authoritative race timer that everyone trusts, like the FIA timing screen (minus the controversy.)</p>
<p>That’s where the timer package came in. Its job was simple: make sure every contestant was racing against the same ticking clock, no excuses, no browser shenanigans.</p>
<p>When the admin fired up <code>SetTime</code>, the backend first checked if a round was already active. Because starting two races at once is how you end up on a Netflix documentary ( Although I really want to feature on Netflix but not this way). If all was clear, it took the admin-provided end time, parsed it into a clean <code>RFC3339</code> timestamp, converted it to Indian Standard Time, and parked it safely inside Redis under the <code>round_end_time</code> hash. Stored in memory, fetched in milliseconds faster than a Mercedes pit stop on a good day.</p>
<p>Then came GetTime, the endpoint every contestant leaned on like a steering wheel in Eau Rouge. When pinged, it first checked whether a round was actually running via <code>is_round_started</code>. It then verified the user’s round ID against the current one in Redis, shutting down any attempts at cross-round funny business. Only after passing scrutineering did it fetch the start time, end time, and current server time, sending them back to the frontend. The result? A countdown timer perfectly in sync with the server, even if the user’s system clock thought it was still 2022.</p>
<p>Finally, UpdateTime handled race control chaos. Need to extend the round? Shorten it? Weather delay? Safety car? This endpoint pulled the current end time from Redis, adjusted it by the given duration, rewrote the round_end_time, and updated the TTL on <code>is_round_started</code>. When the TTL expired, the race ended. Clean. Automatic. No human panic required.</p>
<p>On the surface, it was “just a timer.” Under the hood, it was the FIA timekeeping system: quiet, precise, and absolutely unforgiving.</p>
<h2>The Docker Garage (And the Multi-Car Strategy)</h2>
<p>Every F1 team has a garage. Ours was Docker, deployed on DigitalOcean, clean, repeatable, and mercifully boring.</p>
<p>Each service had a clearly defined role:</p>
<p>Postgres handled persistence, backed by volumes so data didn’t vanish mid-race.</p>
<p>Redis lived entirely in memory, managing timers, flags, and caching with engineer-level precision.</p>
<p>The API container was the main car : handling requests, validating rules, and serving responses under load.</p>
<p>Nginx sat up front, routing traffic cleanly like race control on a good day.</p>
<p>But the real strategy call?</p>
<p>We didn’t run one worker. <strong>We ran multiple.</strong></p>
<p>The worker service was horizontally scaled, spinning up multiple containers to handle submission load in parallel. One worker would’ve been fine in practice. Maybe even qualifying. But race day is different. When hundreds of submissions hit at once, you don’t pray, you call the head office for backup force.</p>
<p>Each worker container picked up jobs independently, pulling from the same queues, processing submissions without stepping on each other’s toes. No bottlenecks. No backlog panic. Just clean parallel execution, like running multiple stints with fresh tyres instead of cooking one set to death.</p>
<p>DigitalOcean was our circuit for the weekend. And for once, nothing exploded.</p>
<h2>Backend So Smooth, It Deserves a Podium</h2>
<p>And then came the race itself.</p>
<p>Everything worked. Not in a “don’t touch it or it’ll break” way, but in a Hamilton in Mercedes way, fast, composed, and suspiciously drama-free. Submissions flew to Judge0 like DRS wide open, Redis hit cache lookups with pit-stop precision, and the backend just… kept going.</p>
<p>At the end for the entire dev team while we were standing at the venue, on contest day, watching the system run felt like watching a perfect lap: clean lines, no oversteer, total confidence.</p>
<p>So, that's enough od my yap for this final part of this series.</p>
<p>If you’ve read this far, congratulations. You now know more about this system than half the pit wall. Go grab a snack, stretch your legs, and enjoy the moment.</p>
<p>You’ve earned your place on the podium.</p>
]]></content:encoded></item><item><title><![CDATA[Capital One’s 200ms Random Forest: Stopping Launderers Before the Wire Hits]]></title><description><![CDATA[Capital One has revolutionized financial surveillance by trading a static, 30-page "if-else" rulebook for a high-speed Random Forest ML Model]]></description><link>https://blogs.codechefvit.com/capital-ones-200ms-random-forest</link><guid isPermaLink="true">https://blogs.codechefvit.com/capital-ones-200ms-random-forest</guid><category><![CDATA[Random Forest]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[decisiontree]]></category><category><![CDATA[fintech]]></category><category><![CDATA[Artificial Intelligence]]></category><dc:creator><![CDATA[Sanjana Shyamsundar]]></dc:creator><pubDate>Sun, 22 Feb 2026 10:41:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1767445134675/ba9f9ed8-a625-4010-9133-09351d471784.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Imagine spotting a money launderer before the wire transaction even settles! Capital One’s ML model just turned a traditional 30 page rulebook into a 200 ms risk score that tells investigators which gift wrapped alert to open first.</p>
<p>The traditional method of a rule based deterministic approach was a simple ledger of “if-else” alarms: If a cash deposit was greater than an amount X and if the frequency was greater than Y in Z days, an alert would be sent out, without any intimation of the level of risk posed. This approach had the following drawbacks :</p>
<ul>
<li><p>99% of the water was simply false positive foam</p>
</li>
<li><p>Investigators had to open cases first in first out, so the needle hid in the haystack</p>
</li>
<li><p>Inability to focus more precisely on just the right combinations of triggers</p>
</li>
</ul>
<h2>Using machine learning to build a suspicious activity monitoring system at Capital One</h2>
<p>In August 2020 Capital One began applying machine learning to suspicious activity monitoring with an aim to :</p>
<ul>
<li><p>Use a wide range of data to enable better decisions and give more insight to the investigators</p>
</li>
<li><p>Prioritise risk based investigations</p>
</li>
</ul>
<p>This algorithm hunts for behavioral patterns that indicate financial crime. It detects Structuring**,** where criminals break a mountain of dirty cash into small, unnoticeable chunks, to dodge the reporting threshold.</p>
<p>It also spots Velocity Spikes, identifying accounts that act like gateways , money wiring in and immediately wiring out, typical attribute of shell companies trying to wash funds quickly.</p>
<p>Additionally, it flags Profile Deviation, noticing when a customer’s behavior doesn't match their identity like a college student’s account suddenly moving large amounts of money for business activities is very unusual.</p>
<h2><strong>Deconstructing the ML Algorithm Used :</strong></h2>
<p>The core of the model is a random forest classifier built using Sci-Kit Learn, coded in Python and PySpark.</p>
<p>A Random Forest algorithm merges the decisions of various decision trees to find an answer that best represents the average of all the decision trees</p>
<h3><strong>Why is a single decision tree not a better fit?</strong></h3>
<p>A single decision tree is prone to a problem called <strong>High Variance (or Overfitting). T</strong>hink of a single gardener who memorizes every specific detail of the plants he has seen during the training process. The flaw here would be that he creates complex rules based on noise rather than the general pattern. The tree captures the noise of the training data so perfectly that it fails to generalize to new data not used during the trainning process.</p>
<p>Now think of a garden with 500 gardeners. If a single pruner might lean the wrong way, the collective decision of 500 gardeners ensures that the flowers and weeds stay sorted the Random Forest accepts that each individual tree might be a little wrong (high variance), but by averaging them, the error cancels out.</p>
<p>When a new transaction arrives :</p>
<ol>
<li><p>The Ballot: Each of the 500 trees casts a simple vote: <em>Suspicious</em> or <em>Not</em>.</p>
</li>
<li><p>The Count: Only the majority isn’t considered, infact the majority voice is converted into a precise</p>
<p> 0-100 probability score. Think of it as a confidence score :</p>
<ul>
<li><p><strong>Scenario A:</strong> 100 gardeners say "Weed", then we get</p>
<p>  100/ 500 = 0.20, which means our score is <strong>20%</strong> ( Least supicious )</p>
</li>
<li><p><strong>Scenario B:</strong> 250 gardeners say "Weed”, then we get</p>
<p>  250 / 500 = 0.50, which means our score is 50% ( Barely suspicious )</p>
</li>
<li><p><strong>Scenario C:</strong> 450 gardeners say "Weed", then we get</p>
<p>  450 / 500 = 0.90, which means our score is 90% ( Highly suspicious )</p>
</li>
</ul>
</li>
</ol>
<p>By keeping the score as a number instead of just a label, the bank knows which alert to open first. In this case, scenario C will be prioritized over scenario B.</p>
<h3><strong>The Data Layer</strong></h3>
<p>For better decisions, they first created several features based on customer transaction histories that could relate to suspicious activity to train the model.  When presented with a customer's identifiers, the model pulls the relevant customer attributes and transaction data, applies it to the model, and generates a score that represents the likelihood the customer's activity would be deemed suspicious.</p>
<img alt="" />

<p>To keep the model explainable, fast, and accurate, they regularly audit and prune i.e remove some features. Think of it as an indoor plant, snip the tiny twigs so the tree stays small, sharp, and always in season, let the strongest branches get the sunlight</p>
<h3><strong>The Model Layer</strong></h3>
<p>At the core sits a 500 tree Random Forest, trained on 65 laser pruned features.  Each tree casts a simple vote, suspicious or not, and the forest turns the majority voice into a 0-100 probability score.  Due to PySpark, the whole ensemble digests 120 k labeled cases in under 30 min on a 16 core cluster, so the model is fresh every morning.</p>
<p>That single score is the baton that is passed on to the investigation team.  Low score alerts skip the queue for a quick one click closure, mid score alerts follow the traditional workflow, and the high score alerts are prioritized to be reviewed first.</p>
<h3><strong>How does a Capital One gardener train his eye?</strong></h3>
<p>Now, let’s dive deep into the math of the random forest algorithm, starting with Mean Square Error ( MSE )</p>
<p>Before the forest can hunt for money launderers, each of the 500 individual gardeners (trees) must calibrate their vision. They look at 120,000 historical cases where the answer is already known and test their intuition.</p>
<ul>
<li><p><code>Yi</code> = The Truth (0 = Legitimate Customer, 1 = Money Launderer)</p>
</li>
<li><p><code>Fi</code> = The Gardener’s Guess (His personal risk score)</p>
</li>
</ul>
<p><code>Square of his mistake = (Yi-Fi)²</code></p>
<p>He sums these up to find his focus, which is:</p>
<p><code>MSE = Average of (Mistakes)²</code></p>
<p>This formula calculates the distance of each node from the predicted actual value, helping to decide which branch is the better decision for your forest. Here, yi is the value of the data point you are testing at a certain node, and fi is the value returned by the decision tree.</p>
<p>A small MSE is good, a sharp gardener is ready for duty; however, a big MSE value means that the data needs to be split again</p>
<p>Where does he snip the branch? (Classification)</p>
<p>The goal is to get pure error free values, and the method is Gini Impurity, which acts as a messiness meter.</p>
<p>Considering that the gardener has 65 laser pruned features to help him decide where to cut. He wants to separate the mix of legitimate shoppers and fraudsters into pure buckets.</p>
<p>Thus, the Gini Impurity score is used to measure the chaos :</p>
<p><code>Gini = 1-(share of Legit²+ share of Fraud²)</code></p>
<p>This formula uses the class and probability to determine the Gini of each branch on a node, determining which of the branches is more likely to occur. Here, pi represents the relative frequency of the class you are observing in the dataset, and c represents the number of classes.</p>
<ul>
<li><p>0.0 = Perfectly pure bed (All fraud or all legit)</p>
</li>
<li><p>0.5 = Worst jungle (50% fraud, 50% legit)</p>
</li>
</ul>
<p>Entropy is a related concept, but it asks how many yes/no questions are still unclear?</p>
<p>Either way, the gardener chops the branch exactly where the messiness drops the most, ensuring the strongest branches get the sunlight and the risk is isolated.</p>
<p>This is how the core investigation of the model is put together statistically to get a score of suspicious activity.</p>
<h2><strong>Conclusion</strong></h2>
<p>The vast majority of scores generated by the system result in the expected investigative output. Overall, the system developed by Capital One has proven itself to be less error prone and more efficient than rules based systems. Capital One overcame the traditional sticking points to create an industry-leading, innovative machine learning solution focusing more on truly suspicious activity, thereby creating a powerful new tool in its arsenal against criminal activity.</p>
]]></content:encoded></item><item><title><![CDATA[Turning The Underworld into a Scavenger Quest Through Game Systems and Design]]></title><description><![CDATA[A full GameDev DevBlog on implementing core dungeon crawler systems such as combat logic, puzzles, progression, AI behavior, and score calculation.]]></description><link>https://blogs.codechefvit.com/underworld-scavenger-quest-game-design</link><guid isPermaLink="true">https://blogs.codechefvit.com/underworld-scavenger-quest-game-design</guid><category><![CDATA[Game Development]]></category><category><![CDATA[Indie Game Development]]></category><category><![CDATA[#Game Design]]></category><category><![CDATA[devlog]]></category><category><![CDATA[DungeonCrawler]]></category><category><![CDATA[unity]]></category><category><![CDATA[C#]]></category><category><![CDATA[gameplay]]></category><category><![CDATA[leveldesign]]></category><category><![CDATA[Pixels Art]]></category><category><![CDATA[puzzle]]></category><category><![CDATA[mythology]]></category><category><![CDATA[CodeChef]]></category><category><![CDATA[Game Jam]]></category><category><![CDATA[backend]]></category><dc:creator><![CDATA[Aditya Gupta]]></dc:creator><pubDate>Wed, 14 Jan 2026 14:10:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1766344931706/b2d7b8b0-12f2-48bc-b662-377d4a20e1cf.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hey wanderers of the underworld. My name is <strong>Aditya Gupta (aka MelloHyu)</strong>, joined by the rest of the brave and occasionally sleep deprived Purgatory team: <strong>Dhruv, Yatharth, Lavnish, Joseph, Aarushi, Narendra, Sanjana, Harsheta and Khalid</strong>. Together, we built <strong>Purgatory</strong>, a hell themed dungeon crawler where combat, puzzles, traps, and deduction work together inside rooms designed to test your instincts, your logic, and sometimes your sanity.</p>
<p>Over the past month before Clueminati 3.0 conducted by CodeChef VIT, we have been designing, debugging, accidentally deleting things, and resurrecting people. In this DevBlog, I will be walking you through the journey of how Purgatory’s systems came together, the problems we faced, the funny moments, and the life mysteries we solved along the way.</p>
<h1 id="heading-what-is-purgatory"><strong>What is Purgatory</strong></h1>
<p>Purgatory is a <strong>Top-Down Dungeon Crawler</strong> set in a stylized version of hell, while making sure that it is not the usual fire and brimstone cliché. Inspired from the gameplay of the old Zelda games, it revolves around solving handcrafted puzzles and exploration while also offering the Players a simple combat system which they can utilize to face their enemies for extra score points. Since it was designed specifically for the Clueminati 3.0 event, it feels more like a treasure hunt embodied within a game rather than a usual Dungeon Crawler. The Player needs to travel from room to room, finding secrets, solving puzzles, fighting enemies and avoiding traps. All of these provide the Player with score points which add up to their final score at the end to decide who is the winner of Clueminati 3.0 treasure hunt.</p>
<h1 id="heading-where-the-inspiration-came-from"><strong>Where the Inspiration Came From</strong></h1>
<p>We had brainstormed a number of scenarios for our game but from the start we had an inkling that we would be fiddling with the concept of the broody and kingdom-style iteration of hell, and naturally the genre of a lone adventure party came to mind.</p>
<p>This was naturally because in a lot of recent mythologies and western media, modern hell is imagined more as a place of entrapment with clever wordplay and preying on the target’s  worst qualities than brute force.</p>
<p>So we focused on these qualities and chose the classic seven layer approach, although we always knew the key layer had to make the cut. It felt like the one ingredient we could not leave off the menu.</p>
<p>One thing that we noticed was that in a lot of fiction, Envy’s lair receives the least attention. It often slips by with barely any explanation, so we decided to turn the idea around and bring it to the center, giving it the weight and personality it rarely gets. After all, “Envy” is as prominent as the others.</p>
<p>Our goal was a game where combat skill matters, but thinking matters even more.<br />A place where players have a lightbulb moment one boss fight at a time.</p>
<h1 id="heading-core-ideas-behind-purgatory"><strong>Core Ideas Behind Purgatory</strong></h1>
<p>Many dungeon crawlers follow the loop of fight and loot.<br />Purgatory deliberately breaks that rhythm.</p>
<h3 id="heading-combat-can-be-optional"><strong>Combat Can Be Optional</strong></h3>
<p>Players can run past enemies if they find them too difficult or if they simply do not want to. Killing enemies is just an incentive to gain a higher score than the other players.</p>
<h3 id="heading-puzzles"><strong>Puzzles</strong></h3>
<p>We designed a mix of:</p>
<ul>
<li><p>Magnetic box lever puzzles</p>
</li>
<li><p>Sherlock Holmes style deduction riddles</p>
</li>
<li><p>Treasure Hunts</p>
</li>
<li><p>Hide and Seek Encounters</p>
</li>
<li><p>Lore discovery chambers</p>
</li>
<li><p>Lava and Spike Gauntlets</p>
</li>
<li><p>Rooms where the real puzzle is realizing the wall was not a wall</p>
</li>
</ul>
<h3 id="heading-two-boss-fights-based-on-goetic-princes"><strong>Two Boss Fights Based on Goetic Princes</strong></h3>
<p>If you are going to hell, meeting management is only polite.</p>
<p>The entire hell theme relied heavily on the theme of the Goetic Princes of Hell. Each level is a physical embodiment of the sin they carry.</p>
<p>While discussing the direction of the game before the first Expo leading to Clueminati 3.0, we realized that we needed to show at least one Boss Fight to the potential treasure hunters. The vision of a bull charging towards the Player seemed like something we wanted to try to implement. We searched for some inspiration and came across an iteration where a certain Goetic Prince is reimagined as a large gold bull. Thus, we started the game by introducing the gold hauling, fortune loved, “The Goetic Prince of Greed”, <strong>Mammon</strong>. The boss challenges the strategic prowess of the player by constantly changing its attack pattern. While these attack patterns may seem impossible to counter at first glance, they often had an intentional weak point. I, having personally worked on Mammon, can say with confidence that the bosses were the most fun part of the experience.</p>
<p>The second boss that we designed is “The Goetic Price of Envy”, <strong>Leviathan</strong>, who is the final boss for now. This boss was a bit tricky to design since we wanted it to give the feel of an endgame. The final consensus was to recreate Leviathan as the huge, monstrous, serpent often portrayed in the media. Thus, the final product was a Serpent that engulfed the entire arena with its body, digging in and out of the ground at will and circling the Player with its body. As Leviathan is often associated with living in deep waters, for the stage creation itself, we decided to give it an underwater thematic style.</p>
<h3 id="heading-a-high-score-system"><strong>A High Score System</strong></h3>
<p>Every decision feeds into your final score.<br />The enemies that you killed among the chaos, the puzzles that you solved somehow, the new rooms that you discovered that hid some secret and how quickly you completed the final center piece.</p>
<h1 id="heading-building-the-systems-behind-the-scenes"><strong>Building the Systems Behind the Scenes</strong></h1>
<p>Like any dungeon, Purgatory’s true structure lives underground inside the codebase.</p>
<p>Here is the ecosystem that brings it all to life:</p>
<h3 id="heading-inventory-and-item-usability"><strong>Inventory and Item Usability</strong></h3>
<p>A flexible system that handles picking up objects, using them, discarding them, and occasionally hoarding them like a dragon.</p>
<h3 id="heading-npc-dialogue-system"><strong>NPC Dialogue System</strong></h3>
<p>Powered by the Dialogue Editor tool from the Unity Asset Store.</p>
<p>NPCs are virtual humans too, which comes with its perks and cons.<br />NPCs can lie, mislead, give lore, give quests, or confuse you completely. The dialogues were not just limited to NPCs either, even the coins splattered over the ground or the never budging walls had some tidbits to express.</p>
<h3 id="heading-spritesheet-animation-pipeline"><strong>SpriteSheet Animation Pipeline</strong></h3>
<p>Animating bosses and traps was unpredictable.<br />One misaligned frame and suddenly the boss started moonwalking.</p>
<p>Our design team did a wonderful job with the sprite sheets and the art style, creating a blend of serious urgency with witty humour. We aimed to create a nostalgic feel with the 16x16 pixel art and a very cool sword.</p>
<h3 id="heading-stat-system"><strong>Stat System</strong></h3>
<p>It handles the Stats of each living, breathing object in the game alongside the inanimate ones that were out to kill you like the traps. They consist of basic sections like current health, max health and attack strength. But it is not limited to just these, they also handle the difficulty of the enemy, if the puzzle is solved and so on.</p>
<h3 id="heading-score-calculator-and-backend-score-manager"><strong>Score Calculator and Backend Score Manager</strong></h3>
<p>A run is evaluated based on:</p>
<ul>
<li><p>Combat Efficiency</p>
</li>
<li><p>Puzzle Performance</p>
</li>
<li><p>Time taken to complete</p>
</li>
</ul>
<p>We even built a login system with a database, which keeps track of the scores of every challenger that enters. This was, for the duration of the Clueminati 3.0, also responsible for giving the treasure hunters a secret unique clue made specifically for their team at the end of the run.</p>
<p>The team working on the backend for the application, used for Clueminati 3.0, did a wonderful job with merging the game into the event. The participants would sign up using the app and use those credentials to log into our game. Through this, using a route, we updated the score earned each round directly to the database allowing seamless integration with the event. To spice things up, we also used a route to send part of a secret code generated from the backend specifically for each team, to them, on finishing the final round. This allowed us to neatly wrap up the indoor section of the game and give the players a sense of wonder.</p>
<h1 id="heading-personal-thoughts-about-the-game"><strong>Personal Thoughts About the Game</strong></h1>
<p>My favorite part is watching players try to solve a puzzle while being chased by the one kamikaze enemy they chose to ignore earlier.</p>
<p>Beyond that:</p>
<p>Designing handcrafted rooms felt like building stories.<br />Seeing players discover hidden walls we never mentioned was magical.<br />Creating the Detective puzzle and watching people role play detectives, feeling like Sherlock Holmes by finding the devil hiding among civilians gave a sense of accomplishment.</p>
<p>The boss fights remain my personal favorite.</p>
<p>Designing the phases the boss goes through and the overall systems that go on behind the scenes were exhausting to make and took a lot of time but the end product compensated for all those late-nights. Witnessing the boss come together piece by piece was very rewarding.<br />Challenging, intense, and narratively meaningful.</p>
<h1 id="heading-team-experiences-and-funny-moments"><strong>Team Experiences and Funny Moments</strong></h1>
<p>Here are some unforgettable stories from development:</p>
<ul>
<li><p>The dialogues for the NPCs kept resetting if we made even a minor tweak in the script. I had to write those dialogues so many times that I have practically memorized them.</p>
</li>
<li><p>Someone put a cat instead of an actual enemy in one of the rooms. The cat has now become a mini-boss.</p>
</li>
<li><p>A hidden wall was so well hidden that even we forgot it existed.</p>
</li>
<li><p>A Test dialogue was left in the final version. We were as confused as the Players when a NPC just blabbered “My Guy” like your high school friend.</p>
</li>
</ul>
<h1 id="heading-critiques-and-lessons-learned"><strong>Critiques and Lessons Learned</strong></h1>
<p>No game emerges perfect from the underworld, and Purgatory is no exception. Here are some of the most important critiques we faced and what we learned from them.</p>
<h3 id="heading-1-difficulty-spikes"><strong>1. Difficulty Spikes</strong></h3>
<p>The most common problem that is faced by developers is difficulty optimization, and we were no exception to this. As the developers, we are so used to replaying the game to test it that we do not realize that the things we found easy to do may very well be almost impossible for new players who do not have such experience with the crooks and corners of the world.</p>
<p>Some rooms were gentle and welcoming.<br />While some rooms sent the Players into a rage.<br />Players wanted a smoother curve, so we reorganized the room flow.</p>
<h3 id="heading-2-puzzle-clarity"><strong>2. Puzzle Clarity</strong></h3>
<p>A few puzzles leaned a bit too hard into abstract thinking.</p>
<p>While it was easy for us to solve since we knew the answer, a new Player did not have enough clues to put two and two together. They often got stuck or occasionally solved them by accident or brute force.<br />We refined clues and interactions to reduce confusion without removing challenges.</p>
<h3 id="heading-3-backtracking-fatigue"><strong>3. Backtracking Fatigue</strong></h3>
<p>Replayability is central to the game, which requires minimum backtracking to not bore the Player. While the “Greed” section of the game maintained that linear path, the “Envy” section was not up to the mark due to a lack of time. The overall layout of the stage required players to tediously backtrack more than it should have.<br />We added shortcuts and streamlined pathways where possible.</p>
<h3 id="heading-4-combat-balance"><strong>4. Combat Balance</strong></h3>
<p>Optional combat is fun, but it also means players can accidentally skip too much.</p>
<p>In the playtesting phase, we noticed a lot of testers who skipped the combat rooms to go straight to puzzles. While this was something we promoted, we also did not want the Players to skip out on the whole combat experience.<br />We increased the score given by defeating enemies which incentivised the Players into killing the enemies to increase their score.</p>
<h3 id="heading-5-visual-communication"><strong>5. Visual Communication</strong></h3>
<p>Some traps were visually subtle and felt unfair when they killed players instantly.<br />We improved telegraphs and animations to make danger readable before it becomes lethal.</p>
<p>Aside from these common mistakes, we also faced a lot of bugs and logical errors due to a lack of a better system foundation. We learned to restructure the code when needed as soon as possible. Another issue that came up was working seamlessly as a team. While we made sure to equally divide the tasks, we did not foresee that we may enter into a stalemate where one developer needs to wait for another developer’s work to finish in order to start his own. As we worked, we eventually learned to plan better and overcome this.</p>
<p>Each critique pushed the project into a better shape and our mental health into the abyss.<br />In hindsight, the dungeon taught us more magic than portrayed.</p>
<h1 id="heading-closing-thoughts"><strong>Closing Thoughts</strong></h1>
<p>Purgatory has been one of our most ambitious and chaotic projects.<br />The deadline kept creeping up on us ever so slightly, while we scrambled to make the foundations work. Despite the sleepless nights, observing the Players play this game at the event was every dime worth. The project taught us a lot as game developers, and I cannot thank my fellow developers enough for pushing through all the adversities that came our way.</p>
<p>Thank you for descending with us.<br />And in the true spirit of envy.<br />We need to be better.</p>
]]></content:encoded></item><item><title><![CDATA[How we designed a code evaluation pipeline using Judge0 with Golang, Echo & Redis.]]></title><description><![CDATA[How we built a Code Judge pipeline with Go, Echo, Redis, PostgreSQL, and Judge0 supporting real-time code execution.]]></description><link>https://blogs.codechefvit.com/pitlane-to-production-p2</link><guid isPermaLink="true">https://blogs.codechefvit.com/pitlane-to-production-p2</guid><category><![CDATA[golang]]></category><category><![CDATA[Redis]]></category><category><![CDATA[judge0]]></category><category><![CDATA[Docker]]></category><category><![CDATA[asynchronous]]></category><category><![CDATA[Worker Thread]]></category><dc:creator><![CDATA[Atharva Neena Sharma]]></dc:creator><pubDate>Sun, 28 Dec 2025 15:07:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1765132102574/39c4908a-e905-4e45-990f-b8c9086b53b3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-race-day-madness-the-submission-pipeline-and-judge0-pit-stops">Race Day Madness: The Submission Pipeline and Judge0 Pit Stops.</h2>
<p>Welcome back to the pit lane.<br />Previously, we designed the backend and confidently assumed the hard part was over. It wasn’t. Because buried deep inside this system lived a group of routes so important that if it breaks, the entire application falls over like Senna's Imola crash. This part of the series is dedicated to that route, how it works, and why it exists.</p>
<p>So, buckle up and let's dive into part two of</p>
<p>"From Pit-Lane to Production".</p>
<h2 id="heading-how-submissions-were-processed-and-sent-to-judge0">How Submissions Were Processed and Sent to Judge0</h2>
<p>Imagine pressing Run in our platform. It felt like starting a fresh engine just to check whether the engine fires up or immediately bursts into flames. Behind that tiny button was a pit crew of backend logic that took your code, wrapped it in digital bubble wrap, and launched it straight to Judge0 at full speed.</p>
<h3 id="heading-run">Run</h3>
<p>Run was basically Free Practice 1. No championship points. No pressure. Just vibes.<br />You clicked it, the backend fetched the sample test case from the Database, built a shiny JSON payload that included your source code, test input, language ID, and expected output, and shipped it to Judge0. Judge0 then compared the output and returned a verdict. Could be Accepted. Could be Wrong Answer. Could be a spectacular Runtime Error fireball. The backend tossed that result straight back to the frontend, giving users instant joy or instant depression.</p>
<h3 id="heading-run-custom">Run Custom</h3>
<p>Run Custom was FP2 with experimental setups. The backend skipped stored test cases and used whatever weird input the user typed. Same payload, minus expected output, because at this point, nobody really cared what the car was supposed to do. Judge0 ran it, sent the raw output back, and users debugged until their sanity evaporated.</p>
<h3 id="heading-submit">Submit</h3>
<p>And then came Race Day.<br />This endpoint did not care about feelings. It checked JWT auth, made sure the user was not banned, verified that the round was active, and only then started the full submission routine like a formation lap.</p>
<p>The backend fetched every test case using a simple for loop. For each one, it created a Judge0 payload. Every payload was collected into a batch. Those batches were sent to Judge0 in one angry POST request. Judge0 replied with a bunch of tokens. Each token represented a test case. These tokens were dumped into Redis, and from this point on, the backend just prayed Judge0 behaved.</p>
<h3 id="heading-redis">Redis</h3>
<p>Redis was our FIA race control.<br />It tracked tokens like a clipboard guy with too much caffeine. Each token was saved as <code>token:tokenID</code> mapping to submission and testcase IDs. Redis also kept a set for each submission to track how many tokens were still pending. Every time a callback was processed, the token was deleted. When the set hit zero, we knew the submission was complete. Very elegant. Very illegal if used in Monaco.</p>
<h3 id="heading-asynq-and-the-worker-system">Asynq and the Worker System</h3>
<p>Once Judge0 sent back the results, they weren’t processed instantly on the same thread. That would have been too civilized. Instead, we threw the payload into an Asynq queue, which let dedicated workers handle the heavy lifting in the background.</p>
<p>The <code>InitQueue</code> function spun up an Asynq server and client, connecting to Redis as the job broker. Each callback from Judge0 created a new task of type submission: process. The worker, sitting patiently (or not), picked up these tasks and started unwrapping the payloads.</p>
<p>Inside <code>ProcessJudge0CallbackTask</code>The worker parsed the JSON payload, fetched the submission and test case IDs from Redis, and then mapped Judge0’s numeric status codes into readable verdicts from “success” and “wrong answer” to the ever-popular “runtime error.” It then logged the runtime, memory, and status into the database using SQLC queries.</p>
<p>To keep things clean, the worker also deleted the processed token from Redis. It then checked whether any tokens remained for that submission. If none did, it called <code>UpdateSubmission</code>, which aggregated all the test case results, counted passed and failed cases, and updated the user’s total score.</p>
<p>After this chaotic drive, every submission found its destiny. Some roared to the top of the leaderboard like Verstappen on a dry track. Others retired with a spectacular "Compilation Error" on the first corner.</p>
<h3 id="heading-the-bigger-picture">The Bigger Picture</h3>
<p>When you zoom out, the whole system looked like a perfectly organized Grand Prix weekend.</p>
<p>Redis was basically the race director shouting orders from the control box. It kept track of every token, every pending test case.</p>
<p>Asynq was the pit crew on RedBull. The moment a token was picked up from the queue, the workers leaped on it like mechanics changing tyres in two seconds, except instead of tyres, they were fighting with building JSON, status codes, and database queries.</p>
<p>Judge0 was the engine supplier that could either deliver championship-level performance or explode in a ball of errors without warning.</p>
<p>And the backend itself. That was our Toto. Too many responsibilities, too little sleep, and constantly pretending everything was under control. One eye on the scoreboard, one eye on Redis, emotionally praying to the digital ocean gods.</p>
<p>In the end, the submission pipeline didn’t explode, no surprise DNFs. The Ferrari-inspired engineers had built a backend that did its job, lap after lap, quietly and reliably. And honestly, this might be the fastest thing we built all season.</p>
<h3 id="heading-coming-up-next-a-deep-dive-into-how-the-clock-the-admin-routes-held-the-entire-system-together"><em>Coming up next: A deep dive into how the clock, the admin routes held the entire system together.</em></h3>
]]></content:encoded></item><item><title><![CDATA[Designing a Race-ready Backend for our Competitive coding portal with Golang, Echo & Redis : Part one]]></title><description><![CDATA[How we built a high-performance competitive programming backend with Go, Echo, Redis, PostgreSQL, and Judge0 supporting real-time code execution.]]></description><link>https://blogs.codechefvit.com/pitlane-to-production-p1</link><guid isPermaLink="true">https://blogs.codechefvit.com/pitlane-to-production-p1</guid><category><![CDATA[Go Language]]></category><category><![CDATA[backend]]></category><category><![CDATA[concurrency]]></category><category><![CDATA[scalability]]></category><category><![CDATA[load]]></category><category><![CDATA[Redis]]></category><category><![CDATA[queue]]></category><category><![CDATA[sqlcl]]></category><dc:creator><![CDATA[Atharva Neena Sharma]]></dc:creator><pubDate>Wed, 10 Dec 2025 15:47:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1765000919380/5dbea981-e8c2-4f71-8a40-712406aaae41.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-pre-race-prep-designing-the-car-praying-it-starts">Pre-Race Prep: Designing the Car, Praying It Starts</h3>
<p>If you’ve ever wondered what happens when a bunch of over-caffeinated developers decide to build their own version of LeetCode (White Monster and Red Bull should probably sponsor us at this point), then welcome to this series of blogs that take you up close behind CookOff 10.0’s backend.</p>
<p>Picture hundreds of students hammering their keyboards like your roommate’s midnight singing, racing to solve problems faster than the McLaren duo this year. It’s CodeChef VIT’s flagship coding event.</p>
<p>To run something this chaotic, you need more than enthusiasm. You need a backend that doesn’t explode the moment hundreds of people press “Submit” at once. So we built one. From scratch. In-house. Because why pick something stable and safe when you can live on the edge and watch your server logs scream in real time? It’s the kind of decision that sounds brilliant at 2 AM and catastrophic at 9 AM like most things developers do (yes, we take inspiration from Ferrari engineers).</p>
<p>This is the story of how we built the backend for CookOff 10.0’s in-house coding portal; a system that could compile, execute, and score submission results in real time while pretending everything was under control. We used Go, the Echo framework, Redis, and a bit of luck to create a pipeline fast enough to keep up with the chaos. It was part engineering, part madness, and somehow, it worked.</p>
<h2 id="heading-the-engine-why-we-chose-go-and-echo">The Engine: Why We Chose Go and Echo</h2>
<p>Every great machine needs an engine, and for us, that engine was Go. We could have gone with Node or Python, but when hundreds of coders start firing requests faster than the Mercedes W16 engine, you need something with raw power. Go doesn’t mess around. It is fast, lightweight, and handles concurrency like it was designed by someone who enjoys watching CPUs suffer. In short, it’s what you pick when you want performance and probably therapy bills.</p>
<p>The other half of our setup was Echo, our chosen framework. We used Chi last year, and it felt like assembling IKEA furniture while blindfolded. Too many moving parts, and one wrong screw could take down the whole thing. Echo was a relief. It felt like walking into a clean, well-lit garage where every tool had a place. It gave us clear routing, smooth structure, and middlewares that actually worked without turning our code into a mess.</p>
<p>Echo handled everything: user routes, admin routes, submission endpoints, and the protected judge APIs. It also gave us ground to build middlewares that acted like bouncers at a club, checking who had a valid token, who was banned, and who was trying to sneak into the wrong endpoint.</p>
<p>It wasn’t over-engineered or flashy. It was built for speed, endurance, and a bit of chaos. Just like a race car that is meant to survive 24 hours of Le Mans, not sit pretty in a museum.</p>
<h2 id="heading-tech-choices-that-actually-worked-somehow">Tech Choices That Actually Worked, Somehow</h2>
<p>Every great system begins with a few terrible decisions that somehow turn out right. For CookOff 10.0, we knew we were building a coding arena that would be hit by hundreds of submissions at once, so we needed tools that could survive chaos without crying for mercy. Every choice we made had a reason, even if that reason was “we don’t want to stop the contest midway while we restart our servers again.”</p>
<p>Let’s start with Judge0, our external code execution engine. We could have spun up our own Docker sandboxes, configured runtimes, managed security, and written endless YAMLs that nobody would ever read again. But Judge0 already handled all of that elegantly. It supported multiple languages, handled time limits, and offered callback URLs to update results asynchronously. We sent batch submissions to Judge0 using its API, received tokens for each job on our server’s callback URL, and let it do the heavy lifting. It was like outsourcing the messy part of the kitchen to a robot chef that never complains.</p>
<p>Now, since these submissions and callbacks arrive faster than I can find a missing semicolon in my code, we needed something to manage temporary state without choking the database. Enter Redis. It became our short-term memory, fast, volatile, and perfect for caching submission status, storing tokens, and tracking progress. It simply acted as the storage layer that made things fast.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764925338658/2449cbd1-7f07-4d2a-b875-cf1516e41509.png" alt class="image--center mx-auto" /></p>
<p>The actual queue was handled by Asynq. Every callback from Judge0 and pushed to Queue using a shared Redis client. Our worker processes picked tasks one by one, updated results in DB, calculated scores, and cleaned up Redis keys when done. Without Asynq controlling task flow, our submission pipeline would have turned into a traffic jam where everything tried to update DB at once.</p>
<p>For the database layer itself, we used SQLC. At first glance, it sounds like one of those tools you install and forget about, but in reality, it saved us from half the bugs we didn’t even know we were writing. It generates type-safe Go code directly from SQL queries, ensuring that we couldn’t accidentally mismatch a column or ruin the schema with an innocent typo. In short, it turned the database layer into something we could actually trust.</p>
<p>Finally, we wrapped everything in Docker containers. Each container in its own environment, so if one goes down, the others just keep going like nothing happened. When traffic spikes, we simply spin up more containers and let them do their thing.</p>
<p>In the end, none of these choices were glamorous, but together they made the system reliable enough to handle chaos at scale. Redis sprinted through caching and timers, while Asynq calmly orchestrated background task execution, and Judge0 crunched through code like a machine possessed. It was a strange symphony of speed, order, and just enough luck to make it through CookOff 10.0 without watching the backend catch fire.</p>
<h2 id="heading-black-flag-or-green-light-jwt-and-middlewares-as-race-stewards"><strong>Black Flag or Green Light? JWT and Middlewares as Race Stewards</strong></h2>
<p>Before any line of code could go racing through the backend, we needed proper authentication and authorization.</p>
<p>We used JWTs as our access control system. During login, the user’s email and password went through validation, bcrypt hashed password comparison, and a successful match triggered token generation. Two tokens were issued: an access token and a refresh token. The access token was short-lived and carried the user ID and role, while the refresh token lived longer and was stored in memory, keyed by the user’s UUID with roughly a one-hour expiry.</p>
<p>Every protected route passed through Echo’s middleware stack. The first checkpoint was the JWT verification middleware. It looked for an <code>access_token</code> cookie, parsed it using our JWT secret, and verified both integrity and expiry. Once validated, it attached the decoded user ID and role to the Echo context. If the token was missing, expired, or malformed, the middleware returned 401 Unauthorized.</p>
<p>Next came the <code>BanCheckUser</code> layer. It pulled the user ID from the context, checked the <code>IsBanned</code> field in the database, and blocked requests from banned users to routes like /submit or /run.</p>
<p>Admin-only routes such as <code>/admin/create-question</code> or <code>/admin/update-testcase</code> were gated by an AdminOnly middleware that checked the role field from JWT claims. If it wasn’t admin, the request returned 403 Forbidden.</p>
<p>Submissions were also gated by round eligibility. Before creating a submission record or queuing a Judge0 job, the handler ensured that the user’s <code>RoundQualified</code> field matched the active round.</p>
<p>This multi-layer design filtered bad or invalid requests early, preventing unnecessary load on Redis or the Judge0 queue and keeping worker traffic meaningful.</p>
<p>JWTs handled identity, refresh tokens lived in memory, and middlewares enforced control. The result was a clean, efficient request pipeline that allowed valid code to flow while blocking unauthorized users.</p>
<h3 id="heading-alright-thats-the-end-of-this-sector-coming-up-next-a-deep-dive-into-the-submission-pipeline-async-job-queues-and-redis"><em>Alright, that’s the end of this sector. Coming up next: a deep dive into the submission pipeline, async job queues, and Redis.</em></h3>
]]></content:encoded></item><item><title><![CDATA[SynthQuest 7: The End.]]></title><description><![CDATA[In this final episode of the SynthQuest series, we complete our basic JUCE synth by implementing the GUI layout, ADSR controls, and oscillator switching.]]></description><link>https://blogs.codechefvit.com/synthquest-7</link><guid isPermaLink="true">https://blogs.codechefvit.com/synthquest-7</guid><category><![CDATA[synth-quest]]></category><category><![CDATA[VST Plugins]]></category><category><![CDATA[JUCE]]></category><category><![CDATA[C++]]></category><dc:creator><![CDATA[Harshit Sarma]]></dc:creator><pubDate>Fri, 03 Oct 2025 13:03:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1759496135923/cdf653f3-acae-4933-8cac-6b724f416608.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Welcome back to the <em>SynthQuest</em> series, where we’re building a VST from scratch. This is the 7th and the final episode of this series (and yes, the title is a reference to the final song by the Beatles on the Abbey Road album •ᴗ•). So, if this is your first time here, make sure to check out the previous episodes to catch up. Today, we are going to complete our GUI implementation. Alright then, let’s start with the resized() function :</p>
<p><code>const auto padding = 12;</code></p>
<p><code>const auto bounds = getLocalBounds().reduced(padding);</code></p>
<p>We are calling the function getLocalBounds() function which stores the width and height of the window and then we are reducing it by 12 pixels so it will be like an invisible border.</p>
<p><code>const auto sliderWidth = bounds.getWidth() / 4 - padding;</code></p>
<p><code>const auto sliderHeight = bounds.getWidth() / 2;</code></p>
<p><code>const auto sliderStartX = 18;</code></p>
<p><code>const auto sliderStartY = bounds.getHeight() / 2 - (sliderHeight / 4);</code></p>
<p>These are the rest of the variables that we will use them as arguments for the setBounds() function, which will define the position of the slider. So firstly, for the attack slider :</p>
<p><code>attackSlider.setBounds(sliderStartX, sliderStartY, sliderWidth, sliderHeight);</code></p>
<p>First argument is the x position on the window, after that y, then the width of the slider, and lastly the height.</p>
<p>And then for the rest of the ADSR sliders :</p>
<p><code>decaySlider.setBounds(attackSlider.getRight() + padding, sliderStartY, sliderWidth, sliderHeight);</code></p>
<p><code>sustainSlider.setBounds(decaySlider.getRight() + padding, sliderStartY, sliderWidth, sliderHeight);</code></p>
<p><code>releaseSlider.setBounds(sustainSlider.getRight() + padding, sliderStartY, sliderWidth, sliderHeight);</code></p>
<p>For the x, we are getting the position where the previous slider is finished. Lastly, for the comboBox:</p>
<p><code>oscSelector.setBounds(bounds.getX(), bounds.getY(), bounds.getWidth(), 30);</code></p>
<p>Since it's just one box, it can take the whole width and start from the beginning of the window. Alright, now if you run the project, you should be able to see the things in the window.</p>
<p>After this, we want the sounds to reflect the changes whenever we change the values of the sliders and the same thing for the oscillators. To do that, we have to create a function in the SynthVoice class that will be called whenever the slider changes :</p>
<p><code>void updateADSR(float attack, float decay, float sustain, float release);</code></p>
<p>Declare it in the <em>pluginProcessor.h</em> file and then implement it in the <em>pluginProcessor.cpp</em> file.</p>
<p><code>void SynthVoice::updateADSR(float attack, float decay, float sustain, float release) {</code></p>
<p><code>adsrParams.attack = attack;</code></p>
<p><code>adsrParams.decay = decay;</code></p>
<p><code>adsrParams.sustain = sustain;</code></p>
<p><code>adsrParams.release = release;</code></p>
<p><code>adsr.setParameters(adsrParams);</code></p>
<p><code>}</code></p>
<p>Remember, I mentioned <strong>adsrParams</strong> object will be useful later? This is what I meant. This object will help us change the ADSR.</p>
<p>In the BasicOscAudioProcessor::processBlock() function, we’ll call this function for every voice :</p>
<p><code>for (int i = 0; i &lt; synth.getNumVoices(); ++i) {</code></p>
<p><code>if (auto voice = dynamic_cast&lt;SynthVoice*&gt;(synth.getVoice(i))) {</code></p>
<p><code>auto &amp;attack = *theValueTree.getRawParameterValue("ATTACK");</code></p>
<p><code>auto &amp;decay = *theValueTree.getRawParameterValue("DECAY");</code></p>
<p><code>auto &amp;sustain = *theValueTree.getRawParameterValue("SUSTAIN");</code></p>
<p><code>auto &amp;release = *theValueTree.getRawParameterValue("RELEASE");</code></p>
<p><code>voice-&gt;updateADSR(attack, decay, sustain, release);</code></p>
<p><code>}}</code></p>
<p>We created this for-loop, but it was empty, we are fetching the values from the sliders and putting them in the updateADSR() function as arguments.</p>
<p>Now, for the different synth options, we’ll create another function, let’s call it <em>changeOsc()</em> in the SynthVoice class. First, define it in the <em>pluginProcessor.h</em> file.</p>
<p>void changeOsc(int oscNum);</p>
<p>In the function, we will need to write some if-else statements to change the oscillator. Here’s the code for the function :</p>
<p><code>void SynthVoice::changeOsc(int oscNum) {</code></p>
<p><code>if (oscNum == 0) {</code></p>
<p><code>osc.initialise([](float x) { return std::sin(x); }, 128); //sine</code></p>
<p><code>}</code></p>
<p><code>else if (oscNum == 1) {</code></p>
<p><code>osc.initialise([](float x) { return x / juce::MathConstants&lt;float&gt;::pi; }, 128); //saw</code></p>
<p><code>}</code></p>
<p><code>else if (oscNum == 2) {</code></p>
<p><code>osc.initialise([](float x) { return x &lt; 0.0f ? -1.0f : 1.0f; }, 128); //sqaure</code></p>
<p><code>}</code></p>
<p><code>else if (oscNum == 3) {</code></p>
<p><code>osc.initialise([](float x) { return x &lt; 0.0f ? -1.0f + (4.0f (x + 0.5f)) : 1.0f - (4.0f (x - 0.5f)); }, 128); //triangle</code></p>
<p><code>}}</code></p>
<p>You can see we are calling the osc.initialise() and in the argument we are passing a lambda function which is returning different waves and an integer value (lookup table size), this value says how detailed the wave should be (128, 256, 512, 1024).</p>
<ul>
<li><p>We already know for a <strong>sine</strong> wave it is, <code>sin(x)</code>,</p>
</li>
<li><p>For a <strong>saw</strong> wave it is, <code>x / juce::MathConstants&lt;float&gt;::pi</code>,</p>
</li>
<li><p>For a <strong>square</strong> wave it is, <code>x &lt; 0.0f ? -1.0f : 1.0f</code>,</p>
</li>
<li><p>For a <strong>triangle</strong> wave it is, <code>x &lt; 0.0f ? -1.0f + (4.0f (x + 0.5f)) : 1.0f - (4.0f (x - 0.5f))</code>.</p>
</li>
</ul>
<p>These are mathematical expressions to define different waveforms. You can go deeper and find the math behind these. Alright, after this, we’ll go to the processBlock() function and call it. Similar to what we did for ADSR, we will first fetch the wave number and then call the changeOsc() function. Here’s the code :</p>
<p><code>auto &amp;waveformType = *theValueTree.getRawParameterValue("OSC");</code></p>
<p><code>voice-&gt;changeOsc(waveformType);</code></p>
<p>The processBlock() function should look something like this :</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1756923367630/e7a4ea8f-fe4a-4688-a1be-8f8021f84bd7.png" alt class="image--center mx-auto" /></p>
<p>We finally have our basic synth ready. Let’s create some music with it.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.youtube.com/watch?v=12f86QbASww">https://www.youtube.com/watch?v=12f86QbASww</a></div>
<p> </p>
<p>With this, we are going to wrap up our tutorial series. I would like you to add some more features to this project like a gain controller, a filter, or make this a polyphonic synth; the possibilities are endless, this is what I like about audio programming. Github link - <a target="_blank" href="https://github.com/kashyap-harshit/basic-osc-tutorial">basic-osc-tutorial</a>. Thank you for following along and see you in a different one till then, have fun coding music.</p>
]]></content:encoded></item><item><title><![CDATA[SynthQuest 6: How to Build the GUI for Your VST in JUCE]]></title><description><![CDATA[Implement createParams() and design the GUI for your VST in SynthQuest 6. Connect parameters to sliders and customize controls]]></description><link>https://blogs.codechefvit.com/synthquest-6</link><guid isPermaLink="true">https://blogs.codechefvit.com/synthquest-6</guid><category><![CDATA[synth-quest]]></category><category><![CDATA[VST Plugins]]></category><category><![CDATA[JUCE]]></category><category><![CDATA[C++]]></category><dc:creator><![CDATA[Harshit Sarma]]></dc:creator><pubDate>Fri, 12 Sep 2025 12:01:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1757097263409/5974ef68-add8-43e6-b633-a589633d4a10.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Welcome back to the SynthQuest series, where we’re building a VST from scratch. This is Episode 6, and today we are going to implement the <strong>createParams()</strong> function along with the <strong>GUI</strong>. If this is your first time here, make sure to check out the previous episodes to catch up. Let’s start by creating the createParams() function:</p>
<p><code>juce::AudioProcessorValueTreeState::ParameterLayout BasicOscAudioProcessor::createParams() {}</code></p>
<p>Inside the function, we are going to create a vector that is going to save the pointers to the juce::RangedAudioParameter class, which is nothing but a base class for all juce plugin parameters.</p>
<p><code>std::vector&lt;std::unique_ptr&lt;juce::RangedAudioParameter&gt;&gt; params;</code></p>
<p>Okay, so in our case, we are going to use AudioParameterChoice (for choosing different sound waves/oscillators) and AudioParameterFloat (for gain, filter, and other things). Let’s create a parameter for the oscillators:</p>
<p><code>params.push_back(std::make_unique&lt;juce::AudioParameterChoice&gt;("OSC", "Oscillator", juce::StringArray{"Sine", "Saw", "Square", "Triangle"}, 0));</code></p>
<p>We are pushing a unique pointer to the <em>juce::AudioParameterChoice</em> object to the vector; this ensures automatic allocation and deallocation, no need for <strong>new</strong> and <strong>delete</strong>. Now, in the constructor, we are passing a few parameters; the first one is the ID, then the name of the parameter, then a juce::StringArray, and lastly the default value.</p>
<p>Let’s create the adsr parameters :</p>
<p><code>params.push_back(std::make_unique&lt;juce::AudioParameterFloat&gt;("ATTACK", "Attack", juce::NormalisableRange{ 0.0f, 1.0f }, 0.0f));</code></p>
<p><code>params.push_back(std::make_unique&lt;juce::AudioParameterFloat&gt;("DECAY", "Decay", juce::NormalisableRange{ 0.0f, 1.0f }, 0.0f));</code></p>
<p><code>params.push_back(std::make_unique&lt;juce::AudioParameterFloat&gt;("SUSTAIN", "Sustain", juce::NormalisableRange{ 0.0f, 1.0f }, 1.0f));</code></p>
<p><code>params.push_back(std::make_unique&lt;juce::AudioParameterFloat&gt;("RELEASE", "Release", juce::NormalisableRange{ 0.0f, 3.0f }, 0.1f));</code></p>
<p>Then lastly, we are going to return the vector:</p>
<p><code>return { params.begin(), params.end() };</code></p>
<p>So, the whole <em>createParams()</em> function should look like this :</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753457848588/25920a5b-0ebc-4ccd-b9e0-4cdb99ed612d.png" alt class="image--center mx-auto" /></p>
<p>Let’s move to the GUI section now, open the <em>pluginEditor.h</em> file and declare the sliders and stuff. We need all the 4 <em>ADSR</em> sliders and a drop-down menu (comboBox) for choosing between different oscillators. There is this <em>juce</em> class for sliders already, so we are just going to use that :</p>
<p><code>juce::Slider attackSlider;</code></p>
<p><code>juce::Slider decaySlider;</code></p>
<p><code>juce::Slider sustainSlider;</code></p>
<p><code>juce::Slider releaseSlider;</code></p>
<p>Also, we are going to write them in the private section. Then we are going to declare a comboBox object for the drop-down :</p>
<p><code>juce::ComboBox oscSelector;</code></p>
<p>Now, let’s understand a new concept. What are <em>attachments</em>? To connect the sliders and knobs in the <em>pluginEditor</em> to <em>pluginProcessor</em> file, we use respective attachment classes. Let’s take an example. Previously, we created parameters in the createParams() function, which was fed to the AudioProcessorValueTreeState class. Now, we need to link those to the GUI. For that, we are going to declare attachments.</p>
<p><code>std::unique_ptr&lt;juce::AudioProcessorValueTreeState::SliderAttachment&gt; attackAttachment;</code></p>
<p><code>std::unique_ptr&lt;juce::AudioProcessorValueTreeState::SliderAttachment&gt; decayAttachment;</code></p>
<p><code>std::unique_ptr&lt;juce::AudioProcessorValueTreeState::SliderAttachment&gt; sustainAttachment;</code></p>
<p><code>std::unique_ptr&lt;juce::AudioProcessorValueTreeState::SliderAttachment&gt; releaseAttachment;</code></p>
<p><code>std::unique_ptr&lt;juce::AudioProcessorValueTreeState::ComboBoxAttachment&gt; oscSelectAttachment;</code></p>
<p>So, now your <em>pluginEditor.h</em> file should look something like this :</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1756920606698/c816214e-a09e-4e4c-b6ba-5510478c3d13.png" alt class="image--center mx-auto" /></p>
<p>Now, head over to the <em>pluginEditor.cpp</em> file and implement the above things. Firstly, we are going to implement the attachments, so let’s take the attack attachment, for example :</p>
<p><code>attackAttachment = std::make_unique&lt;juce::AudioProcessorValueTreeState::SliderAttachment&gt;(audioProcessor.theValueTree, "ATTACK", attackSlider);</code></p>
<p>We are making a unique pointer to the juce::AudioProcessorValueTreeState::SliderAttachment class with three arguments: firstly, the <em>apvts</em> class we declared, then the ID of the parameter (here “ATTACK”), and then the slider. Now, you know how the AudioProcessorValueTreeState class helps with parameters. These should be written in the constructor of the <em>BasicOscAudioProcessorEditor</em> class. We will do this for all the attachments :</p>
<p><code>decayAttachment = std::make_unique&lt;juce::AudioProcessorValueTreeState::SliderAttachment&gt;(audioProcessor.theValueTree, "DECAY", decaySlider);</code></p>
<p><code>sustainAttachment = std::make_unique&lt;juce::AudioProcessorValueTreeState::SliderAttachment&gt;(audioProcessor.theValueTree, "SUSTAIN", sustainSlider);</code></p>
<p><code>releaseAttachment = std::make_unique&lt;juce::AudioProcessorValueTreeState::SliderAttachment&gt;(audioProcessor.theValueTree, "RELEASE", releaseSlider);</code></p>
<p><code>oscSelectAttachment = std::make_unique&lt;juce::AudioProcessorValueTreeState::ComboBoxAttachment&gt;(audioProcessor.theValueTree, "OSC", oscSelector);</code></p>
<p>Now, let’s define the type of slider we want and where to align the text box, and also make the slider visible on the GUI :</p>
<p><code>attackSlider.setSliderStyle(juce::Slider::SliderStyle::LinearVertical);</code></p>
<p><code>attackSlider.setTextBoxStyle(juce::Slider::TextBoxBelow, true, 50, 25);</code></p>
<p><code>addAndMakeVisible(attackSlider);</code></p>
<p>Now, for the rest of the ADSR sliders :</p>
<p><code>decaySlider.setSliderStyle(juce::Slider::SliderStyle::LinearVertical);</code></p>
<p><code>decaySlider.setTextBoxStyle(juce::Slider::TextBoxBelow, true, 50, 25);</code></p>
<p><code>addAndMakeVisible(decaySlider);</code></p>
<p><code>sustainSlider.setSliderStyle(juce::Slider::SliderStyle::LinearVertical);</code></p>
<p><code>sustainSlider.setTextBoxStyle(juce::Slider::TextBoxBelow, true, 50, 25);</code></p>
<p><code>addAndMakeVisible(sustainSlider);</code></p>
<p><code>releaseSlider.setSliderStyle(juce::Slider::SliderStyle::LinearVertical);</code></p>
<p><code>releaseSlider.setTextBoxStyle(juce::Slider::TextBoxBelow, true, 50, 25);</code></p>
<p><code>addAndMakeVisible(releaseSlider);</code></p>
<p>In the drop-down menu, we will now add the other wave types :</p>
<p><code>oscSelector.addItem("Sine", 1);</code></p>
<p><code>oscSelector.addItem("Saw", 2);</code></p>
<p><code>oscSelector.addItem("Square", 3);</code></p>
<p><code>oscSelector.addItem("Triangle", 4);</code></p>
<p>Now setting the default wave as <em>sine</em> :</p>
<p><code>oscSelector.setSelectedId(audioProcessor.theValueTree.getRawParameterValue("OSC")-&gt;load() + 1);</code></p>
<p>I’ll explain what is happening here, audioProcessor.theValueTree.getRawParameterValues(“OSC”)-&gt;load() will return 0 as the value because, in the createParams() function, we set 0 as the default value; however, ComboBox indexes start from 1. To match them correctly, we add 1.</p>
<p>Now you can ask why not directly write 1 in the setSelectedId() function? Well, if you do that, then whenever you switch between different VST windows in a DAW and then open our VST, it is going to be a sine wave again, even if you changed it.</p>
<p><code>oscSelector.setJustificationType(juce::Justification::centred);</code></p>
<p><code>addAndMakeVisible(oscSelector);</code></p>
<p>We just centered the comboBox and made it visible. The file should look something like this :</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1756921113772/9b570a8c-1168-4bdc-9303-8cc8f4a28d6d.png" alt class="image--center mx-auto" /></p>
<p>And the rest of the code follows.</p>
<p>Now, in the paint function, we can change the colour of the background and stuff :</p>
<p><code>g.fillAll (juce::Colour(251, 133, 0));</code></p>
<p>This is a juce::Colour class which can take RGB values on its constructor. This will change the background colour of our VST to a shade of orange. You can run the code and see for yourself.</p>
<p>You can check out the <em>synth-quest-6</em> branch in the <a target="_blank" href="https://github.com/kashyap-harshit/basic-osc-tutorial">GitHub</a> repository for the code till here. In the next episode, we are going to write the resized() function, we set the height, width, x, and y basically we position the sliders. <em>Obrigado,</em> and see you in the next one!</p>
]]></content:encoded></item><item><title><![CDATA[SynthQuest  5: Implementing ADSR]]></title><description><![CDATA[Learn how to implement ADSR in a VST, from setting up JUCE objects to testing your VST in a DAW.]]></description><link>https://blogs.codechefvit.com/synthquest-5</link><guid isPermaLink="true">https://blogs.codechefvit.com/synthquest-5</guid><category><![CDATA[synth-quest]]></category><category><![CDATA[VST Plugins]]></category><category><![CDATA[JUCE]]></category><category><![CDATA[C++]]></category><dc:creator><![CDATA[Harshit Sarma]]></dc:creator><pubDate>Mon, 21 Jul 2025 15:42:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1750584173125/69d994ad-c8fe-41a2-929a-39c79d1c21dc.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Welcome back to the SynthQuest series, where we’re building a VST from scratch. This is Episode 5, and today’s quest is to implement ADSR and open our synth inside a DAW for the first time. If you’re joining us for the first time, be sure to check out the previous episodes to catch up. Alright, let’s begin with a small video clip of 27 seconds to hear ADSR (attack/decay/sustain/release) in action–</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.youtube.com/watch?v=3FQMnk_uzYU">https://www.youtube.com/watch?v=3FQMnk_uzYU</a></div>
<p> </p>
<p>Now, I’ll provide the literal definitions of all these, but after reading, watch the video again (using headphones), and you will get a good idea:</p>
<ul>
<li><p><strong>Attack:</strong> The time it takes for a sound to rise from silence to its peak amplitude when a note is pressed.</p>
</li>
<li><p><strong>Decay: T</strong>he time it takes for the sound to drop from its peak amplitude to the sustain level.</p>
</li>
<li><p><strong>Sustain:</strong> Steady amplitude level that the sound holds as long as the note is held.</p>
</li>
<li><p><strong>Release:</strong>  The time it takes for the sound to fade from the sustain level to silence when the note is released.</p>
</li>
</ul>
<p>We will declare a <strong>juce::ADSR</strong> object as a private member in the <em>SynthVoice</em> class in <em>pluginProcessor.h</em> file. At the same time, we’ll also declare <strong>juce::ADSR::Parameters</strong> object; this will be useful later.</p>
<p><code>juce::ADSR adsr;</code></p>
<p><code>juce::ADSR::Parameters adsrParams;</code></p>
<p>After that, go to the pluginProcessor.cpp file and set the sample rate in the <em>SynthVoice::prepareToPlay()</em> function, write:</p>
<p><code>adsr.setSampleRate(sampleRate);</code></p>
<p>Then in the <strong>SynthVoice::startNote()</strong> function write</p>
<p><code>adsr.noteOn();</code></p>
<p>This lets the <strong>ADSR</strong> object know where to start the attack phase of the envelope. Also,</p>
<p><code>osc.setFrequency(juce::MidiMessage::getMidiNoteInHertz(midiNoteNumber));</code></p>
<p>There are two functions above, one is getMidiNoteInHertz(), which converts the midiNoteNumber to its respective frequency, and then that frequency is fed to the osc.setFrequency() function. The oscillator needs to know which frequency to play.</p>
<p>In the <strong>SynthVoice::stopNote()</strong> function:</p>
<p><code>adsr.noteOff();</code></p>
<p>This starts the release phase of the envelope. Check out the official documentation to learn more about this class and its functions <a target="_blank" href="https://docs.juce.com/master/classADSR.html">here.</a></p>
<p>Let’s go to the <strong>SynthVoice::renderNextBlock()</strong> function and apply this ADSR to the audio buffer for it to show effect:</p>
<p><code>adsr.applyEnvelopeToBuffer(outputBuffer, startSample, numSamples);</code></p>
<p>With this line, we now have a fully-fledged basic synthesizer which can play any note you tap on, and you can write your melodies now. Build the program by clicking on <em>build solution</em> or by pressing Ctrl+Shift+B. If your build is successful, it should show something like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747473682032/149b93cd-aea1-44a5-8a1f-8da3b418c402.png" alt class="image--center mx-auto" /></p>
<p>The main .vst3 file’s location (in the terminal) for me is – <code>E:\Files\C Projects\juce projects\basicOsc\basicOsc\Builds\VisualStudio2022\x64\Debug\VST3\basicOst.vst3\Contents\x86_64-win\basicOsc.vst3</code></p>
<p>Now, to test our plugin in a DAW, first of course we’ll need a DAW, so let’s download one. <em>Reaper</em> would be a good option; it is free and lightweight. <a target="_blank" href="https://www.reaper.fm/download.php">You can download Reaper from here.</a> Its installation is really easy. Create this folder if it’s not there already <code>C:\Program Files\Common Files\VST3</code> , and paste the .vst3 file in that folder. After installation, open <em>Reaper</em> and go to <strong>options-&gt;preferences-&gt;Plug-ins-&gt;VST</strong> and then see if that folder is there or not, if not add it by clicking on <em>edit path list</em> and rescan for plugins. In most cases, it is there by <strong>default</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747473757388/bb59456e-fbe9-48c7-9bd1-fa8a786bebd3.png" alt class="image--center mx-auto" /></p>
<p>After this, go to <strong>track-&gt;insert virtual instrument on new track,</strong> then just search for the VST and open it:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747473825304/17bb8ccf-1af6-4c5a-9126-a6f5141fd2e0.png" alt class="image--center mx-auto" /></p>
<p>Open the VST and then press Alt+B for the MIDI controller.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747473929960/0361f7c2-f56f-4382-a4d8-54d5b5382c1f.png" alt class="image--center mx-auto" /></p>
<p>Every time you build the project, you’ll have to copy the .vst3 file to the VST3 folder for your DAW to recognise it.</p>
<p>Alright, now let’s try to understand what an <em>AudioProcessorValueTreeState</em> (APVTS) class is. See, in a plugin some parameters or <em>knobs</em> can be modulated to change the sound, and we know that to make GUI elements in our plugin, we have to edit the pluginEditor files, but to efficiently link GUI components to the DSP code and ensure parameter changes are properly made, we need to take help of the APVTS class.</p>
<p>Let’s write its code, open the pluginProcessor.h file, and declare an APVTS object publicly in the <em>AudioProcessor</em> class.</p>
<p><code>juce::AudioProcessorValueTreeState theValueTree;</code></p>
<p>And after this, we need a helper function which will help us to create new parameters (like gain, pan, etc) and it will feed the parameters to the APVTS object. This function returns a ParameterLayout, which will be required when we initialize the APVTS in the pluginProcessor.cpp file.</p>
<p><code>juce::AudioProcessorValueTreeState::ParameterLayout createParams();</code></p>
<p>I am going to declare it privately in the AudioProcessor class of the pluginProccessor.h file. After this, your pluginProcessor.h file should look like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747473969082/9fb04fab-1672-4d0e-aeba-2bd6f9049933.png" alt class="image--center mx-auto" /></p>
<p>Now, let’s head over to the pluginProcessor.cpp file and initialize our APVTS object.</p>
<p><code>theValueTree(*this, nullptr, "Parameters", createParams())</code></p>
<p>This is the line of code, the first argument is the parent class, the second one is the undoManager (we don’t need this now, that’s why <em>nullptr</em>), third one is the name of the parameter group, and the fourth one is the parameter creation helper function which returns a ParameterLayout class having all the parameters. Now, your constructor should look like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747474009594/b95868f2-ff97-487b-a3fe-1d479feeb7b3.png" alt class="image--center mx-auto" /></p>
<p>You can check out the <em>synth-quest-5</em> branch in the GitHub re<a target="_blank" href="https://github.com/kashyap-harshit/basic-osc-tutorial">posito</a>ry for the code till here. In the next episode, we’ll be implementing the <em>createParams()</em> function and start with the GUI of the VST. <em>Merci,</em> and see you in the next one!</p>
]]></content:encoded></item><item><title><![CDATA[Under the Hood of Large Language Models]]></title><description><![CDATA[Explore LLMs: transformers, pre-training, tokenization, evaluation metrics, post-training techniques]]></description><link>https://blogs.codechefvit.com/under-the-hood-of-large-language-models</link><guid isPermaLink="true">https://blogs.codechefvit.com/under-the-hood-of-large-language-models</guid><category><![CDATA[AI]]></category><category><![CDATA[llm]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[technology]]></category><category><![CDATA[large language models]]></category><category><![CDATA[Deep Learning]]></category><dc:creator><![CDATA[Aditi Saxena]]></dc:creator><pubDate>Mon, 21 Jul 2025 14:41:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/UopUfxghnWo/upload/05d2be7a7d89375e3356cc3ac95c5579.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-how-to-build-an-llm"><strong>How to build an LLM?</strong></h3>
<hr />
<p>It’s been almost eight years since OpenAI introduced its first large language model — what would later evolve into ChatGPT, and now, more casually, just <em>GPT</em>. The impact has been so profound that the act of searching for information through these models has earned its own verb: <em>GPTing</em>.</p>
<p>Today, <strong>the world can hardly imagine life without AI</strong> — and that, in itself, is a powerful statement. But I’m not here to discuss AI’s impact or the sweeping societal changes it’s driving. Instead, I want to take you behind the scenes, into the heart of what it takes to build a large language model — and what it might take for you to create one of your own.</p>
<h3 id="heading-the-first-bit"><strong>The first bit</strong></h3>
<p>The architecture of an LLM is basically based on a transformer. The Transformer architecture is based on the concept of self-attention, which allows the model to weigh the importance of different parts of the input sequence when processing it. There are a lot of resources on Transformers and their relation with LLMs . Thus, we will focus on the less talked about parts — Training algorithms, Losses, Data and Evaluation. I will be simplifying each of these for you and make sure that you are able to gauge the power of such nuances when you create something as discrete as a LLM model like GPT.</p>
<h3 id="heading-the-not-so-classical-paradigm-pre-training"><strong>The Not so Classical Paradigm —  Pre-Training</strong></h3>
<p>Imagine teaching someone to write poetry. You wouldn’t start by asking them to write a sonnet on day one. You’d first expose them to thousands of poems, books, and stories. They’d pick up patterns, vocabulary, and rhythm  ; <em>before</em> you ever asked them to craft their own verses. That first phase  —  soaking in information without any specific task — is kind of what <strong>pre-training</strong> is for AI models.</p>
<p>Until around <strong>2018</strong>, most natural language models were trained for specific tasks — like sentiment analysis or translation  —  without much general knowledge of language as a whole. That changed with <strong>OpenAI’s GPT (Generative Pre-trained Transformer)</strong>, the very first model in the GPT series. It was the first time pre-training was used at this scale in a <strong>language model</strong>, setting the stage for everything that followed.</p>
<p>In simple terms: <strong>Pre-training</strong> gave AI the chance to read the entire internet (or a big chunk of it) <em>before</em> being asked to answer questions, write essays, or chat like a human. It’s like giving your AI a childhood full of reading before sending it out into the world.</p>
<h4 id="heading-what-is-language-modelling"><strong><em>What is Language Modelling ?</em></strong></h4>
<p>Language Modelling is basically a probability distribution over sequences of words / sentences . The objective is to generate the probability of a sequence in that particular order to be found on the internet or in resources it has been trained on.<br />For example :</p>
<ol>
<li><p>P1 (remarkable, you, are , student) = 0.01</p>
</li>
<li><p>P2 (remarkable, you, you, are, student)=0.001  —  Syntactic knowledge</p>
</li>
<li><p>P3 (student, are, you, remarkable)=0.12  —  Semantic Knowledge</p>
</li>
</ol>
<p>This covers the NLP (Natural Language Processing) Angle and condenses it to a probabilistic distribution giving the LMs the generative power.</p>
<blockquote>
<p><strong><em>The word ‘Generative’ in generative power is sometimes misleading  —  A model can only generate only on what it is trained on  —  not something that can be creatively or artistically distinct. This is where it differentiates from human intelligence.</em></strong></p>
</blockquote>
<p>Each of these probabilities must be expressed as the Chain Rule of Probability — typically called as Autoregressive Model.</p>
<h4 id="heading-predicting-the-next-word"><strong><em>Predicting the Next Word</em></strong></h4>
<p>Predicting the next word  —  applies two concepts : Tokenisation and Autoregressive Model.</p>
<blockquote>
<p><strong><em>Tokenisation: Each word , character, syllable and maybe even a sentence cld treated as a token  —  This what builds on predictability later.</em></strong></p>
<p><strong><em>However, a tokeniser considers a sequence of characters (~3 letters) or a common subsequence as a valid Token.</em></strong></p>
</blockquote>
<p>For Example : ‘I am Aditi. I like reading about llms. I also like chocolates’</p>
<p>Here each character, repeating words , and other words could be tokens.</p>
<p><strong>Note : Each Token has it’s own unique ID.</strong></p>
<p>Autoregressive models  —  are used to predict a plausible next word — using the probability of a token coming in place after a certain selected word. A plausible combination of words are given weights accordingly for them to be able to generate a semantically and syntactically correct sentence.</p>
<h4 id="heading-how-are-llms-evaluated"><strong>How are LLMs evaluated :</strong></h4>
<p>Building a large language model (LLM) is only half the story. The real question is: <strong>How do you know if it’s any good?</strong><br />That’s where evaluation comes in.</p>
<h4 id="heading-1-perplexity-the-how-surprised-are-you-test"><strong>1. Perplexity: The “How Surprised Are You?” Test</strong></h4>
<p>One of the classic ways to evaluate language models — especially <strong>during pretraining</strong> — is by using something called <strong>perplexity</strong>.</p>
<p>Think of <strong>perplexity</strong> as a measure of how <em>surprised</em> your model is when it sees the next word in a sentence. A lower perplexity means the model is less surprised — it predicted the word well. A higher perplexity means the model had no clue.</p>
<p>For example:</p>
<ul>
<li><p>If your model sees:<br />  <em>“The cat sat on the ___”</em><br />  and confidently predicts “mat,” that’s low perplexity.</p>
</li>
<li><p>But if it predicts something odd like “government,” perplexity shoots up.</p>
</li>
</ul>
<p>Mathematically:</p>
<p>Perplexity = e^{cross-entropy loss}</p>
<p>It’s the exponentiation of the average negative log-likelihood of the correct word.</p>
<p><strong>Key takeaway:</strong> Lower perplexity = better model at predicting language.<br />However: Perplexity <strong>only</strong> measures how good the model is at predicting next words, not necessarily how helpful or factual its answers are in real-world usage (this is where human evals &amp; task-specific metrics come in).</p>
<hr />
<h4 id="heading-2-cross-validation-the-dont-fool-yourself-check"><strong>2. Cross-Validation: The “Don’t Fool Yourself” Check</strong></h4>
<p>In classic machine learning, we often use <strong>cross-validation</strong> to make sure our models generalize well — not just memorize the training data.</p>
<ul>
<li><p>The idea is simple: Split your data into <strong>K</strong> chunks (folds). Train on <strong>K-1</strong> folds and test on the remaining one. Repeat this for each fold.</p>
</li>
<li><p>This ensures your model is tested on <strong>every part</strong> of the data at least once.</p>
</li>
</ul>
<p>In LLMs, though, <strong>cross-validation isn’t used in the same way</strong> because:</p>
<ul>
<li><p>The datasets are <strong>massive</strong> (terabytes), so splitting and retraining multiple times is computationally infeasible.</p>
</li>
<li><p>Instead, a <strong>train/validation/test split</strong> is more common.</p>
</li>
<li><p>Sometimes, <strong>cross-validation ideas are borrowed</strong> in smaller setups like fine-tuning small models or domain-specific models.</p>
</li>
</ul>
<p>You <em>can</em> apply cross-validation when:</p>
<ul>
<li><p>You’re working with <strong>smaller fine-tuning datasets</strong> (e.g., customer service chats, legal documents, healthcare data).</p>
</li>
<li><p>You need <strong>robust estimates</strong> of model performance before deploying.</p>
</li>
</ul>
<h3 id="heading-data"><strong>Data</strong></h3>
<p>The most important, sensitive and tedious part of building an LLM is the Data. Yes, a lot of research has to be done. There are a lot of constraints. You need to be careful what you choose as this could be the primary factor to drive analysis, biasness and decision taking abilities of your model.</p>
<p>Conventionally , More data should lead to larger models converting to Overfitting — too many clusters or points close to eachother on a graph — when one is unable to detect a model’s decision boundary (outliers getting undetected or so) . However, while training LLMs — it is noted that more the data , better the performance.</p>
<p>This was not conceived naturally, it was a result of observation. As we think about it — it probably makes sense — To generate data — one needs data , data which covers more aspects than one.</p>
<h4 id="heading-hyperparameter-tuning"><strong>HyperParameter Tuning</strong></h4>
<p><em>The Art of Finding the “Just Right” Settings for Your Model</em></p>
<p>When you build a machine learning model (or even a deep learning model like GPT), there are certain settings you have to choose <strong>before</strong> the training even begins. These settings are called <strong>hyperparameters</strong> — they control <em>how</em> the model learns, not <em>what</em> the model learns.</p>
<p>When you’re training small machine learning models, hyperparameter tuning is all about finding the right knobs to twist: learning rate, batch size, model size, regularization, etc.But when you move into <strong>LLMs</strong> — we’re talking billions or trillions of parameters — the game changes. This is where <strong>Scaling Laws</strong> come in.</p>
<p>When you scale models <em>massively</em>, your <strong>hyperparameters don’t stay fixed</strong>. The values that worked for a 100M parameter model <strong>won’t work</strong> for a 10B or 100B parameter model. This is where <strong>hyperparameter scaling</strong> — or hyperparameter tuning guided by <strong>scaling laws</strong> — becomes crucial.</p>
<h4 id="heading-so-we-need-to-learn-patterns-that-are-scaling-laws"><strong>So we need to learn patterns — that are Scaling Laws.</strong></h4>
<p>Scaling laws are emerging patterns that arise as we train smaller models. For example: <strong>Learning Rate shows the following trend :</strong></p>
<ul>
<li><p>Needs to be adjusted as model size grows.</p>
</li>
<li><p>Too high → Divergence. Too low → Wasted compute.</p>
</li>
</ul>
<p><strong>Weight Decay / Regularization:</strong></p>
<ul>
<li>Needs careful balancing to avoid overfitting in smaller models or underfitting in gigantic ones.</li>
</ul>
<hr />
<h3 id="heading-post-training"><strong>Post-Training</strong></h3>
<p>This is that segment of building an LLM that makes it capable to assist a user. <strong>Post-training</strong> refers to everything you do <strong>after</strong> the base language model has been pretrained on massive amounts of text (like books, articles, web pages). Pretraining teaches the model <strong>how language works</strong> but not necessarily <strong>how to be useful, safe, or aligned to human needs</strong>.</p>
<p>There are three main algorithms that are used for PostTraining :</p>
<ol>
<li><p>Supervised Fine-Tuning</p>
</li>
<li><p>Reinforcement Learning</p>
</li>
<li><p>Instruction Tuning</p>
</li>
</ol>
<h4 id="heading-supervised-fine-tuning-sfts"><strong>Supervised Fine-Tuning (SFT’s)</strong></h4>
<p>The idea behind SFTs is that one can do Language Modelling (predicting the next word) of the desired answers (supervised).</p>
<p>Interestingly, one doesn’t need a lot of data (only few thousands) to train a model on SFT. It is really about making intuition, tone and safety a part of the prediction that an LLM is expected to do. It is trained to not generate violating content — through SFT.</p>
<blockquote>
<p><strong><em>Should the response be bulleted , or in paragraphs ? SFT trains the model.</em></strong></p>
</blockquote>
<h4 id="heading-reinforcement-learning-from-human-feedback-rhlf"><strong>Reinforcement Learning from Human Feedback (RHLF)</strong></h4>
<p>The problem with SFT is that it is about cloning human behaviour. It learns what is expected from it , basically teaching mannerisms to a model. But, it comes with it’s own problems.</p>
<p>Humans will generally prefer a response that they could not think of. They will like a new response and would appreciate it — but that shouldn’t suggest the model that the quality of the response was good every time. Secondly, LLMs tend to hallucinate. Hallucination by LLMs is also misunderstood several times.</p>
<p>If I ask it give me a review on a book it was never trained on- it will infer from the title, the meta data (if provided) and will generate an answer that fits the requirement , but that doesn’t mean it would be factually correct. It will be totally believable until you do a fact check — and that is Hallucination.</p>
<p><strong><em>So, how does this work ?</em></strong></p>
<p><strong>Human — Rank Responses</strong></p>
<p>The model generates <strong>multiple responses</strong> to a prompt. Humans r<strong>ank</strong> these responses: Which one is best? Which is worse?</p>
<p>This creates <strong>pairwise comparisons</strong> of answers.</p>
<p><strong>Bradley-Terry Equation</strong></p>
<p>Imagine you’re rating two football teams: Team A and Team B. Let’s say Team A has a skill score of 1.2, while Team B has a skill score of 0.8. According to the Bradley-Terry model, the probability that Team A wins is determined by the ratio of the exponential of its score to the sum of the exponentials of both teams’ scores. Mathematically, this is expressed as:</p>
<p>P(A beats B)= e^1.2 / (e^1.2+e^ 0.8)</p>
<p>This is effectively a softmax over the two scores, where the higher the score, the greater the probability of winning. The larger the difference between the scores, the more confident the model becomes in its prediction.</p>
<p>In the context of RLHF (Reinforcement Learning from Human Feedback), the exact same principle is used, but instead of football teams, we have two responses to a prompt generated by the language model. Instead of predicting who wins a match, we’re modeling which response humans prefer. The reward model assigns each response a numerical score, and the probability that one response is preferred over another is computed using the same softmax formula. This allows the model to mathematically align its predictions with human preferences, providing a foundation for learning from feedback.</p>
<p><img src="https://cdn-images-1.medium.com/max/1600/1*kSZ6pdU5VZhkSF6796AGtQ.jpeg" alt /></p>
<p><strong>Lastly, Proximal Policy Optimisation</strong></p>
<p>Now that we have a reward signal — thanks to the human preference data and the trained reward model — the next step is to actually fine-tune the large language model (LLM) so that it consistently generates outputs that <strong>score higher according to this reward model</strong>. This is where <strong>Reinforcement Learning (RL)</strong> comes in, and specifically, where <strong>Proximal Policy Optimization (PPO)</strong> becomes crucial to the process.</p>
<p>PPO is the algorithm most commonly used in RLHF (Reinforcement Learning from Human Feedback) for language models because it strikes a careful balance between <strong>learning and stability</strong>. In traditional reinforcement learning, models are updated by maximizing rewards. However, when dealing with LLMs — which can have <strong>billions or even trillions of parameters</strong> — even small changes to the model’s weights can lead to <strong>catastrophic shifts</strong> in behavior. These shifts might cause the model to lose its language fluency, generate nonsensical responses, or exhibit erratic behavior. This is why <strong>safe exploration</strong> and <strong>controlled updates</strong> are essential in this setting.</p>
<p>PPO addresses this by introducing a <strong>clipped objective function</strong> that prevents the new model (the updated policy) from straying too far from the old model (the original policy). It does this by calculating the <strong>probability ratio</strong> between the new and old policies and ensuring that updates are only made if this ratio stays within a small, acceptable range. If the model’s behavior changes too much in one step, the update is <strong>clipped</strong> — effectively acting like a safety belt that protects against drastic deviations.</p>
<p>This mechanism allows PPO to <strong>gradually guide the model towards better behaviors</strong>, such as producing responses that are more helpful, polite, truthful, or safe (as determined by the reward model), while at the same time <strong>preserving the underlying language generation capabilities</strong> that the base model already has. Without this careful balancing act, the model might “over-optimize” for the reward and start generating repetitive, robotic, or unnatural text just to maximize scores — this is called <strong>reward hacking</strong>.</p>
<p>In short, <strong>PPO helps fine-tune the model in a way that improves its alignment with human values and preferences without destabilizing its core language abilities</strong>. It allows the model to learn <strong>how to behave better</strong> while making sure that these improvements are <strong>incremental, reversible, and controlled</strong> — a critical requirement when working with extremely large models that are costly to retrain or repair. This combination of <strong>alignment and stability</strong> is why PPO is the algorithm of choice in RLHF pipelines for assistant LLMs like ChatGPT.</p>
<hr />
<p><strong>And that brings us to the end of this blog.</strong><br />I hope you now have a clearer understanding of what goes on behind the scenes when building a Large Language Model. I’ve done my best to break down the concepts and simplify them so that even someone new to the field — whether a fresher or a curious beginner — can grasp the core ideas and, hopefully, feel inspired to explore further. After all, every expert once started with curiosity.</p>
]]></content:encoded></item><item><title><![CDATA[When Gemini Ghosted Me: The Chaos & Jugaad Behind Building Quiztelify]]></title><description><![CDATA[So I was working on this idea, simple in theory : a website that helps students practice NPTEL weekly quizzes. I called it Quiztelify, and it lets users…]]></description><link>https://blogs.codechefvit.com/when-gemini-ghosted-me-the-chaos-and-jugaad-behind-building-quiztelify</link><guid isPermaLink="true">https://blogs.codechefvit.com/when-gemini-ghosted-me-the-chaos-and-jugaad-behind-building-quiztelify</guid><category><![CDATA[DevHumour]]></category><category><![CDATA[#PromptEngineering]]></category><category><![CDATA[DeveloperStories]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[TechHumor]]></category><dc:creator><![CDATA[Karan Dugar]]></dc:creator><pubDate>Sat, 28 Jun 2025 23:24:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755979322457/72a08fae-6aeb-4c85-9d98-5643a22ccb36.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>So I was working on this idea, simple in theory : a website that helps students practice NPTEL weekly quizzes. I called it</strong> <a target="_blank" href="https://quiztelify.karnx.dev"><strong>Quiztelify</strong></a><strong>, and it lets users either pick from a list of pre-uploaded courses or upload their own NPTEL quiz PDF. The goal? Parse the PDF, extract all MCQs week-by-week, and present them in a clean, test-like interface for practice.</strong></p>
<p>To handle the parsing, I decided early on to use the Gemini 2.0 Flash API, mainly because, during my manual prompt testing, it consistently gave me the best results compared to other AI models. It’s optimized for speed and does a solid job transforming unstructured inputs — like quiz-heavy PDFs — into structured formats like JSON. But as with all LLMs, the real magic lies in the prompt, and that’s where ChatGPT came in. Think of it as my prompt whisperer. I kept bouncing ideas off it, tweaking wording and restructuring instructions until we landed on the Goldilocks prompt: just right. By crafting a precise prompt that specified the extraction schema (weeks, questions, four options, and bolded correct answers), I was able to guide Gemini effectively. The result was a reliable pipeline that converted raw content into clean, usable data with minimal manual intervention.</p>
<p>Except… <strong>boom never happened.</strong></p>
<p>When I parsed a full NPTEL PDF with Gemini 2.0 Flash, I noticed something odd. The response would cut off — not at a hard error, but just kind of fizzle out. The JSON output would include the first few weeks and their questions, and then… it’d just stop. Turns out, Gemini 2.0 Flash has <strong>a response window limit,</strong> basically, the amount of text it can send back is capped. Not by tokens (as in tokens per input + output), but by its internal output length constraints. So, long PDF in + long JSON out = <strong>truncated response</strong>.</p>
<h2 id="heading-jugaad-attempt-1-split-the-prompt-in-half"><strong>Jugaad Attempt #1: Split the Prompt in Half</strong></h2>
<p>Of course, my first instinct was the classic developer fix, split the job in two. I created two separate prompts, First one for <strong>Week 1–6</strong> and Second one for <strong>Week 7–12.</strong></p>
<h2 id="heading-first-half-prompt"><strong>First Half Prompt:</strong></h2>
<pre><code class="lang-plaintext">You are given a course quiz PDF document that contains multiple-choice quiz questions organized week-wise. Each section starts with a heading such as “Week 1”, “Week 2”, and so on.

  Your task is to:
  - Detect the total number of weeks present in the document.
  - Extract only the **first half** of the weeks (e.g., if there are 12 weeks, extract Week 1 to Week 6).
  - Under each detected week, extract all quiz questions that meet the following criteria:

  Each question must have:
  - A question string
  - Exactly **4 options**
  - One option clearly marked as the correct answer using **bold formatting** in the PDF

  Return your output strictly in the following JSON format:

  {
    "Week 1": [
      {
        "question": "Example question?",
        "options": ["Option A", "Option B", "Option C", "Option D"],
        "answer": "Option B"
      }
    ],
    "Week 2": [...],
    ...
  }

  Instructions:
  - Only include valid weeks (do not fabricate or assume week labels).
  - Only include questions with a clearly bolded correct answer and exactly four options.
  - The "answer" value must exactly match the bolded option.
  - Do not include any explanation, extra text, or notes outside of the JSON.
  - Only return valid JSON as described above.
  - If you feel the pdf content is not correct return a respsone with a message saying "Please upload a valid document".
</code></pre>
<h2 id="heading-second-half-prompt"><strong>Second Half Prompt:</strong></h2>
<pre><code class="lang-plaintext">Same, but Extract only the **second half** of the weeks (e.g., if there are 12 weeks, extract Week 7 to Week 12).
</code></pre>
<p>I figured this would reduce the output size and stay within the response limit. Makes sense, right?</p>
<p><strong>Wrong.</strong></p>
<p>The first prompt worked beautifully. Gemini 2.0 Flash returned full, correct JSON with all questions intact. But the second prompt? It gave me all the correct <strong>week headers</strong> — “Week 7”, “Week 8”, and so on, but <strong>most of the questions were missing</strong>. Sometimes I’d get two questions. Sometimes five. Sometimes none. It was like Gemini was feeling lazy after lunch.</p>
<p>I thought it was just a weird fluke. Tried again. And again. But every time, the same issue: <strong>weeks without questions</strong>. No errors, just… silent failure. Lovely.</p>
<p>And that’s when I reached <em>that classic developer moment,</em> I leaned back and said:</p>
<blockquote>
<p><em>“Okay, you know what? At least this two-prompt thing is almost working.<br />I’ll park this for now. Let me finish the other features.<br />This… is a problem for</em> <strong><em>Future Me.*</em></strong>”*</p>
</blockquote>
<p>Every dev knows this moment. You get tired of debugging ghosts and decide to work on the UI instead. That’s what I did. I moved on to building out the rest of Quiztelify — the quiz view, the results modal, the course cards, everything.</p>
<p>But of course, all good things must come to an end, including my illusion that I could ignore this bug forever. Once I wrapped up the rest of the site, I was left staring at the one unfinished piece. The thing I had shoved aside like dirty laundry. Yep, the “I’ll fix this later” moment had arrived. Future Me was now Present Me… and Past Me was a jerk.</p>
<h2 id="heading-desperate-times-call-gpt"><strong>Desperate Times Call GPT</strong></h2>
<p>So I came crawling back to GPT, hoping for a miracle. And to its credit — you (<em>hi again 👋</em>) delivered.</p>
<p>And you suggested a more structured approach:</p>
<ul>
<li><p>First prompt: Ask Gemini to <strong>detect all the weeks</strong> in the document</p>
</li>
<li><p>Second prompt: Explicitly request only Week 1–6</p>
</li>
<li><p>Third prompt: Explicitly request only Week 7–12</p>
</li>
</ul>
<p>This was like a surgical prompt strategy — split, isolate, extract.<br />GPT basically said: <em>“Treat Gemini like a forgetful intern. Be specific. Don’t assume.”</em></p>
<p>Technically, this made sense. It would’ve solved the issue cleanly.<br />But it came at a cost: <strong>speed</strong>. This meant <strong>three API calls per PDF</strong> upload, not exactly snappy when a user just wants to revise for a test. The idea of users staring at a loading spinner while my backend lovingly coaxed out every week’s questions felt… bad.</p>
<p>So, again, I parked it. The dream of a single, reliable Gemini call still glimmered in the distance.</p>
<h2 id="heading-gemini-25-flash-to-the-rescue-kind-of"><strong>Gemini 2.5 Flash to the Rescue (Kind Of)</strong></h2>
<p>After a bit more digging, I stumbled upon <strong>Gemini 2.5 Flash</strong> and it felt like hope. Unlike 2.0, it didn’t suffer from the same output-cutoff issue. When I ran my prompt through 2.5, it actually returned all the weeks <em>and</em> all the questions in one go. No ghosted MCQs, no mysteriously empty arrays. Just clean, full JSON like I’d always dreamed of.</p>
<p>Of course, life being life — <strong>Gemini 2.5 Flash was sloooooow</strong>.<br />If Gemini 2.0 was the overconfident intern who sprints through tasks but forgets half the deliverables, 2.5 was the old-school guy who double-checks everything but takes three coffee breaks while doing it.</p>
<p>That’s when it hit me, a totally unhinged idea, but it made total sense:</p>
<blockquote>
<p><em>“What if I use both?”</em></p>
</blockquote>
<h2 id="heading-jugaad-attempt-2-the-frankenstein-fix"><strong>Jugaad Attempt #2: The Frankenstein Fix</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1751152219823/34bf4018-f6a4-461b-8cfb-6a2e549d6479.png" alt class="image--center mx-auto" /></p>
<p>So I built a hybrid pipeline:</p>
<ul>
<li><p>Use <strong>Gemini 2.0 Flash</strong> to process the <strong>first half</strong> (Week 1–6).<br />  It’s fast, and the JSON is usually accurate here. (Why it worked in the first half but failed in the second is still a mystery to me).</p>
</li>
<li><p>Use <strong>Gemini 2.5 Flash</strong> to handle <strong>Week 7–12</strong>, where the data tends to get long and 2.0 starts dropping things.</p>
</li>
</ul>
<p><strong>And Finallyyy</strong>, this gave me the best of both worlds: Finally, I had a working system. The PDFs parsed beautifully. The JSON was consistent. The quiz data appeared instantly in the UI. I almost cried.</p>
<p><strong>Quiztelify</strong> was built in <strong>just two days</strong>, but those two days were filled with pure chaos, caffeinated debugging, stubborn AI models, and the kind of duct-tape fixes that only make sense at 2 AM.</p>
<p>What started as a “simple NPTEL quiz parser” turned into a wild ride of prompt engineering, model limitations, and plenty of <strong><em>jugaad</em>.</strong> But hey, that’s the fun part, right?</p>
<p>I wanted to share this story not just because it was ridiculous (and kind of hilarious in hindsight), but because building with AI is still very much an up-and-coming adventure. There were weird bugs, partial responses, random hallucinations and moments where I just sat back and thought, <em>“Yeah okay, future me can deal with this.”</em> Honestly, I still don’t fully understand <em>why</em> some things happened the way they did, but I’d love to dig deeper and figure it out someday.</p>
<p><strong>Quiztelify</strong> is now live at <a target="_blank" href="https://quiztelify.karnx.dev/">quiztelify.karnx.dev</a>, and I’m genuinely proud of how it turned out. If you’re prepping for NPTEL, definitely check it out — you can upload your own PDFs or pick from a list of pre-uploaded courses and get instant quiz practice, week by week. The full source code is open-source and available on GitHub: <a target="_blank" href="https://github.com/karannfr/nptel-quiz-app">github.com/karannfr/nptel-quiz-app</a>.</p>
<p>And if you’re just here for the chaos story? I hope you smiled, cringed, or at least related to the <em>“how is this my life right now?”</em> moments.</p>
<p>Because if there’s one thing I’ve learned in 48 hours of pure build mode, it’s this:</p>
<blockquote>
<p><strong><em>Two AI models are better than one.<br />But one stubborn dev is better than both. 💪</em></strong></p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[SynthQuest 4: Adding Voices to our Synth]]></title><description><![CDATA[Learn how to organize SynthVoice code for a VST, manage oscillators, and ensure seamless sound processing in SynthQuest 4]]></description><link>https://blogs.codechefvit.com/synthquest-4</link><guid isPermaLink="true">https://blogs.codechefvit.com/synthquest-4</guid><category><![CDATA[synth-quest]]></category><category><![CDATA[VST Plugins]]></category><category><![CDATA[C++]]></category><category><![CDATA[JUCE]]></category><category><![CDATA[synth]]></category><dc:creator><![CDATA[Harshit Sarma]]></dc:creator><pubDate>Thu, 19 Jun 2025 16:46:23 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1749126884282/8864341f-c60d-4607-85a0-892427abcb85.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Welcome back to the SynthQuest series, where we’re building a VST from scratch. This is Episode 4, and today’s quest is to organize our code by empowering each synth voice with its oscillator and responsibilities. If this is your first time here, be sure to check out the previous episodes to catch up. Let’s get started. First, we will move the oscillator object to SynthVoice’s private section, from where it was previously defined, since each SynthVoice is responsible for playing a separate note, it makes sense to move the oscillator object inside SynthVoice. This way, each voice gets its own oscillator.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747472288264/89469b90-34f4-4896-b7f6-af67b8c62939.png" alt class="image--center mx-auto" /></p>
<p>After this, go to the pluginProcessor.cpp file and start implementing the functions that we defined in the last episode. Firstly, <strong>canPlaySound()</strong> function,</p>
<p><code>bool SynthVoice::canPlaySound(juce::SynthesiserSound* sound){</code></p>
<p><code>return dynamic_cast&lt;juce::SynthesiserSound*&gt;(sound) != nullptr;</code></p>
<p><code>}</code></p>
<p>For safety, we are dynamically casting the sound argument, and if it is a valid SynthesiserSound object instead of a null pointer, then it can play sound.</p>
<p>Then similarly implement the <strong>startNote()</strong> function :</p>
<p><code>void SynthVoice::startNote(int midiNoteNumber, float velocity, juce::SynthesiserSound* sound, int currentPitchWheelPosition){}</code></p>
<p>Then stopNote() function :</p>
<p><code>void SynthVoice::stopNote(float velocity, bool allowTailOff) {}</code></p>
<p>Then controllerMoved() function :</p>
<p><code>void SynthVoice::controllerMoved(int controllerNumber, int newControllerValue) {}</code></p>
<p>Then, for the <strong>prepareToPlay()</strong> function, move everything that was written in the <strong>BasicOscAudioProcessor::prepareToPlay()</strong> to <strong>SynthVoice::prepareToPlay()</strong> since, again, SynthVoice is the real deal now. So, it should look like this :</p>
<p><code>void SynthVoice::prepareToPlay(double sampleRate, int samplesPerBlock, int outputChannels) {</code></p>
<p><code>juce::dsp::ProcessSpec spec;</code></p>
<p><code>spec.maximumBlockSize = samplesPerBlock;</code></p>
<p><code>spec.sampleRate = sampleRate;</code></p>
<p><code>spec.numChannels = outputChannels;</code></p>
<p><code>osc.prepare(spec);</code></p>
<p><code>}</code></p>
<p>Now we will implement the <strong>renderNextBlock()</strong> function and move the things we defined in BasicOscAudioProcessor::processBlock.</p>
<p><code>void SynthVoice::renderNextBlock(juce::AudioBuffer&lt; float &gt;&amp; outputBuffer, int startSample, int numSamples) {</code></p>
<p><code>juce::dsp::AudioBlock&lt;float&gt; audioBlock{ outputBuffer };</code></p>
<p><code>osc.process(juce::dsp::ProcessContextReplacing&lt;float&gt;(audioBlock));</code></p>
<p><code>}</code></p>
<p>So, everything together, your pluginProcessor.cpp should look like this :</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747472512033/6e282d42-812f-4fef-87d1-2fd060a9238c.png" alt class="image--center mx-auto" /></p>
<p>Now, we need to make some changes in <strong>BasicOscAudioProcessor::prepareToPlay</strong> and <strong>BasicOscAudioProcessor::processBlock,</strong> as we have moved those functions to different parts of the <strong>SynthVoice</strong> class. Let’s try to understand this with an analogy.</p>
<p>Our synth is producing only one note constantly, but we want it to play all the notes (like playing two keys on the piano together). And handling each voice with BasicOscAudioProcessor::prepareToPlay() will be pretty difficult; that is why SynthVoice::prepareToPlay() will firstly deal with each voice, and then the whole sound will be sent to BasicOscAudioProcessor::prepareToPlay().</p>
<p>Similarly, in SynthVoice::renderNextBlock() function, each voice is processed separately, but BasicOscAudioProcessor::processBlock() function will process them as a whole. Just like a sound engineer mixing all instruments after each musician plays their part.</p>
<p><code>void BasicOscAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock){</code></p>
<p><code>synth.setCurrentPlaybackSampleRate(sampleRate);</code></p>
<p><code>for (int i = 0;i &lt; synth.getNumVoices(); i++) {</code></p>
<p><code>if (auto voice = dynamic_cast&lt;SynthVoice*&gt;(synth.getVoice(i))) {</code></p>
<p><code>voice-&gt;prepareToPlay(sampleRate, samplesPerBlock, getTotalNumOutputChannels());</code></p>
<p><code>}</code></p>
<p><code>}</code></p>
<p><code>}</code></p>
<p>Let’s understand each line of code, synth.setCurrentPlaybackSampleRate(sampleRate); here, we are defining the sample rate for the synth, ensuring all the voices use the correct sample rate.</p>
<p>In the loop, we are iterating through each voice, retrieving each voice with the <strong>synth.getVoice()</strong> function and then dynamically casting each voice to a pointer to the SynthVoice class and then storing it in the voice variable and then if it exists then calling out the function <strong>prepareToPlay()</strong> to initialize the voice with the necessary parameters.</p>
<p>Then the BasicOscAudioProcessor::processBlock() function should look something like this :</p>
<p><code>void BasicOscAudioProcessor::processBlock (juce::AudioBuffer&lt;float&gt;&amp; buffer, juce::MidiBuffer&amp; midiMessages){</code></p>
<p><code>juce::ScopedNoDenormals noDenormals;</code></p>
<p><code>auto totalNumInputChannels  = getTotalNumInputChannels();</code></p>
<p><code>auto totalNumOutputChannels = getTotalNumOutputChannels();</code></p>
<p><code>for (auto i = totalNumInputChannels; i &lt; totalNumOutputChannels; ++i)</code></p>
<p><code>buffer.clear (i, 0, buffer.getNumSamples());</code></p>
<p><code>for (int i = 0; i &lt; synth.getNumVoices(); ++i) {</code></p>
<p><code>if (auto voice = dynamic_cast&lt;juce::SynthesiserVoice*&gt;(synth.getVoice(i))) {</code></p>
<p><code>}</code></p>
<p><code>}</code></p>
<p><code>synth.renderNextBlock(buffer, midiMessages, 0, buffer.getNumSamples());</code></p>
<p><code>}</code></p>
<p>Here, we are iterating through each voice but not doing anything inside the for loop because that is for extra per-voice processing, like adding a filter or any other effect to the voices, which we are not doing as of right now. At the end, I called the renderNextBlock() function, which handles the sound processing for each active voice.</p>
<p>Now, we are going to let our <em>synth</em> object know about these two classes that we have implemented so that it will know what sounds it can play and how to play them using voices. In the BasicOscAudioProcessor::BasicOscAudioProcessor() class inside <code>#endif</code>, we are going to initialize our synth with classes like this:</p>
<p><code>synth.addSound(new SynthSound());</code></p>
<p><code>synth.addVoice(new SynthVoice());</code></p>
<p>You can check out the <em>synth-quest-4</em> branch in the <a target="_blank" href="https://github.com/kashyap-harshit/basic-osc-tutorial">GitHub</a> repository for the code till here. In the next episode, we will be writing ADSR code. <em>Danke,</em> and see you in the next one!</p>
]]></content:encoded></item><item><title><![CDATA[SynthQuest 3: Implementing MIDI input]]></title><description><![CDATA[The third episode of the synth-quest series focuses on creating a juce::Synthesiser object and handling MIDI input via keyboard.]]></description><link>https://blogs.codechefvit.com/synthquest-3</link><guid isPermaLink="true">https://blogs.codechefvit.com/synthquest-3</guid><category><![CDATA[synth-quest]]></category><category><![CDATA[JUCE]]></category><category><![CDATA[VST Plugins]]></category><category><![CDATA[C++]]></category><dc:creator><![CDATA[Harshit Sarma]]></dc:creator><pubDate>Sun, 15 Jun 2025 08:14:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1749127120703/13927803-603f-43c5-866f-9b0e1a471e79.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Welcome back to the SynthQuest series, where we’re building a VST from scratch. This is Episode 3, and today’s quest is to create a <em>juce::Synthesiser</em> object. If this is your first time here, make sure to check out the previous episodes to catch up. Alright, let’s begin. Why do we need a <em>juce::Synthesiser</em> object? Because it handles a lot of things, and MIDI input is one of them (when we press a key on a piano or keyboard, a sound is produced, and that input is called <em>MIDI</em> input).</p>
<p>Additionally, our current synth is only producing one note continuously. To change this and play different notes when keys are pressed, creating a juce::Synthesiser object is necessary. Then, we will define two classes in the <em>pluginProcessor.h</em> file they are <em>SynthSound</em> and <em>SynthVoice</em>. Why do we need these? Because we need to tell our juce::Synthesiser object the sounds that can be played and how those sounds should be generated, this is how we feed logic to our juce::Synthesiser by creating those two classes. Generally, we create separate files to define these classes, but since our project is relatively small, we are not going to do it that way. Let’s get started:</p>
<p>Firstly, we’ll define the SynthSound class and then the member function as well, since we are deriving it from the juce::SynthesiserSound abstract class.</p>
<p><code>class SynthSound : public juce::SynthesiserSound {</code></p>
<p><code>bool appliesToNote(int midiNoteNumber) override { return true; }</code></p>
<p><code>bool appliesToChannel(int midiChannel) override { return true; }</code></p>
<p><code>};</code></p>
<p>The SynthSound class acts as a filter. For example, if you want to block certain MIDI notes from being played or restrict specific MIDI channels (which are like <em>tracks</em> in a DAW), this is where you do it. The appliesToNote() function checks the notes that can be played, and here we are returning true for all the notes. And appliesToChannel() function checks which channels are allowed, and here we are allowing all the channels. Right now, this is the default state where everything is allowed.</p>
<p>Similarly, for the SynthVoice class:</p>
<p><code>class SynthVoice : public juce::SynthesiserVoice {</code></p>
<p><code>public:</code></p>
<p><code>bool canPlaySound(juce::SynthesiserSound*) override;</code></p>
<p><code>void startNote(int midiNoteNumber, float velocity, juce::SynthesiserSound* sound, int currentPitchWheelPosition) override;</code></p>
<p><code>void stopNote(float velocity, bool allowTailOff) override;</code></p>
<p><code>void controllerMoved(int controllerNumber, int newControllerValue) override;</code></p>
<p><code>void pitchWheelMoved(int newPitchWheelValue) override {}</code></p>
<p><code>void prepareToPlay(double sampleRate, int samplesPerBlock, int outputChannels);</code></p>
<p><code>void renderNextBlock(juce::AudioBuffer&lt; float &gt;&amp; outputBuffer, int startSample, int numSamples) override;</code></p>
<p><code>private:</code></p>
<p><code>};</code></p>
<p>SynthVoice class is where we are going to write the logic for producing sounds. For example, if we want to create a gain slider that increases or decreases gain, we will have to write the logic for that here. The processing of the audio.</p>
<p>Firstly, let’s understand what a voice is. If I play the C major chord, C E G, here we will need three voices, and each voice will be responsible for generating its sound and waveform. If you can recall, our oscillator was making only one sound, and it was having only one voice, and we had no control over it. But with juce::Synthesiser we can create polyphonic sound as well.</p>
<p>The <strong>canPlaySound()</strong> function checks whether this voice can play a specific sound. The startNote() function is called when a MIDI note is pressed, and the <strong>stopNote()</strong> function is triggered when that note is released. These are the places where we usually apply the ADSR envelope logic. The <strong>controllerMoved()</strong> function handles changes in MIDI controllers like mod wheels or expression pedals. <strong>The pitchWheelMoved()</strong> function handles pitch bending, but it is currently not doing anything (just vibing for now). Now, you might be wondering why there's a <strong>prepareToPlay()</strong> function here when we already have one in the main class. The difference is: the main <strong>prepareToPlay()</strong> sets up the entire synthesizer, while this one is specific to an individual voice. Finally, we have the <strong>renderNextBlock()</strong> function. This is where we set up our oscillators, gain, ADSR, etc. Previously, we handled those in the main synthesizer class, but this is the more standard way, doing it inside the voice itself.</p>
<p>So, to sum it all up, SynthSound acts as the filter deciding which notes and channels are allowed, and think of SynthVoice class as real-life individual musicians in an orchestra or a band who generate sound by processing MIDI input and stuff. Now we are going to create a juce::Synthesiser object in the main class in PluginProcessor.h, and the name is synth.</p>
<p><code>juce::Synthesiser synth;</code></p>
<p>So now the pluginProcessor.h file should look like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747471691322/6381d88d-e689-40cb-9d5f-b7b80b690af7.png" alt class="image--center mx-auto" /></p>
<p>You can check out the synth-quest-3 branch in the <a target="_blank" href="https://github.com/kashyap-harshit/basic-osc-tutorial">GitHub</a> repository for the code till here.</p>
<p>In the next episode, we will move some code to the classes we created today and organize it. <em>Grazie,</em> and see you in the next one!</p>
]]></content:encoded></item><item><title><![CDATA[SynthQuest  2: Building an oscillator in JUCE]]></title><description><![CDATA[Learn how to build a synth VST from scratch in just 7 days with our SynthQuest series. Episode 2 covers oscillator creation]]></description><link>https://blogs.codechefvit.com/synthquest-2</link><guid isPermaLink="true">https://blogs.codechefvit.com/synthquest-2</guid><category><![CDATA[synth-quest]]></category><category><![CDATA[VST Plugins]]></category><category><![CDATA[C++]]></category><category><![CDATA[JUCE]]></category><category><![CDATA[synth]]></category><dc:creator><![CDATA[Harshit Sarma]]></dc:creator><pubDate>Mon, 26 May 2025 18:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1753111690400/7a904c7a-4c0f-46fe-99d1-eb69e31ad3fb.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Welcome back to the SynthQuest series, where we’re building a VST from scratch. This is Episode 2, and today’s quest is to create an <strong>oscillator</strong>. If you are new here, make sure to check out the first episode to catch up. Before we begin with our code, let’s take a moment to talk about oscillators. An <strong>Oscillator</strong> is the heart of a synthesizer; it generates a continuous waveform, which is the basis of all synthesized sound. In simpler words, the basic thing that produces sound. We'll start by implementing the sine waveform for now and add the others later.</p>
<p>Let’s explore some audio concepts that will help you understand what’s happening under the hood. They’re fundamental to how digital audio works and will come up often as we build our synth:</p>
<p><strong>Sample Rate:</strong> The number of audio samples captured per second, measured in Hertz (Hz). It's like FPS in video—higher sample rate means smoother and more detailed sound.</p>
<p><strong>Bit Depth:</strong> Determines the resolution of each audio sample, affecting the sound's dynamic range and precision. It's like the division of the <em>Y-axis (amplitude)</em>; more divisions mean greater dynamic range, clearer sound, and less noise.</p>
<p><strong>Buffer Size:</strong>  The number of audio samples processed at a time before sending the data to the output. The computer processes audio data in chunks, and we can define the size of the chunks. A simple analogy for this would be packing boxes for delivery. Smaller boxes (with a low buffer size) are sent faster but require more frequent packing (resulting in more CPU usage), while larger boxes (with a high buffer size) take longer but reduce the number of trips.</p>
<p>Now let’s begin with our project. Open <em>Projucer</em> and click on the IDE icon to open Visual Studio. We will go to the <em>BasicOscAudioProcessor</em> class in the <em>PluginProcessor.h</em> file and initialize an Oscillator as a private member.</p>
<p><code>juce::dsp::Oscillator&lt;float&gt; osc{ [](float x) {return std::sin(x); } };</code></p>
<p>To explain this snippet, in the juce namespace, we are using the <strong>juce::dsp</strong> module's Oscillator class, specifying float as the template parameter. This means the oscillator will generate waveform values in floating-point precision. Using float type reduces distortion, and it is more precise than an integer value, also uses less memory than &lt;double&gt;, as &lt;double&gt; is 64-bit and &lt;float&gt; is 32-bit. This makes it a sine wave oscillator. The file should look like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747470782099/d7fb2d63-231b-4792-ab82-33386a2a88e6.png" alt class="image--center mx-auto" /></p>
<p>It’s time to provide the Oscillator with the necessary data that it requires before processing any sound. We’ll head over to the <em>PluginProcessor.cpp</em> file, and in the <em>prepareToPlay</em> function, we’ll write a few lines of code. Firstly, we’ll declare a processSpec object, let’s call it spec.</p>
<p><code>juce::dsp::ProcessSpec spec;</code></p>
<p>After that, we’ll define buffer size, sample rate, and number of output channels.</p>
<p><code>spec.maximumBlockSize = samplesPerBlock;</code></p>
<p><code>spec.sampleRate = sampleRate;</code></p>
<p><code>spec.numChannels = getTotalNumOutputChannels();</code></p>
<p>After defining all of this, we will prepare the oscillator.</p>
<p><code>osc.prepare(spec);</code></p>
<p>Now, we have fed all the necessary data that the oscillator requires before it can play. This is how the <em>prepareToPlay</em> function should look:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747470964661/11b75336-47ee-4d7e-962e-bb8fbd6e61f1.png" alt class="image--center mx-auto" /></p>
<p>Let’s define the buffer and put audio in it so that it can be heard. In the <em>processBlock</em> function (same file), we are going to define an AudioBlock object, let’s call that audioBlock. So, basically, this is a wrapper around the buffer that helps us deal with the buffer at a very high level. This looks something like this.</p>
<p><code>juce::dsp::AudioBlock&lt;float&gt; audioBlock{ buffer };</code></p>
<p>Now, we can deal with the buffer very easily. We pass <em>audioBlock</em> to <em>osc.process(),</em> instructing the oscillator to generate a waveform and overwrite the buffer with its <em>(oscillator’s)</em> output. In our case, the buffer is empty because no other previous audio data is present.</p>
<p><code>osc.process(juce::dsp::ProcessContextReplacing&lt;float&gt;(audioBlock));</code></p>
<p>With the osc.process() function, we pass the buffer to the oscillator. It is like saying to the oscillator, “Hey, this is a buffer, please fill this with your waveform data”.</p>
<p>What is <em>ProcessContextReplacing</em>? We wrap audioBlock inside ProcessContextReplacing&lt;float&gt;, which tells the oscillator to overwrite the buffer with new waveform data. So, it replaces the previous data. There is ProcessContextReplacing, and the other one is ProcessContextNonReplacing. NonReplacing is used when we want to mix the oscillator’s output with existing audio instead of replacing it. We are sending audioBlock as an argument in the constructor.</p>
<p>Now the buffer is filled, let’s try to run the project. Warning, please decrease the volume of your system before building, since we have not done anything for the gain in the program as of now. Once the program is built, it will produce a sound of the sine wave.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747471058450/1b23881f-0e94-411d-b7d3-592f95d4fad6.png" alt class="image--center mx-auto" /></p>
<p>Here’s the <a target="_blank" href="https://github.com/kashyap-harshit/basic-osc-tutorial">Github link</a>. Just clone the repo and open the <strong>.jucer</strong> file in <strong>Projucer</strong>.</p>
<p>In the next episode, we will shift our code to the <em>juce::SynthesiserSound</em> and <em>juce::SynthesiserVoice</em> classes. Check these out in the documentation <a target="_blank" href="https://docs.juce.com/master/index.html">here.</a> Till then, <em>Gracias</em>, see you in the next one!</p>
]]></content:encoded></item><item><title><![CDATA[SynthQuest  1:  Setting the stage for a VST plugin]]></title><description><![CDATA[Learn how to build a Synth VST in seven days with the JUCE framework and Visual Studio. Perfect for aspiring music tech creators]]></description><link>https://blogs.codechefvit.com/synthquest-1</link><guid isPermaLink="true">https://blogs.codechefvit.com/synthquest-1</guid><category><![CDATA[synth-quest]]></category><category><![CDATA[VST Plugins]]></category><category><![CDATA[C++]]></category><category><![CDATA[JUCE]]></category><category><![CDATA[synth]]></category><dc:creator><![CDATA[Harshit Sarma]]></dc:creator><pubDate>Sun, 25 May 2025 08:21:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1753111808034/1f1f9c52-d0f1-4763-bc40-53f8118b41eb.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>"A musician who can’t create their own instrument ain’t a real one.” Profound, right? Well, if that sounded like something you’d find written on a philosopher's door, trust me, you won’t. I made it up. <em>camera dramatically focuses on my face;</em> Yep, me. But hey, in the spirit of turning words into action, let’s try to create one, shall we? Over the next seven days, we will be diving into the art of crafting a <strong>Synth VST</strong> from scratch.</p>
<p>Let’s begin by installing the necessary libraries and IDEs. I’ll explain any terms or concepts as we encounter them. Start by downloading the latest official release of the JUCE framework from <a target="_blank" href="https://juce.com/download/">Download - JUCE</a>. <strong>JUCE</strong> is a C++ framework for developing Virtual Studio Technology (VST) plugins and audio applications. Now what do we mean by VSTs? I’ll just show you pictures of a synth called <strong>Arturia Mini V.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747469036175/7ee92b1c-6bbf-49c0-bea4-3a05ef1791f6.png" alt="Arturia Mini V (image)" class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747469134632/a0e83e98-5610-40ee-be84-f45de0ada9d8.png" alt class="image--center mx-auto" /></p>
<p>But the thing is that first one is a Physical Synthesizer, and the second one is the Software or VST version. Think of VSTs as digital versions of instruments that work inside your DAW (Digital Audio Workstation) like plugins that act like real synths, samplers, and audio processors. Why do we use VSTs more than hardware version of the same synth? Because:</p>
<ol>
<li><p>They are way cheaper.</p>
</li>
<li><p>Super portable - it is just a file not a bulky hardware.</p>
</li>
<li><p>Layering - you can create multiple instances of the same VST and layer sounds.</p>
</li>
<li><p>Automation – when using in DAW, there is no limit for automation/modulation and have your desired sound.</p>
</li>
</ol>
<p>Instead of diving too deep into the whole 'which vs what' debate, let's focus on the exciting part, <em>developing an actual VST</em>. So, after installing JUCE we need an IDE. The IDE that is recommended by JUCE for windows is Visual Studio. And Xcode for <em>mac</em> users. You can download Visual Studio from <a target="_blank" href="https://visualstudio.microsoft.com/downloads/">here</a>.</p>
<p>After installing JUCE and Visual Studio, open Projucer (\JUCE\Projucer.exe) and click on File-&gt;New Project-&gt;Plug-In-&gt;Basic. Then rename your project and click on Create Project.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747469334225/e13c630d-b1e5-4b08-bdc5-a2b85e5e3da5.png" alt class="image--center mx-auto" /></p>
<p>After Creating the project, open the project on Projucer and open the modules section on the sidebar and click on the + icon to include the DSP (<em>juce_dsp</em>) module as well (we’ll need that to create our synth).</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747469438068/eb1b3b9b-09cd-4e34-ac94-fd585742cb8e.png" alt class="image--center mx-auto" /></p>
<p>Then, click on the settings icon next to <em>basicOsc</em> and then go to pluginCharacteristics and click on <em>plugin is a Synth</em> and <em>plugin midi input.</em></p>
<p>After all this, we can finally open our IDE by clicking on the tiny visual studio icon. Mostly we’ll be dealing with 4 files:</p>
<ol>
<li><p>PluginEditor.h</p>
</li>
<li><p>PluginEditor.cpp</p>
</li>
<li><p>PluginProcessor.h</p>
</li>
<li><p>PluginProcessor.cpp</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747469532238/13e16398-3271-4068-a653-e8f1590ab9e5.png" alt class="image--center mx-auto" /></p>
<p>Let me quickly explain what each of these files is about. The first one <em>PluginProcessor.h</em> is a header file where we declare the audio processing (DSP) classes, functions, variables. In the <em>PluginProcessor.cpp</em> we implement and write the logic for them. The <em>PluginEditor.h</em> is another header file, but this is mostly related to the GUI of the VST, for example if we want to have a slider for gain. Then we declare it there in the header file and for the implementation or the logic we make use of the <em>PluginEditor.cpp</em> file. You’ll understand better once we start coding our Synth.</p>
<p>Alright let’s try to build the plugin to check if everything is alright (too philosophical). Click on the build button (play icon). The first build might take some time but after that it should only take less than a minute. You should see a window like this.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747469676356/72ad347a-ac79-4f7b-9da2-e3e229ea8382.png" alt class="image--center mx-auto" /></p>
<p>We are getting a pop up that is saying “Audio input is muted to avoid feedback loop” this is because we are building the VST as a standalone file and there is no input. In the BasicOscAudioProcessor constructor set input as false. Since we're making a Synth VST, we don’t need any input sound from the outside.</p>
<p>Here’s the <a target="_blank" href="https://github.com/kashyap-harshit/basic-osc-tutorial">github repository</a> with the code. I have created a separate branch called <em>synth-quest-1</em> for the code till here and will continue to create branches for each episode to reduce confusion.</p>
<p>In the next episode, we shall create our first sound, a simple <strong>sine wave</strong> from a basic <strong>Oscillator</strong>. Till then <em>arigato,</em> see you in the next one!</p>
]]></content:encoded></item><item><title><![CDATA[CORS 101: What It Is, Why It Matters, and How It Works]]></title><description><![CDATA[Learn about Cross-Origin Resource Sharing (CORS), why it’s crucial for web security, and how it regulates cross-origin HTTP requests]]></description><link>https://blogs.codechefvit.com/cors-101-what-it-is-why-it-matters-and-how-it-works</link><guid isPermaLink="true">https://blogs.codechefvit.com/cors-101-what-it-is-why-it-matters-and-how-it-works</guid><category><![CDATA[CORS]]></category><category><![CDATA[tech ]]></category><category><![CDATA[Browsers]]></category><category><![CDATA[Frontend Development]]></category><category><![CDATA[Backend Development]]></category><dc:creator><![CDATA[Vedant Matanhelia]]></dc:creator><pubDate>Fri, 18 Apr 2025 16:48:26 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1744994564296/1506d3a9-d877-470a-b6c6-e7c6ff13a7ec.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>It was 2AM, the air thick with anticipation. We were finally ready to deploy our website—the gateway for users to start registering on our new portal. After days of testing everything locally, I took a deep breath and hit deploy. Moments later, I visited the production URL, filled in the registration form, and clicked Register.</p>
<p>And then—<em>boom</em>. “Some error occurred.” My heart sank.</p>
<p>I rushed to check the server logs, expecting a stack trace or at least <em>something</em>. But... nothing. No logs. No request. It was as if the request had vanished into thin air.</p>
<p>Puzzled, I opened Postman and sent the exact same request. It worked perfectly. Now I was more confused than ever. Why would Postman reach my servers, but the website—our actual frontend—not even trigger a server log?</p>
<p>Then I opened the browser console, and there it was. A barrage of errors screaming back at me: <strong>CORS errors</strong>.</p>
<p>That night, I learned (the hard way) about something every web developer inevitably runs into—<strong>Cross-Origin Resource Sharing</strong>, or CORS. If you’re deploying a frontend that talks to an API on a different domain or port, understanding CORS is non-negotiable</p>
<p><strong>So….. What is CORS and Why is it so important ?</strong></p>
<p><strong>CORS</strong> stands for <strong>Cross Origin Resource Sharing</strong> and it is a browser security feature that controls how resources are requested across <strong><em>different origins.</em></strong></p>
<p>This begs another question: <strong>What exactly is an Origin ?</strong></p>
<p><strong>Origin</strong>, as the word suggests, is used to identify the <strong>source</strong> or <strong>origination point</strong> of a request. We all know that a <strong>URL</strong> is a string used to locate resources on the internet—but the <strong>origin</strong> is just a part of that URL.</p>
<p>It was first introduced by <strong>Netscape</strong> and is now part of the <strong>HTML Living Standard</strong>, maintained by <strong>WHATWG</strong> (don’t ask... it’s a long story).</p>
<p>An <strong>origin</strong> is defined as a combination (technically, a <em>tuple</em>) of the following three things:</p>
<ul>
<li><p><strong>Scheme</strong> (the protocol, e.g., <code>http</code>, <code>https</code>)</p>
</li>
<li><p><strong>Hostname</strong> (the domain, e.g., <a target="_blank" href="http://example.com"><code>example.com</code></a>)</p>
</li>
<li><p><strong>Port</strong> (e.g., <code>80</code>, <code>443</code>, or custom ones like <code>3000</code>)</p>
</li>
</ul>
<p>So two URLs might <em>look</em> similar, but if any one of these components differs, the browser will treat them as <strong>different origins</strong>—and that’s where <strong>CORS</strong> comes into play.</p>
<p>Let us take a real world example to understand origins.</p>
<ul>
<li><p><code>https://example.com</code></p>
</li>
<li><p><code>http://example.com</code></p>
</li>
<li><p><code>https://example.com:8000</code></p>
</li>
<li><p><code>https://api.example.com</code></p>
</li>
</ul>
<p>At a glance, these might feel like the <em>same</em> site - but from a browser’s perspective these are <strong>four completely different origins.</strong></p>
<p>Here’s why:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>URL</td><td>Scheme</td><td>Hostname</td><td>Port</td><td>Different Origin ?</td></tr>
</thead>
<tbody>
<tr>
<td><code>https://example.com</code></td><td><code>https</code></td><td><code>example.com</code></td><td>443</td><td>—</td></tr>
<tr>
<td><code>http://example.com</code></td><td><code>http</code></td><td><code>example.com</code></td><td>80</td><td>✅ (different scheme)</td></tr>
<tr>
<td><code>https://example.com:8000</code></td><td><code>https</code></td><td><code>example.com</code></td><td>8000</td><td>✅ (different port)</td></tr>
<tr>
<td><code>https://api.example.com</code></td><td><code>https</code></td><td><code>api.example.com</code></td><td>443</td><td>✅ (different hostname)</td></tr>
</tbody>
</table>
</div><p>So even if your frontend is served from <a target="_blank" href="https://example.com"><code>https://example.com</code></a> and your backend is on <a target="_blank" href="https://api.example.com"><code>https://api.example.com</code></a>, that’s a <strong>cross-origin</strong> request—and that’s when CORS rules apply.</p>
<p>Now that we know what CORS is and how does it detect different <em>Origins.</em> let us understand the reason behind it.</p>
<h2 id="heading-why-is-cors-important"><strong>Why is CORS important ?</strong></h2>
<p>Let us try to understand this with a scenario:</p>
<p>Imagine you are the owner of a bank and you have a website at <code>https://bank.com</code>; this website is the login portal for all your customers and allows them to access there account information and details. Now, there is a an evil guy, let’s call him John. John knows that if he can somehow make the user think that his website also let’s the user access the account he will be able to steal all the information.</p>
<p>So he comes up with an evil plan; He creates a website at <code>https://evil.com</code> and this website sends requests to <code>https://bank.com</code> on behalf of the users. Now his website is posing as the bank’s official website because it is getting all the accurate data from <code>https://bank.com</code></p>
<p>As the owner of the bank you want to prevent this. Now if CORS weren’t present you would have to validate that the Origin of the request header matches the one of your site and this validation would have to be setup at each endpoint of your website.</p>
<p>CORS is this validation layer that you just implemented. CORS is important because it allows website owners to specify who and what can access the website / resource.</p>
<h2 id="heading-how-does-it-work">How does it work ?</h2>
<p><strong>CORS</strong> relies on the mechanisms in the browser using which they send “preflight” request to the web server hosting the <strong>cross origin resource,</strong> in order to check if the server will allow the actual request.</p>
<p>In that preflight, the browser sends headers that indicate the HTTP method and headers that will be used in the actual request. This preflight request can be considered a very light weight version of the original request as it contains no payload or data that the original request might transfer.</p>
<p>How does the server tell if they wanna allow a specific request or not ?</p>
<p>Well in response to the CORS preflight request. The server sends a response containing the headers that tell <strong>Who can access, What can be accessed, What methods are allowed, How to send data</strong> etc</p>
<h3 id="heading-rules-for-a-preflight-request">Rules for a preflight request:</h3>
<p>A preflight request is sent when the actual request does not meet the criteria for a <strong><em>“simple request”.</em></strong> A request is considered <strong>simple</strong> if it follows these rules:</p>
<ol>
<li><strong>HTTP Methods:</strong> The request may use only simple HTTP verbs (methods)</li>
</ol>
<ul>
<li><p><code>GET</code></p>
</li>
<li><p><code>POST</code></p>
</li>
<li><p><code>HEAD</code></p>
</li>
</ul>
<ol start="2">
<li><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary/CORS-safelisted_request_header"><strong>CORS-safelisted request headers</strong></a>: The request can only contain certain headers that are a part of the CORS-safelisted headers.</li>
</ol>
<ul>
<li><p><code>Accept</code></p>
</li>
<li><p><code>Accept-Language</code></p>
</li>
<li><p><code>Content-Language</code></p>
</li>
<li><p><code>Content-Type</code></p>
</li>
<li><p><code>Range</code> (only with a single range header value, e.g. <code>bytes=127</code> or <code>bytes = 127-255</code>)</p>
</li>
</ul>
<ol start="3">
<li><strong>Content-Type restrictions</strong>: If the <code>Content-Type</code> header is set, it can only use the following <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary/MIME_type">media types</a>:</li>
</ol>
<ul>
<li><p><code>application/x-www-form-urlencoded</code></p>
</li>
<li><p><code>multipart/form-data</code></p>
</li>
<li><p><code>text/plain</code></p>
</li>
</ul>
<p>If a request follows these conditions, then it is considered a <strong>simple request</strong> and does not trigger a preflight check. If the request includes an non-simple methods or headers (like custom headers), it will trigger a <strong>CORS preflight.</strong></p>
<p>Let’s take a closer look at how the preflight request works in this scenario.</p>
<p>Let’s say we have to fetch some doc from our backend. Our frontend is hosted on <code>foo.site</code> and backend is on <code>bar.site</code>.</p>
<p>Imagine we want to fetch some document from our backend. Our frontend is hosted on <code>foo.site</code> , and the backend is located at <code>bar.site</code>. Here’s what the request might look like:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> request = fetch(<span class="hljs-string">"https://bar.other/doc"</span>, {
  <span class="hljs-attr">method</span>: <span class="hljs-string">"GET"</span>
  <span class="hljs-attr">headers</span>: {
    <span class="hljs-string">"Accept"</span>: <span class="hljs-string">"application/json"</span>,
    <span class="hljs-string">"Authorization"</span>: <span class="hljs-string">"Bearer 12kdlfajlfja"</span>
  }
});

request.then(<span class="hljs-function">(<span class="hljs-params">response</span>) =&gt;</span> {
  <span class="hljs-keyword">if</span> (response.ok) {
    <span class="hljs-keyword">return</span> response.json()
  }
  <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"invalid response"</span>)
})
.then(<span class="hljs-function">(<span class="hljs-params">data</span>) =&gt;</span> {
    <span class="hljs-built_in">console</span>.log(data)
});
</code></pre>
<p>In this code, we are sending an <code>HTTP</code> request from <code>foo.site</code> to fetch the resource <code>/doc</code> from <code>bar.site</code>. Since the frontend is on <code>foo.site</code> and the request is going to <code>bar.site</code> this qualifies as a Cross-Origin Request. Additionally the above request includes an <code>Authorization</code> header which is not a <strong>CORS-safelisted request header</strong>. As a result, a <strong>preflight request</strong> will be sent by the browser to check if the request is allowed.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744830461702/7b05771d-2f90-4010-b796-3e090f4f2505.png" alt class="image--center mx-auto" /></p>
<p>In the above exchange we can see that there is an <code>OPTIONS</code> request that is sent before the actual <code>GET</code> request. This <code>OPTIONS</code> request is the preflight request that is sent by the browser. We can also see that the in response to the <code>OPTIONS</code> request, the server sent some headers:</p>
<ul>
<li><p><code>Access-Control-Allow-Origin</code> - This tells the browser <strong>who can access</strong> ( here <code>*</code> means all)</p>
</li>
<li><p><code>Access-Control-Allow-Methods</code> - This tells the browser <strong>what methods are allowed</strong></p>
</li>
<li><p><code>Access-Control-Allow-Headers</code> - This tells the browser <strong>what headers are allowed</strong></p>
</li>
</ul>
<p>In summary, the preflight <code>OPTIONS</code> request serves as a <strong><em>security</em></strong> measure enforced by the browser to verify that the actual request is safe to send. By examining the server's response headers—such as <code>Access-Control-Allow-Origin</code>, <code>Access-Control-Allow-Methods</code>, and <code>Access-Control-Allow-Headers</code>—the browser ensures that the cross-origin request complies with the server's policies. If the headers meet the browser's requirements, the actual request proceeds; otherwise, it is blocked. This mechanism is a key part of Cross-Origin Resource Sharing (<strong>CORS</strong>) and helps protect both servers and clients from unauthorized access and potential security risks.</p>
<h2 id="heading-tldr">TL;DR</h2>
<p><strong>CORS</strong> might feel a bit mysterious at first, but it’s essentially a browser-enforced security measure that helps protect users from cross-site attacks. The <strong>preflight request</strong> is a key part of that system—it’s the browser’s way of asking the server, <em>“Hey, is it okay if I send this kind of request?”</em></p>
<p>By understanding what triggers a preflight and how the server should respond, you can confidently build cross-origin applications without running into the dreaded <em>“CORS error”</em> wall. Whether you're sending custom headers, using different HTTP methods, or handling third-party APIs, knowing how CORS works behind the scenes will help you troubleshoot faster and design better APIs.</p>
<p>In the end, it’s all about communication—between browser and server—just a polite check-in before doing something a little out of the ordinary.</p>
]]></content:encoded></item><item><title><![CDATA[Sneaking into your documents: How I hacked DigiLocker?]]></title><description><![CDATA[Hello, friend. Ever wonder what it feels like to hold someone’s entire digital identity in your hands? To have the power to become anyone you want? That’s…]]></description><link>https://blogs.codechefvit.com/sneaking-into-your-documents-how-i-hacked-digilocker</link><guid isPermaLink="true">https://blogs.codechefvit.com/sneaking-into-your-documents-how-i-hacked-digilocker</guid><category><![CDATA[bugbounty]]></category><category><![CDATA[bugbountytips]]></category><category><![CDATA[#cybersecurity]]></category><category><![CDATA[penetration testing]]></category><dc:creator><![CDATA[CodeChef-VIT]]></dc:creator><pubDate>Tue, 01 Oct 2024 06:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1729835042463/13d6f547-7fb3-4a1f-9942-c89d2b1dce25.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><img src="https://miro.medium.com/v2/resize:fit:1200/0*imgWteYlHRtHxaJE.jpg" alt class="image--center mx-auto" /></p>
<p>Hello, friend.</p>
<p>Ever wonder what it feels like to hold someone’s entire digital identity in your hands? To have the power to become anyone you want? That’s the rabbit hole I fell into when I decided to poke around DigiLocker.</p>
<p>You see, DigiLocker is supposed to be this fortress of digital documents. Aadhaar cards, PAN cards, mark sheets — all the little pieces that make up a person’s official existence. But here’s the thing about fortresses, they always have a weak spot. You just need to know where to look.</p>
<p>DigiLocker has a multi-factor authentication (MFA) setup to keep your account secure. A 6-digit security PIN, followed by an OTP verification. Sounds impenetrable, right? Well, only if it was implemented correctly.</p>
<blockquote>
<p><strong>“People always make the best exploits. I’ve never found it hard to hack most people. If you listen to them, watch them, their vulnerabilities are like a neon sign.” ~Elliot Alderson</strong></p>
</blockquote>
<p>It started innocently enough. I entered my phone number for the login process, and that’s when I saw it — a POST request revealing all accounts linked to that number, each with a unique <code>digilockerid</code>. I felt it, like a switch flipping in my mind. My Mr. Robot persona, surging to the forefront. Dissociative identity disorder? Maybe. Hacker instinct? Definitely.</p>
<p><img src="https://cdn-images-1.medium.com/max/1600/1*2uTkmZ9bJ42BJ455ZchW2A.png" alt /></p>
<p>This was just the beginning, and I knew we were in for a wild ride. I fired up Burp Suite. I entered my PIN and landed on the OTP verification page. But wait, what’s this? An option to update the mobile number? Interesting.</p>
<p>I clicked it, and — an OTP was sent to the phone number registered with UIDAI, the one linked to my Aadhaar card. I entered the OTP, and I was presented with a screen to enter a new phone number.</p>
<p><img src="https://cdn-images-1.medium.com/max/1600/1*cAz3ikFNYT-J9UJEulAn_A.png" alt /></p>
<p>But the real magic happened when I intercepted this request. There was a parameter called <strong>“user”</strong> which was nothing but the <code>digilockerid</code>.</p>
<p>I swapped my <code>digilockerid</code> with a friend’s (don’t worry, he was in on it). Hit send, and… holy shit! His DigiLocker account was now linked to my phone number. Just like that, I’d picked the lock on someone’s digital safe.</p>
<p><img src="https://cdn-images-1.medium.com/max/1600/1*y3aE5navYmJMfwZEzCjeIw.png" alt /></p>
<p>But the rabbit hole went deeper. I couldn’t log in without his 6-digit PIN. Brute force? Nah, too noisy, even though their IP-based rate limiting was a joke and could’ve been easily bypassed by rotating IPs. Instead, I whispered to DigiLocker, <em>“Hey, I forgot my security PIN. Can you help me out?”</em></p>
<p>The <strong>“Forgot PIN”</strong> process asked for the account, phone number, and date of birth from the linked Aadhaar card. A speed bump, sure, but nothing a little social engineering couldn’t solve. For testing, I used my own account details first.</p>
<p>And there it was again — that same flow we saw earlier. I intercepted the request, did it dirty by swapping in my friend’s <code>digilockerid</code>, and…</p>
<p><img src="https://cdn-images-1.medium.com/max/1600/1*85sr3pVdWAEl81TlqAOWTA.png" alt /></p>
<p>I was in. Full access to someone else’s digital life. Aadhaar card, PAN card, mark sheets, everything. It’s enough to make you want to put on a hoodie and disappear into the night.</p>
<blockquote>
<p><strong>“The world is a dangerous place, Elliot, not because of those who do evil, but because of those who look on and do nothing.” ~Mr. Robot</strong></p>
</blockquote>
<p>Being an intern at DigiLocker back then, I quickly escalated the issue to the concerned team. They resolved it swiftly. Crisis averted.</p>
<p>But before I end this, I want to give credit where it’s due. This was no solo mission. <a target="_blank" href="https://www.linkedin.com/in/meetsuthar04">Meet Suthar</a> was alongside me throughout. Together, we spent sleepless nights discovering this vulnerability and worked to ensure it was patched up. So, a big shoutout to Meet for being an essential part of this wild ride.</p>
<p>Signing off.</p>
]]></content:encoded></item><item><title><![CDATA[Cloud Computing 101: Why it's a Game Changer]]></title><description><![CDATA[But that’s both boring and difficult especially if you belong from a non-technical background, isn’t it? So, should we just abandon the…]]></description><link>https://blogs.codechefvit.com/cloud-computing-101-why-its-a-game-changer</link><guid isPermaLink="true">https://blogs.codechefvit.com/cloud-computing-101-why-its-a-game-changer</guid><category><![CDATA[engineering]]></category><category><![CDATA[Cloud Computing]]></category><category><![CDATA[technology]]></category><dc:creator><![CDATA[CodeChef-VIT]]></dc:creator><pubDate>Tue, 17 Sep 2024 06:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1729835066391/6366c6bf-e81a-45f1-b0b6-6e04551b1fcd.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><img src="https://cdn-images-1.medium.com/max/1600/1*I4GMG0LZKsNsVe9qSNyeTw.png" alt class="image--center mx-auto" /></p>
<p>A typical technical blog in my understanding would be overloaded with a bunch of complicated technical terms which might make you feel like it would almost take a lifetime to understand and relate these terms to real-life applications.</p>
<p>But that’s both boring and difficult especially if you belong from a non-technical background, isn’t it? <em>So, should we just abandon the idea of learning something new?</em> <em>Absolutely not!</em></p>
<p>In fact, this article aims to bridge the gap by connecting complex technical concepts with you daily life, making them easier to understand.</p>
<p>The term <strong>Cloud computing</strong> is familiar to nearly everyone. <em>But the question that arises is that why is it important and whether it would really make a difference if it didn’t exist in the first place?</em> Let’s try to understand this with the help of public transportation. In today’s era, almost everyone owns a car, a bike or a scooter. Imagine if these were never invented and we still had to either walk or use bullock carts to reach to a certain destination like in the old days. It would take us months or even years to reach to our destination, making it an inefficient journey. <em>Similarly, without cloud computing, it would be very difficult for us to scale up our business as we would have to rely more heavily on physical servers and data centers.</em> And just as lacking public transport would limit our ability to carry or send luggage efficiently, the absence of cloud computing would make managing and storing large amounts of data incredibly challenging.</p>
<h3 id="heading-what-is-cloud-computing"><strong>What is Cloud Computing?</strong></h3>
<p><img src="https://cdn-images-1.medium.com/max/1600/1*I9q7WWU5dIQrBr1lqZehOw.png" alt class="image--center mx-auto" /></p>
<p>Cloud computing is the delivery of computing services-including over the internet (<strong>the cloud</strong>). In simpler words, <em>Cloud computing is like renting a computer that you can access through the internet</em>. Instead of buying and maintaining your own hardware, you use these online services to store data, run programs, and manage resources from anywhere with an internet connection.</p>
<h3 id="heading-wont-the-working-process-of-cloud-computing-be-complicated-though"><strong>Won’t the working process of Cloud Computing be complicated though?</strong></h3>
<p><img src="https://cdn-images-1.medium.com/max/1600/1*aAbHeb5YajEV7ZMtTGamxA.png" alt class="image--center mx-auto" /></p>
<p>Using Cloud computing might seem challenging at first, but in reality, it’s actually quite straightforward once you get the hang of it. It has a big role in scaling the IT infrastructure. It works by delivering computing services such as servers, storage, databases, networking and software over the internet.</p>
<p><em>Imagine your home — it’s where you keep all your essentials, right?</em> Your kitchen handles cooking, your closets store your clothes, and you keep your valuables safe. Now, think of data centres and servers as the <strong>home</strong> for your digital life. These are places where powerful computers, known as servers, work together to manage and store all the important data and applications we rely on daily. Just like your home needs a good lock to keep intruders out, data centres use security measures like firewalls and threat protection to keep your data safe from hackers and other threats. <em>After all, you wouldn’t want someone to steal your data and sell it on dark web?</em> No one would want that, right?</p>
<p><em>Now, what exactly is a server?</em> <em>Picture it as a super-smart helper in a mansion.</em> It’s there to serve multiple guests at the same time, making sure everyone gets what they need. It’s always ready to provide information or perform tasks for other computers, which we call clients.</p>
<p>But how do we connect to these servers? That’s where the internet comes in — it’s like the road that leads you to this mansion, allowing you to access all the amazing services and information stored there. <em>Without the internet, it would be like trying to reach a faraway house without any road and so you’d be stuck!</em></p>
<p><em>Next up, let’s talk about cloud computing.</em> Imagine cloud services as different types of helpers or assistants in your mansion. There’s IaaS who takes care of all the infrastructure, so you don’t have to worry about maintaining physical servers. Then there’s PaaS where you can build and test new things. And finally, SaaS, which takes care of everything, offering you software that’s ready to use right away.</p>
<p>Virtualization is like building a skyscraper instead of a bunch of individual houses. Instead of using lots of land for separate homes, you place apartments in one tall building. Similarly, virtualization lets a single physical server host multiple “virtual” servers, saving space and resources.</p>
<p><em>And what about storage?</em> Think of it as different types of closets in your house. Object storage is like a big filing cabinet, block storage is like a bunch of small safes, file storage is your traditional closet with shelves and drawers, and archive storage is the dusty attic where you keep things you rarely need but don’t want to throw away.</p>
<p><em>Lastly, cloud management is like being the smart homeowner who keeps an eye on everything and makes sure that nothing goes wrong.</em> It’s about monitoring your <strong>home</strong> in the cloud to ensure everything runs smoothly, efficiently, and within budget.</p>
<h3 id="heading-is-cloud-computing-worth-the-hype"><strong>Is Cloud Computing worth the hype?</strong></h3>
<p><img src="https://cdn-images-1.medium.com/max/1600/1*gquCu9TCUQXc-0AfVlqGPg.png" alt class="image--center mx-auto" /></p>
<p>Cloud computing has gained a lot of attention in the recent years. Why? Let’s understand this with the help of an example.</p>
<p>Imagine you have a vast collection of photos and important documents stored on your personal devices. Here’s how cloud computing can transform your experience:</p>
<ul>
<li><p>By using cloud storage services like Google Drive, Dropbox, or iCloud, all your photos and documents are stored in one place. You can access them anytime, from any device, as long as you have an internet connection.</p>
</li>
<li><p>Cloud storage offers scalable space. You can easily upgrade your storage plan as your collection grows, eliminating the worry of running out of space.</p>
</li>
<li><p>Cloud computing operates on a ‘pay-as-you-go’ model, offering a cost-effective way. It is often cheaper to pay a subscription fee for cloud access than maintain physical storage. With a reliable cloud partner, you can avoid the need to search for and purchase physical infrastructure.</p>
</li>
<li><p>Cloud services automatically back up your files. Even if something happens to your device, your data remains safe and can be quickly restored.</p>
</li>
<li><p>Sharing files becomes effortless. You can simply share a link to the file or folder, and others can view or collaborate in real-time, no matter where they are.</p>
</li>
</ul>
<p><em>Cloud computing has revolutionized the way businesses operate by offering scalable and flexible solutions that enhance efficiency, security, and innovation.</em> With its ability to provide on-demand access to a wide range of resources and services, cloud computing continues to drive digital transformation across industries, promising a future where organizations can adapt quickly to changing demands and use advanced technologies easily. <em>It uses the internet to store data on remote servers, computing power, and services.</em> Users access advanced computing resources without needing expensive hardware or complex management.</p>
<p>THANK YOU!</p>
]]></content:encoded></item><item><title><![CDATA[The Melting Pot of Diversity]]></title><description><![CDATA[A Management Angle]]></description><link>https://blogs.codechefvit.com/the-melting-pot-of-diversity</link><guid isPermaLink="true">https://blogs.codechefvit.com/the-melting-pot-of-diversity</guid><category><![CDATA[management]]></category><category><![CDATA[Diversity]]></category><category><![CDATA[work]]></category><category><![CDATA[personal development]]></category><category><![CDATA[perspective]]></category><dc:creator><![CDATA[CodeChef-VIT]]></dc:creator><pubDate>Fri, 05 Jul 2024 06:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1729835090306/ddff86a7-8446-49dd-b8b0-7536769d8f04.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h4 id="heading-a-management-angle">A Management Angle</h4>
<p><img src="https://cdn-images-1.medium.com/max/1600/1*HTsNtW-LLEkH3bGsZQ4Eiw.jpeg" alt="Melting Pot of Diversity" class="image--center mx-auto" /></p>
<p>When we think diversity and management, what is the first thing that pops into your mind?<br />You’re probably thinking of people from different religions or races.</p>
<h4 id="heading-what-is-diversity-really">What is Diversity Really?</h4>
<p>Most people think of different races, religions, and genders when it comes to diversity. But, is this the true essence of diversity?<br />Diversity, in a nutshell, means variety. From a management angle, it is the ability of groups to think along various tangents, generate unique ideas efficiently, and get different perspectives on the same thing. There are several misconceptions on diversity, which hamper true diversity, and reduce its benefits.</p>
<p><img src="https://cdn-images-1.medium.com/max/1600/1*9PnCsX2Sv5trI2228h1x6w.png" alt class="image--center mx-auto" /></p>
<p>Diversity should not be treated as a burden, but a blessing. Instead of just fulfilling the diversity quota or trying to meet societal expectations, you should treat diversity as a way to obtain people with distinct approaches to thinking. These people should have the ability to create their own niche in your organization.</p>
<h4 id="heading-management-in-a-true-sense">Management in a true Sense</h4>
<p>When people think of management, people usually think of a rigid structure of command, with an employee having a boss, who in turn has a boss, and so on. This is the autocratic method and is only effective in certain scenarios.</p>
<p>Some bosses include their employees in the decision making process. This is called the participative method of management. When the boss assigns a task to the employee and trusts him/her to get it done in whatever way they wish, this is the delegative method.</p>
<p>The two methods mentioned above have one thing in common- They do not follow a rigid structure of command, but include everyone in the decision making process, to some extent. In the end, the final decision is in the hands of the leader, but these strategies help him/her generate new ideas and get fresh perspectives.</p>
<p><img src="https://cdn-images-1.medium.com/max/1600/0*dmgCOV4b_v3jSNj0.jpeg" alt class="image--center mx-auto" /></p>
<p>Organizations need to figure out what they require, and implement management methods accordingly. Management usually refers to the act of getting things done in the most efficient manner, by planning and successfully implementing ideas. Being good at management usually requires you to inspire your associates or employees to greater heights. This can be done in multiple ways, from leading by example to incentivizing work.</p>
<h4 id="heading-how-diversity-and-management-go-together">How Diversity and Management Go Together</h4>
<p>Now integrating the two concepts together, the essence of diversity in management lies not on the race, religion, economic status, or gender, but on the diversity of the different minds working together. That being said, diversity is usually catalyzed by having different races and genders, because of the difference in their upbringing. The thought process leading to spontaneous generation of ideas, unique solutions, and out of the box methods is what organizations look for.</p>
<p><img src="https://cdn-images-1.medium.com/max/1600/0*XX7WzCL5iEbZ0rUV.jpg" alt class="image--center mx-auto" /></p>
<p>Usually, people with different backgrounds have different approaches to problems. For example, a person from India might produce efficient ideas to work for most people, whereas a person from the United States might produce ideas with the maximum profit in mind. There is a tendency for people from similar backgrounds to think in a similar fashion. When you are able to get people with different mindsets in your organization, you will have achieved a true ‘Melting Pot of Diversity’.</p>
<h4 id="heading-is-diversity-worth-it">Is Diversity Worth It?</h4>
<p>Is diversity always beneficial? <strong>No!</strong> Diversity can lead to negative effects such as:</p>
<ul>
<li><p>Poor communication and reduced teamwork</p>
</li>
<li><p>Resentment amongst individuals or groups</p>
</li>
<li><p>Conflicts</p>
</li>
<li><p>Exclusion of people</p>
</li>
</ul>
<p>However, Diversity can have many benefits:</p>
<ul>
<li><p>Better problem-solving capabilities</p>
</li>
<li><p>Unique, out-of-the box solutions</p>
</li>
<li><p>Different perspectives, leading to innovation</p>
</li>
<li><p>Increase in profits and/or productivity</p>
</li>
</ul>
<p>In most cases, the benefits of diversity outweigh the negative effects and it is usually a good idea to implement diversity.</p>
<h4 id="heading-implementing-diversity">Implementing Diversity</h4>
<p><img src="https://cdn-images-1.medium.com/max/1600/1*1lVQyTzZHhv70-4FO9q9aw.jpeg" alt class="image--center mx-auto" /></p>
<p>As a leader, you need to decide the best for your organization. Diversity in management has a significant effect on any organization. Therefore, it is important for the organization (and by extension its top brass) to recognize its needs and choose the level of diversity required accordingly. You need to weigh all your options carefully and meticulously examine all the pros and cons of diversity, before coming to a decision. You can then, based on requirement, decide the types of people you need.</p>
<p>For example, an organization that requires new ideas and solutions periodically, such as an advertisement company, would benefit tremendously if they have diversity in their ranks. On the contrary, an organization that needs to get specific tasks done, such as ed-tech companies, would be better off having people from similar backgrounds to optimize communication.</p>
<p>It is important to have diversity, but it should be tailored according to the scenario. It falls on you to strike the perfect balance and concoct the perfect recipe to obtain the ‘Melting Pot of Diversity’!</p>
]]></content:encoded></item></channel></rss>