Skip to content

Environment Setup

Now that we have a basic understanding of what we are going to do in this project, let us now setup the environment for the project.

Before moving forward, these are the prerequisites for the project.

Once you are done installing all the above stack, you can verify the installation of Nodejs by opening your terminal and typing this:

Checking Node Version..
node --v
node -version

Think of LangChain like a recipe for building smart apps that talks and thinks in natural language. In the old days, you’d hard-code every step of a program. LangChain lets you mix and match “blocks” (like kitchens with different tools) so you can whip up an AI application without reinventing the wheel each time.

LangChain


  • What they are: Huge, pretrained text engines (e.g., OpenAI’s GPT, Google’s PaLM).
  • What they do: They “understand” and “write” human-like text when you give them prompts.
  • Analogy: Think of an LLM as your master chef - it knows tons of language and cuisines, but needs your distractions.

  • What they are: Connectors to outside services - weather APIs, search engines, databases, even your own CSV files.
  • What they do: They fetch data or perform tasks that in the LLM alone can’t do (like checking today’s weather or querying your customer list).
  • Analogy: Tools are like pots, pans, and mixers in the kitchen. Your chef (LLM) uses them to get special ingredients or cook things just right.

  • What they are: Predefined workflows that string LLM calls and Tools together in order.
  • What they do: Make multi-step processes easy: e.g., “Read a customer question -> look up their order status in the database -> draft a reply email.”
  • Analogy: A chain in your recipe’s step-by-step instructions. It tells the chef when to grab the whisk or preheat the oven, so every dish comes out perfect.

  1. You write a prompt
    “Find me today’s weather in Mumbai”

  2. LangChain sends it to the LLM to understand your intent.

  3. LLM says, “I need outside data,“so LangChain invokes the Weather API tool.

  4. The tool returns “31 °C, Sunny,“which the LLM wraps up intro a friendly response.

  5. Result”Good afternoon! Right now in Mumbai it’s 31 °C and sunny. Don’t forget your sunglasses!


  • Save Time: No need to glue together every API and prompt by hand.
  • Stay Organized: Recipes (chains) live in code so you can review, update, and share them easily.
  • Scale Up: Add new tools or swap in a different LLM without rewriting your whole app.

Just like learning to cook, you’ll start with simple recipes. Over time you’ll look back—and thank yourself for mastering the basics. With LangChain’s blocks (LLMs, Tools, Chains), you’ll be mixing up powerful AI dishes in no time!


We will be creating the backend server using Express. Follow the following steps to setup:

  1. Create a directory with the name server inside your project folder

    Terminal window
    mkdir youtube-rag && cd youtube-rag
    mkdir server
    cd server
  2. Initialise a package.json file

    Terminal window
    npm init -y
  3. Install the following packages

    Terminal window
    npm install express cors dotenv @langchain/core @langchain/community youtubei youtubei.js

    Here we are using various packages, each has its own role:

    • express = A minimal and flexible Node.js web framework used to build APIs and web servers.
    • cors = A middleware for Express that enables Cross-Origin Resource Sharing, allowing your frontend to talk to your backend.
    • dotenv = Load environment variables from a .env file into process.env. Helps you keep secrets (like API keys) out of your source code.
    • @langchain/core = The foundational building blocks of the LangChain framework. It contains core abstractions like prompts, memory, output parsers, and chains.
    • @langchain/community = This is where all the community-supported integrations live — including tools, retrievers, and document loaders.
    • youtubei = Unofficial Node.js wrapper for YouTube’s internal API. Helps you fetch YouTube video details, search results, comments, etc., without needing an API key.
    • youtubei.js = A fork or related implementation of youtubei. It’s used in a similar way to fetch YouTube video data.
  4. Creating a very basic server in express

    index.js
    import express from 'express';
    import cors from 'cors';
    const app = express();
    //Middleware to parse JSON bodies
    app.use(express.json())
    //Configure and use cors
    const corsOptions = {
    origin: 'http://localhost:5173' //Our Frontend URL,
    methods ['GET', 'POST','PUT', 'DELETE'] //API Methods to Support
    allowedHeaders: ['Content-Type', 'Autorization']
    }
    app.use(cors(corsOptions))
    app.use('/',(req,res) => {
    res.send('Server is Up and Running!!')
    })
    app.listen('8000', () => {
    console.log('Server Running on PORT 8000')
    })
    export default app;
  5. Start the Server by Running

    Terminal window
    nodemon index.js

    Here nodemon will help restart the server on every small change we make on the server. Else traditionally we will have to kill the server and restart it again.


  • Go to Supabase
  • Create an Organization: Org
  • Once Organization is created, get the API Key and Base Url: Credentials
  • Copy them in .env file created in the root of your server directory:
    .env
    SUPABASE_URL=YOUR_SUPABASE_URL
    SUPABASE_API_KEY=YOUR_API_KEY

Once you are done with this, this is how your final server folder setup will look like:

  • Directoryserver
    • node_modules
    • index.js
    • .env
    • package.json
    • package-lock.json

If your structure looks somewhat like this, Congratulations 🥳 on creating your first node server.


In the next section, we’ll:

  • Create and Configure the Tables for Supabase

If you want to know more about this, do checkout our video :