<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muzammil Mulla</title>
    <description>The latest articles on DEV Community by Muzammil Mulla (@muzammil_mulla_8f5efce546).</description>
    <link>https://dev.to/muzammil_mulla_8f5efce546</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3936233%2Ff6a98eae-0c23-4d6a-b092-ee817dcf1ff1.png</url>
      <title>DEV Community: Muzammil Mulla</title>
      <link>https://dev.to/muzammil_mulla_8f5efce546</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/muzammil_mulla_8f5efce546"/>
    <language>en</language>
    <item>
      <title>Behind the Scenes: Building "Captain Cool" — The Agentic Multi-Agent IPL Strategist Powered by Gemini</title>
      <dc:creator>Muzammil Mulla</dc:creator>
      <pubDate>Sun, 17 May 2026 12:53:43 +0000</pubDate>
      <link>https://dev.to/muzammil_mulla_8f5efce546/behind-the-scenes-building-captain-cool-the-agentic-multi-agent-ipl-strategist-powered-by-4oil</link>
      <guid>https://dev.to/muzammil_mulla_8f5efce546/behind-the-scenes-building-captain-cool-the-agentic-multi-agent-ipl-strategist-powered-by-4oil</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3di1cownj4bqnafqy7xj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3di1cownj4bqnafqy7xj.png" alt=" " width="474" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the Indian Premier League (IPL), a split-second decision can define the fate of a multi-million dollar franchise. Should a leg-spinner bowl the 18th over against a left-handed pinch-hitter when the dew is setting in? Should the captain invoke the "Impact Player" rule right now, or hold it back? &lt;/p&gt;

&lt;p&gt;Traditionally, captains rely on gut instinct, and analysts rely on static historical databases. But what if you could combine &lt;strong&gt;Dhoni’s calm strategic foresight&lt;/strong&gt;, &lt;strong&gt;Ricky Ponting’s aggressive counter-analyses&lt;/strong&gt;, &lt;strong&gt;real-time live match state integration&lt;/strong&gt;, and &lt;strong&gt;advanced generative AI&lt;/strong&gt; to create the ultimate virtual captain?&lt;/p&gt;

&lt;p&gt;Welcome to &lt;strong&gt;Captain Cool&lt;/strong&gt; — a state-of-the-art, multi-agent AI cricket strategist built using the Google Gemini stack and Next.js. &lt;/p&gt;




&lt;h2&gt;
  
  
  🌟 The Vision: Why "Captain Cool" Stands Out
&lt;/h2&gt;

&lt;p&gt;Most hackathon entries build either simple wrappers around LLMs or basic static data dashboards. &lt;strong&gt;Captain Cool&lt;/strong&gt; breaks this mold by introducing &lt;strong&gt;Collaborative Agentic Reasoning&lt;/strong&gt; directly into live sports analytics.&lt;/p&gt;

&lt;p&gt;Instead of asking a single AI to spit out a recommendation, Captain Cool simulates a &lt;strong&gt;high-stakes virtual dugout debate&lt;/strong&gt; between specialized AI agents before presenting a unified, bulletproof tactic:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The Stats Analyst (Data &amp;amp; Environment)&lt;/strong&gt;: Feeds live match API data and dynamically queries real-time weather and stadium dew conditions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Strategist (Dhoni Style)&lt;/strong&gt;: Formulates the calm, optimal tactical decision, prioritizing matchups and situational math.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Devil’s Advocate (Ricky Ponting Style)&lt;/strong&gt;: Forcefully challenges the plan, highlighting critical flaws, matchup anomalies, and overlooked risks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Captain Cool (Consensus Synthesizer)&lt;/strong&gt;: The final decision-maker. It digests the debate, resolves the conflicts, and delivers a structured, authoritative captain's call.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🏗️ Technical Architecture: Under the Hood
&lt;/h2&gt;

