<?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>Forem: arunagri82</title>
    <description>The latest articles on Forem by arunagri82 (@arunagri82).</description>
    <link>https://forem.com/arunagri82</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%2F598731%2F275f4e37-4c19-4736-a22d-3b904d523cf3.png</url>
      <title>Forem: arunagri82</title>
      <link>https://forem.com/arunagri82</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/arunagri82"/>
    <language>en</language>
    <item>
      <title>Adding Human-in-the-Loop (HITL) to Your AI Agent with LangGraph</title>
      <dc:creator>arunagri82</dc:creator>
      <pubDate>Mon, 01 Dec 2025 06:19:47 +0000</pubDate>
      <link>https://forem.com/arunagri82/adding-human-in-the-loop-hitl-to-your-ai-agent-with-langgraph-515o</link>
      <guid>https://forem.com/arunagri82/adding-human-in-the-loop-hitl-to-your-ai-agent-with-langgraph-515o</guid>
      <description>&lt;p&gt;Modern AI agents are powerful, but you don’t always want them to act fully on their own.&lt;br&gt;
Sometimes you need a human to review, approve, or correct what the AI is doing — especially for publishing content, sending emails or notifications, or taking actions in production systems.&lt;br&gt;
This pattern is called Human-in-the-Loop (HITL).&lt;/p&gt;

&lt;p&gt;In this guide, we’ll see how to build a simple HITL workflow using LangGraph (built on top of LangChain). By the end, you’ll have a working example that lets the AI draft a response, sends that draft to a human for review, and either finalizes or revises the response based on human feedback, looping until the human is happy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is LangGraph?&lt;/strong&gt;&lt;br&gt;
LangGraph is a framework on top of LangChain for building stateful, multi-step workflows with LLMs, tools/APIs, and humans. Instead of writing one long function, you define a graph where each node is a step in your workflow, and edges control the flow. You can add conditions, loops, and retries, which makes it natural to add HITL into your AI agent.&lt;br&gt;
&lt;strong&gt;Example: Human Review for AI Responses&lt;/strong&gt;&lt;br&gt;
We’ll build a small workflow where the user asks a question, the AI drafts an answer, a human reviews the draft, and then either approves or requests changes. If they approve, we finalize the answer. If they suggest changes, the AI revises the answer and sends it back for review, repeating until they approve.&lt;/p&gt;

&lt;p&gt;Step 1: Define the Workflow State&lt;br&gt;
We define a shared state object that flows through the graph. Each node reads from and writes to this state. In our case, the state tracks: the user’s original question, the AI’s draft, the human feedback, and the final approved response.&lt;br&gt;
Python state definition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class HumanInTheLoopState(TypedDict):
    question: str           # User's original question
    ai_draft: str           # AI's current draft
    human_feedback: str     # Human review / comments
    final_response: str     # Final approved response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Define the Workflow Nodes&lt;/strong&gt;&lt;br&gt;
We define separate functions for each step in the process:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;draft_response – AI drafts the initial answer.&lt;/li&gt;
&lt;li&gt;get_human_feedback – human reviews and either approves or suggests changes.&lt;/li&gt;
&lt;li&gt;decide_next_step – decides whether to revise or finalize.&lt;/li&gt;
&lt;li&gt;revise_response – AI updates the answer based on feedback.&lt;/li&gt;
&lt;li&gt;finalize_response – produces the final, approved response.
Each of these functions receives the current state (a dict), prints some helpful information, and returns a dict with the updated fields.
&lt;strong&gt;Step 3: Wire It Up with LangGraph&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We then use StateGraph from LangGraph to connect all the nodes and control execution order. We add nodes, add edges to define the flow, and add a conditional edge from human_review to either revise or finalize, based on human_feedback.&lt;br&gt;
The flow looks like this:&lt;br&gt;
   [draft] → [human_review] → (decide)&lt;br&gt;
                     ↓&lt;br&gt;
                 revise? → [revise] → back to [human_review]&lt;br&gt;
                 approve? → [finalize] → END&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Running the Workflow&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%2F5ok5tkcm7vy5ni679n0l.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%2F5ok5tkcm7vy5ni679n0l.png" alt=" " width="616" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After compiling the graph using graph.compile(), we call workflow.invoke(initial_state) with an initial state. The system will automatically run through the nodes according to the edges, calling the human review step whenever needed, and looping until the human types 'approve'.&lt;br&gt;
