<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hitesh</title>
    <description>The latest articles on DEV Community by Hitesh (@hiteshchawla).</description>
    <link>https://dev.to/hiteshchawla</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%2F1244059%2Fffee9d5a-c125-4f3a-8fbc-1756d1267222.webp</url>
      <title>DEV Community: Hitesh</title>
      <link>https://dev.to/hiteshchawla</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hiteshchawla"/>
    <language>en</language>
    <item>
      <title>Understand it before you get late</title>
      <dc:creator>Hitesh</dc:creator>
      <pubDate>Tue, 24 Feb 2026 12:02:46 +0000</pubDate>
      <link>https://dev.to/hiteshchawla/understand-it-before-you-get-late-2aaj</link>
      <guid>https://dev.to/hiteshchawla/understand-it-before-you-get-late-2aaj</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/hiteshchawla" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F1244059%2Fffee9d5a-c125-4f3a-8fbc-1756d1267222.webp" alt="hiteshchawla"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/hiteshchawla/how-claude-multi-agents-work-5c0" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;How Claude Multi-Agents work&lt;/h2&gt;
      &lt;h3&gt;Hitesh ・ Feb 24&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#claude&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#python&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#programming&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#productivity&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>claude</category>
      <category>python</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How Claude Multi-Agents work</title>
      <dc:creator>Hitesh</dc:creator>
      <pubDate>Tue, 24 Feb 2026 12:00:09 +0000</pubDate>
      <link>https://dev.to/hiteshchawla/how-claude-multi-agents-work-5c0</link>
      <guid>https://dev.to/hiteshchawla/how-claude-multi-agents-work-5c0</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%2Fwne958g82afyij6w534g.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%2Fwne958g82afyij6w534g.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Multi-agent systems on Claude work by having multiple AI instances collaborate, each handling specialized tasks, with results passed between them to complete complex workflows.&lt;/p&gt;

&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Orchestrator + Subagents pattern&lt;/strong&gt; is the most common approach. One Claude instance acts as the "orchestrator" that breaks down a complex task and delegates subtasks to specialized "subagent" Claude instances. Each subagent focuses on one thing, returns results, and the orchestrator synthesizes everything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Communication happens through context&lt;/strong&gt; — agents don't share memory directly. They pass information via:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tool call results&lt;/li&gt;
&lt;li&gt;Structured outputs (JSON, XML)&lt;/li&gt;
&lt;li&gt;Conversation history passed into new API calls&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Each agent is stateless&lt;/strong&gt; — every Claude instance only knows what's in its current context window. So orchestration logic must explicitly carry state forward.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Patterns
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Sequential pipelines&lt;/strong&gt; — Agent A's output becomes Agent B's input. Good for: extract → transform → summarize workflows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parallel execution&lt;/strong&gt; — Multiple agents run simultaneously on different subtasks, then results are merged. Good for: analyzing multiple data sources at once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hierarchical&lt;/strong&gt; — Orchestrator → sub-orchestrators → workers. Good for very complex tasks needing multiple layers of decomposition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Critic/reviewer loop&lt;/strong&gt; — One agent generates, another reviews/critiques, repeat until quality threshold is met.&lt;/p&gt;

&lt;h2&gt;
  
  
  In Practice with the API
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Orchestrator call&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;plan&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;anthropic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&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="s2"&gt;claude-sonnet-4-6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;system&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 an orchestrator. Break the task into subtasks and return JSON.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;userTask&lt;/span&gt; &lt;span class="p"&gt;}]&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Subagent calls (can be parallelized)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;subtasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;task&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="nx"&gt;anthropic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&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="s2"&gt;claude-haiku-4-5-20251001&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// cheaper model for subtasks&lt;/span&gt;
    &lt;span class="na"&gt;system&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 a specialist agent for...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;task&lt;/span&gt; &lt;span class="p"&gt;}]&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;// Synthesize&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;final&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;anthropic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&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="s2"&gt;claude-sonnet-4-6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Synthesize these results: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;results&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="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>claude</category>
      <category>python</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Kafka interview questions for Data Engineer</title>
      <dc:creator>Hitesh</dc:creator>
      <pubDate>Fri, 09 Jan 2026 11:34:30 +0000</pubDate>
      <link>https://dev.to/hiteshchawla/kafka-interview-questions-for-data-engineer-8oh</link>
      <guid>https://dev.to/hiteshchawla/kafka-interview-questions-for-data-engineer-8oh</guid>
      <description>&lt;p&gt;Here are &lt;strong&gt;Kafka interview questions&lt;/strong&gt; tailored for &lt;strong&gt;AI / Backend / Data Engineer (0–3 yrs)&lt;/strong&gt; roles, with &lt;strong&gt;clear, crisp answers&lt;/strong&gt; you can revise quickly.&lt;br&gt;
I’ve grouped them by &lt;strong&gt;difficulty &amp;amp; topic&lt;/strong&gt;, exactly how interviews flow.&lt;/p&gt;




&lt;h1&gt;
  
  
  1️⃣ Kafka Basics (Must-Know)
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Q1. What is Kafka?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
Kafka is a &lt;strong&gt;distributed event-streaming platform&lt;/strong&gt; used for publishing, storing, and consuming streams of records in real time. It is designed for &lt;strong&gt;high throughput, fault tolerance, and scalability&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q2. Kafka vs traditional message queue?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Kafka&lt;/th&gt;
&lt;th&gt;Message Queue&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pull-based&lt;/td&gt;
&lt;td&gt;Push-based&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Persistent logs&lt;/td&gt;
&lt;td&gt;Messages deleted after consume&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multiple consumers&lt;/td&gt;
&lt;td&gt;Usually single consumer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Replay supported&lt;/td&gt;
&lt;td&gt;Replay difficult&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  Q3. What is a topic?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
A topic is a &lt;strong&gt;logical stream of messages&lt;/strong&gt; where data is written and read.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q4. What is a partition?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
A partition is a &lt;strong&gt;unit of parallelism&lt;/strong&gt; in Kafka. Each partition is an &lt;strong&gt;ordered, immutable log&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q5. Why partitions matter?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
They enable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Parallel processing&lt;/li&gt;
&lt;li&gt;Horizontal scalability&lt;/li&gt;
&lt;li&gt;Ordered processing per partition&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  2️⃣ Producers &amp;amp; Consumers
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Q6. What is a Kafka producer?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
A producer publishes records to Kafka topics.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q7. How does Kafka decide which partition to write to?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Key provided → hash(key) % partitions&lt;/li&gt;
&lt;li&gt;No key → round-robin&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Q8. What is a Kafka consumer?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
A consumer reads records from topics.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q9. What is a consumer group?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
A consumer group is a set of consumers that &lt;strong&gt;share the load&lt;/strong&gt; of reading partitions.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;One partition → one consumer within a group&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Q10. What happens if consumers &amp;gt; partitions?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
Extra consumers stay &lt;strong&gt;idle&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  3️⃣ Offsets &amp;amp; Delivery Semantics
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Q11. What is an offset?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
An offset is a &lt;strong&gt;unique position&lt;/strong&gt; of a record in a partition.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q12. How does Kafka track offsets?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
Offsets are stored in Kafka’s internal topic: &lt;code&gt;__consumer_offsets&lt;/code&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q13. At-least-once vs At-most-once?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;At-least-once:&lt;/strong&gt; no data loss, duplicates possible&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;At-most-once:&lt;/strong&gt; no duplicates, data loss possible&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Q14. Does Kafka support exactly-once?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
Yes, using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Idempotent producers&lt;/li&gt;
&lt;li&gt;Transactions&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  4️⃣ Fault Tolerance &amp;amp; Replication
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Q15. What is a broker?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
A broker is a Kafka server that stores and serves data.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q16. What is replication factor?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
Number of copies of a partition across brokers.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q17. What is leader and follower?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Leader:&lt;/strong&gt; handles reads/writes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Follower:&lt;/strong&gt; replicates leader data&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Q18. What happens if leader fails?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
A follower is automatically elected as the new leader.&lt;/p&gt;




