<?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 Ankit Maurya on Medium]]></title>
        <description><![CDATA[Stories by Ankit Maurya on Medium]]></description>
        <link>https://medium.com/@ankitmaurya1994?source=rss-f51a4359f8d4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1ZzscnH07SWHY35Cp4zg8w.png</url>
            <title>Stories by Ankit Maurya on Medium</title>
            <link>https://medium.com/@ankitmaurya1994?source=rss-f51a4359f8d4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 21:57:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ankitmaurya1994/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[Escaping the Backend Comfort Zone | TypeForge]]></title>
            <link>https://medium.com/@ankitmaurya1994/escaping-the-backend-comfort-zone-typeforge-cfdd71690edb?source=rss-f51a4359f8d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfdd71690edb</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[gemini]]></category>
            <dc:creator><![CDATA[Ankit Maurya]]></dc:creator>
            <pubDate>Sat, 16 May 2026 13:39:08 GMT</pubDate>
            <atom:updated>2026-05-16T13:40:02.475Z</atom:updated>
            <content:encoded><![CDATA[<h3>How I Built TypeForge Using Next.js and the Gemini API</h3><p>As a backend-heavy engineer, I’ve spent years comfortable in the shadows of databases, API design, and system architecture. The frontend always felt like a chaotic wild west of CSS alignment, shifting state, and fast-moving frameworks. But growth happens at the ragged edge of your comfort zone.</p><p>Recently, I decided to cross the aisle. I set a strict constraint for myself: build a fully functional, highly responsive, AI-powered application while staying almost entirely within the frontend ecosystem.</p><p>The result? <strong>TypeForge</strong> — a minimalist typing application that blends the aesthetic of MonkeyType with the analytical power of a dedicated AI writing and biomechanical typing coach.</p><p>Here is the story of how I built it, the architectural hurdles I encountered, and what I learned by looking at application design through a frontend lens.</p><h3>The Concept: Muscle Memory Meets Cognitive Refinement</h3><p>The initial blueprint for TypeForge was straightforward: build a tool that helps users train their typing speed while simultaneously offering an AI utility to refine messy daily text (like emails or Slack messages).</p><p>But as the architecture evolved, the scope transformed into something far more compelling. Instead of building two disconnected tools, I wanted to create an analytical feedback loop. The final application structure spans three core pillars:</p><ol><li><strong>The Typing Sandbox:</strong> A minimalist, dark-themed character-matching engine that calculates live Words Per Minute (WPM), Accuracy, and Error Density.</li><li><strong>The Dual-View Analytics Dashboard:</strong> A localized tracking center that maps historic user progress via interactive charts, but also lets users click into individual test runs to see granular breakdowns.</li><li><strong>The AI Hub (Powered by Gemini 2.5 Flash):</strong> A serverless backend engine that processes text tone refinements and acts as a biological typing instructor.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wQH7JBrfaHnwjp8h4K3F4g.png" /><figcaption>Type Forge</figcaption></figure><h3>Embracing Frontend Constraints: The Power of Local Storage</h3><p>Coming from a backend background, my default instinct for storing data is always to spin up a PostgreSQL database or a Redis cache. However, to keep this project completely lean, hostable on Vercel’s free tier, and heavily focused on frontend data management, I made a deliberate architectural pivot: <strong>I built the entire data persistence layer using the browser’s </strong><strong>localStorage.</strong></p><p>Every keystroke anomaly, backspace smash, and missed character is grouped into a unique session object and appended to a personalized user array in the browser cache.</p><p>This constraint forced me to master React state synchronization. When a user completes a test, the metrics are instantly calculated, committed tolocalStorage, and fired off to update a dual-view dashboard using recharts. Users can switch seamlessly between a multi-session cumulative progress trend and a hyper-specific individual run deep-dive without a single database round-trip query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-3mOYdGTaaQWI3Tff92SZg.png" /><figcaption>Typing Test With Blind Mode</figcaption></figure><h3>Elevating the UX: Blind Mode and Biomechanical Mapping</h3><p>To make TypeForge stand out, I wanted to track metrics that generic typing tests ignore. This led to the development of two advanced features that turned standard data points into actual cognitive insights.</p><h3>1. “Blind” Accuracy Mode</h3><p>Top-tier typists know that visual dependency can slow you down. I implemented a “Blind Mode” toggle that completely hides the user’s typed input. The user must type purely by feel. If they make a mistake, the entire container border flashes a soft crimson tint for 150 milliseconds before fading back.</p><h3>2. Mechanical Finger Weakness Mapping</h3><p>Because the app tracks the exact characters a user misses, I wrote a QWERTY matrix that maps individual keys to their corresponding fingers, e.g., attributing W, S, and X to the left ring finger. The dashboard aggregates these mistakes into a visual heatmap, instantly showing the user which finger is causing the most mechanical friction.</p><pre>Left Index:   ██████████░░░░░ (64% of errors) - High Friction<br>Right Middle: ██░░░░░░░░░░░░░ (12% of errors) - Optimal</pre><blockquote><strong><em>The AI Masterstroke:</em></strong><em> When a user requests feedback, the application bundles the raw metrics, the finger mapping data, and an </em><em>isBlindMode boolean flag, sending it all to the </em><em>gemini-2.5-flash model.</em></blockquote><blockquote><em>If a user maintains a roaring speed normally but crumbles under Blind Mode, the Gemini model recognizes this cognitive bottleneck, skips generic formatting advice, and explicitly instructs them on building spatial finger anchoring.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DN2bTRxLRXnoSaj9lWLTVw.png" /><figcaption>Metrics for Typing Test Sessions</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QlS7ao1IWsFu75zahb3f5g.png" /><figcaption>Detailed BioMechanical Metrics</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v9g8ibZQn3aN6-p0Qty7HQ.png" /><figcaption>Text Enhancer</figcaption></figure><h3>The Rookie Trap: Surviving the Vercel Production Build</h3><p>When the local build was pristine, I committed the code to Git and linked it to Vercel.</p><p><strong>And the deployment immediately crashed.</strong></p><p>This was my first major Next.js hydration lesson. Because Next.js attempts to pre-render pages on the server side during the build phase, it has no concept of a browser environment. The moment the server compiler hit my standalone localStorage calls, it threw a fatal window is not defined error.</p><p>To safeguard the production application, I had to learn how to strictly isolate client-side side effects. I audited the codebase, wrapping all browser-dependent calls inside useEffect hooks and adding window existence guard clauses:</p><pre>if (typeof window !== &#39;undefined&#39;) {<br>  const cachedHistory = localStorage.getItem(`typing_history_${userName}`);<br>}</pre><p>This ensures the page builds safely as static HTML on Vercel’s servers, and then gracefully “hydrates” with the user’s personalized browser data the microsecond it hits their actual screen.</p><h3>Security Architecture: Hiding the Keys in Plain Sight</h3><p>Even in a frontend-heavy project, security cannot be ignored. I needed to call the Gemini API without exposing my API keys to the open web via inspect element or the network tab.</p><p>Next.js Route Handlers provided the perfect serverless firewall. By creating a secure backend endpoint (src/app/api/ai-hub/route.tsThe frontend simply sends the user metrics via a POST request. The API key remains securely locked in Vercel&#39;s environment variables, so the user&#39;s browser only ever sees the final, beautifully parsed JSON analysis string.</p><h3>Key Takeaways from the Journey</h3><p>Stepping out of my backend comfort zone to build TypeForge taught me three major things:</p><ul><li><strong>The Frontend has Serious Horsepower:</strong> Modern browsers are incredibly powerful data processors. Leveraging client-side caching localStorage can eliminate massive database overhead for early-stage MVPs and POCs.</li><li><strong>Context is King for AI:</strong> Passing structural state flags (like whether a test was taken “blind”) drastically alters the quality of LLM outputs. The more behavioral context you pass to models like Gemini, the more human and adaptive the response feels.</li><li><strong>Embrace the Build Errors:</strong> Transitioning to full-stack frameworks like Next.js forces you to respect the boundary between server-side generation and client-side execution.</li></ul><p>TypeForge started as a simple experiment to shake off development stagnation. It ended up becoming a masterclass in responsive UI layout, complex client state management, and the incredible speed of serverless AI integrations.</p><p>If you are a backend engineer staring at the frontend with hesitation: take the leap, pick an idea, and start forging.</p><p>Give it a try: <a href="https://type-forge-jade.vercel.app/">https://type-forge-jade.vercel.app/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfdd71690edb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Local MCP Task Tracker Server in Java]]></title>
            <link>https://medium.com/@ankitmaurya1994/building-a-local-mcp-task-tracker-server-in-java-68e4b41f3bee?source=rss-f51a4359f8d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/68e4b41f3bee</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[mcp-server]]></category>
            <dc:creator><![CDATA[Ankit Maurya]]></dc:creator>
            <pubDate>Mon, 22 Dec 2025 10:03:02 GMT</pubDate>
            <atom:updated>2025-12-22T12:06:58.189Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern IDEs are getting better at understanding <em>code</em>.<br>What they still struggle with is understanding <em>work context</em>.</p><p>Which task I am working on?<br>Which features are in progress?<br>What changed yesterday?<br>What is actually “done”?</p><p>This article documents a <strong>local-first MCP (Model Context Protocol) server</strong> built to solve exactly that problem: a <strong>task and feature tracking service</strong>, designed for IDE and tooling integration using <strong>JSON-RPC</strong>.</p><p>No UI.<br>No cloud.<br>No LLMs.<br>Just deterministic state, stored locally, and exposed cleanly to MCP-aware clients.</p><h3>Why This Exists</h3><p>Most task trackers fail developers for one fundamental reason:</p><blockquote><em>They live outside the development loop.</em></blockquote><p>Tools like Jira, Notion, or Linear are useful, but disconnected from:</p><ul><li>branches</li><li>feature-level progress</li><li>coding sessions</li><li>IDE-native workflows</li></ul><p>This project takes a different approach.</p><p>The goal is to run a <strong>local daemon</strong> that:</p><ul><li>tracks tasks and feature evolution,</li><li>speaks <strong>MCP-compatible JSON-RPC</strong>,</li><li>integrates directly with IDEs and tools,</li><li>generates deterministic documentation from real work.</li></ul><p>This is not a project management tool.<br>This is <strong>structured memory for developer intent</strong>.</p><h3>Design Principles</h3><p>The constraints are intentional and shape everything:</p><ul><li>Local-only, single user</li><li>Append-only data model</li><li>Deterministic behaviour</li><li>No AI dependency</li><li>Portable storage</li></ul><p>These constraints eliminate complexity and make the system reliable enough to embed directly into IDE workflows.</p><h3>High-Level Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*llFonxdAPYb1tPa0usOZBQ.png" /></figure><h3>Why this architecture works</h3><ul><li><strong>stdio support</strong> enables native MCP integration with IDEs</li><li><strong>HTTP support</strong> makes testing and debugging trivial</li><li><strong>Spring Boot</strong> provides a stable lifecycle</li><li><strong>SQLite</strong> keeps the system local, portable, and zero-setup</li></ul><h3>JSON-RPC as the Single Interface</h3><p>Both HTTP and stdio use the <strong>same JSON-RPC 2.0 envelope</strong>.</p><h3>Request</h3><pre>{<br>  &quot;jsonrpc&quot;: &quot;2.0&quot;,<br>  &quot;id&quot;: &quot;42&quot;,<br>  &quot;method&quot;: &quot;addFeatureToTask&quot;,<br>  &quot;params&quot;: {<br>    &quot;taskName&quot;: &quot;feature/db-flag&quot;,<br>    &quot;featureName&quot;: &quot;API contract&quot;,<br>    &quot;update&quot;: &quot;Documented request/response schema&quot;<br>  }<br>}</pre><h3>Success Response</h3><pre>{<br>  &quot;jsonrpc&quot;: &quot;2.0&quot;,<br>  &quot;id&quot;: &quot;42&quot;,<br>  &quot;result&quot;: {<br>    &quot;feature&quot;: {<br>      &quot;taskId&quot;: &quot;uuid&quot;,<br>      &quot;featureName&quot;: &quot;API contract&quot;,<br>      &quot;status&quot;: &quot;IN_PROGRESS&quot;<br>    }<br>  },<br>  &quot;error&quot;: null<br>}</pre><h3>Error Response</h3><pre>{<br>  &quot;jsonrpc&quot;: &quot;2.0&quot;,<br>  &quot;id&quot;: &quot;42&quot;,<br>  &quot;result&quot;: null,<br>  &quot;error&quot;: {<br>    &quot;code&quot;: -32602,<br>    &quot;message&quot;: &quot;Missing required param: taskName&quot;<br>  }<br>}</pre><p>This consistency is critical for MCP tooling and agent integration.</p><h3>Domain Model</h3><h3>Tasks</h3><p>A <strong>task</strong> represents a logical unit of work, typically mapped to a branch or feature goal.</p><p>Field Meaning</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*KSKZGsc8FDTVLjSC-E7N9A.png" /></figure><p>Tasks are <strong>never deleted</strong>. They are only closed.</p><h3>Feature Updates (Append-Only by Design)</h3><p>There is <strong>no </strong><strong>features table</strong>.</p><p>Every feature change is stored as a new row:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*C7OgW4W8KhCS8jGhANHxnA.png" /></figure><p><strong>Rule:</strong><br>The latest row per (task_name, feature_name) represents current state.</p><p>This provides:</p><ul><li>Full history</li><li>Easy reconstruction</li><li>Zero overwrite ambiguity</li></ul><h3>MCP Tools Explained</h3><h3>Start a Task Session</h3><pre>{<br>  &quot;method&quot;: &quot;startSession&quot;,<br>  &quot;params&quot;: {<br>    &quot;taskName&quot;: &quot;feature/db-flag&quot;,<br>    &quot;title&quot;: &quot;Wire MCP task tracking&quot;<br>  }<br>}</pre><p>Creates or resumes a task.</p><h3>Add Feature Progress</h3><pre>{<br>  &quot;method&quot;: &quot;addFeatureToTask&quot;,<br>  &quot;params&quot;: {<br>    &quot;taskName&quot;: &quot;feature/db-flag&quot;,<br>    &quot;featureName&quot;: &quot;API contract&quot;,<br>    &quot;update&quot;: &quot;Defined request and response schema&quot;<br>  }<br>}</pre><ul><li>Creates the feature implicitly if it does not exist</li><li>Appends a new history entry</li></ul><h3>Update Feature Status</h3><pre>{<br>  &quot;method&quot;: &quot;updateFeatureStatus&quot;,<br>  &quot;params&quot;: {<br>    &quot;taskName&quot;: &quot;feature/db-flag&quot;,<br>    &quot;featureName&quot;: &quot;API contract&quot;,<br>    &quot;status&quot;: &quot;DONE&quot;<br>  }<br>}</pre><p>A status change is a <strong>new row</strong>, not a mutation.</p><h3>Get Active Features</h3><pre>{<br>  &quot;method&quot;: &quot;getActiveFeatures&quot;,<br>  &quot;params&quot;: {<br>    &quot;taskName&quot;: &quot;feature/db-flag&quot;<br>  }<br>}</pre><p>Returns all IN_PROGRESS features with their latest updates.</p><h3>Generate Markdown Documentation</h3><pre>{<br>  &quot;method&quot;: &quot;generateDocumentForTask&quot;,<br>  &quot;params&quot;: {<br>    &quot;taskName&quot;: &quot;feature/db-flag&quot;<br>  }<br>}</pre><p>Example output:</p><pre># Task: feature/db-flag</pre><pre>## Goal<br>Wire MCP task tracking</pre><pre>## Features</pre><pre>### API contract (DONE)<br>- Defined request/response schema<br>- Reviewed error handling</pre><p>The output is <strong>deterministic, repeatable, and auditable</strong>.</p><h3>Why This Server Does Not Use LLMs</h3><p>This is intentional.</p><p>The server:</p><ul><li>Records facts</li><li>Preserves history</li><li>Produces deterministic output</li></ul><p>LLMs are excellent <strong>consumers</strong> of structured context.<br>They are poor <strong>sources of truth</strong>.</p><p>Keeping the state layer deterministic allows safe agent reasoning <em>on top</em> without corrupting the underlying data.</p><h3>Running the Server</h3><pre>mvn clean package<br>mvn spring-boot:run</pre><p>Health check:</p><pre>curl http://localhost:8080/health</pre><pre>{<br>  &quot;status&quot;: &quot;UP&quot;,<br>  &quot;service&quot;: &quot;Task Tracker MCP Server&quot;<br>}</pre><p>The same server can be launched in <strong>stdio mode</strong> for MCP-aware IDEs.</p><h3>Constraints (Explicit by Design)</h3><ul><li>Single user</li><li>Local-only</li><li>No authentication</li><li>No multi-tenancy</li><li>No distributed guarantees</li></ul><p>This is infrastructure for <strong>thinking</strong>, not collaboration.</p><h3>Where This Fits in the MCP Ecosystem</h3><p>This server acts as:</p><ul><li>A ground-truth memory layer</li><li>A context anchor for AI tools</li><li>A documentation generator based on real work</li><li>A bridge between IDE actions and durable state</li></ul><p>It is intentionally boring — and therefore reliable.</p><h3>Closing Thoughts</h3><p>Most developer tools try to be <em>smart</em>.</p><p>This project focuses on being <strong>predictable</strong>.</p><p>When tools can trust their memory, intelligence becomes optional — and composable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68e4b41f3bee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Brushing Up Spring Security]]></title>
            <link>https://medium.com/@ankitmaurya1994/brushing-up-spring-security-5431fecc7973?source=rss-f51a4359f8d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5431fecc7973</guid>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Ankit Maurya]]></dc:creator>
            <pubDate>Fri, 03 Oct 2025 16:15:26 GMT</pubDate>
            <atom:updated>2025-10-03T23:54:52.172Z</atom:updated>
            <content:encoded><![CDATA[<p>Every once in a while, I like to revisit the fundamentals not because I’ve forgotten them, but because brushing up on core skills sharpens intuition for handling complex production-grade systems. Recently, I revisited <strong>Spring Security</strong> with a small Proof of Concept. The goal wasn’t to learn it from scratch, but to refresh key ideas while aligning them with how I’d design things in production.</p><h3>Why This POC?</h3><p>Security in enterprise systems is rarely optional. Whether it’s authentication, authorization, or fine-grained role checks, production apps live and die by their security design. This POC became my way to re-examine best practices and remind myself of pitfalls.</p><h3>Basic Authentication Refresher</h3><p>I started with <strong>in-memory authentication</strong>, not because it’s realistic, but because it’s a quick way to validate wiring. Here’s the snippet:</p><pre>@Bean<br>public UserDetailsService userDetailsService() {<br>UserDetails user = User.withUsername(&quot;****&quot;)<br>.password(passwordEncoder().encode(&quot;****&quot;))<br>.roles(&quot;USER&quot;)<br>.build();<br><br><br>UserDetails admin = User.withUsername(&quot;****&quot;)<br>.password(passwordEncoder().encode(&quot;****&quot;))<br>.roles(&quot;ADMIN&quot;)<br>.build();<br>return new InMemoryUserDetailsManager(user, admin);<br>}</pre><p>It works, but the reminder here is: <strong>never carry this forward to production.</strong> Real systems demand DB-backed users or integration with identity providers like OAuth, LDAP, or SSO.</p><h3>Role-Based API Restrictions</h3><p>Next, I revisited API-level restrictions. This is where clarity in role design directly influences API maintainability.</p><pre>@Override<br>protected void configure(HttpSecurity http) throws Exception {<br>http<br>.authorizeRequests()<br>.antMatchers(&quot;/admin/**&quot;).hasRole(&quot;ADMIN&quot;)<br>.antMatchers(&quot;/user/**&quot;).hasAnyRole(&quot;USER&quot;, &quot;ADMIN&quot;)<br>.anyRequest().authenticated()<br>.and()<br>.formLogin();<br>}</pre><p>Brushing up here reminded me of the importance of <strong>API design with security baked in</strong>. Retrofitting roles later is painful.</p><h3>Method-Level Locks</h3><p>Service-layer annotations like @PreAuthorize remain one of the cleanest ways to enforce security close to business logic. This prevents accidental exposure if API mappings shift.</p><pre>@PreAuthorize(&quot;hasRole(&#39;ADMIN&#39;)&quot;)<br>public void deleteOrder(Long orderId) {<br>// delete logic here<br>}</pre><p>This practice reinforces the idea of layered defense: endpoints validate roles, but so does the business layer.</p><h3>Multi-Tenancy Handling</h3><p>One of the scenarios I brushed up on was multi-tenant security. In real-world systems, not every tenant should access the same APIs. For example, U.S. customers might have access to a certain set of services, while Canadian customers get a slightly different experience.</p><pre>@PreAuthorize(&quot;@tenantChecker.isTenantAllowed(#tenantHeader, ‘US’)&quot;)<br>public void processOrder(String tenantHeader, Long orderId) {<br>    // order processing logic<br>}</pre><pre>@Component<br>public class TenantChecker {<br><br>    @Value(&quot;${tenant.allowed}&quot;)<br>    private String allowedTenant;<br><br>    public boolean isTenantAllowed(String tenantHeader, String expectedTenant) {<br>        return allowedTenant.equalsIgnoreCase(tenantHeader) &amp;&amp; expectedTenant.equalsIgnoreCase(tenantHeader);<br>    }<br>}</pre><p>To enforce this, I used header-based tenant validation combined with Spring Security’s expression-based annotations.</p><p>This allowed me to mimic real production restrictions: tenant-specific logic, configurable through application.properties, and enforced consistently at the service layer.</p><h3>Key Reminders From the POC</h3><ol><li><strong>Always think production.</strong> Even quick POCs should model real-world scenarios.</li><li>Multi-tenancy isn’t just data separation, it’s also API and feature separation. Security needs to enforce that at every layer.</li><li><strong>Security is layered.</strong> Endpoint rules and business rules complement each other, not replace each other.</li><li><strong>Keep configs flexible.</strong> Hardcoding too much in early stages leads to brittle systems.</li><li><strong>Security evolves.</strong> Revisiting fundamentals helps spot gaps in how you’d scale them.</li></ol><h3>Closing Thoughts</h3><p>This POC wasn’t about building a toy app. It was about sharpening reflexes for production-grade design. Revisiting Spring Security in this structured way reminded me that while the framework is powerful, it’s the mindset you bring layered defenses, forward-thinking API design, and scalability that makes it production-ready.</p><p>Find the codebase here- <a href="https://github.com/AnkitKiet/spring-practice-workspace/tree/main/spring-security-example">https://github.com/AnkitKiet/spring-practice-workspace/tree/main/spring-security-example</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5431fecc7973" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an AI-Powered Document Search System]]></title>
            <link>https://medium.com/@ankitmaurya1994/building-an-ai-powered-document-search-system-5f477a009681?source=rss-f51a4359f8d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f477a009681</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ankit Maurya]]></dc:creator>
            <pubDate>Sun, 17 Aug 2025 14:53:48 GMT</pubDate>
            <atom:updated>2025-08-17T14:53:48.068Z</atom:updated>
            <content:encoded><![CDATA[<p>Every hackathon starts with a problem worth solving.<br>In our case, it was simple but powerful:</p><p><em>“How can we make document search smarter within our existing confluence data systems?”</em></p><p>We had a bunch of internal documents- some PDFs, some text-heavy reports. Normal keyword search didn’t cut it. We wanted the system to understand <em>human language</em> queries like:</p><ul><li>“What are the steps in onboarding to application ?”</li><li>“Explain customer refund rules.”</li></ul><p>and return <strong>context-aware answers</strong> instead of just keyword matches.</p><p>That’s how our team’s hackathon idea was born:<br>An <strong>AI-powered document search system- </strong>simple, fast, and extensible.</p><h3>Architecture at a Glance</h3><p>We kept the design pragmatic. No over-engineering. Here’s the high-level flow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XHilz-JIqRm7YzuDEyLxuQ.png" /><figcaption>High Level Diagram</figcaption></figure><ol><li><strong>Document Upload (Spring Boot Backend)<br> </strong><em>a.</em> Our backend is written in <strong>Spring Boot</strong> (Java).<br> <em>b.</em> A REST endpoint lets users upload documents.<br> <em>c.</em> Each document is assigned a <strong>unique document identifier</strong> (so we can later scope searches to a specific file).</li><li><strong>Vectorization with Ollama (nomic-embed-text)<br> </strong><em>a.</em> Instead of traditional full-text indexing, we use <strong>embeddings</strong>.<br> <em>b.</em> We chose <strong>Ollama</strong> as the embedding model runtime (running locally).<br> <em>c.</em> The specific model: <strong>nomic-embed-text</strong>, which transforms each chunk of text into a dense vector representation.<br> <em>d.</em> Why Ollama? Because it’s <strong>lightweight, easy to run locally, and avoids cloud costs</strong>. Perfect for a hackathon.</li><li><strong>Vector Storage in Qdrant<br></strong>We store embeddings in <strong>Qdrant</strong>, an open-source vector database.<br>Why Qdrant?<br> <em>a. </em>Simple <strong>Docker setup</strong> → great for hackathon speed.<br> <em>b.</em> <strong>Filtering support</strong> → so we can limit search results to a single. document (document_id).<br> <em>c.</em> Very <strong>developer-friendly APIs</strong>.<br> <em>d</em>. We ask Qdrant: <em>“Find me the most relevant chunks for this query within document X.”<br>f.</em> Qdrant returns the closest matches.<br><em>g</em>. Backend stitches these into a <strong>human-friendly response</strong>.<br><em>h</em>. If nothing is relevant enough → system politely says <em>“I’m not able to find an answer in this document.”</em></li><li><strong>React UI<br></strong>A lightweight frontend built in <strong>React</strong>.<br>Users can:<br> <em>a</em>. Upload documents.<br> <em>b</em>. Select a specific document.<br> <em>c</em>. Ask natural-language queries.<br> <em>d</em>. Responses come back in near real-time.</li></ol><h3>Why These Tech Choices?</h3><p>We had a lot of debate in the team, but here’s why we landed where we did:</p><p><strong>Spring Boot</strong> → <br>Our comfort zone. Reliable, production-grade, and integrates smoothly with REST + databases.</p><p><strong>Ollama (nomic-embed-text)</strong> →</p><ul><li>Local inference, no API billing.</li><li>Text-only embeddings, lightweight but high-quality.</li><li>Runs perfectly inside hackathon laptops.</li></ul><p><strong>Qdrant</strong> →</p><ul><li>Quick setup via Docker.</li><li>Optimized for similarity search.</li><li>Document-level filtering makes it ideal for our “per-document” search boundary.</li></ul><p><strong>React UI</strong> →</p><ul><li>Clean, hackathon-fast development.</li><li>Easy integration with backend APIs.</li></ul><p>In short → <strong>every tech decision balanced speed of building + credibility of scaling later.</strong></p><h3>Key Engineering Decisions</h3><ol><li><strong>Document Singularity</strong></li><li>We explicitly designed the system so search is done <strong>within a single document</strong> only. This avoids cross-document noise and gives users confidence:</li></ol><p><em>“This answer comes only from the file you selected.”</em></p><p>3.<strong> No Overtraining</strong></p><ul><li>We skipped full-blown ML training for hackathon speed.</li><li>Instead, embeddings + vector DB already give semantic understanding.</li><li>Later, we can retrain or fine-tune if needed.</li></ul><p>4.<strong> Fallback Responses</strong></p><ul><li>Instead of hallucinating answers, we return:</li><li><em>“Sorry, I couldn’t find anything in this document.”</em></li><li>This keeps the system trustworthy.</li></ul><h3>🏆 Hackathon Outcome</h3><p>In just two days, we had:</p><ul><li>A <strong>working prototype</strong> where users could upload a doc and query it.</li><li>A <strong>smooth UI</strong> that made it feel “real”.</li><li>An architecture that isn’t throwaway, can actually evolve into production.</li></ul><p>The best part? Our system didn’t just “search keywords.” It <strong>understood questions</strong> in natural language and gave answers with context.</p><p>But for a hackathon? We’re proud.<br>We shipped something that worked, wowed, and showed how AI can be integrated into backend-heavy systems without massive overhead.</p><p>That’s the story of our hackathon project: <strong>AI-Powered Document Search with Spring Boot + Qdrant + Ollama + React. <br>Screenshot ahead-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*86Iqcr8CjlsGOjvWi0hFaA.png" /><figcaption>Homepage</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_JKWfSKM3ulJc3cVCS-Vig.png" /><figcaption>Login Screen</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qdxu01iKB6r6y3b98BbPrg.png" /><figcaption>Dashboard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fj2cRddYf2-xh66FXa7DoQ.png" /><figcaption>Search Within Doc</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f477a009681" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Designing a High-Scale, Fair Ticket Booking System with Redis + Kafka (Now with Geo Priority &…]]></title>
            <link>https://medium.com/@ankitmaurya1994/designing-a-high-scale-fair-ticket-booking-system-with-redis-kafka-now-with-geo-priority-64aca4a232c5?source=rss-f51a4359f8d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/64aca4a232c5</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <dc:creator><![CDATA[Ankit Maurya]]></dc:creator>
            <pubDate>Sat, 19 Jul 2025 19:17:56 GMT</pubDate>
            <atom:updated>2025-07-19T19:18:25.350Z</atom:updated>
            <content:encoded><![CDATA[<h3>Designing a High-Scale, Fair Ticket Booking System with Redis + Kafka</h3><p>Concerts. Cricket. Flash sales. Imagine <strong>millions</strong> of users logging in at 10:00 AM sharp to book tickets.<br> The challenge?<br> 🔹 <strong>Ensure fairness (FCFS)</strong><br> 🔹 <strong>Prevent fraud or abuse</strong><br> 🔹 <strong>Scale to 1M transactions per minute</strong><br> 🔹 <strong>Introduce geo-based prioritization or pre-booking privileges</strong></p><p>In this article, we’ll design a <strong>modern ticket booking backend</strong> that solves these problems using <strong>Redis</strong>, <strong>Kafka</strong>, <strong>microservices</strong>, and a few clever strategies.</p><h3>Real-World Problems to Solve</h3><ul><li>Handle <strong>1 million transactions per minute (TPM)</strong></li><li>Maintain <strong>first-come-first-served (FCFS)</strong></li><li>Allow <strong>Geo-based Priority</strong> (e.g., local region booking first)</li><li>Introduce <strong>Pre-Booking Windows</strong> (VIPs, loyalty tiers, etc.)</li><li>Detect and <strong>block fraud, bots, abuse</strong></li><li>Provide <strong>durability + retry</strong> under load</li><li>Maintain <strong>low latency</strong> and <strong>resilience</strong></li></ul><h3>🧮 Back-of-Envelope Calculation (Revisited)</h3><ul><li><strong>1M TPM = ~16,667 transactions/sec</strong></li><li>Assume each booking has:</li><li>1 Redis write</li><li>1 Kafka publish</li><li>3 microservice calls (Inventory, Payment, Booking)</li><li>Fraud + Geo + Pre-book validation (lightweight checks)</li></ul><p><strong>Est. ops/sec</strong> = 16.7K x ~6 = <strong>~100K ops/sec</strong> (plus 10% headroom)</p><p>This is feasible with:</p><ul><li>Redis Cluster (10K+ writes/sec/node)</li><li>Kafka (multi-partitioned)</li><li>Horizontally scaled microservices</li></ul><h3>High-Level Architecture (HLD)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KD8m7a1OBcmKoQOn7f8B8g.png" /><figcaption>Design Overview</figcaption></figure><h3>Booking Flow with New Enhancements</h3><ul><li>User Request → API Gateway</li><li>API hits:<br>FraudService: blocks bots, suspicious IPs<br>GeoPrioritizer: applies priority boosts to Redis score<br>PreBookingManager: checks if user is eligible now</li><li>Request added to Redis Sorted Set</li><li>Score = timestamp ± geo or VIP window delta</li><li>Dispatcher pops in FCFS order (score-based), sends batch to Kafka</li><li>Kafka feeds into BookingOrchestrator</li><li>Executes:<br>Inventory check + lock<br>Payment<br>Booking confirmation<br>Notification dispatch<br>Logs/audits to ELK/Clickhouse</li><li>DLQ handles failed or partial bookings</li></ul><h3>Components Overview</h3><pre>| Microservice          | Role                                                |<br>| --------------------- | --------------------------------------------------- |<br>| `FraudService`        | Checks user IPs, rate limits, device fingerprinting |<br>| `GeoPrioritizer`      | Adds boost/penalty to Redis score based on region   |<br>| `PreBookingManager`   | Enforces booking windows (e.g., VIP 10:00–10:15 AM) |<br>| `RedisQueueService`   | Enqueues user request with updated score            |<br>| `DispatcherService`   | Reads in sorted order, batches to Kafka             |<br>| `Kafka`               | Buffers and decouples processing                    |<br>| `InventoryService`    | Checks ticket availability, locks                   |<br>| `PaymentService`      | Handles transaction lifecycle                       |<br>| `BookingService`      | Finalizes booking                                   |<br>| `NotificationService` | Sends SMS, Email                                    |<br>| `DLQHandlerService`   | Retries failures                                    |<br>| `AdminConsole`        | Monitor + Override flows                            |</pre><h3>Geo-Based Priority: How It Works</h3><ul><li>Each user includes region info (IP, zip, lat/long)</li><li>A config defines <strong>regional priority weights</strong> (e.g. Mumbai users get +10ms priority)</li><li>Redis ZADD score is:</li></ul><pre>score = currentTimeMillis - geoBoost</pre><p>This ensures <strong>users in preferred zones appear earlier in FCFS queue</strong>, even if the delta is small (~10–100ms).</p><h3>Pre-Booking Windows</h3><p>Define slots like:</p><pre>| Tier     | Time Slot        |<br>| -------- | ---------------- |<br>| Platinum | 10:00 – 10:10 AM |<br>| Gold     | 10:10 – 10:20 AM |<br>| Public   | After 10:20 AM   |</pre><p>The PreBookingManager enforces this by:</p><ul><li>Rejecting ineligible users early</li><li>Delaying entry into Redis queue</li></ul><p>This avoids chaos at 10:00 AM sharp and distributes load.</p><h3>Fraud Detection Strategies</h3><p>Fraud Service uses:</p><ul><li>IP blacklists</li><li>Device fingerprinting (browser + deviceID)</li><li>Rate limits by userID/device</li><li>Velocity checks (too many requests per second)</li><li>Captcha fallback</li></ul><p>This reduces bots and hoarders.</p><h3>Pros</h3><pre>|                 | Why It Works                                     |<br>| --------------- | ------------------------------------------------ |<br>| FCFS Guarantee  | Redis Sorted Set handles ordered writes at scale |<br>| Scalable        | Kafka + stateless microservices handle 1M+ TPM   |<br>| Durable         | Kafka provides fail-safe buffering and retries   |<br>| Fair + Flexible | Geo and window logic enhance fairness            |<br>| Resilient       | DLQ, retries, and observability are built-in     |</pre><h3>Cons</h3><pre>|                      | Drawbacks                                                     |<br>| -------------------- | ------------------------------------------------------------- |<br>| Complex Setup        | Redis + Kafka + PreBooking + Fraud is non-trivial             |<br>| Score Tuning         | Geo / priority weights need calibration                       |<br>| Edge Race Cases      | Slight time skews or score collisions need handling           |<br>| Increased Infra Cost | More services = more infra, monitoring, and team coordination |</pre><p>🌴If you liked this post, Do checkout other stories on profile! Have questions? Do comment. Thanks for reading! 💛</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64aca4a232c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Your Own HTTP Server in Java 21 — From Raw Sockets to Static Sites]]></title>
            <link>https://medium.com/@ankitmaurya1994/build-your-own-http-server-in-java-21-from-raw-sockets-to-static-sites-04c3ec92371b?source=rss-f51a4359f8d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/04c3ec92371b</guid>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Ankit Maurya]]></dc:creator>
            <pubDate>Wed, 02 Jul 2025 17:35:53 GMT</pubDate>
            <atom:updated>2025-07-02T17:35:53.128Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build Your Own HTTP Server in Java 21 — From Raw Sockets to Static Sites</h3><blockquote>Ever wondered how web servers like Apache or Nginx actually work under the hood? Let’s strip away the frameworks and build one from scratch using modern Java 21.</blockquote><h3>Why Build an HTTP Server From Scratch?</h3><p>As a senior backend engineer, you often operate one level above the networking layer — using frameworks like Spring Boot or Flask. But underneath, it’s all TCP, HTTP, headers, sockets, and protocols.</p><p>Building your own web server is the best way to learn:</p><ul><li>What protocols really are (and how HTTP works)</li><li>How to parse real-world requests</li><li>How sockets, threads, and ports interact</li><li>How routing and static file serving happens under the hood</li></ul><h3>🏗️ Project Goals</h3><p>We’ll build a simple but robust server that can:</p><ul><li>Accept HTTP requests over TCP</li><li>Parse headers and request line manually</li><li>Serve static files like HTML, JS, images</li><li>Later extend to handle RESTful API routes (/api/...)</li><li>Use Java 21 features like Virtual Threads</li></ul><h3>📁 Initial Project Structure</h3><pre>mini-http-server/<br>├── Main.java<br>├── HttpServer.java<br>├── ConnectionHandler.java<br>├── HttpRequest.java<br>├── HttpResponse.java<br>├── StaticFileHandler.java<br>├── utils/<br>│   ├── Logger.java<br>│   └── MimeTypeMapper.java<br>└── www/<br>    ├── index.html<br>    └── style.css</pre><h3>⚙️ Part 1: Accepting TCP Connections</h3><p>Here’s how we bind to a port and handle connections with lightweight virtual threads.</p><h4>HttpServer.java</h4><pre>public class HttpServer {<br>    private final int port;<br>    private final ExecutorService executor;<br><br>public HttpServer(int port) {<br>        this.port = port;<br>        this.executor = Executors.newVirtualThreadPerTaskExecutor(); // Java 21<br>    }<br>    public void start() {<br>        try (ServerSocket serverSocket = new ServerSocket(port)) {<br>            Logger.info(&quot;HTTP Server started on port &quot; + port);<br>            while (true) {<br>                Socket clientSocket = serverSocket.accept();<br>                executor.submit(new ConnectionHandler(clientSocket));<br>            }<br>        } catch (IOException e) {<br>            Logger.error(&quot;Failed to start server: &quot; + e.getMessage());<br>        }<br>    }<br>}</pre><blockquote><em>☕️ </em><strong><em>Learning:</em></strong><em> </em><em>Executors.newVirtualThreadPerTaskExecutor() enables a scalable concurrency model with minimal footprint.</em></blockquote><h3>📥 Part 2: Parsing HTTP Requests by Hand</h3><p>No libraries. Raw parsing.</p><h4>HttpRequest.java</h4><pre>public record HttpRequest(String method, String path, String version, Map&lt;String, String&gt; headers) {<br>    public static HttpRequest parse(String requestLine, BufferedReader reader) throws IOException {<br>        String[] parts = requestLine.split(&quot; &quot;);<br>        String method = parts[0], path = parts[1], version = parts[2];<br><br>        Map&lt;String, String&gt; headers = new HashMap&lt;&gt;();<br>        String line;<br>        while ((line = reader.readLine()) != null &amp;&amp; !line.isBlank()) {<br>            int sep = line.indexOf(&quot;:&quot;);<br>            headers.put(line.substring(0, sep).trim(), line.substring(sep + 1).trim());<br>        }<br>        return new HttpRequest(method, path, version, headers);<br>    }<br>}</pre><blockquote><em>🔎 </em><strong><em>Learning:</em></strong><em> This gives you a deep understanding of what HTTP really is — a textual protocol with very defined rules.</em></blockquote><h3>🌐 Part 3: Serving Static Files</h3><p>We set up a www/ folder and use a secure resolver to map request paths to real files, with content-type detection.</p><h4>StaticFileHandler.java (core logic)</h4><pre>Path resolvedPath = BASE_DIR.resolve(path.substring(1)).normalize();<br>if (!resolvedPath.startsWith(BASE_DIR)) return forbidden();<br>if (!Files.exists(resolvedPath) || Files.isDirectory(resolvedPath)) return notFound();<br>byte[] content = Files.readAllBytes(resolvedPath);<br>String mimeType = MimeTypeMapper.getMimeType(resolvedPath.toString());</pre><blockquote><em>🛡 </em><strong><em>Learning:</em></strong><em> Preventing directory traversal (e.g., </em><em>../../etc/passwd) is critical for any file server.</em></blockquote><h4>MIME Type Detection</h4><pre>Map&lt;String, String&gt; mimeTypes = Map.of(<br>    &quot;html&quot;, &quot;text/html&quot;,<br>    &quot;css&quot;, &quot;text/css&quot;,<br>    &quot;js&quot;, &quot;application/javascript&quot;,<br>    &quot;png&quot;, &quot;image/png&quot;,<br>    &quot;jpg&quot;, &quot;image/jpeg&quot;<br>);</pre><blockquote><em>📦 </em><strong><em>Learning:</em></strong><em> Browsers rely on MIME types for correct rendering. Always send them!</em></blockquote><h3>🧪 Sample Output</h3><p>When you hit <a href="http://localhost:8080/index.html:">http://localhost:8080/index.html:</a></p><pre>HTTP/1.1 200 OK<br>Content-Type: text/html<br>Content-Length: 121<br><br>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;&lt;head&gt;&lt;title&gt;Mini Server&lt;/title&gt;&lt;/head&gt;&lt;body&gt;Hello from scratch server!&lt;/body&gt;&lt;/html&gt;</pre><h3>🧵 What You’ve Built So Far</h3><ol><li>Raw TCP socket handling</li><li>Manual HTTP request parsing</li><li>Static file server with MIME support</li><li>Path traversal protection</li><li>Virtual thread concurrency</li></ol><h3>🛣️ What’s Next?</h3><ul><li>Add a <strong>routing layer</strong> to support /api/hello or /api/users</li><li>Implement <strong>POST support</strong> with request body parsing</li><li>Extend to use <strong>non-blocking NIO</strong> for thousands of concurrent connections</li><li>Add <strong>TLS/HTTPS</strong> support with Java’s SSLContext</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04c3ec92371b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an AI Note Finder]]></title>
            <link>https://medium.com/@ankitmaurya1994/building-an-ai-note-finder-4474901a9f5b?source=rss-f51a4359f8d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4474901a9f5b</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Ankit Maurya]]></dc:creator>
            <pubDate>Sat, 28 Jun 2025 11:29:28 GMT</pubDate>
            <atom:updated>2025-06-28T11:29:28.850Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>“What if your notes could actually understand what you’re looking for, even when you don’t phrase it perfectly?”</em></blockquote><p>That was the question I found myself asking after weeks of juggling technical notes — from Docker commands to system design ideas and obscure Linux errors. And it led me to build a lightweight <strong>AI-powered Note Finder</strong> using nothing more than Spring Boot, a local embedding model (via <strong>Ollama</strong>), and <strong>Qdrant</strong> as the vector database.</p><p>In this article, I’ll walk you through the what, why, and how of building this <strong>semantic search POC</strong> — a practical example of vector-powered applications beyond GenAI chatbots.</p><h3>💡 Why Build This?</h3><p>We all take notes — hundreds of them. But plain keyword search quickly breaks down:</p><ul><li>You search for “thread-safe queue” but your note says “concurrent buffer in Java.”</li><li>You remember what a note is <em>about</em>, not the exact words.</li></ul><p>With semantic search, we can finally close that gap.</p><h3>🧰 The Stack</h3><p>To keep things simple and local:<br>ComponentRole<strong>Spring Boot</strong>REST APIs to insert/search notes. <strong>Ollama</strong>Generates vector embeddings (nomic-embed-text)<strong>Qdrant</strong>Vector similarity search engine<strong>Docker</strong>Local orchestration for Ollama and Qdrant</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XSNLO9jwiFona0Za.png" /><figcaption>Behind the scenes</figcaption></figure><h3>🏗️ System Architecture</h3><pre>User<br> |<br> └──&gt; Spring Boot REST API<br>         ├── POST /note         - Add single note<br>         ├── POST /note/bulk    - Insert multiple notes<br>         └── GET  /note/search  - Search semantically<br>              ↓<br>     Embedding Provider (Ollama: nomic-embed-text)<br>              ↓<br>     Vector DB (Qdrant)</pre><h3>🚀 Step-by-Step Setup</h3><h3>🔌 1. Run Qdrant (Vector Database)</h3><pre>docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant</pre><p>Create a vector collection for notes:</p><pre>curl -X PUT http://localhost:6333/collections/notes \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{&quot;vectors&quot;: { &quot;size&quot;: 768, &quot;distance&quot;: &quot;Cosine&quot; }}&#39;</pre><h3>🧠 2. Run Ollama and Load Embedding Model</h3><pre>docker run -d --name ollama -p 11434:11434 -v ollama-data:/root/.ollama ollama/ollama</pre><p>Load the embedding model:</p><pre>curl -X POST http://localhost:11434/api/pull \<br>  -d &#39;{&quot;name&quot;: &quot;nomic-embed-text&quot;}&#39;</pre><p>This model transforms your notes into 768-dimensional vectors that “understand” meaning.</p><h3>🔧 3. Build the Spring Boot App</h3><p>Use your Maven wrapper or JAR:</p><pre>./mvnw spring-boot:run<br># OR<br>java -jar target/ai-note-finder-0.0.1-SNAPSHOT.jar</pre><h3>🔎 How It Works</h3><h3>➕ Insert a Note</h3><pre>curl -X POST http://localhost:8080/note \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{&quot;text&quot;: &quot;Spring Boot is a powerful Java backend framework.&quot;}&#39;</pre><p>The app:</p><ol><li>Sends text to Ollama for embedding.</li><li>Stores vector + note in Qdrant with a UUID.</li></ol><h3>📦 Bulk Insert Notes</h3><p>You can insert 1000+ notes at once:</p><pre>curl -X POST http://localhost:8080/note/bulk \<br>  -H &quot;Content-Type: application/json&quot; \<br>  --data @random_notes.json</pre><p>Here’s a ready-to-use 1000-note file with programming tips and system design lines.</p><h3>🔍 Search Semantically</h3><pre>curl &quot;http://localhost:8080/note/search?q=java backend&quot;</pre><ol><li>Embeds the query</li><li>Sends vector to Qdrant</li><li>Returns top matches with cosine similarity</li></ol><p>Even if your query says “backend in Java,” it’ll match notes about “Spring Boot,” “REST APIs,” or “microservices.”</p><h3>💡 What Makes This Useful?</h3><ul><li><strong>Truly intelligent search</strong>: You don’t need exact keywords anymore.</li><li><strong>Offline/local</strong>: No OpenAI key needed. Ollama runs locally.</li><li><strong>Extendable</strong>: Add tags, timestamps, users, or even a web UI.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4474901a9f5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering LangGraph: A 5-Day Journey to Building AI Agents (Day 3)]]></title>
            <link>https://medium.com/@ankitmaurya1994/mastering-langgraph-a-10-day-journey-to-building-ai-agents-day-3-b9a76aa8bb09?source=rss-f51a4359f8d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9a76aa8bb09</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ankit Maurya]]></dc:creator>
            <pubDate>Sun, 02 Mar 2025 11:16:22 GMT</pubDate>
            <atom:updated>2025-10-04T06:02:25.222Z</atom:updated>
            <content:encoded><![CDATA[<p>On Day 2, <a href="https://medium.com/@ankitmaurya1994/mastering-langgraph-a-10-day-journey-to-building-ai-agents-day-2-e290429c497b">we built memory based LangGraph workflow</a>. Today, we extend it by adding memory to allow AI agents to remember past conversations!</p><h3>Introduction</h3><p>In this third installment of our 5<strong>-day LangGraph series</strong>, I’m enhancing our <strong>“Chat with Us” system</strong> by integrating <strong>Redis as a vector database</strong> and <strong>memory to maintain conversation history</strong>. This upgrade will allow the chatbot to respond with <strong>the most relevant answers</strong> and provide <strong>context-aware responses</strong>.</p><h3>Key Features</h3><ol><li><strong>Uses Redis Vector DB for Semantic Search</strong> (instead of exact keyword matches)</li><li><strong>Stores and Retrieves Vector Embeddings</strong> for more accurate results</li><li><strong>Maintains Memory to Provide Contextual Responses</strong></li><li><strong>Analyzes Sentiment and Escalates Concerns When Necessary</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*cVxuXV2jEnpS7wJ4rwB15Q.jpeg" /><figcaption>LangGraph Series</figcaption></figure><h3>Step 1: Setting Up Redis Vector DB</h3><h3>Store Responses in Redis as Vector Embeddings</h3><p>To enable <strong>semantic search</strong>, I’ll first convert our text responses into <strong>vector embeddings</strong> using <strong>Ollama</strong> and store them in <strong>Redis</strong>.</p><pre>import redis<br>import ollama<br>import numpy as np<br>import json<br><br># Connect to Redis<br>redis_client = redis.Redis(host=&quot;localhost&quot;, port=6379, decode_responses=False)<br># Function to Generate Vector Embeddings<br>def get_embedding(text):<br>    &quot;&quot;&quot;Generate embedding vector for given text using Ollama.&quot;&quot;&quot;<br>    response = ollama.embeddings(model=&quot;mistral&quot;, prompt=text)<br>    return response[&quot;embedding&quot;]  # Returns a list of floats<br># Store Data in Redis with Embeddings<br>def store_vector_data():<br>    sample_data = {<br>        &quot;What is LangGraph?&quot;: &quot;LangGraph is a Python library for AI workflows.&quot;,<br>        &quot;How does Redis work?&quot;: &quot;Redis is an in-memory key-value store for fast data retrieval.&quot;,<br>        &quot;What is vector search?&quot;: &quot;Vector search finds the closest match using embeddings.&quot;<br>    }<br>    for text, response in sample_data.items():<br>        vector = get_embedding(text)  # Convert text to vector<br>        redis_client.hset(&quot;vector_store&quot;, json.dumps(vector), response)<br>    print(&quot;Sample data stored in Redis Vector DB.&quot;)<br>store_vector_data()</pre><h3>Step 2: Implementing the “Chat with Us” System</h3><pre>import langgraph<br>from langchain.schema import HumanMessage<br>import smtplib<br><br># In-Memory Storage for Conversation History<br>conversation_memory = []<br><br># Function to Retrieve the Closest Matching Response<br>def retrieve_nearest_response(state):<br>    &quot;&quot;&quot;Finds the most relevant response using Redis vector search.&quot;&quot;&quot;<br>    user_query = state[&quot;user_input&quot;]<br>    user_vector = get_embedding(user_query)  # Convert input into embedding<br>    # Retrieve all stored vectors from Redis<br>    stored_vectors = redis_client.hgetall(&quot;vector_store&quot;)<br>    best_match = None<br>    best_similarity = -1<br>    for vector, response in stored_vectors.items():<br>        stored_vector = np.array(json.loads(vector))<br>        similarity = np.dot(user_vector, stored_vector)  # Cosine similarity<br>        if similarity &gt; best_similarity:<br>            best_match = response.decode(&quot;utf-8&quot;)<br>            best_similarity = similarity<br>    return {&quot;response&quot;: best_match or &quot;I&#39;m sorry, I don&#39;t have an answer for that.&quot;}<br><br># Function for Sentiment Analysis<br>def analyze_sentiment(state):<br>    &quot;&quot;&quot;Analyze sentiment using Ollama LLM.&quot;&quot;&quot;<br>    user_message = state[&quot;user_input&quot;]<br>    # Using Ollama for sentiment analysis<br>    sentiment_prompt = f&quot;Analyze sentiment of this message: &#39;{user_message}&#39;. Respond with &#39;positive&#39; or &#39;negative&#39; only.&quot;<br>    sentiment_response = ollama.chat(model=&quot;mistral&quot;, messages=[{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: sentiment_prompt}])<br>    sentiment = sentiment_response[&quot;message&quot;][&quot;content&quot;].strip().lower()<br>    return {&quot;sentiment&quot;: sentiment}<br><br># Memory-Enhanced Response Handling<br>def handle_positive_query(state):<br>    &quot;&quot;&quot;Uses memory to provide more personalized responses.&quot;&quot;&quot;<br>    user_query = state[&quot;user_input&quot;]<br>    retrieved_response = retrieve_nearest_response(state)[&quot;response&quot;]<br>    # Use memory to make responses more conversational<br>    conversation_memory.append({&quot;user&quot;: user_query, &quot;bot&quot;: retrieved_response})<br>    memory_text = &quot; &quot;.join([f&quot;User: {msg[&#39;user&#39;]} -&gt; Bot: {msg[&#39;bot&#39;]}&quot; for msg in conversation_memory[-3:]])  # Last 3 exchanges<br>    personalized_response = f&quot;{retrieved_response} (Context: {memory_text})&quot;<br>    return {&quot;response&quot;: personalized_response}<br><br># Email Escalation for Negative Sentiment<br>def escalate_issue(state):<br>    &quot;&quot;&quot;Send an escalation email for negative sentiment.&quot;&quot;&quot;<br>    user_message = state[&quot;user_input&quot;]<br>    print(f&quot;📧 Escalating issue: &#39;{user_message}&#39; to support team.&quot;)<br>    return {&quot;response&quot;: &quot;I&#39;m sorry to hear that. Your concern has been escalated to our support team.&quot;}<br><br># Build LangGraph Workflow<br>builder = langgraph.Graph()<br># Add nodes<br>builder.add_node(&quot;analyze_sentiment&quot;, analyze_sentiment)<br>builder.add_node(&quot;handle_positive_query&quot;, handle_positive_query)<br>builder.add_node(&quot;escalate_issue&quot;, escalate_issue)<br># Define execution flow<br>builder.set_entry_point(&quot;analyze_sentiment&quot;)<br>builder.add_conditional_edges(<br>    &quot;analyze_sentiment&quot;,<br>    lambda state: &quot;handle_positive_query&quot; if state[&quot;sentiment&quot;] == &quot;positive&quot; else &quot;escalate_issue&quot;<br>)<br>builder.add_edge(&quot;handle_positive_query&quot;, &quot;END&quot;)<br>builder.add_edge(&quot;escalate_issue&quot;, &quot;END&quot;)<br># Compile Graph<br>chat_graph = builder.compile()<br># Run Example Queries<br>test_queries = [<br>    {&quot;user_input&quot;: &quot;Tell me about LangGraph&quot;},<br>    {&quot;user_input&quot;: &quot;I am very upset with your service.&quot;},<br>    {&quot;user_input&quot;: &quot;Can you explain vector search?&quot;}<br>]<br>for query in test_queries:<br>    output = chat_graph.invoke(query)<br>    print(f&quot;\nUser Input: {query[&#39;user_input&#39;]}\nResponse: {output[&#39;response&#39;]}&quot;)</pre><h3>Expected Output</h3><pre>User Input: Tell me about LangGraph<br>Response: LangGraph is a Python library for AI workflows. (Context: User: Tell me about LangGraph -&gt; Bot: LangGraph is a Python library for AI workflows.)<br>User Input: I am very upset with your service.<br>Escalating issue: &#39;I am very upset with your service.&#39; to support team.<br>Response: I&#39;m sorry to hear that. Your concern has been escalated to our support team.<br>User Input: Can you explain vector search?<br>Response: Vector search finds the closest match using embeddings. (Context: User: Can you explain vector search? -&gt; Bot: Vector search finds the closest match using embeddings.)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9a76aa8bb09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering LangGraph: A 5-Day Journey to Building AI Agents (Day 2)]]></title>
            <link>https://medium.com/@ankitmaurya1994/mastering-langgraph-a-10-day-journey-to-building-ai-agents-day-2-e290429c497b?source=rss-f51a4359f8d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e290429c497b</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ankit Maurya]]></dc:creator>
            <pubDate>Mon, 17 Feb 2025 17:36:55 GMT</pubDate>
            <atom:updated>2025-10-04T06:00:57.385Z</atom:updated>
            <content:encoded><![CDATA[<p>On Day 1, <a href="https://medium.com/@ankitmaurya1994/mastering-langgraph-a-10-day-journey-to-building-ai-agents-day-1-29b6bd6bf742">we built our first simple LangGraph workflow</a>. Today, we extend it by adding memory to allow AI agents to remember past conversations!</p><h3>🤔 Why Do AI Agents Need Memory?</h3><p>AI agents interact with users in <strong>conversational flows</strong>. Without memory, every interaction is <strong>stateless</strong>, meaning the AI forgets what was said earlier.</p><p>With <strong>memory</strong>, we can:<br>1. Maintain <strong>context</strong> across multiple exchanges.<br>2. Improve <strong>user experience</strong> by making AI responses more coherent.<br>3. Store &amp; retrieve information <strong>efficiently</strong> using <strong>Redis</strong>.</p><p>Let’s see <strong>how LangGraph can handle memory</strong> with an example!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*cVxuXV2jEnpS7wJ4rwB15Q.jpeg" /><figcaption>LangGraph Series</figcaption></figure><h3>Step 1: Setting Up Redis Memory</h3><p>LangGraph doesn’t come with built-in memory. Instead, we use <strong>LangChain’s </strong><strong>RedisChatMessageHistory</strong> to store messages in <strong>Redis</strong>, a fast key-value store.</p><h3>Install Dependencies</h3><pre>pip install langgraph langchain redis<br><br>redis-server</pre><h3>Step 2: Storing &amp; Retrieving Messages in LangGraph</h3><p>We’ll now:<br>1. <strong>Preload memory</strong> with a stored conversation.<br>2. <strong>Store new user inputs dynamically</strong>.<br>3. <strong>Retrieve the full conversation history</strong>.</p><h3>LangGraph with Redis Memory</h3><pre>import redis<br>import langgraph<br>from langchain.memory import RedisChatMessageHistory<br>from langchain.schema import HumanMessage, AIMessage<br><br># Step 1: Connect to Redis<br>redis_client = redis.Redis(host=&quot;localhost&quot;, port=6379, decode_responses=True)<br># Step 2: Initialize Redis-backed Memory<br>memory = RedisChatMessageHistory(url=&quot;redis://localhost:6379&quot;)<br># Step 3: Preload Memory with a Sample QA Pair<br>def preload_memory():<br>    &quot;&quot;&quot;Pre-stores a QA pair in Redis memory&quot;&quot;&quot;<br>    memory.clear()  # Clear existing memory<br>    memory.add_message(HumanMessage(content=&quot;What is LangGraph?&quot;))<br>    memory.add_message(AIMessage(content=&quot;LangGraph is a framework for AI workflows.&quot;))<br>preload_memory()  # Load predefined memory<br># Step 4: Define Functions for Storing &amp; Retrieving Memory<br>def store_memory(state):<br>    &quot;&quot;&quot;Stores user input &amp; AI response in Redis&quot;&quot;&quot;<br>    user_message = state[&quot;user_input&quot;]<br>    <br>    # Store the user&#39;s message<br>    memory.add_message(HumanMessage(content=user_message))<br>    # Generate a simulated AI response<br>    ai_response = f&quot;Simulated AI response for: {user_message}&quot;<br>    memory.add_message(AIMessage(content=ai_response))<br>    return {&quot;response&quot;: ai_response}<br>def retrieve_memory(state):<br>    &quot;&quot;&quot;Retrieves stored chat history&quot;&quot;&quot;<br>    chat_history = memory.messages  # Fetch stored messages<br>    <br>    # Format response<br>    formatted_history = [f&quot;{msg.__class__.__name__}: {msg.content}&quot; for msg in chat_history]<br>    <br>    return {&quot;chat_history&quot;: formatted_history}<br># Step 5: Build LangGraph Workflow<br>builder = langgraph.Graph()<br># Add nodes<br>builder.add_node(&quot;store_memory&quot;, store_memory)<br>builder.add_node(&quot;retrieve_memory&quot;, retrieve_memory)<br># Define execution flow<br>builder.set_entry_point(&quot;store_memory&quot;)<br>builder.add_edge(&quot;store_memory&quot;, &quot;retrieve_memory&quot;)<br>builder.add_edge(&quot;retrieve_memory&quot;, &quot;END&quot;)<br># Step 6: Compile Graph<br>graph = builder.compile()<br># Step 7: Run the Workflow<br>initial_state = {&quot;user_input&quot;: &quot;Tell me about AI agents.&quot;}<br>output = graph.invoke(initial_state)<br># Step 8: Print Stored Chat History<br>print(&quot;\nStored Chat History:&quot;)<br>for entry in output[&quot;chat_history&quot;]:<br>    print(entry)</pre><h3>Step 3: Understanding the Flow</h3><h3>1. Preloading Memory</h3><p>Before we start the conversation, we <strong>store a predefined question-answer pair</strong>:</p><pre>def preload_memory():<br>    memory.clear()  # Clears Redis<br>    memory.add_message(HumanMessage(content=&quot;What is LangGraph?&quot;))<br>    memory.add_message(AIMessage(content=&quot;LangGraph is a framework for AI workflows.&quot;))</pre><p>Ensures the AI has some <strong>stored knowledge</strong> before interaction.</p><h3>2. Storing User Messages &amp; AI Responses</h3><p>Every time the user sends a message, we store:<br>1️⃣ <strong>User input (</strong><strong>HumanMessage)</strong><br>2️⃣ <strong>AI-generated response (</strong><strong>AIMessage)</strong></p><pre>def store_memory(state):<br>    user_message = state[&quot;user_input&quot;]<br>    memory.add_message(HumanMessage(content=user_message))<br><br>ai_response = f&quot;Simulated AI response for: {user_message}&quot;<br>    memory.add_message(AIMessage(content=ai_response))<br>    return {&quot;response&quot;: ai_response}</pre><p>Ensures <strong>both human &amp; AI messages</strong> are saved in Redis.</p><h3>3. Retrieving the Full Conversation</h3><p>At the end of each interaction, we retrieve all <strong>stored messages</strong>:</p><pre>def retrieve_memory(state):<br>    chat_history = memory.messages  # Fetch stored messages<br>    formatted_history = [f&quot;{msg.__class__.__name__}: {msg.content}&quot; for msg in chat_history]<br>    return {&quot;chat_history&quot;: formatted_history}</pre><p>Fetches <strong>entire conversation</strong> from Redis.</p><h3>Step 4: Expected Output</h3><p>If we run the script, we get:</p><pre>Stored Chat History:<br>HumanMessage: What is LangGraph?<br>AIMessage: LangGraph is a framework for AI workflows.<br>HumanMessage: Tell me about AI agents.<br>AIMessage: Simulated AI response for: Tell me about AI agents.</pre><p><strong>AI remembers the old conversation</strong> &amp; adds new messages dynamically!</p><h3>Summary: Key Takeaways</h3><ol><li>AI <strong>stores and remembers previous interactions</strong> in Redis.</li><li>LangGraph <strong>retrieves entire chat history</strong> for context-aware conversations.</li><li><strong>Structured memory handling</strong> improves user experience in AI agents.</li></ol><h3>Read the Full Series</h3><p><a href="https://medium.com/@ankitmaurya1994/mastering-langgraph-a-10-day-journey-to-building-ai-agents-day-1-29b6bd6bf742"><strong>Day 1: Introduction to LangGraph &amp; AI Workflows</strong></a></p><p>💡 <strong>Stay tuned for the next article in this 5-part series!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e290429c497b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering LangGraph: A 5-Day Journey to Building AI Agents (Day 1)]]></title>
            <link>https://medium.com/@ankitmaurya1994/mastering-langgraph-a-10-day-journey-to-building-ai-agents-day-1-29b6bd6bf742?source=rss-f51a4359f8d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/29b6bd6bf742</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[langgraph]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ankit Maurya]]></dc:creator>
            <pubDate>Fri, 07 Feb 2025 10:18:58 GMT</pubDate>
            <atom:updated>2025-10-04T05:42:12.355Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Welcome to Day 1 of the “Mastering LangGraph” Series!</strong></p><p>This article is the <strong>first</strong> in a 5<strong>-day series</strong> where we’ll go from the basics of LangGraph to building fully functional AI agents. Today, we kick off by understanding <strong>what LangGraph is, why it matters, and how to set up a simple AI agent</strong> using it.</p><h3>What is LangGraph?</h3><p>LangGraph extends <strong>LangChain</strong> by allowing you to structure AI applications using <strong>graph-based workflows</strong> rather than traditional sequential chains. It enables:</p><ol><li><strong>Parallel execution</strong> of multiple tasks</li><li><strong>Stateful workflows</strong> where agents retain memory</li><li><strong>Modular AI agent design</strong> using directed graphs</li><li><strong>Scalability</strong> for complex AI applications</li></ol><p>Unlike a simple sequence of function calls, LangGraph represents an AI workflow as a <strong>Directed Acyclic Graph (DAG)</strong>, where each node represents a step in processing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*cVxuXV2jEnpS7wJ4rwB15Q.jpeg" /><figcaption>LangGraph Series</figcaption></figure><h3>Setting Up Your LangGraph Environment</h3><p>Before we start building, let’s set up our development environment.</p><h4>Install Dependencies</h4><p>Run the following command to install the necessary libraries:</p><pre>pip install langchain langgraph openai</pre><h3>Building Your First LangGraph Workflow</h3><p>Let’s create a <strong>simple AI agent</strong> that: <br>1. Accepts user input<br>2. Processes it using an AI model<br>3. Returns a response</p><h4>Step 1: Import Libraries &amp; Define AI Model</h4><pre>import langgraph<br>from langchain.chat_models import ChatOpenAI<br>from langchain.schema import SystemMessage, HumanMessage<br><br># Initialize LLM (You can swap OpenAI with another model)<br>llm = ChatOpenAI(model=&quot;gpt-3.5-turbo&quot;)<br>def process_input(state):<br>    user_message = state[&quot;user_input&quot;]<br>    response = llm.invoke([<br>        SystemMessage(content=&quot;You are an AI assistant.&quot;),<br>        HumanMessage(content=user_message)<br>    ])<br>    return {&quot;response&quot;: response.content}</pre><h4>Step 2: Define Graph Workflow</h4><pre># Create a LangGraph builder<br>builder = langgraph.Graph()<br><br># Add a processing node to the graph<br>builder.add_node(&quot;process_input&quot;, process_input)<br># Define the start and end points<br>builder.set_entry_point(&quot;process_input&quot;)<br>builder.add_edge(&quot;process_input&quot;, &quot;END&quot;)<br># Compile the graph<br>graph = builder.compile()</pre><h4>Step 3: Run the Graph</h4><pre># Define initial state with user input<br>initial_state = {&quot;user_input&quot;: &quot;What is LangGraph?&quot;}<br># Execute the graph<br>output = graph.invoke(initial_state)<br>print(&quot;AI Response:&quot;, output[&quot;response&quot;])</pre><h3>Understanding the Graph Structure</h3><p>Let’s break down two key lines that define execution flow:</p><p>1. <strong>builder.set_entry_point(&quot;process_input&quot;)</strong> → This tells LangGraph to <strong>start execution</strong> at the process_inputnode.</p><p>2. <strong>builder.add_edge(&quot;process_input&quot;, &quot;END&quot;)</strong> → This defines what happens after process_input finishes. Since we connect it to END, execution stops there.</p><p>If we wanted to add another processing step, we could modify this:</p><pre>builder.add_edge(&quot;process_input&quot;, &quot;analyze_response&quot;)<br>builder.add_edge(&quot;analyze_response&quot;, &quot;END&quot;)</pre><p>This would create a workflow where LangGraph first <strong>processes the input</strong>, then <strong>analyzes the response</strong> before stopping execution.</p><h3>Expected Output</h3><p>If you run the above script, the AI should respond with:</p><pre>AI Response: LangGraph is a framework for structuring AI workflows using graphs.</pre><p>💡 <strong>Stay tuned for the next article in this 5-part series!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29b6bd6bf742" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>