At the end, the final approved response is available in final_state['final_response'], which you can send back to the user or store.&lt;br&gt;
&lt;strong&gt;Summary:&lt;/strong&gt;&lt;br&gt;
In this document we covered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What Human-in-the-Loop (HITL) means.&lt;/li&gt;
&lt;li&gt;How LangGraph lets you build stateful workflows with clear steps and branching.&lt;/li&gt;
&lt;li&gt;How to define state, nodes, and conditional edges for a HITL approval loop.&lt;/li&gt;
&lt;li&gt;How to adapt the console-based example into a real application UI.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>langgraph</category>
      <category>langchain</category>
      <category>hitl</category>
      <category>ai</category>
    </item>
    <item>
      <title>AI for Bharat: Tired of Just Reading About AI? It’s Time to Start Building</title>
      <dc:creator>arunagri82</dc:creator>
      <pubDate>Sun, 23 Nov 2025 18:09:26 +0000</pubDate>
      <link>https://forem.com/arunagri82/ai-for-bharat-tired-of-just-reading-about-ai-its-time-to-start-building-275k</link>
      <guid>https://forem.com/arunagri82/ai-for-bharat-tired-of-just-reading-about-ai-its-time-to-start-building-275k</guid>
      <description>&lt;p&gt;Artificial Intelligence is reshaping industries, accelerating careers, and creating new opportunities every single day. Yet most developers in India are stuck in the same cycle:&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%2Fkn6e34l5hhjq3x1zfx58.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%2Fkn6e34l5hhjq3x1zfx58.png" alt=" " width="800" height="116"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👉 Watching tutorials&lt;br&gt;
👉 Saving AI videos&lt;br&gt;
👉 Reading articles&lt;/p&gt;

&lt;p&gt;…but not building anything real.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI for Bharat&lt;/strong&gt; is here to break that cycle.&lt;/p&gt;

&lt;p&gt;This is your chance to join a nationwide movement designed for one purpose:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Turn AI theory into real-world building.&lt;/strong&gt;
&lt;/h3&gt;




&lt;h1&gt;
  
  
  ⭐ &lt;strong&gt;Program Highlights at a Glance&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Before we dive deeper, here’s everything you need to know right away:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;👥 Team Size: 1–5 Members&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Work solo or collaborate with a small, powerful team.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🎓 Age Requirement: 18+&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Anyone above 18 can participate—students, professionals, beginners, all are welcome.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🇮🇳 India Only&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A movement built &lt;strong&gt;for Indian developers&lt;/strong&gt;, shaping India’s AI future.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🌐 Fully Online&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Participate from &lt;em&gt;anywhere&lt;/em&gt; in India—no travel, no barriers.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;💰 Prize Pool: INR 40 Lakhs&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Massive rewards for innovators who build impactful AI solutions.&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;strong&gt;A Nationwide Movement to Build India’s Next Generation of AI Builders&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;AI for Bharat&lt;/strong&gt; is more than a program—it’s a mission.&lt;br&gt;
A mission to empower Indian developers with &lt;strong&gt;hands-on experience&lt;/strong&gt;, &lt;strong&gt;guidance&lt;/strong&gt;, and &lt;strong&gt;real challenges&lt;/strong&gt; that turn learning into action.&lt;/p&gt;

&lt;p&gt;It's designed for anyone who believes India should not just consume AI…&lt;br&gt;
India should &lt;strong&gt;create&lt;/strong&gt;, &lt;strong&gt;innovate&lt;/strong&gt;, and &lt;strong&gt;lead&lt;/strong&gt; with AI.&lt;/p&gt;




&lt;h1&gt;
  
  
  🔥 &lt;strong&gt;Why AI for Bharat?&lt;/strong&gt;
&lt;/h1&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;✓ Practical, Hands-On Learning&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;No boring lectures. You will &lt;strong&gt;build from Day 1&lt;/strong&gt; through guided workshops and tool-based sessions.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;✓ Real-World AI Challenges&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Tackle problems inspired by actual Indian use cases—healthcare, agriculture, governance, accessibility &amp;amp; more.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;✓ Build With Industry-Ready Tools&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Learn the same tools used by startups, research labs, and AI innovators worldwide.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;✓ Work Solo or With a Team&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Choose to build alone or collaborate with up to 4 friends or colleagues.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;✓ Massive ₹40 Lakhs Prize Pool&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Your innovation could directly earn rewards and recognition at a national level.&lt;/p&gt;




