My journey from learning the fundamentals of LangChain to building an AI-powered Angular Developer Assistant.
Introduction
I've been working with frontend technologies, particularly Angular, and I've always been interested in understanding how AI can make software development more productive.
AI-powered applications are becoming increasingly common. From chatbots and coding assistants to intelligent agents that can use tools and perform tasks, there are many possibilities to explore.
I wanted to understand how these applications are built rather than just using existing AI tools.
That's what motivated me to start learning LangChain.
My goal wasn't to jump straight into building an advanced AI application. Instead, I wanted to start with the fundamentals, understand each concept, implement it through practical exercises, and gradually build something useful.
For this learning journey, I decided to use:
- Python as the programming language.
- LangChain as the framework for building AI applications.
- Google Gemini as the AI model provider.
- VS Code as my development environment.
Eventually, my goal was to build an AI assistant specifically designed to help with Angular development.
But before getting there, I needed to prepare my development environment.
This is where Phase 1 began.
Phase 1: Setting Up the Development Environment
Before writing any LangChain code, I wanted to make sure my development environment was properly configured.
I divided the setup into a few small steps.
Step 1: Installing Python
Since LangChain supports Python, I first needed a working Python installation.
I used Python 3.11+ for this learning project.
After installation, I verified Python from the terminal:
python --version This confirmed that Python was available and ready to use.
Step 2: Creating the project directory
I wanted to keep all my learning exercises and project files organized in one place.
I created a project directory:
D:\langchain-learning Then I opened this directory in VS Code.
Keeping a dedicated project directory made it easier to organize lessons, exercises, configuration files, and the practical project that I would build later.
Step 3: Creating a virtual environment
One thing I wanted to understand early was why Python projects use virtual environments.
A virtual environment provides an isolated Python environment for a particular project.
Without it, installing packages globally can create dependency conflicts between different projects.
For example, one project might require a particular version of LangChain, while another project might depend on a different version.
A virtual environment helps keep those dependencies separate.
From the project root, I created one:
python -m venv .venv This created a .venv directory inside my project.
Since I was using Windows, I activated it with:
.venv\Scripts\activate After activation, my terminal displayed:
(.venv) D:\langchain-learning> The (.venv) prefix confirmed that the virtual environment was active.
Step 4: Installing the required dependencies
Now that the environment was ready, I needed to install the packages required for the project.
I installed three main dependencies:
pip install langchain pip install langchain-google-genai pip install python-dotenv Here's what each package does.
| Package | Purpose |
|---|---|
langchain | Provides the core framework and components for building AI Applications |
langchain-google-genai | Integrates Google Gemini models with LangChain |
python-dotenv | Loads environment variables from a .env file |
I wanted to keep the initial setup simple and avoid installing packages that I didn't need yet.
I would introduce additional concepts and dependencies as the learning journey progressed.
Step 5: Getting a Google Gemini API key
To interact with Google's Gemini models, I needed an API key.
I obtained one through Google AI Studio.
The API key allows my Python application to authenticate with Google's Gemini API.
However, I didn't want to put the API key directly inside my Python source code.
Hardcoding credentials is a bad practice because source files can accidentally be shared, uploaded to GitHub, or committed to a public repository.
Instead, I decided to use environment variables.
I created a .env file in the project root:
D:\langchain-learning\.env Inside it, I added:
GOOGLE_API_KEY=your_actual_gemini_api_key Important: Replace the placeholder with your actual API key. Never publish your real key in a blog post, source repository, or screenshot.
Step 6: Loading the API key in Python
Installing python-dotenv allowed me to load the environment variables from the .env file.
I used:
from dotenv import load_dotenv import os load_dotenv() google_api_key = os.getenv("GOOGLE_API_KEY") if not google_api_key: raise ValueError("GOOGLE_API_KEY is missing from .env file.") Let's understand what's happening.
- load_dotenv() reads the .env file and loads its variables into the environment.
- os.getenv("GOOGLE_API_KEY") retrieves the API key.
- The if not google_api_key condition checks whether the key is missing. This gave me a simple way to manage credentials without exposing them in my Python code.
Step 7: Making my first Gemini API call through LangChain
This was the most exciting part of the setup.
I had Python installed, my virtual environment configured, the required packages installed, and my Gemini API key ready.
Now I wanted to verify that everything worked together.
I created a file called main.py in the project root.
from dotenv import load_dotenv from langchain_google_genai import ChatGoogleGenerativeAI load_dotenv() llm = ChatGoogleGenerativeAI( model="gemini-3.5-flash-lite" ) response = llm.invoke( "Explain what LangChain is in simple terms." ) print(response.content) Let's break down the important parts.
My initial implementation was:
- Importing ChatGoogleGenerativeAI
from langchain_google_genai import ChatGoogleGenerativeAI This class provides the integration between LangChain and Google's Gemini chat models.
Instead of directly calling the Gemini API, I can interact with the model through LangChain's chat model interface.
- Initializing the model
llm = ChatGoogleGenerativeAI(model="gemini-3.5-flash-lite") Here, I initialized a Gemini chat model.
The model parameter specifies which Gemini model I want to use.
- Sending a prompt
response = llm.invoke("Explain what LangChain is in simple terms.") The invoke() method sends the input to the model and returns its response.
- Printing the response
print(response.content) The response is a LangChain message object. Its content property contains the generated response.
I ran the application from the project root:
python main.py When Gemini returned a response, I knew the basic integration was working.
That was my first successful milestone.
Understanding the project structure
At this stage, my project was still small.
I had the following structure:
langchain-learning/ │ ├── .venv/ │ ├── .env │ ├── main.py │ └── requirements.txt As the course progressed, I would add separate directories for lessons, exercises, and the practical Angular assistant project.
I also added a .gitignore file to prevent sensitive and generated files from being committed.
For example:
.env .env.* !.env.example .venv/ venv/ __pycache__/ *.py[cod] .vscode/ .pytest_cache/ .coverage htmlcov/ I also created an .env.example file containing a placeholder:
GOOGLE_API_KEY=your_google_api_key_here This allows someone else to understand which environment variable is required without exposing my actual credentials.
What I learned in Phase 1
Although this phase was mostly about environment setup, I learned several important things that would become useful throughout the course.
- Python virtual environments: Why each project should have its own isolated environment.
- Package management: How to install dependencies using pip.
- Environment variables: How to keep sensitive configuration outside source code.
- Gemini integration: How to connect Google's Gemini model through LangChain.
- LangChain invocation: How to send a prompt using invoke() and retrieve the response through response.content.
Challenges and observations
There wasn't a major technical issue during the initial setup, but a few things became important as I continued learning.
- I needed to make sure the virtual environment was activated before installing or running project dependencies.
- The API key had to be available through the .env file.
- The model response was a LangChain message object, not simply a Python string.
- I needed to protect .env from being committed to source control.
These small details helped me establish good development practices from the beginning.
Final thoughts
Phase 1 was complete.
I now had a working Python environment, LangChain installed, Gemini configured, and a simple Python application successfully communicating with the AI model.
It wasn't an advanced AI application yet, but it was an important starting point.
I wanted to understand what was happening behind the scenes, so my next step was to explore LangChain itself.
I planned to learn how chat models work, how messages are structured, and how to build a chatbot that could interact with users through the terminal.
That brings me to Phase 2.
What's next?
In the next article:
Understanding LangChain Fundamentals: Messages, Chat Models, and My First Chatbot.
I'll explore:
- What is an LLM?
- What is a chat model?
- Understanding SystemMessage, HumanMessage, and AIMessage.
- Building an interactive terminal chatbot.
- Why my first chatbot couldn't remember previous questions.
This is just the beginning of my LangChain learning journey!
Series: My LangChain Learning Journey: From Beginner to Building an AI Agent
Phase: 1 of 9 — Environment Setup

