From Full Stack to AI: Building Agentic Workflow with LangGraph
Explore the process of designing an agentic workflow through LangGraph.

I’m a full-stack developer who enjoys building practical, scalable applications with React.js, Node.js, and Next.js. My journey into open source started with Hacktoberfest 2023, and it opened the door to real collaboration, learning from global contributors, and supporting early developers as they grow.
Since then, I’ve contributed to and mentored in programs like GSSoC’24, SSOC’24, and C4GT’24. As a Google Gen AI Exchange Hackathon ’24 Finalist and a Google Women Techmakers Ambassador, I’ve had the chance to help communities explore AI and build meaningful solutions. I’m also part of the Top 1% mentors on Topmate, where I guide students on open source, career building, and technical growth.
My work has been featured at Times Square NYC, and I’ve spoken on international podcasts about tech, learning, and community. I’ve also written technical content for CoderArmy and continue to share insights through articles and public posts. LinkedIn has recognized my work with seven Top Voice badges as well as Golden Badges in research, critical thinking, teamwork, and interpersonal skills.
I completed my MCA from Chandigarh University in 2023 and continue to stay curious by exploring AI, building new projects, and contributing to developer communities. Whether it’s improving a UI, debugging backend logic, or helping someone with their first pull request, I enjoy learning alongside others.
If you want to collaborate, learn together, or discuss an idea, feel free to reach out at kumaripayal7488@gmail.com
When you come from a full stack background, you are used to clear flows. A request comes in, it goes through some functions, maybe hits a database, and returns a response.
But AI agents are different. They think in steps. Sometimes they call tools. Sometimes they retry. Sometimes they decide what to do next.
This is where LangGraph becomes useful.
It lets us design AI workflows like a flowchart, but in code.
Let us go step by step and understand how to build an agentic workflow using LangGraph.
1. Why LangGraph Is a Game-Changer for AI Agents
If you have worked with LangChain before, you know it is great for chaining LLM calls.
But real AI agents are not simple chains. They:
Keep memory
Make decisions
Branch into different paths
Retry when needed
LangGraph gives us a graph structure instead of a simple chain.
Think of it like:
Nodes are functions
Edges define what runs next
State carries data between nodes
This feels natural for developers because it is similar to backend request pipelines or workflow engines.

2. Core Concepts: Nodes and Edges
What Is a Node?
A node is just a Python function.
It takes a state as input and returns an updated state.
Example:
def greet(state):
state["message"] = "Hello " + state["name"]
return state
If we run:
state = {"name": "Payal"}
print(greet(state))
Output:
{'name': 'Payal', 'message': 'Hello Payal'}
The node modified the state.
Simple.
What Is an Edge?
An edge connects one node to another.
It defines the execution order.
If we say:
Start → greet → End
Then greet runs after start.
Think of edges like routing in Express:
app.use(auth)
app.use(controller)
Same idea.
3. Setting Up LangGraph
First install:
pip install -U langgraph
Now let us create a minimal graph.
from langgraph.graph import StateGraph, START, END
from typing_extensions import TypedDict
class State(TypedDict):
message: str
def first_node(state: State):
state["message"] = "Hello from first node"
return state
graph_builder = StateGraph(State)
graph_builder.add_node("first_node", first_node)
graph_builder.add_edge(START, "first_node")
graph_builder.add_edge("first_node", END)
graph = graph_builder.compile()
result = graph.invoke({"message": ""})
print(result)
Output:
{'message': 'Hello from first node'}
The graph executed exactly one node between START and END.
4. Defining State in LangGraph
State is shared memory between nodes.
It is defined using TypedDict.
Example:
class State(TypedDict):
messages: list
If one node appends to messages, the next node sees the updated list.
This is how we maintain conversation context in AI agents.
It works like a request object in backend systems.
5. Defining Nodes and Functions in LangGraph
Let us now integrate an LLM.
from dotenv import load_dotenv
from typing_extensions import TypedDict
from typing import Annotated
from langgraph.graph.message import add_messages
from langgraph.graph import StateGraph, START, END
from langchain.chat_models import init_chat_model
load_dotenv()
llm = init_chat_model(
model="gpt-4.1-mini",
model_provider="openai",
)
class State(TypedDict):
messages: Annotated[list, add_messages]
def chatboat(state: State):
response = llm.invoke(state.get("messages"))
return {"messages": [response]}
This node:
Takes conversation history
Sends it to the model
Returns new message
6. Connecting Nodes with Edges
Now let us add another node.
def samplenode(state: State):
print("Inside samplenode node", state)
return {"messages": state["messages"] + ["Sample Message Appended"]}
graph_builder = StateGraph(State)
graph_builder.add_node("chatboat", chatboat)
graph_builder.add_node("samplenode", samplenode)
graph_builder.add_edge(START, "chatboat")
graph_builder.add_edge("chatboat", "samplenode")
graph_builder.add_edge("samplenode", END)
graph = graph_builder.compile()
updated_state = graph.invoke(
{"messages": ["Hi, My name is Payal Kumari"]}
)
print(updated_state)
Example Output:
Inside samplenode node {'messages': [AIMessage(content='Hello Payal...')]}
updated_state {'messages': ['Hi, My name is Payal Kumari', 'Hello Payal...', 'Sample Message Appended']}
Flow is:
Start → chatboat → samplenode → End
Each node modifies state step by step.
7. Testing and Debugging
Debugging is simple.
Just print state inside nodes.
def debug_node(state):
print("Current state:", state)
return state
When you run the graph, you will see the state at each step.
This is similar to logging middleware in backend apps.
8. Integrating LLMs into LangGraph
Here is the full example:
updated_state = graph.invoke(
{"messages": ["Hi, My name is Payal Kumari"]}
)
print(updated_state)
If the user says:
"Hi, My name is Payal Kumari"
The model replies. Then samplenode appends a message.
Final state contains full conversation.
This is how agents maintain memory.
9. Conditional Edges and Smart Routing
Now things get interesting.
Sometimes we want decision making.
Example:
If response is good → End
Else → Call another model
Here is simplified code:
from typing import Optional, Literal
from langgraph.graph import StateGraph, START, END
from typing_extensions import TypedDict
class State(TypedDict):
user_query: str
llm_output: Optional[str]
is_good: Optional[bool]
def chatbot(state: State):
state["llm_output"] = "Result is 3.5"
return state
def evaluate_response(state: State) -> Literal["endnode", "retry"]:
if state["llm_output"]:
return "endnode"
return "retry"
def endnode(state: State):
print("Final State:", state)
return state
Graph logic:
Start → chatbot → evaluate_response
If good → endnode
Else → retry
Example invocation:
updated_state = graph.invoke(
{"user_query": "2 + 3 * 5 / 10"}
)
print(updated_state)
Output:
Final State: {'user_query': '2 + 3 * 5 / 10', 'llm_output': 'Result is 3.5'}
The graph decided what to do next.
This is agent behavior.
Real-World Mental Model
Think of LangGraph like:
Node = function handler
Edge = routing rule
State = shared request context
Conditional edge = decision engine
It feels like building backend workflows, but for AI reasoning.
Closing Thoughts
If you are moving from full stack to AI, do not rush into complex agent frameworks.
Start with:
Understanding state
Writing small nodes
Connecting them step by step
Adding conditions slowly
LangGraph makes agent workflows structured and readable.
Once you understand graphs deeply, you will design better AI systems instead of just calling an LLM once and hoping it works.
Build slowly. Test each node. Understand how state flows.
Strong foundations matter more than fancy demos.