&lt;h1&gt;
  
  
  🧭 &lt;strong&gt;Program Structure: Two Power-Packed Phases&lt;/strong&gt;
&lt;/h1&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🔹 Phase 1 — Learn &amp;amp; Build&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Hands-on workshops, guided coding tasks, and real-time tool training.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🔹 Phase 2 — Challenge &amp;amp; Innovate&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Compete in structured AI challenges designed to bring out your best.&lt;/p&gt;

&lt;p&gt;This program turns:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Curiosity → Skills → Real Projects → AI Innovation&lt;/strong&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  👤 &lt;strong&gt;Who Can Join?&lt;/strong&gt;
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Students (18+)&lt;/li&gt;
&lt;li&gt;Working professionals&lt;/li&gt;
&lt;li&gt;Developers transitioning to AI&lt;/li&gt;
&lt;li&gt;Startup founders&lt;/li&gt;
&lt;li&gt;Tech enthusiasts&lt;/li&gt;
&lt;li&gt;Anyone who wants to &lt;em&gt;start building&lt;/em&gt; with AI&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No prior AI experience required—only passion and commitment.&lt;/p&gt;




&lt;h1&gt;
  
  
  🇮🇳 &lt;strong&gt;Why India Needs AI for Bharat&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;India is home to millions of talented developers, but talent alone isn’t enough.&lt;br&gt;
Developers need &lt;strong&gt;access&lt;/strong&gt;, &lt;strong&gt;guidance&lt;/strong&gt;, and &lt;strong&gt;opportunities&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;AI for Bharat gives you everything:&lt;/p&gt;

&lt;p&gt;✔ Real tools&lt;br&gt;
✔ Real practice&lt;br&gt;
✔ Real community&lt;br&gt;
✔ Real rewards&lt;/p&gt;

&lt;p&gt;This is how we transform India from an AI consumer into a &lt;strong&gt;global AI innovator&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  🚀 &lt;strong&gt;Stop Reading About AI. Start Building It.&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;You’ve read enough AI content.&lt;br&gt;
You’ve saved enough tutorials.&lt;br&gt;
Now it’s time to &lt;strong&gt;take action&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Thousands of developers across India are already joining.&lt;br&gt;
If you want to be a part of this movement…&lt;br&gt;
If you want to build your first real AI project…&lt;br&gt;
If you want a chance at the &lt;strong&gt;₹40 lakhs prize pool&lt;/strong&gt;…&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;👉 This is the moment. Don’t miss it.&lt;/strong&gt;
&lt;/h3&gt;




&lt;h1&gt;
  
  
  🔥 &lt;strong&gt;Sign Up Now – Limited Spots&lt;/strong&gt;
&lt;/h1&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;➡️ &lt;a href="https://tinyurl.com/yss6xyxc" rel="noopener noreferrer"&gt;https://tinyurl.com/yss6xyxc&lt;/a&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Take the first step toward becoming one of India’s next AI builders.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don’t wait. Don’t hesitate. Just start.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>challenge</category>
      <category>aws</category>
    </item>
    <item>
      <title>Spring Security Flow</title>
      <dc:creator>arunagri82</dc:creator>
      <pubDate>Sun, 23 Nov 2025 17:57:22 +0000</pubDate>
      <link>https://forem.com/arunagri82/spring-security-flow-1hkg</link>
      <guid>https://forem.com/arunagri82/spring-security-flow-1hkg</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%2Fbpukkwjp8jao34xk26zl.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%2Fbpukkwjp8jao34xk26zl.png" alt=" " width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a user submits login details, Spring Security’s authentication filter intercepts the request and converts it into an Authentication object. This object is then passed to the AuthenticationManager.&lt;/p&gt;

&lt;p&gt;The AuthenticationManager decides which authentication method to use (e.g., database authentication, OAuth, LDAP, or custom logic). It forwards the request to the appropriate AuthenticationProvider.&lt;/p&gt;

&lt;p&gt;The AuthenticationProvider contains the logic for validating the user. It uses the UserDetailsService to load user information and the PasswordEncoder to verify the password. If authentication succeeds, it returns a fully authenticated Authentication object.&lt;/p&gt;