&lt;h1&gt;
  
  
  5️⃣ Performance &amp;amp; Reliability
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Q19. Why is Kafka fast?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sequential disk writes&lt;/li&gt;
&lt;li&gt;Zero-copy transfer&lt;/li&gt;
&lt;li&gt;Batching&lt;/li&gt;
&lt;li&gt;Page cache usage&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Q20. What is ISR?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
ISR (In-Sync Replicas) are replicas fully caught up with the leader.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q21. What is &lt;code&gt;acks&lt;/code&gt; in producer?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;acks=0&lt;/code&gt; → no guarantee&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;acks=1&lt;/code&gt; → leader only&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;acks=all&lt;/code&gt; → leader + replicas&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  6️⃣ Real-World Scenarios (Very Important)
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Q22. How do you ensure message ordering?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
Use the &lt;strong&gt;same key&lt;/strong&gt; so messages go to the same partition.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q23. How to handle duplicate messages?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Idempotent consumers&lt;/li&gt;
&lt;li&gt;Deduplication using unique IDs&lt;/li&gt;
&lt;li&gt;Exactly-once semantics&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Q24. How to reprocess old data?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
Reset consumer offsets to an earlier value.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q25. Kafka vs RabbitMQ?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Kafka → high throughput, replay, streaming&lt;/li&gt;
&lt;li&gt;RabbitMQ → low latency, task queues&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  7️⃣ Kafka + Data Engineering / AI
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Q26. Kafka in ETL pipelines?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
Kafka acts as a &lt;strong&gt;buffer and ingestion layer&lt;/strong&gt; between producers and downstream ETL systems.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q27. Kafka with Spark / Flink?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
Kafka provides real-time data streams; Spark/Flink process them.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q28. Kafka for ML pipelines?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
Used for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Real-time feature ingestion&lt;/li&gt;
&lt;li&gt;Streaming inference&lt;/li&gt;
&lt;li&gt;Online model updates&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  8️⃣ Configuration &amp;amp; Monitoring
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Q29. How do you monitor Kafka?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lag&lt;/li&gt;
&lt;li&gt;Throughput&lt;/li&gt;
&lt;li&gt;Broker health&lt;/li&gt;
&lt;li&gt;Consumer offsets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prometheus + Grafana&lt;/li&gt;
&lt;li&gt;CloudWatch (MSK)&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Q30. What is consumer lag?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
Difference between latest offset and consumer offset.&lt;/p&gt;




&lt;h1&gt;
  
  
  9️⃣ Advanced (Bonus)
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Q31. What is log compaction?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
Kafka keeps the &lt;strong&gt;latest record per key&lt;/strong&gt;, deleting older ones.&lt;/p&gt;




&lt;h3&gt;
  
  
  Q32. What is retention policy?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time-based&lt;/li&gt;
&lt;li&gt;Size-based&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Q33. Schema Registry?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
Manages schema evolution for messages (Avro/Protobuf).&lt;/p&gt;




&lt;h1&gt;
  
  
  🔥 5 One-Line Interview Killers
&lt;/h1&gt;

&lt;p&gt;Memorize these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“Kafka is a distributed commit log.”&lt;/li&gt;
&lt;li&gt;“Partitions give scalability; keys give ordering.”&lt;/li&gt;
&lt;li&gt;“Offsets enable replayability.”&lt;/li&gt;
&lt;li&gt;“Consumer groups provide horizontal scaling.”&lt;/li&gt;
&lt;li&gt;“Exactly-once requires idempotent producers and transactions.”&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  🎯 How to Answer Like a Pro
&lt;/h1&gt;

&lt;p&gt;When stuck, say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“In production, the choice depends on throughput, ordering, and replay requirements.”&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>kafka</category>
      <category>data</category>
      <category>python</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Create MCP into an existing FastAPI backend</title>
      <dc:creator>Hitesh</dc:creator>
      <pubDate>Thu, 08 Jan 2026 08:30:46 +0000</pubDate>
      <link>https://dev.to/hiteshchawla/create-mcp-into-an-existing-fastapi-backend-3onp</link>
      <guid>https://dev.to/hiteshchawla/create-mcp-into-an-existing-fastapi-backend-3onp</guid>
      <description>&lt;p&gt;You can absolutely integrate MCP into an existing FastAPI backend. There are two primary ways to do this depending on how much control you want over which routes are exposed.&lt;/p&gt;

&lt;p&gt;The most common tool for this is the &lt;strong&gt;&lt;code&gt;fastapi-mcp&lt;/code&gt;&lt;/strong&gt; library (or the similar &lt;code&gt;fastmcp&lt;/code&gt; utility), which acts as a bridge to turn your REST endpoints into "tools" that AI agents can call.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option 1: Using &lt;code&gt;fastapi-mcp&lt;/code&gt; (Best for existing apps)
&lt;/h3&gt;