&lt;p&gt;The application is built on a highly performant, responsive stack designed to deliver instantaneous, real-time streamed responses.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;graph TD
    A[User / CricAPI Live Data] --&amp;gt;|Match Context| B[Next.js API Route]
    B --&amp;gt;|Fetch Weather| C[Open-Meteo API]
    C --&amp;gt;|Dew &amp;amp; Wind Data| D[Agent 1: Stats Analyst]
    D --&amp;gt;|Situation Brief| E[Agent 2: Strategist]
    E --&amp;gt;|DHONI-style Tactic| F[Agent 3: Devil's Advocate]
    F --&amp;gt;|PONTING-style Critique| G[Agent 4: Captain Cool]
    G --&amp;gt;|Consensus Synthesis| H[SSE Streaming Stream]
    H --&amp;gt;|Premium Glassmorphic UI| I[Client Dashboard]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1. The Collaborative Multi-Agent Loop
&lt;/h3&gt;

&lt;p&gt;The core intelligence runs inside a Next.js API route (&lt;code&gt;src/app/api/captain/route.js&lt;/code&gt;). It leverages the new &lt;code&gt;@google/genai&lt;/code&gt; SDK and utilizes &lt;code&gt;gemini-2.5-flash&lt;/code&gt; for lighting-fast generation speeds.&lt;/p&gt;

&lt;p&gt;Here is how the sequential context handoff works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Agent 1: Stats Analyst queries stadium conditions&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;analystResponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendMessage&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; 
  &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Analyze this match state and check the weather for Chennai...`&lt;/span&gt; 
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Agent 2: Strategist proposes the initial Dhoni-style plan&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;strategistPlan&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;ai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generateContent&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;gemini-2.5-flash&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;systemInstruction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;You are MS Dhoni, the master tactician...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;contents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Stats: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;analystResponse&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. Match Context: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;matchContext&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Agent 3: Devil's Advocate aggressively critiques&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;devilCritique&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;ai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generateContent&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;gemini-2.5-flash&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;systemInstruction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;You are the Devil's Advocate (Ricky Ponting style)...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;contents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Strategist proposed: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;strategistPlan&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Agent 4: Captain Cool synthesizes into a 3-part consensus&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;finalDecision&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;ai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generateContent&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;gemini-2.5-flash&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;systemInstruction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Synthesize this debate into the final captain's call...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;contents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Strategist: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;strategistPlan&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. Devil's Advocate: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;devilCritique&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Solving the "Live Data" Challenge
&lt;/h3&gt;

&lt;p&gt;Unlike static simulators, Captain Cool connects to &lt;strong&gt;CricAPI&lt;/strong&gt; to fetch actual live match data. &lt;br&gt;
Because live matches aren't always active during development hours, we engineered a brilliant &lt;strong&gt;three-step lookup pipeline&lt;/strong&gt; in &lt;code&gt;src/app/api/live-match/route.js&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Search specifically for the active IPL Series (&lt;code&gt;/v1/series?search=IPL&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Resolve the latest match from the tournament schedule (&lt;code&gt;/v1/series_info&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Fetch detailed innings-by-innings scorelines (&lt;code&gt;/v1/match_info&lt;/code&gt;) to build a perfect, up-to-the-minute tactical dataset for our agent debate loop.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  3. Server-Sent Events (SSE) Streaming
&lt;/h3&gt;

&lt;p&gt;To make the dashboard feel alive, we didn't want the user waiting 15 seconds for all four agents to finish talking. We built a custom &lt;strong&gt;ReadableStream&lt;/strong&gt; returning &lt;code&gt;text/event-stream&lt;/code&gt;. As each agent finishes their thought, it is streamed immediately to the user's dashboard, visualizing the internal dugout debate in real-time.&lt;/p&gt;


&lt;h2&gt;
  
  
  🎨 Premium Sports-Themed Glassmorphism UI
&lt;/h2&gt;

&lt;p&gt;A great algorithm deserves an equally stunning interface. We rejected boring default templates in favor of a custom, highly premium design:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Atmospheric Stadium Lights&lt;/strong&gt;: A dynamic background featuring slowly pulsing radial gradients simulating Chennai/Wankhede floodlights under the night sky.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Premium Glassmorphic Panels&lt;/strong&gt;: High-blur backdrops (&lt;code&gt;backdrop-filter: blur(16px)&lt;/code&gt;), bright top-left borders for 3D depth, and clean micro-animations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Color-Coded Agent Identities&lt;/strong&gt;: 

&lt;ul&gt;
&lt;li&gt;🔵 &lt;strong&gt;Stats Analyst&lt;/strong&gt;: Cool Data Blue&lt;/li&gt;
&lt;li&gt;🟢 &lt;strong&gt;Strategist&lt;/strong&gt;: Calm Matchup Green&lt;/li&gt;
&lt;li&gt;🔴 &lt;strong&gt;Devil's Advocate&lt;/strong&gt;: Aggressive Dissenting Red&lt;/li&gt;
&lt;li&gt;🟡 &lt;strong&gt;Captain Cool&lt;/strong&gt;: Golden Masterpiece Glow&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  📊 The Ultimate Output: What the Submission Replies With
&lt;/h2&gt;

&lt;p&gt;When you hit the &lt;strong&gt;"Generate Captain's Strategy"&lt;/strong&gt; button, the debate wraps up, and Captain Cool delivers a distinct, beautifully structured three-part response:&lt;/p&gt;
&lt;h3&gt;
  
  
  1. The Next Decision
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tactic&lt;/strong&gt;: Bring in the Left-Arm orthodox spinner from the Pavilion End. Immediately transition to a defensive 6-3 field setup on the leg side (deep mid-wicket, deep square leg, long-on back). Keep the Impact Player (pinch-hitting opener) padded up in the dugout.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  2. The Reasoning
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Look, the data shows the dew is settling in fast, making the ball like a cake of soap. However, we've got a fresh right-handed batter who struggles immensely when forced to hit against the spin on a gripping pitch. Bringing the spinner now forces him to hit into the wind toward the longer boundary. It’s about squeezing the run rate, not just chasing wickets."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  3. What the Dissenting Agent Said
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;\"The Devil's Advocate strongly argued that exposing a spinner during heavy dew is suicide, as wet balls lead to full tosses and easy boundary balls. They suggested sticking to hard-length pace bowling. However, we have overridden this warning because the batter's negative matchup index against left-arm spin (-35%) outweighs the wet ball risk if we instruct the bowler to bowl slightly flatter through the air.\"&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  🚀 Impact &amp;amp; Future Scope
&lt;/h2&gt;

&lt;p&gt;Captain Cool is more than a hackathon proof-of-concept. It represents the future of real-time sports broadcasting and tactical coaching:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Interactive Live Broadcasts&lt;/strong&gt;: Imagine streaming platforms (like JioCinema or Hotstar) letting viewers click a button to see what "Captain Cool" would do right now during a live match.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smart Coaching Systems&lt;/strong&gt;: Local clubs and academy teams can input their current scorecard to receive elite, professional-level tactical debates on how to turn the game around.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Voice-Activated Strategy&lt;/strong&gt;: Integrating speech-to-text to let a physical captain discuss scenarios with the dugout assistant on the field.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  🛠️ How to Run Locally
&lt;/h2&gt;

&lt;p&gt;Get the dugout running on your machine in under 3 minutes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Clone the repository&lt;/span&gt;
git clone https://github.com/your-username/captain-cool.git
&lt;span class="nb"&gt;cd &lt;/span&gt;captain-cool

&lt;span class="c"&gt;# 2. Install dependencies&lt;/span&gt;
npm &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# 3. Create your .env.local file&lt;/span&gt;
&lt;span class="nv"&gt;CRIC_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your_cricapi_key
&lt;span class="nv"&gt;GEMINI_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your_gemini_api_key

&lt;span class="c"&gt;# 4. Spin up the development server&lt;/span&gt;
npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;code&gt;http://localhost:3000&lt;/code&gt; and start captaining your team!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Developed with ❤️ for the Google Gemini Developer Hackathon. Elevate your sports strategy today with Captain Cool!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a class="mentioned-user" href="https://dev.to/gdgcmu"&gt;@gdgcmu&lt;/a&gt; #gdgcloudpune #&lt;/p&gt;

</description>
      <category>gdgcloudpune</category>
      <category>gdg</category>
    </item>
  </channel>
</rss>