&lt;p&gt;The authentication filter receives the result. If the credentials are valid, Spring Security stores the authentication object in the SecurityContext, which is maintained in the SecurityContextHolder. For every subsequent request, Spring Security checks this context (session or JWT token) to determine whether the user is already authenticated.&lt;/p&gt;

&lt;p&gt;If the token or session is valid, the request proceeds; otherwise, the user is denied access.&lt;/p&gt;

</description>
      <category>spring</category>
      <category>security</category>
      <category>java</category>
      <category>javasecurity</category>
    </item>
    <item>
      <title>Mastering Spring Annotations: The Ultimate Guide for Beginners</title>
      <dc:creator>arunagri82</dc:creator>
      <pubDate>Mon, 06 Oct 2025 18:46:17 +0000</pubDate>
      <link>https://forem.com/arunagri82/mastering-spring-annotations-the-ultimate-guide-for-beginners-38nh</link>
      <guid>https://forem.com/arunagri82/mastering-spring-annotations-the-ultimate-guide-for-beginners-38nh</guid>
      <description>&lt;p&gt;&lt;strong&gt;@Component Annotation in Spring&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The @Component annotation marks a class as a Spring-managed bean.&lt;br&gt;
It is a stereotype annotation, meaning it indicates that the class is a candidate for auto-detection during component scanning.&lt;/p&gt;

&lt;p&gt;If a class is not annotated with @Component (or other stereotype annotations like @Service, @Repository, or @Controller), Spring will not register it in the application context.&lt;/p&gt;

&lt;p&gt;Functionality&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Bean Registration&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When a class is annotated with @Component and component scanning is enabled, Spring automatically registers the bean in the application context.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Dependency Injection&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Spring can automatically inject the bean into other components where it is required, using @Autowired or constructor injection.&lt;/p&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;import org.springframework.stereotype.Component;