&lt;p&gt;This library is designed to sit on top of your existing FastAPI app. It inspects your routes and automatically generates the MCP schema.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Install the package:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;fastapi-mcp uvicorn

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Integration Code:&lt;/strong&gt;&lt;br&gt;
You only need to add a few lines to your &lt;code&gt;main.py&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FastAPI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi_mcp&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FastApiMCP&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;My Existing Backend&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Your existing routes
&lt;/span&gt;&lt;span class="nd"&gt;@app.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/items/{item_id}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;read_item&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;item_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;item_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Sample Item&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Initialize MCP and "mount" it to your app
&lt;/span&gt;&lt;span class="n"&gt;mcp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastApiMCP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;My Business Tools&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;base_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://localhost:8000&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;mcp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# This creates a /mcp endpoint automatically
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Option 2: Using &lt;code&gt;FastMCP.from_fastapi&lt;/code&gt; (Official SDK style)
&lt;/h3&gt;

&lt;p&gt;If you are using the official &lt;code&gt;mcp&lt;/code&gt; Python SDK, it includes a &lt;code&gt;FastMCP&lt;/code&gt; class that can wrap a FastAPI app directly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastmcp&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FastMCP&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;my_app&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="c1"&gt;# Import your existing FastAPI instance
&lt;/span&gt;
&lt;span class="c1"&gt;# Convert the entire FastAPI app to an MCP server
&lt;/span&gt;&lt;span class="n"&gt;mcp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;FastMCP&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_fastapi&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;mcp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Key Technical Details
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Automatic Tool Mapping:&lt;/strong&gt; By default, these libraries convert your &lt;code&gt;POST&lt;/code&gt;, &lt;code&gt;PUT&lt;/code&gt;, and &lt;code&gt;DELETE&lt;/code&gt; requests into &lt;strong&gt;Tools&lt;/strong&gt; and your &lt;code&gt;GET&lt;/code&gt; requests into &lt;strong&gt;Resources&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SSE Transport:&lt;/strong&gt; FastAPI-based MCP servers typically use &lt;strong&gt;Server-Sent Events (SSE)&lt;/strong&gt;. This is ideal because it runs over standard HTTP, meaning you don't need a separate process or complex setup for your AI to talk to your backend.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Filtering Routes:&lt;/strong&gt; You likely don't want to expose every internal endpoint. You can use the &lt;code&gt;include_operations&lt;/code&gt; or &lt;code&gt;exclude_operations&lt;/code&gt; arguments to control exactly what the AI sees:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;mcp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastApiMCP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;include_operations&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;get_user_info&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;process_order&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to use it in your AI Tool (Cursor, Claude, etc.)
&lt;/h3&gt;

