<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Anusha Gundeti on Medium]]></title>
        <description><![CDATA[Stories by Anusha Gundeti on Medium]]></description>
        <link>https://medium.com/@anusha.gundeti2298?source=rss-d03fd3d1e672------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*vrjQ_cG5GShU9JlX</url>
            <title>Stories by Anusha Gundeti on Medium</title>
            <link>https://medium.com/@anusha.gundeti2298?source=rss-d03fd3d1e672------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 05:34:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anusha.gundeti2298/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[BudgetSense AI — Analyser & Advisor]]></title>
            <link>https://medium.com/@anusha.gundeti2298/budgetsense-ai-analyser-advisor-8c6d56333833?source=rss-d03fd3d1e672------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c6d56333833</guid>
            <category><![CDATA[capstone-project]]></category>
            <category><![CDATA[adk]]></category>
            <category><![CDATA[google-adk]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Anusha Gundeti]]></dc:creator>
            <pubDate>Wed, 26 Nov 2025 18:26:01 GMT</pubDate>
            <atom:updated>2025-11-26T18:26:01.586Z</atom:updated>
            <content:encoded><![CDATA[<h3>BudgetSense AI — Analyser &amp; Advisor</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0a-eQ0h1-vT8jDwrcBpSGQ.png" /></figure><h3>BudgetSense AI — How I Built an Automated Financial Advisor Using Gemini ADK Agents</h3><p>Most of us know the feeling:<br> You download your monthly bank statement, open the CSV, and instantly regret your life choices. The headers look different from last month. Some dates are missing. Merchant names are a puzzle. And the categories? Forget it nothing makes sense.</p><p>If you’ve ever tried to analyze your spending manually, you know it’s slow, frustrating, and rarely leads to meaningful financial decisions.</p><p>I wanted to solve that pain point for myself — and build something ambitious enough for my Google Gemini Capstone submission.</p><p>That’s how <strong>BudgetSense AI</strong> idea was born:<br> An <strong>AI-powered financial analyser and advisor</strong> that cleans your messy data, studies your spending patterns, and gives you straightforward, expert-level recommendations.</p><p>And the magic behind it?<br> The <strong>Gemini Agent Development Kit (ADK)</strong> and a clean multi-agent architecture.</p><p>In this post, I’ll walk you through how everything works, the system design, the agents, the tools, and how I tied it all together.</p><h3>Why I Chose This Problem</h3><p>Personal finance is one of those areas where people want clarity but don’t want the mental load. Tracking your money isn’t hard. Interpreting it — and acting on it — is the real challenge.</p><p>I noticed three consistent issues:</p><ol><li><strong>Messy data</strong> — Inconsistent CSV headers, missing entries, different formats</li><li><strong>Generic tools</strong> — Most apps show charts, not insights</li><li><strong>Time and effort</strong> — Cleaning data manually every month isn’t sustainable</li></ol><p>This made it a great Capstone project:<br> interesting problem, clear user value, and perfect for <strong>multi-agent workflows</strong>.</p><h3>Why Agents Are the Right Fit</h3><p>A single prompt-based LLM won’t cut it here.</p><p>Financial analysis involves several competing responsibilities:</p><ul><li>Parsing unpredictable CSV structures</li><li>Cleaning and validating rows</li><li>Saving history to a ledger</li><li>Comparing multiple datasets</li><li>Producing structured financial advice</li></ul><p>Each step requires different reasoning.</p><p>If you load everything into one prompt, the model gets confused or forgets previous steps. That’s why dividing the system into <strong>two specialized agents</strong> works beautifully.</p><h3>1. Ingestion Agent</h3><p>This agent behaves like an ETL pipeline:</p><ul><li>Cleans messy headers</li><li>Maps unknown column names</li><li>Normalizes merchants</li><li>Validates all rows via Pydantic</li><li>Extracts only the first 50 rows from the Kaggle baseline dataset to reduce model load</li><li>Merges Kaggle data + new user uploads</li></ul><h3>2. Planner Agent</h3><p>This one acts like a financial advisor:</p><ul><li>Loads the long-term ledger</li><li>Compares month-over-month spending</li><li>Detects patterns and anomalies</li><li>Generates clear, actionable financial advice</li></ul><p>A <strong>Sequential Orchestrator</strong> ensures the exact flow runs in order:<br> <strong>Extract → Validate → Save → Load → Analyze → Recommend</strong></p><p>That’s what makes it reliably produce the same professional result every time.</p><h3>The Architecture — A Complete Breakdown</h3><p>Here’s the full system, step by step.</p><h3>1. Multi-Agent Pipeline</h3><p>My architecture is built around two Gemini agents:</p><p><strong>Ingestion Agent: </strong>Cleans the raw CSV and ensures everything follows the same schema.</p><p><strong>Planner Agent: </strong>Looks at your spending historically and generates meaningful insights.</p><p>Both are powered by Gemini 2 Flash/Pro and orchestrated through ADK.</p><h3>2. Custom Tools</h3><p>I built three tools to support the agents:</p><h3>extract_transactions_from_csv</h3><p>Handles:</p><ul><li>Header mapping</li><li>Type validation</li><li>Missing or malformed rows</li><li>Sample extraction (first 50 Kaggle rows)</li><li>Combined dataset creation</li></ul><h3>save_to_memory</h3><p>Writes cleaned data into a JSON ledger:</p><ul><li>Consolidates past + new data</li><li>Deduplicates rows</li><li>Maintains chronological order</li></ul><h3>load_history</h3><p>Loads transactions with:</p><ul><li>Date filters</li><li>Category aggregation</li><li>Monthly summaries</li></ul><p>These tools transform the system from “just AI” to a <strong>proper data pipeline</strong>.</p><h3>3. Long-Term Memory Ledger</h3><p>I store everything in budget_data.json.</p><p>This lets the system:</p><ul><li>Grow over time</li><li>Compare spending across months</li><li>Track improvements or regressions</li><li>Generate evolving recommendations</li></ul><p>It’s simple, transparent, and ideal for Capstone evaluation.</p><h3>4. Context Engineering</h3><p>The Planner Agent runs with a carefully controlled system instruction:</p><ul><li>Tone: financial advisor</li><li>Temperature: 0.2 (stable, predictable)</li><li>Structure: fixed outline (summary, trends, category analysis, goals)</li><li>Depth: numbers, percentages, actionable tasks</li></ul><p>This ensures the output always feels professional and consistent.</p><h3>5. UI &amp; User Flow</h3><p>I used <strong>Gradio</strong> to keep things clean:</p><ul><li>Upload Kaggle sample or real CSV</li><li>View ingestion logs</li><li>Trigger analysis</li><li>See the advisor-style report</li><li>View the internal workflow log</li></ul><p>It’s simple, transparent, and perfect for a Capstone demo.</p><h3>How It Actually Works — A Demo Walkthrough</h3><p>Let’s walk through the flow as if a user is interacting with the system.</p><h3>Step 1 — Upload CSV</h3><p>The user uploads messy financial data — maybe rows missing dates or inconsistent merchant names.</p><h3>Step 2 — Ingestion Agent Cleans the Data</h3><p>It maps headers, validates values, and normalizes categories.</p><h3>Step 3 — Data Is Saved into Memory</h3><p>The cleaned data gets merged with the Kaggle baseline + any past user uploads.</p><h3>Step 4 — History Loads</h3><p>The system pulls all saved data from budget_data.json.</p><h3>Step 5 — Planner Agent Generates a Report</h3><p>It analyzes:</p><ul><li>Category totals</li><li>Monthly trends</li><li>Unusual spikes</li><li>Spending inefficiencies</li></ul><p>Then gives actionable insights:</p><ul><li>Reduce dining by 12% next month</li><li>Monitor subscription renewals</li><li>Set a weekly grocery target</li></ul><h3>Step 6 — User Sees a Clear, Professional Output</h3><p>Not charts.<br> Not raw numbers.<br> But real financial advice.</p><p>That’s what makes the project meaningful.</p><h3>Flowchart — Visualizing the Workflow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GE-lj9xt6k1STR6999rhiA.png" /><figcaption>BudgetSense AI — Multi-Agent Workflow</figcaption></figure><h3>What I Learned While Building This</h3><p>This project taught me several important lessons:</p><h3>1. Multi-Agent Systems Are Powerful</h3><p>Splitting responsibilities gives you cleaner output and fewer model errors.</p><h3>2. Tooling Makes Agents Real</h3><p>The custom tools were the backbone of reliability.</p><h3>3. Memory Changes Everything</h3><p>Once the system remembers past uploads, the insights become richer.</p><h3>4. Context Engineering Matters</h3><p>The tone of the planner agent changed the quality of the recommendations dramatically.</p><h3>5. Keeping It Lightweight Helps</h3><p>Using only the first 50 rows from the Kaggle dataset avoided unnecessary model load while still demonstrating capability.</p><h3>Future Enhancements</h3><p>If I continue building this, here’s what I’d like to add:</p><ul><li>Personal profiles (income, goals, savings targets)</li><li>Predictive spending forecasts</li><li>Anomaly detection</li><li>Real-time bank ingestion</li><li>Alerts for overspending</li><li>Visual dashboards and charts</li><li>PDF export for monthly financial summaries</li></ul><p>This could evolve into a powerful, lightweight financial intelligence assistant.</p><h3>Final Thoughts</h3><p>BudgetSense AI is more than a Capstone project for me.<br> It’s a personal finance tool I wish existed in real life: something that takes away the burden of cleaning data and gives me the clarity I actually need.</p><p>Building it with Gemini ADK agents showed me how multi-agent systems can solve real-world problems gracefully, reliably, and intelligently.</p><p>If you’re exploring agents, finance automation, or Gemini’s ADK, I hope this walkthrough gives you a practical perspective — and maybe even inspires your next project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c6d56333833" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Voice TODO AI App: Complete Journey & Deep Notes]]></title>
            <link>https://medium.com/@anusha.gundeti2298/voice-todo-ai-app-complete-journey-deep-notes-879508401614?source=rss-d03fd3d1e672------2</link>
            <guid isPermaLink="false">https://medium.com/p/879508401614</guid>
            <category><![CDATA[voice-ai]]></category>
            <category><![CDATA[open-ai-api]]></category>
            <category><![CDATA[whisper]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[open-router]]></category>
            <dc:creator><![CDATA[Anusha Gundeti]]></dc:creator>
            <pubDate>Mon, 14 Jul 2025 23:02:08 GMT</pubDate>
            <atom:updated>2025-07-14T23:02:08.050Z</atom:updated>
            <content:encoded><![CDATA[<p>A Ruby on Rails application that allows users to <strong>upload or record voice notes</strong>, transcribes them using <strong>local Whisper</strong>, and uses <strong>OpenRouter (LLM)</strong> to extract actionable TODOs.</p><h3>✨ Project Goal</h3><p>Build a Rails app that lets users:</p><ul><li>📥 Upload or 🎤 record audio (mic)</li><li>✏️ Transcribe the audio (via Whisper)</li><li>🧠 Extract TODOs (via OpenRouter API)</li><li>📃 Save/display TODOs per user</li></ul><h3>✨ Initial Setup</h3><p>Command used:</p><pre>rails new voice_todo_ai --css=tailwind --skip-javascript</pre><p><strong>Tech stack:</strong></p><ul><li>Ruby on Rails (backend + views)</li><li>TailwindCSS (for styling)</li><li>PostgreSQL (or SQLite in dev)</li><li>Whisper (local transcription)</li><li>OpenRouter (AI-powered task extraction)</li><li>dotenv (for managing API keys)</li></ul><h3>⚡ Why --skip-javascript?</h3><p>I initially avoided JS setup to keep it simple (no bundlers, no Webpack). But later, mic functionality required JavaScript.</p><h3>❌ Issues Encountered &amp; Fixes Applied</h3><h3>🚫 1. Missing JavaScript Pipeline</h3><ul><li>No app/javascript/application.js created</li><li>No importmap setup</li><li>Couldn’t use JS modules like MediaRecorder</li></ul><p><strong>✅ Fix:</strong></p><ul><li>Added importmap-rails gem manually</li><li>Ran bin/rails importmap:install</li><li>Created application.js and recording.js</li><li>Added proper layout tag: &lt;%= javascript_importmap_tags %&gt;</li></ul><h3>🚫 2. Importmap Skipping Files</h3><pre>Importmap skipped missing path: ./application.js<br>Importmap skipped missing path: ./recording.js</pre><p><strong>Why?</strong></p><ul><li>Files weren’t pinned in config/importmap.rb</li><li>Wrong syntax: used ./recording instead of just recording</li></ul><p><strong>✅ Fix:</strong></p><ul><li>Edited config/importmap.rb:</li></ul><pre>pin &quot;application&quot;<br>pin &quot;recording&quot;</pre><ul><li>Updated application.js:</li></ul><pre>import &quot;recording&quot;;</pre><ul><li>Ran: bin/importmap json &gt; importmap.json</li></ul><h3>🚫 3. Mic Not Recording</h3><ul><li>No browser permission requested</li><li>No JS console logs seen</li><li>Buttons didn’t respond</li></ul><p><strong>✅ Fix:</strong></p><ul><li>Added logs in recording.js</li><li>Verified DOMContentLoaded worked</li><li>Confirmed MediaRecorder and navigator.mediaDevices were available</li><li>Correctly bound Start/Stop button events</li></ul><h3>🚫 4. 404 on /assets/recording</h3><ul><li>Caused by javascript_include_tag &quot;application&quot;, type: &quot;module&quot;</li><li>This tag expects asset-pipeline JS, not importmap</li></ul><p><strong>✅ Fix:</strong></p><ul><li>Removed that tag</li><li>Used only: &lt;%= javascript_importmap_tags %&gt;</li></ul><h3>🚫 5. Upload Form Worked, but Mic Didn’t</h3><ul><li>Upload file button worked fine (ActiveStorage)</li><li>Mic needed extra JS setup</li></ul><p><strong>✅ Fix:</strong></p><ul><li>Generated blob via JS</li><li>Filled hidden file input with new File([blob], &quot;recording.webm&quot;)</li><li>Form submitted just like a file upload</li></ul><h3>✅ Key Features Implemented</h3><h3>✉️ 1. Audio Upload (ActiveStorage)</h3><ul><li>File field in form</li><li>Uploaded .ogg or .mp3 saved and processed</li></ul><h3>🎤 2. Mic Recording (JavaScript)</h3><ul><li>Used MediaRecorder to record voice</li><li>Converted audio to webm</li><li>Attached to form as virtual file</li></ul><h3>🎵 3. Audio Conversion (FFmpeg)</h3><ul><li>OGG/WEBM → WAV via FFmpeg</li><li>Preprocessed before transcription</li></ul><h3>🧠 4. Whisper Transcription (Local)</h3><ul><li>Used Whisper CLI with --language en --model tiny</li><li>Output .txt read by Rails</li></ul><h3>⚖️ 5. OpenRouter Integration</h3><ul><li>Sent transcript as prompt to OpenRouter</li><li>Received structured TODOs</li><li>Saved to DB as Todo models</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=879508401614" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate Daily Gold Price Alerts to WhatsApp Using n8n and Twilio]]></title>
            <link>https://medium.com/@anusha.gundeti2298/automate-daily-gold-price-alerts-to-whatsapp-using-n8n-and-twilio-f9e7646cb066?source=rss-d03fd3d1e672------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9e7646cb066</guid>
            <category><![CDATA[n8n-workflow-automation]]></category>
            <category><![CDATA[daily-gold-update]]></category>
            <category><![CDATA[n8n-workflow]]></category>
            <category><![CDATA[n8n]]></category>
            <dc:creator><![CDATA[Anusha Gundeti]]></dc:creator>
            <pubDate>Fri, 30 May 2025 17:00:02 GMT</pubDate>
            <atom:updated>2025-05-30T17:00:02.567Z</atom:updated>
            <content:encoded><![CDATA[<p>Are you exploring automation and AI with <strong>n8n</strong>? Here’s a complete beginner-friendly guide to building a simple workflow that sends the <strong>daily gold price to your WhatsApp</strong> using <strong>n8n</strong> and <strong>Twilio</strong> — no prior experience needed.</p><blockquote><em>✨ Bonus: Downloadable </em><em>.json file attached at the end so you can import and run this workflow instantly!</em></blockquote><h3>🚀 What You’ll Build</h3><p>A 4-step automation that:</p><ol><li>Triggers daily</li><li>Fetches the latest gold price using an API</li><li>Formats the message</li><li>Sends it to your WhatsApp using Twilio</li></ol><h3>🔍 Step 1: Sign Up for Free Tools</h3><h3>✅ 1. n8n (Workflow Automation Tool)</h3><ul><li>Sign up at <a href="https://cloud.n8n.io/">https://cloud.n8n.io/</a></li><li>Click “New Workflow” to start building your automation</li></ul><h3>✅ 2. Metals.dev (Gold Price API)</h3><ul><li>Sign up at <a href="https://metals.dev/">https://metals.dev/</a></li><li>Get your free API key</li></ul><h3>✅ 3. Twilio (WhatsApp Messaging)</h3><ul><li>Sign up at <a href="https://www.twilio.com/try-twilio">https://www.twilio.com/try-twilio</a></li><li>Go to Twilio WhatsApp Sandbox</li><li>Note your join code (e.g., join believed-rain)</li><li>Send that code from your WhatsApp to +1 415 523 8886</li><li>Copy your <strong>Account SID</strong>, <strong>Auth Token</strong>, and <strong>Sandbox Number</strong></li></ul><h3>💡 Step 2: Build the Workflow in n8n</h3><h3>✅ Node 1: Schedule Trigger</h3><ul><li>Add node: Schedule Trigger</li><li>Mode: Every Day</li><li>Time: Choose when you’d like the message sent</li></ul><h3>✅ Node 2: HTTP Request (Fetch Gold Price)</h3><ul><li>Add node: HTTP Request</li><li>Method: GET</li><li>URL:</li></ul><pre>https://api.metals.dev/v1/latest?base=USD&amp;symbols=gold&amp;api_key=YOUR_API_KEY</pre><ul><li>Response Format: JSON</li></ul><h3>✅ Node 3: Code Node (Format Message)</h3><ul><li>Add node: Code</li><li>Paste this:</li></ul><pre>const goldPrice = $json.metals?.gold || &quot;unavailable&quot;;<br>return [<br>  {<br>    json: {<br>      message: `Today&#39;s Gold Price is ${goldPrice} USD per ounce.`<br>    }<br>  }<br>];</pre><h3>✅ Node 4: Twilio (Send WhatsApp Message)</h3><ul><li>Add node: Twilio</li><li>Resource: Message</li><li>Operation: Send</li><li>From: whatsapp:+14155238886</li><li>To: whatsapp:+YourNumber</li><li>Message: {{$json[&quot;message&quot;]}}</li><li>Add Credentials:</li><li>Account SID and Auth Token from your Twilio Console</li></ul><h3>🛫 Step 3: Connect and Run the Workflow</h3><ul><li>Connect the nodes:</li></ul><pre>Schedule Trigger ➔ HTTP Request ➔ Code Node ➔ Twilio</pre><ul><li>Click “Execute Node” on each step to test</li><li>Once it works, click “Activate” in the top-right corner</li></ul><p>You’ll now get a <strong>WhatsApp message daily with the gold price!</strong></p><h3>🌐 Share the Experience</h3><p>To let others join your sandbox:</p><ul><li>Share this link: <a href="https://wa.me/14155238886?text=join%20believed-rain">https://wa.me/14155238886?text=join%20believed-rain</a></li><li>Or convert it into a QR code for easy scanning</li></ul><p>Here is the workflow reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HZcOgeckdHqEGSEXxdlO1w.png" /><figcaption><strong>n8n Workflow.</strong></figcaption></figure><h3>🙌 Conclusion</h3><p>As a complete beginner, it took me around an hour to explore, understand, and experiment with building this workflow. n8n is beginner-friendly, visual, and incredibly powerful once you get the hang of it.</p><p>I’ve attached the <strong>ready-to-import </strong><strong>.json file</strong> of this workflow below — just upload it into your n8n instance and click “Execute”.</p><p>Whether you’re exploring automation, learning AI integrations, or just testing new tech, this is a fun and useful place to start.</p><p>Happy automating! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9e7646cb066" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CORS in Action: Real-World Scenarios with React and Rails]]></title>
            <link>https://medium.com/@anusha.gundeti2298/cors-in-action-real-world-scenarios-with-react-and-rails-cfb33c93ed9a?source=rss-d03fd3d1e672------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfb33c93ed9a</guid>
            <category><![CDATA[cors]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[cors-error]]></category>
            <category><![CDATA[cross-browser]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[Anusha Gundeti]]></dc:creator>
            <pubDate>Thu, 15 May 2025 03:44:36 GMT</pubDate>
            <atom:updated>2025-05-15T03:44:36.042Z</atom:updated>
            <content:encoded><![CDATA[<h3>Have You Ever Encountered or Tried to Learn About the Dreaded CORS Issue?</h3><p>If you’re building modern web applications with a separate frontend (like React) and backend (like Ruby on Rails), chances are you’ve run into the dreaded CORS (Cross-Origin Resource Sharing) problem. This blog post breaks down what CORS is, when it’s required, and how to handle it across different real-world deployment setups.</p><h3>🤔 Key Questions to Understand CORS</h3><ul><li>When is CORS required?</li><li>Why does the browser block my request?</li><li>Is CORS a server or client-side issue?</li><li>Can I avoid it altogether?</li></ul><h3>🚦 What is CORS?</h3><p>CORS is a browser security feature that restricts cross-origin HTTP requests initiated from scripts. An origin is defined by <strong>protocol + domain + port</strong>.</p><ul><li>http://localhost:3000 is a different origin from <a href="http://localhost:3001/">http://localhost:3001</a></li><li>http://example.com ≠ <a href="https://example.com/">https://example.com</a></li></ul><p>So even small differences count!</p><h3>🧭 Scenario 1: Same-Origin (No CORS Required)</h3><p><strong>Setup</strong>: React frontend is built and served from the same Rails app.</p><ul><li>✅ React is placed in /public or compiled using webpacker/esbuild.</li><li>✅ Rails serves both frontend and API from the same domain and port.</li></ul><p><strong>Result</strong>: Browser sees this as same-origin. No CORS restrictions.</p><pre>rails new myapp --api<br>npx create-react-app frontend<br>npm run build<br>cp -r build/* ../public/</pre><p>📌 No CORS headers or configuration needed.</p><h3>🌍 Scenario 2: Cross-Origin (CORS Required)</h3><p><strong>Setup</strong>: React runs on localhost:3000, Rails API on localhost:3001.</p><p>Browser blocks requests unless CORS is explicitly allowed.</p><p><strong>Rails setup:</strong></p><pre># Gemfile<br>gem &#39;rack-cors&#39;</pre><pre># Gemfile<br>gem &#39;rack-cors&#39;</pre><pre># config/initializers/cors.rb<br>Rails.application.config.middleware.insert_before 0, Rack::Cors do<br>  allow do<br>    origins &#39;<a href="http://localhost:3000&#39;">http://localhost:3000&#39;</a><br>    resource &#39;*&#39;, headers: :any, methods: [:get, :post, :put,    :patch, :delete, :options]<br>  end<br>end</pre><p><strong>React fetch example:</strong></p><pre>fetch(&quot;http://localhost:3001/employees&quot;, {<br>  method: &quot;POST&quot;,<br>  headers: { &quot;Content-Type&quot;: &quot;application/json&quot; },<br>  body: JSON.stringify({ name: &quot;John&quot; })<br>})</pre><h3>🔐 Scenario 3: Cross-Origin With Credentials (Cookies / JWT Auth)</h3><p><strong>Setup</strong>: React uses cookies or headers to pass login credentials.</p><p><strong>Rails CORS config:</strong></p><pre>Rails.application.config.middleware.insert_before 0, Rack::Cors do<br>  allow do<br>    origins &#39;http://localhost:3000&#39;<br>    resource &#39;*&#39;, headers: :any, methods: [:get, :post], credentials: true<br>  end<br>end</pre><p><strong>React fetch:</strong></p><pre>fetch(&quot;http://localhost:3001/login&quot;, {<br>  method: &quot;POST&quot;,<br>  credentials: &quot;include&quot;,<br>  headers: { &quot;Content-Type&quot;: &quot;application/json&quot; },<br>  body: JSON.stringify({ email, password })<br>})</pre><p>❗ You <strong>must not use</strong> origins &#39;*&#39; if you&#39;re using credentials.</p><h3>🔄 Scenario 4: Server-to-Server (CORS Not Required)</h3><p><strong>Setup</strong>: Rails backend talking to external services (like GitHub API).</p><p><strong>Example:</strong></p><pre>response = HTTParty.get(&quot;https://api.github.com/users/octocat&quot;)<br>data = JSON.parse(response.body)</pre><p>✅ This works fine because CORS is a <strong>browser-only</strong> rule. Server-to-server traffic is unrestricted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*hQ5Z2ycR_-edemAL03sBSw.png" /></figure><h3>💡 Answers to Key Questions</h3><p><strong>1. When is CORS required?</strong><br>CORS is required when a browser-based frontend (like React) makes a request to a backend on a different origin (different protocol, domain, or port).</p><p><strong>2. Why does the browser block my request?</strong><br>Because of the Same-Origin Policy. If a script on one origin tries to call another origin, the browser blocks it unless CORS headers allow it.</p><p><strong>3. Is CORS a server or client-side issue?</strong><br>CORS is enforced by the <strong>browser</strong>, but it must be <strong>handled by the server</strong> by sending the appropriate headers.</p><p><strong>4. Can I avoid it altogether?</strong></p><p>YES By,</p><ul><li>Serving frontend and backend from the same origin</li><li>Using a reverse proxy (like Nginx)</li><li>Making server-to-server calls instead of frontend-to-backend when possible</li></ul><h3>📌 Conclusion</h3><p>Understanding CORS is key when working with separated frontend and backend architectures. The setup you choose, same-origin, cross-origin, or reverse proxy — determines how you handle it.</p><p>Still confused or facing issues? Try matching your scenario to one of the patterns above and apply the code accordingly. Let CORS be a solved problem, not a blocker!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfb33c93ed9a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Servers to Serverless: The Story of AWS API Gateway & Lambda in Real-Time Web Apps]]></title>
            <link>https://medium.com/@anusha.gundeti2298/from-servers-to-serverless-the-story-of-aws-api-gateway-lambda-in-real-time-web-apps-3a7db6002738?source=rss-d03fd3d1e672------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a7db6002738</guid>
            <category><![CDATA[aws-gateway]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Anusha Gundeti]]></dc:creator>
            <pubDate>Fri, 18 Apr 2025 00:48:23 GMT</pubDate>
            <atom:updated>2025-04-18T00:48:23.259Z</atom:updated>
            <content:encoded><![CDATA[<h3>Once Upon a Time in the Cloud…</h3><p>There was a time when deploying a web application meant provisioning physical servers. You had to install your OS, manage security patches, and pray the traffic wouldn’t spike beyond your load balancer’s mercy.</p><p>Then came cloud computing — EC2 instances, scalable databases, and auto-scaling groups. Life became easier, but there was still overhead: managing runtimes, idle instances, patching, and figuring out how to expose your logic securely via APIs.</p><p>Enter the heroes of our story: <strong>AWS Lambda</strong> and <strong>AWS API Gateway</strong> — the champions of serverless computing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*5Fbp1NIjE4sVbjN9aX7Lmw.png" /></figure><h3>Chapter 1: The Birth of AWS Lambda</h3><p>Launched in 2014, AWS Lambda was introduced to solve a specific pain: <em>Why should developers worry about servers when they just want to run code?</em></p><p>With Lambda, you could:</p><ul><li>Upload your function code.</li><li>Define triggers (events).</li><li>Let AWS handle the infrastructure.</li></ul><p>It was a revolutionary concept: you pay only for the compute time used, no idle time, and it scales infinitely (well, almost).</p><p>But Lambda had a problem — it needed a <em>gatekeeper</em>, a <em>facilitator</em> to accept requests from the outside world and direct them to the right function. That’s where <strong>API Gateway</strong> enters the story.</p><h3>Chapter 2: The Rise of API Gateway</h3><p>API Gateway, introduced by AWS around the same time, acted like a concierge. It stood at the front door, listened for HTTP(S) requests, validated them, routed them to the correct Lambda function (or other backends), and then handed the response back.</p><p>With API Gateway, you could:</p><ul><li>Define RESTful or WebSocket APIs.</li><li>Add throttling, caching, and authentication.</li><li>Securely expose Lambda functions without writing boilerplate code.</li></ul><p>Together, <strong>Lambda</strong> and <strong>API Gateway</strong> became a match made in cloud heaven.</p><h3>Chapter 3: A Real-Time Web Application is Born</h3><p>Let’s say we’re building a real-time chat application. Here’s how it unfolds:</p><h4>Step 1: The Client Sends a Request</h4><p>A user types a message and hits “Send.” The browser (client) sends a POST request to an <strong>API Gateway endpoint</strong>.</p><h4>Step 2: API Gateway Kicks In</h4><p>API Gateway receives this request. It’s been configured to forward the request to a Lambda function.</p><h4>Step 3: Lambda Executes Business Logic</h4><p>Lambda processes the message: validates it, stores it in a database, and maybe sends out real-time WebSocket notifications to other users.</p><h4>Step 4: API Gateway Returns the Response</h4><p>The processed response is returned through API Gateway back to the client. The user sees “Message sent.”</p><p>This is shown beautifully in the diagram above.</p><h3>Chapter 4: Why Developers Fell in Love</h3><ul><li><strong>Zero infrastructure worries:</strong> No servers to provision.</li><li><strong>Event-driven architecture:</strong> Lambda responds to events — HTTP, S3 uploads, DynamoDB streams, etc.</li><li><strong>Cost-efficient:</strong> You’re billed per millisecond of execution.</li><li><strong>Scalable:</strong> Your backend grows with your traffic, automatically.</li><li><strong>Secured &amp; Monitored:</strong> IAM, throttling, CORS, WAF, logging — all baked in.</li></ul><h3>Chapter 5: How To Set It Up — Step-by-Step</h3><blockquote>1. <strong>Create an API Gateway Endpoint</strong></blockquote><ul><li>Choose your runtime (Node.js, Python, Ruby, etc.).</li><li>Code your business logic.</li><li>Upload it to AWS Lambda.</li></ul><blockquote>2. <strong>Create an API Gateway Endpoint</strong></blockquote><ul><li>Use REST or HTTP API.</li><li>Define resources and methods (like /send-message, POST).</li></ul><blockquote>3. Connect API Gateway to Lambda</blockquote><ul><li>Use the integration wizard or manually link it.</li><li>Add request/response transformations if needed.</li></ul><blockquote>4. Deploy your API</blockquote><ul><li>Create a new stage (dev, prod, etc.).</li><li>Deploy and get your endpoint URL.</li></ul><blockquote>5. Secure it</blockquote><ul><li>Add authentication (JWT, Cognito).</li><li>Enable CORS for web access.</li><li>Set up throttling and monitoring.</li></ul><h3>Chapter 6: Beyond Basics — Real-Time Features</h3><p>Want real-time updates? Use <strong>API Gateway WebSocket APIs</strong> with Lambda:</p><ul><li>Client opens a WebSocket connection.</li><li>Messages are routed to Lambda.</li><li>Lambda broadcasts to all connected clients.</li></ul><p>Perfect for chats, notifications, dashboards.</p><h3>The Epilogue: Serverless is the Future</h3><p>AWS Lambda and API Gateway changed the game. They allow startups to ship faster, enterprises to reduce cost, and developers to focus on what matters — building.</p><p>In real-time web applications, their synergy offers unmatched scalability, minimal latency, and clean architecture.</p><p>So the next time someone says, <em>“We need to build a scalable backend, fast…”</em> — tell them the tale of API Gateway &amp; Lambda. Chances are, that’s the hero they need.</p><h3>Conclusion: The Serverless Symphony</h3><p>In the evolving landscape of web application development, <strong>AWS Lambda</strong> and <strong>API Gateway</strong> have redefined how we think about infrastructure, scalability, and delivery speed. What began as a way to abstract away server management has blossomed into a <strong>powerful serverless paradigm, </strong>empowering developers to build <strong>real-time, scalable, and event-driven applications</strong> with minimal overhead.</p><p>From handling simple HTTP requests to powering full-fledged WebSocket communication, and from enabling seamless CI/CD pipelines to providing secure, throttled, and monitored APIs, this duo stands tall as a cornerstone of <strong>modern cloud-native architectures</strong>.</p><p>Whether you’re a startup sprinting toward your MVP or an enterprise seeking cost-efficiency and agility, API Gateway and Lambda invite you to code less, configure more, and scale endlessly.</p><p><strong>So go ahead — write your code, deploy in minutes, and let the cloud do the rest. The serverless future is here.</strong> 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a7db6002738" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Simple Yet Functional Blog Using Django: A Complete Walkthrough]]></title>
            <link>https://medium.com/@anusha.gundeti2298/creating-a-simple-yet-functional-blog-using-django-a-complete-walkthrough-f28e94301488?source=rss-d03fd3d1e672------2</link>
            <guid isPermaLink="false">https://medium.com/p/f28e94301488</guid>
            <category><![CDATA[django-admin]]></category>
            <category><![CDATA[django-rest-framework]]></category>
            <category><![CDATA[sample-django-application]]></category>
            <category><![CDATA[django]]></category>
            <dc:creator><![CDATA[Anusha Gundeti]]></dc:creator>
            <pubDate>Thu, 10 Apr 2025 06:24:25 GMT</pubDate>
            <atom:updated>2025-04-10T06:24:25.057Z</atom:updated>
            <content:encoded><![CDATA[<p>Django, a high-level Python web framework, enables rapid development of secure and maintainable websites. In this blog, we walk you through creating a basic blog application that showcases Django’s Model-View-Template (MVT) architecture. Whether you’re a beginner or someone looking to brush up on Django fundamentals, this guide is for you.</p><h3>🧩 What This Blog App Is All About</h3><p>This Django blog application is a simple yet functional web-based platform where users can browse and read blog posts. It showcases a clean layout with a homepage that lists all blog posts, and each post links to a detailed view displaying its full content. Posts are created and managed through Django’s admin interface, making content management seamless.</p><h4>Key features include:</h4><ul><li>A homepage displaying all blog posts in reverse chronological order.</li><li>Individual pages for each blog post with detailed content.</li><li>Clean and styled HTML templates for better readability.</li><li>Admin dashboard integration to manage posts.</li></ul><h3>📂 Project Structure Overview</h3><p>Here’s how the project is organized:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*3h5zmbfg1JvpZqqgG4rjPQ.png" /></figure><h3>Explanation</h3><ul><li>blog_project/: Root project configuration directory.</li><li>blog/: Our blog app with models, views, URLs, and templates.</li><li>templates/: Contains all HTML templates.</li><li>manage.py: A utility to manage the Django project.</li></ul><h3>⚙️ Installation &amp; Setup</h3><h3>Step 1: Create and Activate Virtual Environment</h3><pre>python -m venv venv<br>source venv/bin/activate  # Windows: venv\Scripts\activate</pre><h3>Step 2: Install Django</h3><pre>pip install django</pre><h3>Step 3: Start the Project and App</h3><pre>django-admin startproject blog_project .<br>python manage.py startapp blog</pre><h3>Step 4: Add App to Installed Apps</h3><p>In blog_project/settings.py:</p><pre>INSTALLED_APPS = [<br>    ...,<br>    &#39;blog&#39;,<br>]</pre><p>The complete code for this project is available in a Git repository, which I will link at the end of this blog. For now, I’ve listed the filenames corresponding to the respective code snippets shared above.</p><h3>🔄 Models and Admin Integration</h3><p>models.py</p><pre>from django.db import models<br>from django.utils import timezone<br>from django.contrib.auth.models import User<br><br>class Post(models.Model):<br>    title = models.CharField(max_length=200)<br>    content = models.TextField()<br>    date_posted = models.DateTimeField(default=timezone.now)<br>    author = models.ForeignKey(User, on_delete=models.CASCADE)<br><br>    def __str__(self):<br>        return self.title</pre><p>admin.py</p><pre>from django.contrib import admin<br>from .models import Post<br><br>admin.site.register(Post)</pre><h3>👥 Views and URL Routing</h3><p>views.py</p><pre>from django.shortcuts import render, get_object_or_404<br>from .models import Post<br><br>def post_list(request):<br>    posts = Post.objects.all().order_by(&#39;-date_posted&#39;)<br>    return render(request, &#39;blog/post_list.html&#39;, {&#39;posts&#39;: posts})<br><br>def post_detail(request, pk):<br>    post = get_object_or_404(Post, pk=pk)<br>    return render(request, &#39;blog/post_detail.html&#39;, {&#39;post&#39;: post})</pre><p>blog/urls.py</p><pre>from django.urls import path<br>from . import views<br><br>urlpatterns = [<br>    path(&#39;&#39;, views.post_list, name=&#39;post_list&#39;),<br>    path(&#39;post/&lt;int:pk&gt;/&#39;, views.post_detail, name=&#39;post_detail&#39;),<br>]</pre><p>blog_project/urls.py</p><pre>from django.contrib import admin<br>from django.urls import path, include<br><br>urlpatterns = [<br>    path(&#39;admin/&#39;, admin.site.urls),<br>    path(&#39;&#39;, include(&#39;blog.urls&#39;)),<br>]</pre><h3>🌐 Templates and Basic Styling</h3><h3>🚀 Run the Application</h3><h3>Apply Migrations &amp; Create Superuser</h3><pre>python manage.py makemigrations<br>python manage.py migrate<br>python manage.py createsuperuser</pre><h3>Start the Development Server</h3><pre>python manage.py runserver</pre><h4>Visit:</h4><ul><li>Blog: <a href="http://127.0.0.1:8000/">http://127.0.0.1:8000/</a></li><li>Admin: <a href="http://127.0.0.1:8000/admin/">http://127.0.0.1:8000/admin/</a></li></ul><h3>✨ Enhancements Addressed</h3><ol><li><strong>User Authentication</strong>: Let users sign up, log in, and manage their posts.</li><li><strong>CRUD from Frontend</strong>: Add forms to create, edit, and delete posts.</li><li><strong>Comment System</strong>: Allow users to comment on posts.</li><li><strong>Categories/Tags</strong>: Organize posts for easier navigation.</li><li><strong>Pagination</strong>: Limit posts per page for performance.</li></ol><h3>⚙️ Behind the Scenes: Django’s MVT Architecture</h3><ul><li><strong>Model</strong>: Post defines the schema.</li><li><strong>View</strong>: Functions in views.py manage logic and data fetching.</li><li><strong>Template</strong>: HTML files render the output to users.</li><li><strong>URL Dispatcher</strong>: Connects the user’s request to the right view.</li></ul><h3>📁 GitHub Repository</h3><p>You can find the complete source code for this Django blog project here:<br> 👉 <a href="https://github.com/anushagundeti/django_blog_project">https://github.com/anushagundeti/django_blog_project</a></p><h3>🎓 Final Thoughts</h3><p>This blog application is more than just a basic project — it’s a perfect way to get hands-on experience with Django’s core principles. From URL routing to database models and template rendering, you’ve now seen the full power of Django’s modular and scalable design.</p><p>Feel free to build upon this by adding features and refining the UI. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f28e94301488" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Django Framework: A Beginner’s Guide]]></title>
            <link>https://medium.com/@anusha.gundeti2298/django-framework-a-beginners-guide-fd4adc012f3d?source=rss-d03fd3d1e672------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd4adc012f3d</guid>
            <category><![CDATA[django-rest-framework]]></category>
            <dc:creator><![CDATA[Anusha Gundeti]]></dc:creator>
            <pubDate>Tue, 08 Apr 2025 04:58:39 GMT</pubDate>
            <atom:updated>2025-04-08T04:58:39.131Z</atom:updated>
            <content:encoded><![CDATA[<h3>🌟 What is Django?</h3><p>Django is a high-level Python web framework designed for rapid development of secure and maintainable websites. It follows the “batteries-included” philosophy, providing many built-in features (like database, admin panel, user authentication, etc.)so you can focus on building your application rather than reinventing the wheel.</p><h3>Core Features of Django</h3><ul><li><strong>ORM (Object-Relational Mapper)</strong>: Write Python classes instead of SQL to interact with your database</li><li><strong>Admin Interface</strong>: Automatically generated admin panel for content management</li><li><strong>URL Routing</strong>: Map URLs to Python functions (views)</li><li><strong>Template System</strong>: Design HTML pages with simple template language</li><li><strong>Form Handling</strong>: Generate and validate forms easily</li><li><strong>Authentication System</strong>: Handle user accounts, groups, permissions</li><li><strong>Security Features</strong>: Protection against common vulnerabilities (CSRF, SQL injection, XSS)</li></ul><h3>Technologies Django Works With</h3><ul><li><strong>Databases</strong>: PostgreSQL, MySQL, SQLite, Oracle (SQLite comes by default)</li><li><strong>Frontend</strong>: Can integrate with any frontend technology (React, Vue, Angular) or use its own template system</li><li><strong>Deployment</strong>: Can be deployed on any server that supports Python (AWS, Heroku, DigitalOcean, etc.)</li><li><strong>APIs</strong>: Can create RESTful APIs with Django REST Framework</li></ul><h3>When to Use Django</h3><p>Django is ideal for:</p><ul><li>Content-based websites (blogs, news sites)</li><li>CMS systems (content management)</li><li>E-commerce sites</li><li>Social network services</li><li>Internal tools and admin interfaces</li><li>Data-driven websites and dashboards</li><li>API services (especially with Django REST Framework)</li></ul><p>Django’s “batteries-included” approach makes it perfect for beginners who want a complete solution but can also scale to handle large enterprise applications with millions of users.</p><h3>Below is the Django framework architecture for better clarity and understanding.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*K0KQOPhlCDkKemvnaqEgrQ.png" /></figure><p>Explanation of the Django Architecture Diagram</p><p>The diagram shows the core components of Django and how they interact:</p><h3>Key Components</h3><ol><li><strong>URLs (urls.py)</strong> — The entry point for HTTP requests. URLs patterns are defined here to route requests to specific views.</li><li><strong>Views (views.py)</strong> — The processing center that handles requests, interacts with models to get data, and returns responses (often by rendering templates).</li><li><strong>Models (models.py)</strong> — Python classes that define your database schema and provide an ORM layer to interact with your database.</li><li><strong>Templates (.html)</strong> — HTML files with Django template language that define how pages look. Views render these templates with context data.</li><li><strong>Forms (forms.py)</strong> — Handle input validation and processing user submitted data.</li><li><strong>Admin Interface</strong> — Auto-generated administration panel for managing content based on your models.</li><li><strong>Database</strong> — Where your data is stored. Django’s ORM abstracts the database operations.</li><li><strong>Static Files</strong> — CSS, JavaScript, and images that are served as-is.</li><li><strong>Middleware</strong> — Components that process requests and responses globally.</li></ol><h3>Request Flow</h3><ol><li>A user sends a request from their browser to your Django application</li><li>URLs route the request to the appropriate view function</li><li>The view processes the request, interacting with models if data is needed</li><li>Models communicate with the database through Django’s ORM</li><li>The view renders a template with the data</li><li>Django sends the rendered HTML back to the client browser</li></ol><p>This <strong>MVT (Model-View-Template)</strong> pattern is Django’s adaptation of the traditional MVC pattern, where:</p><ul><li>Models handle data structure and database operations</li><li>Views contain the business logic</li><li>Templates define the presentation layer</li></ul><p>This architecture makes Django both powerful and beginner-friendly by enforcing a clean separation of concerns while providing all the components you need to build a full web application.</p><p>👉 If you’re a Python enthusiast or a backend dev exploring modern stacks, Django is a must-try!</p><p>More detailed insights into Django usage coming soon — stay tuned!</p><p>Happy Coding!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd4adc012f3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Packages in a Spring Boot Application: Mapper, DTO, Controller, Repository, Service…]]></title>
            <link>https://medium.com/@anusha.gundeti2298/understanding-packages-in-a-spring-boot-application-mapper-dto-controller-repository-service-3668285fe09b?source=rss-d03fd3d1e672------2</link>
            <guid isPermaLink="false">https://medium.com/p/3668285fe09b</guid>
            <dc:creator><![CDATA[Anusha Gundeti]]></dc:creator>
            <pubDate>Sun, 30 Mar 2025 01:54:03 GMT</pubDate>
            <atom:updated>2025-03-30T01:54:03.010Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Packages in a Spring Boot Application: Mapper, DTO, Controller, Repository, Service and Entity</h3><h3>Introduction</h3><p>In modern software development, <strong>Spring Boot</strong> applications follow a layered architecture to ensure <strong>clean code, scalability, and maintainability</strong>. In this blog post, we will explore the key components of a Spring Boot project, including <strong>Mapper, DTO, Controller, Repository, and Entity</strong>, and how they work together.</p><h3>Why Use a Layered Architecture?</h3><p>A layered approach helps in <strong>separating concerns</strong>, making the code easier to debug, maintain, and scale. Each layer has a <strong>specific responsibility</strong>, ensuring a <strong>structured and modular approach</strong> to application development.</p><h3>Breakdown of Key Components</h3><h3>1. Entity (Model Layer)</h3><p>An <strong>Entity</strong> represents a <strong>database table</strong> in Java using <strong>JPA (Java Persistence API)</strong>. It defines the structure of the data we store.</p><pre>@Entity<br>@Table(name = &quot;users&quot;)<br>public class UserEntity {<br>    @Id<br>    @GeneratedValue(strategy = GenerationType.IDENTITY)<br>    private Long id;<br>    private String name;<br>    private String email;<br>}</pre><h3>2. Repository (Data Access Layer)</h3><p>A <strong>Repository</strong> interacts with the database, using <strong>Spring Data JPA</strong> to perform CRUD operations.</p><pre>@Repository<br>public interface UserRepository extends JpaRepository&lt;UserEntity, Long&gt; {<br>    Optional&lt;UserEntity&gt; findByEmail(String email);<br>}</pre><h3>3. DTO (Data Transfer Object)</h3><p>A <strong>DTO</strong> is a simple Java class used for <strong>transferring data</strong> between layers while keeping the database model private.</p><pre>public class UserDTO {<br>    private String name;<br>    private String email;<br>}</pre><h3>4. Mapper (Converting Between Entity &amp; DTO)</h3><p>A <strong>Mapper</strong> is responsible for converting between <strong>Entity and DTO</strong> objects to maintain a clean architecture.</p><pre>@Component<br>public class UserMapper {<br>    public UserDTO toDTO(UserEntity user) {<br>        UserDTO dto = new UserDTO();<br>        dto.setName(user.getName());<br>        dto.setEmail(user.getEmail());<br>        return dto;<br>    }<br><br>    public UserEntity toEntity(UserDTO dto) {<br>        UserEntity user = new UserEntity();<br>        user.setName(dto.getName());<br>        user.setEmail(dto.getEmail());<br>        return user;<br>    }<br>}</pre><h3>5. Service Layer (Business Logic Layer)</h3><p>The <strong>Service Layer</strong> contains business logic and calls the <strong>Repository</strong> for data manipulation.</p><pre>@Service<br>public class UserService {<br>    private final UserRepository userRepository;<br>    private final UserMapper userMapper;<br><br>    public UserService(UserRepository userRepository, UserMapper userMapper) {<br>        this.userRepository = userRepository;<br>        this.userMapper = userMapper;<br>    }<br><br>    public UserDTO getUserById(Long id) {<br>        UserEntity user = userRepository.findById(id)<br>                .orElseThrow(() -&gt; new RuntimeException(&quot;User not found&quot;));<br>        return userMapper.toDTO(user);<br>    }<br><br>    public void saveUser(UserDTO userDTO) {<br>        UserEntity userEntity = userMapper.toEntity(userDTO);<br>        userRepository.save(userEntity);<br>    }<br>}</pre><h3>6. Controller (API Layer)</h3><p>A <strong>Controller</strong> handles HTTP requests, calls the <strong>Service Layer</strong>, and returns responses.</p><pre>@RestController<br>@RequestMapping(&quot;/users&quot;)<br>public class UserController {<br>    private final UserService userService;<br><br>    public UserController(UserService userService) {<br>        this.userService = userService;<br>    }<br><br>    @GetMapping(&quot;/{id}&quot;)<br>    public ResponseEntity&lt;UserDTO&gt; getUser(@PathVariable Long id) {<br>        return ResponseEntity.ok(userService.getUserById(id));<br>    }<br><br>    @PostMapping<br>    public ResponseEntity&lt;String&gt; createUser(@RequestBody UserDTO userDTO) {<br>        userService.saveUser(userDTO);<br>        return ResponseEntity.status(HttpStatus.CREATED).body(&quot;User created&quot;);<br>    }<br>}</pre><h3>How These Layers Work Together?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x1AvMYQyqh9NzK4NCp0nOg.png" /></figure><h3>Request Flow</h3><ol><li><strong>User makes a request</strong> to the API (/users/{id}).</li><li>The <strong>Controller</strong> handles the request and calls the <strong>Service Layer</strong>.</li><li>The <strong>Service Layer</strong> fetches data using the <strong>Repository</strong>.</li><li>The <strong>Mapper</strong> converts the <strong>Entity</strong> into a <strong>DTO</strong>.</li><li>The <strong>Controller</strong> sends back the <strong>DTO as a JSON response</strong>.</li></ol><h3>Real-World Example</h3><p>Consider a <strong>User Registration System</strong> where:</p><ul><li>The <strong>Controller</strong> manages HTTP requests (/users).</li><li>The <strong>Service</strong> handles business logic like checking if a user exists.</li><li>The <strong>Repository</strong> communicates with the database.</li><li>The <strong>Entity</strong> represents a users table.</li><li>The <strong>DTO</strong> ensures only required fields are returned.</li><li>The <strong>Mapper</strong> converts <strong>Entity ↔ DTO</strong>.</li></ul><h3>Conclusion</h3><p>Using a <strong>layered architecture</strong> in a Spring Boot application helps in writing <strong>clean, maintainable, and scalable code</strong>. By using <strong>Entities, Repositories, DTOs, Mappers, Services, and Controllers</strong>, we can <strong>decouple concerns and improve modularity</strong>.</p><p>If you’re building a Spring Boot application, consider using this architecture to make your development process efficient and structured!</p><h3>Happy Coding! 🚀</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3668285fe09b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crafting a Real-Time AI Chat Application: A Deep Dive into Ruby on Rails, Hotwire, and Stimulus]]></title>
            <link>https://medium.com/@anusha.gundeti2298/crafting-a-real-time-ai-chat-application-a-deep-dive-into-ruby-on-rails-hotwire-and-stimulus-ee4d3539bbc6?source=rss-d03fd3d1e672------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee4d3539bbc6</guid>
            <dc:creator><![CDATA[Anusha Gundeti]]></dc:creator>
            <pubDate>Wed, 26 Mar 2025 05:27:50 GMT</pubDate>
            <atom:updated>2025-03-26T05:27:50.783Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In the ever-evolving landscape of web development, creating interactive, real-time applications has become increasingly important. This blog post will walk you through my journey of building an AI-powered chat window overview using Ruby on Rails, with a focus on Hotwire and Stimulus for creating a dynamic, responsive user experience.</p><h3>Project Repository</h3><p>🔗 <strong>GitHub Repository</strong>: <a href="https://github.com/yourusername/rails-ai-chat-app">https://github.com/yourusername/rails-ai-chat-app</a></p><h3>A Sample Screenshot of the final output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Boq_R9OOMAvXzhGuh1x_Rw.png" /></figure><h4>For the API key please signup and generate a new API key/Access Token from here:</h4><h4><a href="https://platform.openai.com/api-keys">https://platform.openai.com/api-keys</a></h4><h3>Why Hotwire and Stimulus?</h3><h3>The Problem with Traditional JavaScript Frameworks</h3><p>Before diving into the solution, let’s understand the challenges:</p><ul><li>Complex JavaScript frameworks can be heavyweight</li><li>Excessive client-side rendering impacts performance</li><li>Maintaining state across multiple components is challenging</li></ul><h3>Enter Hotwire: A Modern Approach</h3><p>Hotwire (HTML Over The Wire) offers a revolutionary approach to building web applications:</p><ul><li>Minimal JavaScript required</li><li>Server-driven updates</li><li>Better performance and simplicity</li></ul><h4>Key Hotwire Components:</h4><ol><li><strong>Turbo Drive</strong>: Accelerates page loads</li><li><strong>Turbo Frames</strong>: Partial page updates</li><li><strong>Turbo Streams</strong>: Real-time content modifications</li></ol><h3>Stimulus: Lightweight JavaScript Interaction</h3><p>Stimulus provides just enough JavaScript to add interactivity:</p><ul><li>Minimal overhead</li><li>Directly connects HTML with behavior</li><li>Easy to understand and maintain</li></ul><h3>Implementation Details</h3><h3>1. Project Setup</h3><pre>rails new llm_chat_app<br>cd llm_chat_app</pre><pre># Add essential gems<br>bundle add ruby-openai hotwire-rails stimulus-rails</pre><h3>2. Hotwire Integration</h3><pre># app/controllers/chats_controller.rb<br>class ChatsController &lt; ApplicationController<br>  def create<br>    @chat = Chat.new(chat_params)<br>    <br>    respond_to do |format|<br>      if @chat.save<br>        # Turbo Stream: Update chat messages in real-time<br>        format.turbo_stream do<br>          render turbo_stream: [<br>            turbo_stream.append(&#39;chat_messages&#39;, partial: &#39;chats/chat_message&#39;, locals: { chat: @chat }),<br>            turbo_stream.update(&#39;new_chat_form&#39;, partial: &#39;chats/form&#39;)<br>          ]<br>        end<br>      end<br>    end<br>  end<br>end</pre><h3>3. Stimulus Controller for Enhanced Interaction</h3><pre>// app/javascript/controllers/chat_controller.js<br>import { Controller } from &quot;@hotwired/stimulus&quot;<br>export default class extends Controller {<br>  static targets = [ &#39;input&#39;, &#39;messages&#39; ]<br>  connect() {<br>    this.scrollToBottom()<br>  }<br>  resetForm(event) {<br>    // Clear input and scroll to latest message<br>    this.inputTarget.value = &#39;&#39;<br>    this.scrollToBottom()<br>  }<br>  scrollToBottom() {<br>    const messagesContainer = this.messagesTarget<br>    messagesContainer.scrollTop = messagesContainer.scrollHeight<br>  }<br>}</pre><h3>4. View Implementation with Turbo Frames</h3><pre>&lt;%# app/views/chats/index.html.erb %&gt;<br>&lt;div class=&quot;chat-container&quot; data-controller=&quot;chat&quot;&gt;<br>  &lt;div <br>    class=&quot;messages&quot; <br>    data-chat-target=&quot;messages&quot;<br>  &gt;<br>    &lt;%= render @chats %&gt;<br>  &lt;/div&gt;<br>  &lt;%= turbo_frame_tag &quot;new_chat_form&quot; do %&gt;<br>    &lt;%= render &#39;form&#39; %&gt;<br>  &lt;% end %&gt;<br>&lt;/div&gt;</pre><h3>Key Benefits Demonstrated</h3><h3>1. Real-Time Updates</h3><ul><li>Instant message rendering</li><li>No page reloads</li><li>Smooth user experience</li></ul><h3>2. Minimal JavaScript</h3><ul><li>Stimulus controller with &lt; 20 lines of code</li><li>Server-driven updates</li><li>Reduced client-side complexity</li></ul><h3>3. Performance Optimization</h3><ul><li>Partial page updates</li><li>Reduced network overhead</li><li>Faster perceived loading times</li></ul><h3>Challenges</h3><p>API Rate Limiting<br>Deployment Considerations<br>Environment variable management<br>OpenAI API key security<br>Scalability planning</p><h3>Conclusion</h3><p>This project showcases the power of modern Rails techniques:</p><ul><li>Hotwire for real-time interactions</li><li>Stimulus for lightweight JavaScript</li><li>OpenAI integration</li><li>Robust error handling</li></ul><h3>Next Steps</h3><ul><li>Add user authentication</li><li>Implement conversation threads</li><li>Enhanced AI model selection</li></ul><h3>Tech Stack</h3><ul><li>Ruby on Rails 8.0.2</li><li>Hotwire</li><li>Stimulus</li><li>OpenAI API</li><li>Postgres database(Development)</li></ul><h3>Learning Resources</h3><ul><li><a href="https://hotwired.dev/">Hotwire Documentation</a></li><li><a href="https://stimulus.hotwired.dev/">Stimulus Handbook</a></li><li><a href="https://github.com/alexrudall/ruby-openai">Ruby-OpenAI Gem</a></li></ul><p>The most exciting technologies are those that make the complex seem simple. The Ruby OpenAI gem does exactly that — transforming advanced AI capabilities into elegant, approachable code.</p><p><em>Your journey with AI and Ruby is just beginning.</em></p><p>🚀 <strong>Keep coding, keep exploring, keep innovating.</strong></p><h3>Connect with Me At</h3><ul><li>LinkedIn: <a href="https://www.linkedin.com/in/a-gun2298/">https://www.linkedin.com/in/a-gun2298/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee4d3539bbc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing a Persist-Then-Submit Mechanism in Rails: A Scalable Approach for Draft Data Handling]]></title>
            <link>https://medium.com/@anusha.gundeti2298/implementing-a-persist-then-submit-mechanism-in-rails-a-scalable-approach-for-draft-data-handling-7c6ca64c0d28?source=rss-d03fd3d1e672------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c6ca64c0d28</guid>
            <category><![CDATA[papertrail]]></category>
            <category><![CDATA[validation]]></category>
            <category><![CDATA[ruby-on-rai]]></category>
            <category><![CDATA[submit]]></category>
            <category><![CDATA[persistence]]></category>
            <dc:creator><![CDATA[Anusha Gundeti]]></dc:creator>
            <pubDate>Mon, 03 Mar 2025 23:02:10 GMT</pubDate>
            <atom:updated>2025-03-03T23:02:10.501Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Handling complex forms and workflows in web applications often requires a mechanism for users to temporarily save data before permanently committing it to the database. This is particularly useful in scenarios where users need to save progress incrementally, ensuring that incomplete data does not affect production tables.</p><p>In one of my projects, I encountered this challenge and implemented a <strong>persist-then-submit</strong> approach to efficiently manage draft data. In this post, I’ll walk through the problem, why existing solutions didn’t work, and how I designed a custom solution to achieve a flexible and scalable draft management system.</p><h3>The Problem: Why a Draft Mechanism Was Needed</h3><p>The requirement was to allow users to fill out forms progressively without committing incomplete data to the actual database. This was essential for workflows involving multi-step forms, contract approvals, or any scenario where users needed to save drafts before submission.</p><p>A robust solution needed to:</p><ul><li>Allow temporary persistence of incomplete data.</li><li>Validate data at different stages before final submission.</li><li>Ensure that production tables remained clean and unaffected by partially entered records.</li></ul><h3>Why Existing Solutions Didn’t Work</h3><p>I explored various existing approaches, but none fully met our requirements:</p><h4><strong>Versioning Gems (PaperTrail, Audited)</strong></h4><ul><li>Good for tracking historical changes but inefficient for temporary draft storage.</li><li>More suited for auditing rather than managing user-entered drafts.</li></ul><h4>Staging Tables</h4><ul><li>Effective for ETL processes but required additional management to prevent table bloat.</li><li>Increased database overhead due to duplicate schema maintenance.</li></ul><h4><strong>Redis</strong></h4><ul><li>Excellent for fast, in-memory storage but not ideal for relational data requiring structured validation.</li><li>Risk of data loss unless persistence is explicitly configured.</li></ul><h4><strong>File-Based Draft Storage (JSON/YAML)</strong></h4><ul><li>Simple but becomes unmanageable for large-scale applications.</li><li>Lacks relational capabilities needed for complex form workflows.</li></ul><p>Since none of these approaches fully addressed the challenge, I decided to build a custom <strong>persist-then-submit</strong> mechanism.</p><h3>The Custom Solution: Using Dummy Tables for Drafts</h3><p>To manage draft data efficiently, I designed a system where user inputs were first stored in <strong>dummy tables</strong> before being moved to the actual database. There are 2 buttons maintained save and submit, on hitting save data is persisted and on hitting submit, data is saved to the production data tables</p><h3>How It Works:</h3><h4><strong>Creating Dummy Tables</strong></h4><ul><li>I created shadow tables mirroring the actual database tables (users, employees, etc.).</li><li>These dummy tables stored user-entered data in <strong>JSON format</strong>, allowing flexibility in handling drafts.</li></ul><h4><strong>Persisting Draft Data</strong></h4><ul><li>As users entered data, it was first stored in these dummy tables.</li><li>The data remained in draft mode until explicitly submitted.</li></ul><h4><strong>Final Submission to Production Tables</strong></h4><ul><li>Once users completed the form, the data was validated and transferred from the dummy tables to the actual tables.</li><li>This ensured that only <strong>complete and verified</strong> data entered the main system.</li></ul><h3>Key Technologies and Optimizations</h3><p>To make the solution robust, I incorporated:</p><ul><li><strong>JSON Storage:</strong> Enabled flexible draft management without rigid schema constraints.</li><li><strong>Validation Mechanisms:</strong> Ensured that only valid data moved to production.</li><li><strong>Optimized Queries:</strong> Indexed dummy tables for faster reads/writes.</li><li><strong>Automated Cleanup:</strong> Periodically removed stale or unsubmitted drafts to prevent table bloat.</li></ul><h3>Challenges and How I Overcame Them</h3><h4>1. Data Synchronization</h4><ul><li><strong>Challenge:</strong> Ensuring consistency between dummy and production tables.</li><li><strong>Solution:</strong> Used <strong>transactions</strong> to transfer data atomically, preventing partial updates.</li></ul><h4>2. Performance Bottlenecks</h4><ul><li><strong>Challenge:</strong> Managing large datasets without slowing down queries.</li><li><strong>Solution:</strong> Optimized indexing and periodically cleaned up unsubmitted drafts.</li></ul><h4>3. Data Integrity Issues</h4><ul><li><strong>Challenge:</strong> Preventing corruption or loss of draft data.</li><li><strong>Solution:</strong> Used <strong>database constraints</strong> and triggers to enforce integrity rules.</li></ul><h4>4. Scalability Concerns</h4><ul><li><strong>Challenge:</strong> Maintaining multiple dummy tables as the application scaled.</li><li><strong>Solution:</strong> Implemented a <strong>centralized staging table</strong> with metadata tags to distinguish drafts by user and workflow.</li></ul><h4>5. Maintenance Overhead</h4><ul><li><strong>Challenge:</strong> Keeping dummy tables in sync with schema changes.</li><li><strong>Solution:</strong> Automated schema replication using Rails migrations.</li></ul><h3>Key Benefits of This Approach</h3><p>This <strong>persist-then-submit</strong> method provided several advantages:</p><p>✅ Users could save drafts without affecting production tables.<br>✅ Data corruption risks were minimized with controlled validation.<br>✅ JSON-based storage allowed flexibility in handling complex forms.<br>✅ The approach was optimized for performance and scalability.</p><h3>Final Thoughts</h3><p>Building a <strong>persist-then-submit</strong> system in Rails required balancing flexibility, performance, and data integrity. While existing solutions had their own trade-offs, this custom approach provided an efficient way to manage draft data while ensuring a smooth user experience.</p><p>If you’re dealing with similar challenges, consider implementing a <strong>dummy table mechanism</strong> with JSON storage and optimized database transactions. It’s a scalable way to handle draft data while keeping your production environment clean.</p><p>💬 <strong>Have you worked on similar challenges? Let’s discuss in the comments!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c6ca64c0d28" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>