@Component
public class ComponentClass {
    // Class implementation here
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a class="mentioned-user" href="https://dev.to/bean"&gt;@bean&lt;/a&gt; Annotation in Spring&lt;/p&gt;

&lt;p&gt;The &lt;a class="mentioned-user" href="https://dev.to/bean"&gt;@bean&lt;/a&gt; annotation is a method-level annotation used to explicitly define a Spring bean.&lt;br&gt;
It is typically used when you want to create a third-party or custom object that cannot be annotated directly with @Component.&lt;/p&gt;

&lt;p&gt;A method annotated with &lt;a class="mentioned-user" href="https://dev.to/bean"&gt;@bean&lt;/a&gt; inside a class annotated with @Configuration tells Spring that the return value of this method should be registered as a bean in the application context.&lt;/p&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;import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig {

    @Bean
    public SomeApiClientFromALibrary someClassFromLibrary() {
        return new SomeApiClientFromALibrary();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;@Configuration Annotation&lt;/p&gt;

&lt;p&gt;The @Configuration annotation indicates that a class contains Spring bean definitions.&lt;br&gt;
If a class is annotated with @Configuration, the methods inside it that are annotated with &lt;a class="mentioned-user" href="https://dev.to/bean"&gt;@bean&lt;/a&gt; will produce beans managed by the IoC container.&lt;/p&gt;

&lt;p&gt;It replaces the old XML-based configuration and provides a type-safe, Java-based configuration approach.&lt;/p&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;@Configuration
public class TestConfig {

    @Bean
    public Insert tester() {
        return new Insertion();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;@ComponentScan Annotation&lt;/p&gt;

&lt;p&gt;The @ComponentScan annotation enables component scanning in Spring.&lt;br&gt;
When enabled, Spring automatically detects and registers all the stereotype annotations —&lt;br&gt;
@Controller, @Service, @Component, @Repository, and @Configuration — into the Spring IoC container, making them available for dependency injection.&lt;/p&gt;

&lt;p&gt;@PostConstruct Annotation&lt;/p&gt;

&lt;p&gt;The @PostConstruct annotation marks a method to be executed after the bean is initialized by Spring.&lt;br&gt;
It is typically used to load or initialize data from an external source after bean creation.&lt;/p&gt;

&lt;p&gt;The method must be non-static.&lt;/p&gt;

&lt;p&gt;Only one @PostConstruct method is allowed per class.&lt;/p&gt;

&lt;p&gt;It can have any access level (public, private, etc.).&lt;/p&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;import jakarta.annotation.PostConstruct;
import org.springframework.stereotype.Component;

@Component
public class PostExample {

    @PostConstruct
    public void postMethod() {
        System.out.println("PostConstruct method executed after bean initialization");
    }
}


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

&lt;/div&gt;



&lt;p&gt;@PreDestroy Annotation&lt;/p&gt;

&lt;p&gt;The @PreDestroy annotation marks a method to be executed before the bean is destroyed.&lt;br&gt;
It is useful for performing cleanup operations, such as closing connections, clearing caches, or stopping background threads.&lt;/p&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;import jakarta.annotation.PreDestroy;
import org.springframework.stereotype.Component;

@Component
public class PreDestroyExample {

    @PreDestroy
    public void destruct() {
        System.out.println("PreDestroy method executed before bean destruction");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;The &lt;a class="mentioned-user" href="https://dev.to/primary"&gt;@primary&lt;/a&gt; annotation is used when multiple beans of the same type exist in the Spring context.&lt;br&gt;
It tells Spring which bean should be given preference during autowiring.&lt;/p&gt;

&lt;p&gt;If a bean is annotated with &lt;a class="mentioned-user" href="https://dev.to/primary"&gt;@primary&lt;/a&gt;, that bean will be injected by default when there are multiple candidates.&lt;/p&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;public interface Message {
    String message();
}

@Component
public class WhatsApp implements Message {
    @Override
    public String message() {
        return "Hi from WhatsApp";
    }
}

@Component
@Primary
public class Telegram implements Message {
    @Override
    public String message() {
        return "Hello from Telegram";
    }
}

@Component
public class MessageService {

    @Autowired
    private Message msg;

    public String sendMessage() {
        return msg.message();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;➡ Here, Telegram will be injected because it is marked as &lt;a class="mentioned-user" href="https://dev.to/primary"&gt;@primary&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;@Qualifier Annotation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The @Qualifier annotation is used when multiple beans of the same type exist and you want to specify exactly which bean should be injected.&lt;/p&gt;

&lt;p&gt;It works alongside @Autowired to disambiguate bean selection.&lt;/p&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;public interface Message {
    String message();
}

@Component("whatsapp")
public class WhatsApp implements Message {
    @Override
    public String message() {
        return "Hi from WhatsApp";
    }
}

@Component("telegram")
public class Telegram implements Message {
    @Override
    public String message() {
        return "Hello from Telegram";
    }
}

@Component
public class MessageService {

    @Autowired
    @Qualifier("telegram")
    private Message telegramMessage;

    @Autowired
    @Qualifier("whatsapp")
    private Message whatsappMessage;

    public void displayMessages() {
        System.out.println(telegramMessage.message());
        System.out.println(whatsappMessage.message());
    }
}

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

&lt;/div&gt;



&lt;p&gt;➡ Here, @Qualifier("telegram") ensures the Telegram bean is injected.&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>java</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>REST API and Common HTTP Methods</title>
      <dc:creator>arunagri82</dc:creator>
      <pubDate>Sun, 21 Sep 2025 11:29:10 +0000</pubDate>
      <link>https://forem.com/arunagri82/rest-api-and-common-http-methods-1i2l</link>
      <guid>https://forem.com/arunagri82/rest-api-and-common-http-methods-1i2l</guid>
      <description>&lt;p&gt;REST stands for Representational State Transfer. It is a type of API (Application Programming Interface) that helps clients send HTTP requests to a server and receive responses, usually in XML or JSON format.&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%2F4otpyn2dqj1frl6j8npx.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%2F4otpyn2dqj1frl6j8npx.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Commonly Used HTTP Methods&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;REST APIs typically use the following five common HTTP methods to communicate with servers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GET&lt;/li&gt;
&lt;li&gt;POST&lt;/li&gt;
&lt;li&gt;PUT&lt;/li&gt;
&lt;li&gt;PATCH&lt;/li&gt;
&lt;li&gt;DELETE&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;GET Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The GET method is used to retrieve data from the server.&lt;/p&gt;

&lt;p&gt;On success, it returns HTTP 200 (OK).&lt;/p&gt;

&lt;p&gt;On failure:&lt;/p&gt;

&lt;p&gt;404 (Not Found) → Resource does not exist.&lt;/p&gt;

&lt;p&gt;400 (Bad Request) → Invalid request.&lt;/p&gt;

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

&lt;p&gt;GET /user/123&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;POST Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The POST method is used to create a new resource in the database.&lt;/p&gt;

&lt;p&gt;On success, it returns HTTP 201 (Created).&lt;/p&gt;

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

&lt;p&gt;POST /user&lt;br&gt;
{&lt;br&gt;
  "userId": "1234",&lt;br&gt;
  "name": "Siva"&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PUT Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The PUT method is used to update an entire resource.&lt;/p&gt;

&lt;p&gt;If the resource exists → It is updated.&lt;/p&gt;

&lt;p&gt;If the resource does not exist → A new resource is created.&lt;/p&gt;

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

&lt;p&gt;PUT /user/1234&lt;br&gt;
{&lt;br&gt;
  "userId": "1234",&lt;br&gt;
  "name": "Kumar"&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;PATCH Method&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
The PATCH method is used to partially update a resource.&lt;/p&gt;

&lt;p&gt;It sends only the fields that need to be modified, instead of replacing the whole resource.&lt;/p&gt;

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

&lt;p&gt;PATCH /user/1234&lt;br&gt;
{&lt;br&gt;
  "name": "Kumar"&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DELETE Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The DELETE method is used to remove a resource from the database.&lt;/p&gt;

&lt;p&gt;On success, it typically returns HTTP 200 (OK) or 204 (No Content).&lt;/p&gt;

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

&lt;p&gt;DELETE /user/1234&lt;/p&gt;

&lt;p&gt;✅ With these methods, REST APIs make communication between client and server simple, consistent, and standardized.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>restapi</category>
      <category>rest</category>
      <category>webapi</category>
    </item>
    <item>
      <title>Understanding the Spring MVC Design Pattern</title>
      <dc:creator>arunagri82</dc:creator>
      <pubDate>Sat, 20 Sep 2025 19:26:17 +0000</pubDate>
      <link>https://forem.com/arunagri82/understanding-the-spring-mvc-design-pattern-n2g</link>
      <guid>https://forem.com/arunagri82/understanding-the-spring-mvc-design-pattern-n2g</guid>
      <description>&lt;p&gt;Spring MVC internally follows the MVC (Model–View–Controller) design pattern. It divides the application into three parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Model – Manages data and business logic.&lt;/li&gt;
&lt;li&gt;View – Represents the front-end (such as JSP pages, Thymeleaf templates). It displays information to the user and collects input.&lt;/li&gt;
&lt;li&gt;Controller – Acts as an intermediary between the View and the Model. It processes user requests, invokes business logic, and sends data back to the View.
In Spring MVC, the @Controller and @RequestMapping annotations are mainly responsible for handling HTTP requests.&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%2Fwhjl8os5mrpegcrhfxql.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%2Fwhjl8os5mrpegcrhfxql.png" alt=" " width="800" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Key Components in Spring MVC Pattern&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Client

&lt;ul&gt;
&lt;li&gt;The browser (or any client) sends an HTTP request.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;DispatcherServlet

&lt;ul&gt;
&lt;li&gt;Known as the Front Controller.&lt;/li&gt;
&lt;li&gt;This is the entry point of the Spring MVC application.&lt;/li&gt;
&lt;li&gt;It receives every request from the client and delegates it to the right component.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Handler Mapping

&lt;ul&gt;
&lt;li&gt;Determines which Controller should handle the incoming request.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Controller

&lt;ul&gt;
&lt;li&gt;Connects the View and the Model.&lt;/li&gt;
&lt;li&gt;Handles the client request and invokes business logic from the Model.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Model

&lt;ul&gt;
&lt;li&gt;Represents the data and business logic of the application.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;View Resolver

&lt;ul&gt;
&lt;li&gt;Selects the appropriate View (such as JSP, Thymeleaf).&lt;/li&gt;
&lt;li&gt;In case of a REST controller, the data is returned directly without going through a View.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;View

&lt;ul&gt;
&lt;li&gt;The final output shown to the user (HTML, JSON, XML, etc.).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Advantages of Spring MVC&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lightweight – Works with a lightweight servlet container.&lt;/li&gt;
&lt;li&gt;Separation of concerns – Clear separation between front-end and back-end code.&lt;/li&gt;
&lt;li&gt;Loosely coupled – Easy to maintain and extend.&lt;/li&gt;
&lt;li&gt;Team-friendly – Multiple developers can work together efficiently (front-end and back-end separately).&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>springboot</category>
      <category>mvc</category>
      <category>designpatterns</category>
    </item>
  </channel>
</rss>