&lt;p&gt;Once your server is running (e.g., at &lt;code&gt;http://localhost:8000&lt;/code&gt;), you connect your AI agent using the SSE URL:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Endpoint:&lt;/strong&gt; &lt;code&gt;http://localhost:8000/mcp&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Type:&lt;/strong&gt; SSE&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>fastapi</category>
      <category>mcp</category>
      <category>rag</category>
    </item>
    <item>
      <title>How LLM use MCPs?</title>
      <dc:creator>Hitesh</dc:creator>
      <pubDate>Thu, 08 Jan 2026 07:09:13 +0000</pubDate>
      <link>https://dev.to/hiteshchawla/how-llm-use-mcps-4mp2</link>
      <guid>https://dev.to/hiteshchawla/how-llm-use-mcps-4mp2</guid>
      <description>&lt;p&gt;To understand how a Large Language Model (LLM) knows what is in a Model Context Protocol (MCP) server, it helps to think of the LLM not as a person who "knows" things, but as a chef who is handed a &lt;strong&gt;menu&lt;/strong&gt; right before they start cooking.&lt;/p&gt;

&lt;p&gt;The LLM doesn't actually "know" the MCP exists until the moment you send a message. Here is the step-by-step breakdown of how that discovery happens:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The "Handshake" (Discovery)
&lt;/h3&gt;

&lt;p&gt;When you start a session in an MCP-enabled application (like Claude Desktop or Cursor), the &lt;strong&gt;MCP Client&lt;/strong&gt; (the app) talks to the &lt;strong&gt;MCP Server&lt;/strong&gt; (the tool) behind the scenes using a standard request called &lt;code&gt;tools/list&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The server replies with a list of every tool it has.&lt;/li&gt;
&lt;li&gt;For each tool, it provides a &lt;strong&gt;Name&lt;/strong&gt;, a &lt;strong&gt;Description&lt;/strong&gt;, and a &lt;strong&gt;JSON Schema&lt;/strong&gt; (the specific arguments it needs).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. The Context Injection
&lt;/h3&gt;

&lt;p&gt;This is the "aha!" moment. The MCP Client takes that list of tools and &lt;strong&gt;injects it directly into the LLM's prompt context&lt;/strong&gt; (usually in the system instructions).&lt;/p&gt;

&lt;p&gt;When the LLM receives your message, it also sees a hidden block of text that looks like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"You have access to the following tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;get_weather&lt;/code&gt;: Get current weather. Parameters: &lt;code&gt;location&lt;/code&gt; (string).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;query_postgres&lt;/code&gt;: Run SQL on the DB. Parameters: &lt;code&gt;query&lt;/code&gt; (string)."&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  3. Intent Matching
&lt;/h3&gt;

&lt;p&gt;When you ask, &lt;em&gt;"What's the weather in Tokyo?"&lt;/em&gt;, the LLM doesn't "run" the tool. Instead, it looks at its instructions and realizes: &lt;em&gt;"I don't know the weather, but I see a tool called &lt;code&gt;get_weather&lt;/code&gt; that matches this intent."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Because the LLM is trained to follow "Tool Use" or "Function Calling" patterns, it stops generating regular text and instead outputs a structured snippet:&lt;br&gt;
&lt;code&gt;{ "call": "get_weather", "args": { "location": "Tokyo" } }&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The Execution Loop
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The Client&lt;/strong&gt; sees this snippet in the LLM's output.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Client&lt;/strong&gt; pauses the LLM and sends that specific request to the &lt;strong&gt;MCP Server&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Server&lt;/strong&gt; runs the actual code and sends the result back to the Client.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Client&lt;/strong&gt; feeds that result back to the LLM.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The LLM&lt;/strong&gt; reads the result and finally gives you the answer: &lt;em&gt;"The weather in Tokyo is 15°C and sunny."&lt;/em&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>mcp</category>
      <category>rag</category>
      <category>llm</category>
      <category>fastapi</category>
    </item>
    <item>
      <title>Understanding Polygons and `ST_` Functions in PostGIS</title>
      <dc:creator>Hitesh</dc:creator>
      <pubDate>Wed, 28 May 2025 07:49:25 +0000</pubDate>
      <link>https://dev.to/hiteshchawla/understanding-polygons-and-st-functions-in-postgis-2o2j</link>
      <guid>https://dev.to/hiteshchawla/understanding-polygons-and-st-functions-in-postgis-2o2j</guid>
      <description>&lt;p&gt;PostGIS is a powerful spatial extension for PostgreSQL that allows you to store, query, and manipulate geographic objects. If you're working with maps, geometry, or location-based data, PostGIS is an essential tool. In this article, we’ll explore what a &lt;strong&gt;polygon&lt;/strong&gt; is in PostGIS, what the parameters in a polygon definition mean, and the role of &lt;code&gt;ST_&lt;/code&gt; functions in spatial queries.&lt;/p&gt;




&lt;h3&gt;
  
  
  🧱 What is a Polygon in PostGIS?
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;polygon&lt;/strong&gt; in PostGIS is a two-dimensional geometric object that represents an &lt;strong&gt;enclosed area&lt;/strong&gt; defined by one or more rings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;outer ring&lt;/strong&gt; defines the exterior boundary.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inner rings&lt;/strong&gt; (optional) define holes within the polygon.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each ring is made up of &lt;strong&gt;at least four coordinate points&lt;/strong&gt;, and the first and last point must be the same to form a closed loop.&lt;/p&gt;




&lt;h3&gt;
  
  
  📐 Example: Creating a Polygon
&lt;/h3&gt;

&lt;p&gt;Consider the following SQL query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;ST_GeomFromText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This uses &lt;strong&gt;WKT (Well-Known Text)&lt;/strong&gt; format to define a simple square polygon.&lt;/p&gt;

&lt;h4&gt;
  
  
  Breaking down the parameters:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Point&lt;/th&gt;
&lt;th&gt;Coordinates&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0 0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Bottom-left corner (starting point)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0 5&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Top-left corner&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;&lt;code&gt;5 5&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Top-right corner&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;&lt;code&gt;5 0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Bottom-right corner&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0 0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Closes the polygon (must match point 1)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This creates a square with sides of 5 units.&lt;/p&gt;




&lt;h3&gt;
  
  
  🧭 What Does &lt;code&gt;ST_&lt;/code&gt; Mean in PostGIS?
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;ST_&lt;/code&gt; prefix stands for &lt;strong&gt;"Spatial Type"&lt;/strong&gt; and is used for all spatial functions in PostGIS. It follows standards defined by the &lt;strong&gt;Open Geospatial Consortium (OGC)&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Why use &lt;code&gt;ST_&lt;/code&gt;?
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;To &lt;strong&gt;clearly distinguish&lt;/strong&gt; spatial functions from regular SQL functions.&lt;/li&gt;
&lt;li&gt;To comply with OGC naming conventions.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🛠️ Common &lt;code&gt;ST_&lt;/code&gt; Functions
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ST_GeomFromText()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Converts WKT into a PostGIS geometry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ST_AsText()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Converts geometry back to WKT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ST_Area()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Calculates the area of a polygon&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ST_Length()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Measures the length of a linestring&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ST_Intersects()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Checks if two geometries intersect&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ST_Contains()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Tests whether one geometry completely contains another&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ST_Buffer()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Expands a geometry outward by a given distance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ST_Distance()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Measures the distance between two geometries&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  🧪 Example Usage
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Create a polygon from WKT&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;ST_GeomFromText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;-- Compute the area&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;ST_Area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ST_GeomFromText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example returns &lt;code&gt;25&lt;/code&gt;, the area of the 5×5 square.&lt;/p&gt;




&lt;h3&gt;
  
  
  📦 Summary
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;polygon&lt;/strong&gt; in PostGIS is a closed shape defined by coordinate points.&lt;/li&gt;
&lt;li&gt;The parameters in &lt;code&gt;'POLYGON((x y, x y, ..., x y))'&lt;/code&gt; represent the vertices.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;ST_&lt;/code&gt; prefix identifies spatial functions that handle geometry or geography types.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Whether you're building map-based applications or analyzing spatial data, understanding how polygons and &lt;code&gt;ST_&lt;/code&gt; functions work is key to leveraging the full power of PostGIS.&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>interview</category>
      <category>python</category>
      <category>programming</category>
    </item>
    <item>
      <title>Fast API Request Handling</title>
      <dc:creator>Hitesh</dc:creator>
      <pubDate>Mon, 19 May 2025 08:08:05 +0000</pubDate>
      <link>https://dev.to/hiteshchawla/fast-api-request-handling-39be</link>
      <guid>https://dev.to/hiteshchawla/fast-api-request-handling-39be</guid>
      <description>&lt;p&gt;In &lt;strong&gt;FastAPI&lt;/strong&gt;, how route handlers (endpoints) behave in terms of &lt;strong&gt;parallelism&lt;/strong&gt; and &lt;strong&gt;concurrency&lt;/strong&gt; depends on whether they are defined using &lt;code&gt;async def&lt;/code&gt; or &lt;code&gt;def&lt;/code&gt;, and whether the work inside them is &lt;strong&gt;I/O-bound&lt;/strong&gt; or &lt;strong&gt;CPU-bound&lt;/strong&gt;.&lt;/p&gt;

&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%2Fgodjq88uibpljrjaonh5.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%2Fgodjq88uibpljrjaonh5.png" alt=" " width="800" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are the &lt;strong&gt;four combinations&lt;/strong&gt; of route handlers and how they affect parallel or concurrent handling of requests:&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ 1. &lt;code&gt;async def&lt;/code&gt; with &lt;strong&gt;async I/O-bound work&lt;/strong&gt; (e.g., &lt;code&gt;await asyncio.sleep&lt;/code&gt;, database calls)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@router.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/async-io&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;async_io_route&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;status&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;async io&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Handled concurrently&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Non-blocking — multiple such requests can be handled at the same time.&lt;/li&gt;
&lt;li&gt;Best performance for I/O tasks like DB queries, network calls, file access.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  ✅ 2. &lt;code&gt;async def&lt;/code&gt; with &lt;strong&gt;CPU-bound work&lt;/strong&gt; (e.g., heavy computation, no &lt;code&gt;await&lt;/code&gt;)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@router.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/async-cpu&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;async_cpu_route&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;result&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Not truly concurrent&lt;/strong&gt; for CPU-bound work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blocks the event loop&lt;/strong&gt; — slows down other async endpoints.&lt;/li&gt;
&lt;li&gt;BAD practice — use a thread pool for CPU-bound tasks instead.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  ✅ 3. &lt;code&gt;def&lt;/code&gt; with &lt;strong&gt;CPU-bound work&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@router.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/sync-cpu&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sync_cpu_route&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;result&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Parallel execution&lt;/strong&gt; via &lt;strong&gt;thread pool executor&lt;/strong&gt; (Starlette/FastAPI handles this).&lt;/li&gt;
&lt;li&gt;Slower than async I/O but doesn't block the event loop.&lt;/li&gt;
&lt;li&gt;Suitable for CPU-bound work when properly limited.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  ✅ 4. &lt;code&gt;def&lt;/code&gt; with &lt;strong&gt;I/O-bound work&lt;/strong&gt; (e.g., time.sleep)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@router.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/sync-io&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sync_io_route&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;status&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sync io&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Blocks thread&lt;/strong&gt; and wastes resources.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not concurrent nor parallel&lt;/strong&gt; in a performant way.&lt;/li&gt;
&lt;li&gt;Worst option — avoid using blocking I/O in sync routes.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Summary Table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Route Type&lt;/th&gt;
&lt;th&gt;I/O Type&lt;/th&gt;
&lt;th&gt;Concurrent?&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;async def&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Async I/O&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;Best option for scalable I/O-bound endpoints&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;async def&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;CPU-bound&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;Blocks the event loop — BAD&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;def&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;CPU-bound&lt;/td&gt;
&lt;td&gt;✅ Parallel&lt;/td&gt;
&lt;td&gt;Runs in thread pool — acceptable for CPU tasks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;def&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Blocking I/O&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;Blocks threads — worst case, avoid&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;blockquote&gt;
&lt;p&gt;✅ &lt;strong&gt;Best Practices&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;async def&lt;/code&gt; + &lt;code&gt;await&lt;/code&gt; for I/O-bound operations.&lt;/li&gt;
&lt;li&gt;Offload CPU-heavy operations to a thread/process pool (e.g., &lt;code&gt;run_in_executor()&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Avoid blocking operations like &lt;code&gt;time.sleep()&lt;/code&gt; in FastAPI routes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s a clear and concise table showing different &lt;strong&gt;FastAPI route types&lt;/strong&gt;, the &lt;strong&gt;kind of operation&lt;/strong&gt; they perform, and whether the request handling is &lt;strong&gt;parallel&lt;/strong&gt; or &lt;strong&gt;concurrent&lt;/strong&gt;:&lt;/p&gt;




&lt;h3&gt;
  
  
  🧩 FastAPI Route Behavior Comparison
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Route Type&lt;/th&gt;
&lt;th&gt;Operation Type&lt;/th&gt;
&lt;th&gt;Example Code Snippet&lt;/th&gt;
&lt;th&gt;Behavior&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;async def&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Async I/O-bound&lt;/td&gt;
&lt;td&gt;&lt;code&gt;await asyncio.sleep(1)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅ Concurrent&lt;/td&gt;
&lt;td&gt;Best for DB queries, API calls, file I/O, etc.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;async def&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;CPU-bound&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sum(i * i for i in range(10**7))&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;❌ Blocking&lt;/td&gt;
&lt;td&gt;Blocks event loop – BAD pattern&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;async def&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;CPU-bound (offload)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;await loop.run_in_executor(None, cpu_task)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅ Parallel&lt;/td&gt;
&lt;td&gt;Offloads to thread pool – does not block event loop&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;async def&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;CPU-bound (multi-core)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;run_in_executor(ProcessPool, cpu_task)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅✅ True Parallel&lt;/td&gt;
&lt;td&gt;Uses multiple CPU cores – best for heavy computations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;def&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;CPU-bound&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sum(i * i for i in range(10**7))&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅ Parallel&lt;/td&gt;
&lt;td&gt;Runs in thread pool – doesn't block event loop&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;def&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Blocking I/O&lt;/td&gt;
&lt;td&gt;&lt;code&gt;time.sleep(2)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;❌ Blocking&lt;/td&gt;
&lt;td&gt;Wastes threads – avoid blocking I/O in sync functions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  ✅ Legend
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Concurrent&lt;/strong&gt;: Multiple tasks share the same thread (async I/O).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parallel&lt;/strong&gt;: Tasks run in separate threads or processes simultaneously.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blocking&lt;/strong&gt;: One task prevents others from proceeding.&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>fastapi</category>
      <category>python</category>
      <category>interview</category>
      <category>backend</category>
    </item>
    <item>
      <title>How to train LLM faster</title>
      <dc:creator>Hitesh</dc:creator>
      <pubDate>Mon, 28 Apr 2025 05:24:49 +0000</pubDate>
      <link>https://dev.to/hiteshchawla/how-to-train-llm-faster-pa2</link>
      <guid>https://dev.to/hiteshchawla/how-to-train-llm-faster-pa2</guid>
      <description>&lt;p&gt;RAG is an architecture where an LLM (Large Language Model) is not asked to answer purely from its own parameters but is given &lt;strong&gt;external information&lt;/strong&gt; &lt;em&gt;at runtime&lt;/em&gt; to use while answering.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Goal&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduce hallucination.&lt;/li&gt;
&lt;li&gt;Answer based on &lt;strong&gt;updated, private, or niche data&lt;/strong&gt; without re-training the model.&lt;/li&gt;
&lt;/ul&gt;

&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%2Fhw676fnqal7ytxyxqwv0.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%2Fhw676fnqal7ytxyxqwv0.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;strong&gt;Breaking Down RAG — Technical View&lt;/strong&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. &lt;strong&gt;Retriever&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Input&lt;/strong&gt;: A user query (like "What are the side effects of aspirin?")&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Goal&lt;/strong&gt;: Find the most relevant information from an &lt;strong&gt;external knowledge source&lt;/strong&gt; (documents, database, etc.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;The user query is first passed through an &lt;strong&gt;embedding model&lt;/strong&gt; (like OpenAI &lt;code&gt;text-embedding-ada-002&lt;/code&gt;) that turns the text into a &lt;strong&gt;high-dimensional vector&lt;/strong&gt; (like a list of 1536 numbers).&lt;/li&gt;
&lt;li&gt;Stored documents are &lt;strong&gt;already embedded&lt;/strong&gt; beforehand into the same vector space.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;vector similarity search&lt;/strong&gt; (cosine similarity, Euclidean distance, etc.) to find top &lt;code&gt;k&lt;/code&gt; nearest documents.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;This is exactly like "nearest neighbors search" but in &lt;strong&gt;high-dimensional space&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;📚 &lt;strong&gt;Key Tech Terminologies&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Embedding&lt;/strong&gt;: Mapping text into numerical vectors capturing semantic meaning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vector Database&lt;/strong&gt;: Special database optimized for fast nearest-neighbor search (e.g., FAISS, Pinecone, ChromaDB).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cosine Similarity&lt;/strong&gt;: Mathematical measure of "how similar" two vectors are.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Approximate Nearest Neighbor (ANN)&lt;/strong&gt;: Search algorithm used to make vector search fast in high dimensions.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. &lt;strong&gt;Augmentation&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What&lt;/strong&gt;: After retrieving top relevant documents (say top 5 chunks), we prepare a &lt;strong&gt;prompt&lt;/strong&gt; that includes both:

&lt;ul&gt;
&lt;li&gt;The retrieved knowledge.&lt;/li&gt;
&lt;li&gt;The original question.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Context:
- Aspirin is known to cause stomach ulcers if taken in high doses.
- Patients with asthma may experience worsened symptoms with aspirin.

Question:
What are the side effects of aspirin?

Answer:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This entire constructed text is fed into the LLM.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📚 &lt;strong&gt;Key Tech Terminologies&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prompt Engineering&lt;/strong&gt;: Crafting the right input text for a model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context Window&lt;/strong&gt;: The maximum number of tokens (words/pieces) the model can take at once. (e.g., GPT-4 Turbo has 128k tokens)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. &lt;strong&gt;Generator&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Model's Job&lt;/strong&gt;: Generate a coherent, fluent, and grounded answer using the provided context.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLM behavior&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Reads the question and retrieved context.&lt;/li&gt;
&lt;li&gt;Predicts the &lt;strong&gt;next token&lt;/strong&gt; at each step (one token at a time) until the output is complete.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;📚 &lt;strong&gt;Key Tech Terminologies&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Autoregressive Language Model&lt;/strong&gt;: A model that predicts the next word/token given previous words.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Token&lt;/strong&gt;: A word piece, not always a full word (e.g., "un-", "happi-", "-ness" could be tokens).&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  &lt;strong&gt;What Exactly is a Model (in LLMs)?&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;✅ Technically:&lt;br&gt;&lt;br&gt;
A model is a &lt;strong&gt;huge mathematical function&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;$$ f(\text{input}) \to \text{output} $$&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;✅ &lt;strong&gt;More specifically&lt;/strong&gt; for LLMs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's a &lt;strong&gt;neural network&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;With &lt;strong&gt;hundreds of layers&lt;/strong&gt; of &lt;strong&gt;matrix multiplications&lt;/strong&gt; and &lt;strong&gt;nonlinear transformations&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Trained to &lt;strong&gt;minimize&lt;/strong&gt; a &lt;strong&gt;loss function&lt;/strong&gt; (how wrong it was when predicting the next token).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Formula View:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If ( x ) = input tokens, and ( y ) = output tokens,&lt;/li&gt;
&lt;li&gt;The model learns a function ( f_{\theta}(x) ) parameterized by &lt;strong&gt;θ&lt;/strong&gt; (weights) such that:

&lt;ul&gt;
&lt;li&gt;( \text{Loss} = \text{CrossEntropy}(f_{\theta}(x), y) ) is minimized.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;✅ The model's &lt;strong&gt;weights θ&lt;/strong&gt; are &lt;strong&gt;massive matrices&lt;/strong&gt; — &lt;strong&gt;GPT-3&lt;/strong&gt; had 175 billion parameters (numbers).&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;strong&gt;How are LLMs Trained Fastly?&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Good question — because LLMs training seems impossible, yet it’s done!&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Ingredients to fast LLM training&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Parallelization&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Data Parallelism&lt;/strong&gt;: Split the batch across GPUs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Model Parallelism&lt;/strong&gt;: Split parts of the model across GPUs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tensor Parallelism&lt;/strong&gt;: Split individual matrices inside layers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pipeline Parallelism&lt;/strong&gt;: Different GPUs work on different sequential layers.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Hardware&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Specialized hardware: &lt;strong&gt;NVIDIA A100&lt;/strong&gt;, &lt;strong&gt;H100&lt;/strong&gt; GPUs.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;TPUs&lt;/strong&gt; (Tensor Processing Units) in Google's case.&lt;/li&gt;
&lt;li&gt;Very high memory bandwidth (HBM memory).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Optimization Techniques&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mixed Precision Training&lt;/strong&gt;: Use float16 (half-precision) instead of float32 to make it faster without much loss.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gradient Checkpointing&lt;/strong&gt;: Save memory by recomputing certain activations during backprop.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AdamW Optimizer&lt;/strong&gt;: Special gradient descent variant that helps converge faster.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Training Tricks&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Curriculum Learning&lt;/strong&gt;: Start easy, go harder.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Masked Language Modeling&lt;/strong&gt; (for pretraining): Randomly mask some words to predict.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Distributed Systems&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use frameworks like &lt;strong&gt;DeepSpeed&lt;/strong&gt;, &lt;strong&gt;Megatron-LM&lt;/strong&gt;, &lt;strong&gt;FSDP&lt;/strong&gt; (Fully Sharded Data Parallel).&lt;/li&gt;
&lt;li&gt;Train on &lt;strong&gt;thousands of GPUs&lt;/strong&gt; at the same time across multiple datacenters.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;✅ &lt;strong&gt;Training Dataset Size&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Trillion tokens (Common Crawl, books, code, forums, wikipedia).&lt;/li&gt;
&lt;li&gt;LLMs learn token-by-token prediction, very, very slowly but over &lt;strong&gt;giant&lt;/strong&gt; amounts of data.&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  &lt;strong&gt;Summary&lt;/strong&gt;
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concept&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Retriever&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Finds relevant data from external source&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Augmentation&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Adds found documents to the user prompt&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Generator&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;LLM generates an answer based on the prompt&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Model&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Giant neural network = mathematical function ( f_\theta(x) )&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Training Fast&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Parallelization, hardware acceleration, optimizer tricks&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  ⚡ Visual View of RAG ⚡
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  +-----------------+
  | User's Query (Q) |
  +-----------------+
           |
           v
 +----------------------+
 | Query Encoder (Embed) |
 | (ex: OpenAI Embedding)|
 +----------------------+
           |
           v
 +-------------------------+
 | Similarity Search Engine |
 | (Vector Database: FAISS, |
 | Pinecone, ChromaDB)      |
 +-------------------------+
           |
           v
 +------------------------------+
 | Retrieved Top-K Context Docs |
 +------------------------------+
           |
           v
 +-------------------------------------------------+
 | Construct Final Prompt:                         |
 | [Retrieved Context] + [Original User Question]   |
 +-------------------------------------------------+
           |
           v
 +--------------------------+
 |  Large Language Model (LLM)|
 | (ex: GPT-4, Llama 3)       |
 +--------------------------+
           |
           v
 +---------------------+
 | Generated Final Answer |
 +---------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Waiting for comments!&lt;/p&gt;

</description>
      <category>llm</category>
      <category>rag</category>
      <category>ai</category>
      <category>data</category>
    </item>
    <item>
      <title>My Amazon SDE (FTC) Interview Experience 2025</title>
      <dc:creator>Hitesh</dc:creator>
      <pubDate>Tue, 01 Apr 2025 11:52:49 +0000</pubDate>
      <link>https://dev.to/hiteshchawla/my-amazon-sde-interview-experience-1bpc</link>
      <guid>https://dev.to/hiteshchawla/my-amazon-sde-interview-experience-1bpc</guid>
      <description>&lt;p&gt;I recently (27-03-2025) had the opportunity to appear for the Amazon SDE interview, which consisted of a &lt;strong&gt;Two intense DSA rounds in one day&lt;/strong&gt;. In these rounds, the interviewer tested me on a mix of &lt;strong&gt;problem-solving&lt;/strong&gt;, &lt;strong&gt;logic-building&lt;/strong&gt;, and &lt;strong&gt;optimization awareness&lt;/strong&gt;. I was asked &lt;strong&gt;4 DSA questions, 2/round&lt;/strong&gt;, each evaluating different skillsets.&lt;/p&gt;




&lt;h3&gt;
  
  
  🔹 &lt;strong&gt;Question 1: Binary Tree – Sum Tree Validation&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Topic:&lt;/strong&gt; Binary Trees, Recursion&lt;/p&gt;

&lt;p&gt;I was given a binary tree and asked to determine if it satisfies a specific &lt;strong&gt;sum property&lt;/strong&gt; (i.e., whether each node’s value equals the sum of its children’s subtree values).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concepts Tested:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Post-order traversal&lt;/li&gt;
&lt;li&gt;Recursive return of tuple &lt;code&gt;(isValid, sum)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Handling base cases for leaf nodes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🧠 &lt;em&gt;Tip:&lt;/em&gt; Be confident with writing custom recursive functions and returning multiple values from each call.&lt;/p&gt;




&lt;h3&gt;
  
  
  🔹 &lt;strong&gt;Question 2: Grid BFS – Virus Spread Simulation&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Topic:&lt;/strong&gt; Matrix, Multi-Source BFS&lt;/p&gt;

&lt;p&gt;This problem simulated an infection spreading across a 2D grid. Each infected cell (&lt;code&gt;P&lt;/code&gt;) spreads to its adjacent non-infected ones (&lt;code&gt;N&lt;/code&gt;) per time unit. The task was to compute the &lt;strong&gt;minimum time&lt;/strong&gt; needed to infect all reachable people.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concepts Tested:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;BFS using a queue&lt;/li&gt;
&lt;li&gt;Level-wise traversal (multi-source)&lt;/li&gt;
&lt;li&gt;Grid bounds and visited updates&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🧠 &lt;em&gt;Tip:&lt;/em&gt; Practice BFS on 2D grids, especially with multiple starting points.&lt;/p&gt;




&lt;h3&gt;
  
  
  🔹 &lt;strong&gt;Question 3: Range Coverage – Router Signal on Buildings&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Topic:&lt;/strong&gt; Arrays, Prefix Sum, Greedy&lt;/p&gt;

&lt;p&gt;Given routers placed on buildings with certain ranges, I had to compute how many buildings are &lt;strong&gt;adequately served&lt;/strong&gt; (i.e., covered by enough routers compared to the number of people in them).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concepts Tested:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Range marking via prefix sum&lt;/li&gt;
&lt;li&gt;Efficient array manipulation&lt;/li&gt;
&lt;li&gt;Early stopping conditions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🧠 &lt;em&gt;Tip:&lt;/em&gt; Learn how to apply &lt;strong&gt;difference arrays&lt;/strong&gt; to mark and process range updates efficiently.&lt;/p&gt;




&lt;h3&gt;
  
  
  🔹 &lt;strong&gt;Question 4: Graph Reconstruction – Circular Sequence from Pairs&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Topic:&lt;/strong&gt; Graphs, Adjacency List, Traversal&lt;/p&gt;

&lt;p&gt;I was given unordered pairs of adjacent symbols forming a &lt;strong&gt;circular sequence&lt;/strong&gt;. The task was to reconstruct a possible valid sequence of those symbols.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concepts Tested:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Graph building from undirected edges&lt;/li&gt;
&lt;li&gt;Identifying a cycle&lt;/li&gt;
&lt;li&gt;Visited tracking during DFS or BFS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🧠 &lt;em&gt;Tip:&lt;/em&gt; Be ready to reconstruct orderings from unordered pair data, using adjacency lists.&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ Final Advice
&lt;/h3&gt;

&lt;p&gt;This round tested:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Recursion depth (Tree problems)&lt;/li&gt;
&lt;li&gt;BFS reasoning (Simulation &amp;amp; infection spread)&lt;/li&gt;
&lt;li&gt;Optimized array processing (Greedy, prefix sum)&lt;/li&gt;
&lt;li&gt;Graph traversal and cycle detection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To prepare well:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Master recursion with trees&lt;/li&gt;
&lt;li&gt;Practice BFS from multiple sources&lt;/li&gt;
&lt;li&gt;Learn range-based greedy techniques&lt;/li&gt;
&lt;li&gt;Get comfortable with graph fundamentals using adjacency lists&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I still don't know if there are even implementing these algorithms Amazon. Waiting for the result :/&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>algorithms</category>
      <category>interview</category>
      <category>career</category>
    </item>
    <item>
      <title>Introducing my project GitFilter! Looking for contributions!</title>
      <dc:creator>Hitesh</dc:creator>
      <pubDate>Thu, 27 Feb 2025 14:21:51 +0000</pubDate>
      <link>https://dev.to/hiteshchawla/introducing-my-project-gitfilter-looking-for-contributions-2pgf</link>
      <guid>https://dev.to/hiteshchawla/introducing-my-project-gitfilter-looking-for-contributions-2pgf</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/gitfilter" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__org__pic"&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%2Forganization%2Fprofile_image%2F10419%2F937c77c0-c22d-494d-b80b-5a5717b84459.jpg" alt="GitFilter" width="400" height="400"&gt;
      &lt;div class="ltag__link__user__pic"&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%2Fuser%2Fprofile_image%2F1244059%2Fffee9d5a-c125-4f3a-8fbc-1756d1267222.webp" alt="" width="800" height="800"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/gitfilter/release-001-2jh1" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Release 0.0.1&lt;/h2&gt;
      &lt;h3&gt;Hitesh for GitFilter ・ Feb 27 '25&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#opensource&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#nextjs&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#github&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>opensource</category>
      <category>nextjs</category>
      <category>javascript</category>
      <category>github</category>
    </item>
    <item>
      <title>Looking for Devs!</title>
      <dc:creator>Hitesh</dc:creator>
      <pubDate>Thu, 27 Feb 2025 14:20:49 +0000</pubDate>
      <link>https://dev.to/hiteshchawla/looking-for-devs-b63</link>
      <guid>https://dev.to/hiteshchawla/looking-for-devs-b63</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/gitfilter" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__org__pic"&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%2Forganization%2Fprofile_image%2F10419%2F937c77c0-c22d-494d-b80b-5a5717b84459.jpg" alt="GitFilter" width="400" height="400"&gt;
      &lt;div class="ltag__link__user__pic"&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%2Fuser%2Fprofile_image%2F1244059%2Fffee9d5a-c125-4f3a-8fbc-1756d1267222.webp" alt="" width="800" height="800"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/gitfilter/release-001-2jh1" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Release 0.0.1&lt;/h2&gt;
      &lt;h3&gt;Hitesh for GitFilter ・ Feb 27 '25&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#opensource&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#nextjs&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#github&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>opensource</category>
      <category>nextjs</category>
      <category>javascript</category>
      <category>github</category>
    </item>
    <item>
      <title>Release 0.0.1</title>
      <dc:creator>Hitesh</dc:creator>
      <pubDate>Thu, 27 Feb 2025 14:11:43 +0000</pubDate>
      <link>https://dev.to/gitfilter/release-001-2jh1</link>
      <guid>https://dev.to/gitfilter/release-001-2jh1</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%2F3jhqczyuvxervvd9xqk1.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%2F3jhqczyuvxervvd9xqk1.png" alt="www.Gitfilter.com" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hola Devs! This is our first post on Dev.to and We are excited to introduce the first release of &lt;strong&gt;GitFilter (0.0.1)&lt;/strong&gt;—a platform designed to help developers discover impactful repositories, showcase their contributions, and enable organizations to find open-source talent. Our focus is on building a &lt;strong&gt;community-driven, open-source&lt;/strong&gt; solution that makes navigating the open-source ecosystem easier and more effective.&lt;/p&gt;

&lt;p&gt;This release lays the foundation for GitFilter’s core functionality, including &lt;strong&gt;GitHub OAuth authentication, repository search, user profile display, and skill-based filtering.&lt;/strong&gt; Let’s dive into the details of our &lt;strong&gt;Release 0.0.1&lt;/strong&gt; and how you can contribute to shaping its future!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: If you are a developer, &lt;a href="https://forms.gle/a2Fvq6f7KAyFsvLT9" rel="noopener noreferrer"&gt;fill this form to contribute!&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Technologies We Are Using&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;For the MVP, we have carefully chosen technologies that ensure scalability, security, and a great developer experience:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Frontend&lt;/strong&gt;: Next.js (App Router) – Provides server-side rendering, fast performance, and better SEO.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UI Styling&lt;/strong&gt;: Tailwind CSS – A utility-first CSS framework for responsive and modern UI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authentication &amp;amp; Database&lt;/strong&gt;: Supabase – An open-source Firebase alternative for authentication, database management, and real-time updates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backend&lt;/strong&gt;: Next.js API routes – Eliminates the need for a separate backend, making API handling smoother.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hosting&lt;/strong&gt;: Vercel – Ensures fast deployments and seamless scaling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This tech stack allows us to move quickly while ensuring maintainability and future extensibility.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why Contribute to GitFilter?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;GitFilter is more than just a platform—it’s a &lt;strong&gt;community-driven initiative&lt;/strong&gt; to enhance the open-source experience. Here’s why you should contribute:&lt;/p&gt;

&lt;p&gt;🔹 &lt;strong&gt;Build the Future of Open Source Discovery&lt;/strong&gt; – Help create a tool that empowers developers and organizations to collaborate effectively.&lt;br&gt;&lt;br&gt;
🔹 &lt;strong&gt;Gain Visibility in the Community&lt;/strong&gt; – Your contributions will be acknowledged, and you’ll be part of an open-source project that aims to scale globally.&lt;br&gt;&lt;br&gt;
🔹 &lt;strong&gt;Learn &amp;amp; Grow&lt;/strong&gt; – Work with Next.js, Supabase, and modern web technologies while collaborating with developers worldwide.&lt;br&gt;&lt;br&gt;
🔹 &lt;strong&gt;Make Open Source More Accessible&lt;/strong&gt; – Help contributors find projects that match their interests and skills effortlessly.  &lt;/p&gt;

&lt;p&gt;If you’re a developer passionate about open-source, your contributions will directly shape GitFilter's evolution.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;How GitFilter Benefits Developers&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;✅ &lt;strong&gt;Showcase Your Contributions&lt;/strong&gt; – Your GitHub activity and skillset are displayed in a structured way, making it easier to present your work.&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Discover Projects That Matter&lt;/strong&gt; – Instead of endlessly searching, get &lt;strong&gt;curated recommendations&lt;/strong&gt; for repositories to contribute to.&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Connect with Organizations&lt;/strong&gt; – Organizations looking for skilled contributors can find you based on your &lt;strong&gt;real-world open-source contributions.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Filter Repositories Based on Interests&lt;/strong&gt; – Whether you prefer web dev, AI, or systems programming, GitFilter helps you find the right projects.  &lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Join Us – Contribute to GitFilter!&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We believe in the power of &lt;strong&gt;community-driven development&lt;/strong&gt; and want &lt;strong&gt;you&lt;/strong&gt; to be part of GitFilter’s journey.&lt;/p&gt;

&lt;p&gt;If you’re interested in contributing, &lt;strong&gt;&lt;a href="https://forms.gle/a2Fvq6f7KAyFsvLT9" rel="noopener noreferrer"&gt;fill out this form&lt;/a&gt;&lt;/strong&gt; to get involved&lt;/p&gt;

&lt;p&gt;We hope to &lt;strong&gt;open-source our Release 0.0.1 soon&lt;/strong&gt; if everything goes well. Stay tuned, and let’s build the future of open-source collaboration together! 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  Find us below
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/git-filter" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://x.com/gitfilter" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.instagram.com/gitfilter/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/@GitFilter" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.GitFilter.com" rel="noopener noreferrer"&gt;Website&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Open for Sponsorships and Collabs, Follow &lt;a href="https://x.com/ihiteshchawla" rel="noopener noreferrer"&gt;Founder&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Bring your ideas and thoughts to enhance this platform in comment section below! &lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Participants will be getting a big surprise!)&lt;/em&gt;&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>nextjs</category>
      <category>javascript</category>
      <category>github</category>
    </item>
  </channel>
</rss>
