<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hitesh Kumar Sahoo</title>
    <description>The latest articles on DEV Community by Hitesh Kumar Sahoo (@repausecodes).</description>
    <link>https://dev.to/repausecodes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3910455%2F4b9843ae-8100-419f-a318-8a7af689969f.jpg</url>
      <title>DEV Community: Hitesh Kumar Sahoo</title>
      <link>https://dev.to/repausecodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/repausecodes"/>
    <language>en</language>
    <item>
      <title>Building an AI-Powered Voter Education Assistant with Vanilla JS &amp; Gemini</title>
      <dc:creator>Hitesh Kumar Sahoo</dc:creator>
      <pubDate>Sun, 03 May 2026 15:12:06 +0000</pubDate>
      <link>https://dev.to/repausecodes/building-an-ai-powered-voter-education-assistant-with-vanilla-js-gemini-21c6</link>
      <guid>https://dev.to/repausecodes/building-an-ai-powered-voter-education-assistant-with-vanilla-js-gemini-21c6</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fso5s4edztde4vy1vy8pm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fso5s4edztde4vy1vy8pm.png" alt=" " width="800" height="677"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Vision
&lt;/h2&gt;

&lt;p&gt;Civic technology is at its best when it removes barriers to information.&lt;br&gt;
I set out to solve a very specific problem: How can we make the often confusing electoral process—from registration to results—accessible and interactive for the average citizen?&lt;/p&gt;

&lt;p&gt;The result is the &lt;strong&gt;Voter Education Assistant&lt;/strong&gt;, a Single Page Application (SPA) that acts as an interactive timeline and AI-powered guide for voters.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Architecture: Why I Avoided a Framework
&lt;/h2&gt;

&lt;p&gt;In modern web development, it's tempting to reach for React, Next.js, or Vue immediately. However, for an educational guide designed to be lightweight, universally accessible, and blazing fast, I opted for a purely modular Vanilla JavaScript approach.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. The Core Stack
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;HTML/CSS:&lt;/strong&gt; Semantic structure with custom CSS (avoiding heavy libraries).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;JavaScript:&lt;/strong&gt; Native ES6 modules (&lt;code&gt;app.js&lt;/code&gt;, &lt;code&gt;bot.js&lt;/code&gt;, &lt;code&gt;firebase-config.js&lt;/code&gt;) to keep the global scope clean and logic separated.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Database:&lt;/strong&gt; Google Firebase Firestore for tracking user progress securely.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;AI Engine:&lt;/strong&gt; Google Gemini 1.5 Flash via native REST API calls.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Bypassing SDK Limitations with Native &lt;code&gt;fetch()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;One of the most interesting challenges during this build was integrating the Gemini AI. Initially, I used the &lt;code&gt;@google/generative-ai&lt;/code&gt; SDK. However, due to browser caching issues and module resolution conflicts in a strict non-bundler environment, the SDK occasionally triggered silent 404 and 400 errors.&lt;/p&gt;

&lt;p&gt;To guarantee 100% uptime and bypass these limitations, I completely decoupled the AI from the SDK and built a native REST wrapper.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// A simplified look at the native fetch implementation bypassing the SDK&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;API_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;API_KEY&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;API_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;contents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;newHistory&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This simple pivot immediately resolved all environment conflicts and made the chatbot wildly responsive.&lt;/p&gt;

&lt;h2&gt;
  
  
  Security and Cloud Run Deployment
&lt;/h2&gt;

&lt;p&gt;Because this application handles civic data, security could not be an afterthought. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;XSS Protection:&lt;/strong&gt; Strict Content Security Policies (CSP) were defined, and DOM manipulation strictly utilizes &lt;code&gt;.textContent&lt;/code&gt; rather than &lt;code&gt;.innerHTML&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Containerization:&lt;/strong&gt; The app is containerized using a lightweight Nginx Alpine Docker image.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Serverless Hosting:&lt;/strong&gt; It is deployed to &lt;strong&gt;Google Cloud Run&lt;/strong&gt;, ensuring it can scale from 10 users to 10,000 instantly without managing infrastructure.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Building the Voter Education Assistant was a masterclass in building clean, dependency-free web applications that leverage state-of-the-art AI. By combining the speed of native JavaScript with the reasoning capabilities of Gemini, we can create tools that genuinely empower citizens.&lt;/p&gt;

&lt;p&gt;You can check out the full source code on my GitHub repository here: &lt;a href="https://github.com/hitesh-kumar-sahoo/Voter-Education-Assistant" rel="noopener noreferrer"&gt;Voter Education Assistant on GitHub&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>googlecloud</category>
      <category>ai</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
