<?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 Ramasamy Mohan on Medium]]></title>
        <description><![CDATA[Stories by Ramasamy Mohan on Medium]]></description>
        <link>https://medium.com/@ramasamymohan?source=rss-1cb03fe0ca6d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gxzRtmvxNVWNNSmj6bw_9w@2x.jpeg</url>
            <title>Stories by Ramasamy Mohan on Medium</title>
            <link>https://medium.com/@ramasamymohan?source=rss-1cb03fe0ca6d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 13:00:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ramasamymohan/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[Designing a Production Agentic AI System(TypeScript)]]></title>
            <link>https://medium.com/@ramasamymohan/designing-a-production-agentic-ai-system-typescript-5f1e4f7a12df?source=rss-1cb03fe0ca6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f1e4f7a12df</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[applied-ai]]></category>
            <dc:creator><![CDATA[Ramasamy Mohan]]></dc:creator>
            <pubDate>Sun, 27 Sep 2026 05:23:49 GMT</pubDate>
            <atom:updated>2026-09-27T05:23:49.345Z</atom:updated>
            <content:encoded><![CDATA[<p><em>From Prompt to Platform — Part 1</em></p><p>We’ll start with a simple LLM call and evolve the same application into a production-grade agentic system — one engineering constraint at a time.</p><blockquote><strong><em>Build: </em></strong><em>01<br></em><strong><em>System:</em></strong><em> Storefront AI<br></em><strong><em>Capability:</em></strong><em> Basic LLM Chat<br></em><strong><em>Agents:</em></strong><em> 0<br></em><strong><em>Tools:</em></strong><em> 0<br></em><strong><em>Knowledge:</em></strong><em> Model knowledge only<br></em><strong><em>State:</em></strong><em> Stateless<br></em><strong><em>Architecture Delta:</em></strong><em> + Server-Side AI API</em></blockquote><p>Most AI demos end where production engineering begins.</p><p>A few lines of code are enough to send a prompt to an LLM and get an impressive response.</p><pre>const response = await openai.responses.create({<br>  model: process.env.OPENAI_MODEL!,<br>  input: &quot;Help me find a pair of running shoes.&quot;<br>});</pre><p>It works.</p><p>We send text in.</p><p>We get intelligent-looking text back.</p><p>We have technically built an AI-powered application.</p><p>But now imagine putting that application on the website of a large online retailer.</p><p>A customer might ask:</p><blockquote><em>“Do you have this jacket in medium?”</em></blockquote><p>Another asks:</p><blockquote><em>“Where is my order?”</em></blockquote><p>Another says:</p><blockquote><em>“Can I return the headphones I bought last week?”</em></blockquote><p>And eventually:</p><blockquote><em>“My package is late. Check whether it will arrive by Friday. If not, see whether I’m eligible for a replacement.”</em></blockquote><p>To the customer, these are all messages in the same chat interface.</p><p>Architecturally, they are very different.</p><p>One requires inventory data. Another requires authenticated customer information. Another requires company policy knowledge. The last one may require multiple service calls and decisions before the system can respond.</p><p>At that point, calling an LLM is probably the easiest part.</p><p>The more interesting engineering question is:</p><blockquote><strong><em>How do we safely place an LLM inside a real production system?</em></strong></blockquote><p>That’s what this series is about.</p><h3>What we’re building</h3><p>Throughout this series, we’ll evolve a fictional e-commerce assistant called <strong>Storefront AI</strong>.</p><p>The goal isn’t simply to create a chatbot.</p><p>By the end of the series, Storefront AI should be able to understand customer requests, retrieve company knowledge, access real-time business data, use tools, perform multi-step workflows, maintain state, recover from failures, and operate with the security and observability we expect from production software.</p><p>We’ll primarily work with technologies in the TypeScript ecosystem:</p><pre>React<br>TypeScript<br>Node.js<br>Fastify<br>Zod<br>Model-provider SDKs<br>LangChain.js<br>LangGraph.js<br>PostgreSQL / pgvector<br>Redis<br>MCP</pre><p>But we won’t introduce all of them immediately.</p><p>The rule for this series is simple:</p><blockquote><strong><em>We won’t introduce technology until the system gives us a reason to need it.</em></strong></blockquote><p>No vector database just because this is an AI application.</p><p>No MCP just because MCP is popular.</p><p>No agent framework before we understand the workflow it is orchestrating.</p><p>We’ll let production requirements evolve the architecture.</p><h3>Start with the smallest useful system</h3><p>Our first requirement is straightforward:</p><blockquote><em>A customer enters a message in a React application and receives an answer from an LLM.</em></blockquote><p>The most direct implementation would be:</p><pre>React → Model Provider</pre><p>Technically, that can work.</p><p>Client-side code runs in an environment controlled by the user. A secret shipped to the browser should effectively be considered exposed.</p><p>So we introduce a server-side boundary.</p><pre>React<br>   ↓<br>Fastify API<br>   ↓<br>Model Provider</pre><p>The browser talks to <strong>our API</strong>.</p><p>Our backend talks to the model provider.</p><p>That distinction becomes the foundation for almost everything we add later.</p><h3>Architecture delta #1</h3><p><em>This will be a recurring section throughout the series.</em></p><h3>Before</h3><pre>React<br>   ↓<br>Model Provider</pre><h3>After</h3><pre>React + TypeScript<br>        ↓<br>POST /api/chat<br>        ↓<br>Fastify + TypeScript<br>        ↓<br>Zod Validation<br>        ↓<br>Provider SDK<br>        ↓<br>LLM</pre><p>The important architectural decision isn’t Fastify itself.</p><p>It’s the introduction of a <strong>server-side AI boundary</strong>.</p><p>Today, that boundary protects credentials and validates requests.</p><p>Later, it may also become responsible for authentication, authorization, streaming, retrieval, tools, agent orchestration, guardrails, tracing and cost controls.</p><p>But we don’t need those yet.</p><h3>Build it</h3><p>Let’s keep the first implementation intentionally small.</p><p>The React application sends:</p><pre>POST /api/chat</pre><p>with:</p><pre>{<br>  &quot;message&quot;: &quot;Help me find a lightweight jacket for fall.&quot;<br>}</pre><p>On the server, Fastify receives the request and Zod validates it.</p><pre>import Fastify from &quot;fastify&quot;;<br>import { z } from &quot;zod&quot;;<br>import OpenAI from &quot;openai&quot;;<br><br>const app = Fastify({<br>  logger: true,<br>});<br><br>const openai = new OpenAI({<br>  apiKey: process.env.OPENAI_API_KEY,<br>});<br><br>const ChatRequestSchema = z.object({<br>  message: z.string().min(1).max(4000),<br>});<br><br>app.post(&quot;/api/chat&quot;, async (request, reply) =&gt; {<br>  const result = ChatRequestSchema.safeParse(request.body);<br>  if (!result.success) {<br>    return reply.status(400).send({<br>      error: &quot;Invalid request&quot;,<br>    });<br>  }<br>  const response = await openai.responses.create({<br>    model: process.env.OPENAI_MODEL!,<br>    input: result.data.message,<br>  });<br>  return {<br>    message: response.output_text,<br>  };<br>});</pre><blockquote>Startup/configuration code and additional production hardening are omitted here to keep the example focused on the request path.</blockquote><p>The flow is now:</p><pre>Customer<br>   ↓<br>React<br>   ↓<br>Fastify<br>   ↓<br>Zod<br>   ↓<br>Provider SDK<br>   ↓<br>LLM<br>   ↓<br>Response</pre><p>At this point, Storefront AI can hold a very basic conversation.</p><p>Nothing agentic yet.</p><p>That’s intentional.</p><h3>Why start with the provider SDK?</h3><p>At this stage, I want the model interaction to remain easy to see.</p><p>Our backend receives a request, validates it, calls the model provider, and returns the result.</p><pre>Fastify API<br>    ↓<br>Provider SDK<br>    ↓<br>Model API</pre><p>There are libraries and frameworks that can abstract parts of this interaction for us, and we’ll introduce some of them later as the system becomes more complex.</p><p>But abstractions are most useful when we understand <strong>what they are abstracting and why we need them</strong>.</p><h3>The Model Is Not the Application</h3><p>This is one idea I want to establish early.</p><p>It’s easy to think:</p><pre>AI Application = LLM</pre><p>But production systems quickly become:</p><pre>             Application<br>                  │<br>        ┌─────────┼─────────┐<br>        ↓         ↓         ↓<br>    Knowledge    Tools      State<br>        └─────────┼─────────┘<br>                  ↓<br>                 LLM</pre><p>The LLM can provide reasoning and language capabilities.</p><p>But our application must still decide:</p><ul><li>what information the model can see,</li><li>what tools it can use,</li><li>which customer data it may access,</li><li>which actions are allowed,</li><li>how failures are handled,</li><li>and when a human should remain in control.</li></ul><p>A principle we’ll keep coming back to is:</p><blockquote><strong><em>The application controls the environment. The model helps decide what to do inside that environment.</em></strong></blockquote><p>That distinction becomes especially important once we introduce agents.</p><h3>What Breaks Next?</h3><p>Our simple chatbot works.</p><p>But try asking:</p><blockquote><em>“Where is my order?”</em></blockquote><p>The model doesn’t know.</p><p>We need access to an order service.</p><p>Ask:</p><blockquote><em>“What is your return policy for opened electronics?”</em></blockquote><p>That may require private company knowledge.</p><p>We need retrieval.</p><p>Ask:</p><blockquote><em>“Do you have this jacket in medium?”</em></blockquote><p>We need current inventory.</p><p>And ask:</p><blockquote><em>“My package is late. Check the shipment, determine whether I qualify for a replacement, and open a support case if necessary.”</em></blockquote><p>Now the system may need several steps:</p><pre>Check order<br>    ↓<br>Check shipment<br>    ↓<br>Retrieve policy<br>    ↓<br>Determine eligibility<br>    ↓<br>Possibly create case<br>    ↓<br>Respond</pre><p>That’s where our architecture will eventually start becoming agentic.</p><p>But we’ll get there one constraint at a time.</p><h3>Production Lens</h3><p><em>This will be a recurring section throughout the series.</em></p><p>Making the happy path work is not enough.</p><p>If this version of Storefront AI were going live tomorrow, I’d already be asking:</p><ul><li>What happens when the model provider times out?</li><li>Are requests rate-limited?</li><li>How are secrets managed?</li><li>Are request payloads validated?</li><li>What happens if someone sends an extremely large prompt?</li><li>How do we correlate an API request with the corresponding model call?</li><li>How do we measure latency and token usage?</li><li>What information are we logging?</li><li>Could sensitive customer data accidentally end up in those logs?</li></ul><p>We aren’t going to solve all of those in Build 1.</p><p>But production engineering starts by <strong>seeing the problems before they become incidents</strong>.</p><p>And that leads to one of the themes of this series:</p><blockquote><strong><em>Production AI engineering is still production engineering. AI introduces new failure modes; it doesn’t remove the old ones.</em></strong></blockquote><p><strong>Production question: </strong>If your team had to put this version of Storefront AI into production tomorrow,</p><blockquote><strong><em>What would you worry about first?</em></strong></blockquote><p>Security, reliability, cost, scaling, privacy, failure handling — or something I haven’t mentioned?</p><p>Add it in the comments. I’d like to bring some of those questions back into future architecture decisions as this system evolves.</p><h3>System State</h3><p>At the end of each article, we’ll take inventory of what we’ve actually built.</p><h3>Storefront AI can now</h3><pre>✓ Accept a customer message<br>✓ Route it through our server<br>✓ Validate the request<br>✓ Keep provider credentials server-side<br>✓ Call an LLM<br>✓ Return the answer</pre><h3>It cannot yet</h3><pre>✗ Stream responses<br>✗ Remember conversations<br>✗ Search product data<br>✗ Access live inventory<br>✗ Retrieve company knowledge<br>✗ Call business tools<br>✗ Perform multi-step tasks<br>✗ Recover unfinished workflows</pre><p>That list will shrink as the series progresses.</p><h3>The Next Constraint</h3><p>There’s already a problem with our implementation.</p><p>The backend waits until the model finishes generating the entire answer before returning it.</p><p>For longer responses, the customer sees nothing while the model is already working.</p><p>Instead, we want the response to appear progressively:</p><pre>I found...</pre><pre>I found three...</pre><pre>I found three jackets...</pre><pre>I found three jackets that match...</pre><p>That introduces our next capability:</p><blockquote><strong><em>Streaming</em></strong></blockquote><p>And with it, we’ll need to understand model events, text deltas, HTTP streaming, connection lifecycles and incremental UI updates.</p><h3>Next: From Prompt to Platform — Part 2</h3><h3>Streaming LLM Responses End-to-End with React, Fastify and TypeScript</h3><p>We’ll evolve:</p><pre>React → Fastify → LLM → Complete Response</pre><p>into:</p><pre>LLM<br> ↓ stream<br>Fastify<br> ↓ stream<br>React<br> ↓<br>Incremental UI</pre><p>One new constraint.</p><p>One architecture evolution.</p><p>One step closer to a production agentic system.</p><h3>From Prompt to Platform</h3><p><strong>System:</strong> Storefront AI<br><strong>Build:</strong> 01<br><strong>Capability:</strong> Basic LLM Chat<br><strong>Architecture Delta:</strong> Server-Side AI API<br><strong>Current State:</strong> Stateless<br><strong>Next Constraint:</strong> Streaming</p><p><em>AI-assisted writing note: I use AI tools throughout this series for brainstorming, research assistance, editing, diagrams and occasional code scaffolding. The architecture, engineering decisions, implementation choices, technical validation and final editorial judgment are my own.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f1e4f7a12df" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>