DEV Community

Cover image for I built an AI Indie hacker that can research and make MVPs in minutes πŸš€ πŸ”₯
Sunil Kumar Dash Subscriber for Composio

Posted on β€’ Edited on

35 32 32 31 31

I built an AI Indie hacker that can research and make MVPs in minutes πŸš€ πŸ”₯

TL;DR

Building with AI is fun, but it's more fun when you can solve real problems like creating a clone/MVP of a trending app.

In this blog, I will walk you through building your own AI bot that can

  • Find an interesting product on HackerNews
  • Analyse the website
  • Build a clone of it

Cat AI


Tech Stack

Composio - For integrating the external tools and services with AI

Composio is the integration platform with over 250+ application support for building complex agentic flows. It takes care of all the authentication troubles so you can focus on building agents.

This blog will use HackerNews, CodeInterpreter, File tool, and shell tool integrations.

Composio Dashboard

LangGraph - Agentic framework

An agentic framework from LangChain lets you define workflows regarding graphs and nodes. It is ideal for building agents for production with maximum control.

OpenAI - Inference provider

For LLM inferencing. We'll use the GPT-4o model. You may use other models or providers like Claude, Gemini, Deepseek, etc. You might get even better results for complex use cases.


Workflow

The flow is effortless and straightforward.

Flow:

  1. Agent receives user instructions.
  2. Automatically decides which tools to use.
  3. No manual intervention is needed once they started
  4. Follows a straightforward, sequential process

Tool Selection:

  • Agent intelligently picks appropriate tools for each task
  • HackerNews tool for research
  • Code Interpreter for implementation
  • Web and Shell tools for execution
  • File tools for handling data

HackerNews Research Process:

  • Scans through Show HN feed
  • Identifies interesting projects
  • Evaluate the feasibility of MVP creation
  • Select the most promising idea

MVP Creation:

  • Takes the chosen idea
  • Creates a simplified version
  • Implements core functionality
  • Delivers working prototype
  • Executes and demonstrates results

IndieHacker AI Mermaid flow


Next, Create a .env file and add environment variables for the OpenAI API key.

OPENAI_API_KEY=your API key
Enter fullscreen mode Exit fullscreen mode

To create an OpneAI API key, go to the official site and create an API key in the dashboard.

OpenAI API key


Set up Composio

Next, you need to log in and authenticate with Composio.

composio login
Enter fullscreen mode Exit fullscreen mode

This will open a tab asking you to log in. You can log in with GitHub, Gmail, or any Email ID.

Composio Login

Upon logging in, a screen with a key will appear.

Composio Authentication Key

Copy it and paste it into the terminal.

Now, update apps.

composio apps update
Enter fullscreen mode Exit fullscreen mode

Setting up Environment

Create requirements.txt file

composio-langgraph
langgraph
langchain-groq
langchain-openai
python-dotenv
Enter fullscreen mode Exit fullscreen mode

The next step is to set up your virtual environment.
Create a setup.sh account and paste the following code.

#!/bin/bash

# Create a virtual environment
echo "Creating virtual environment..."
python3 -m venv ~/.venvs/indie_hacker 

# Activate the virtual environment
echo "Activating virtual environment..."
source ~/.venvs/indie_hacker/bin/activate

# Install libraries from requirements.txt 
echo "Installing libraries from requirements.txt..."
pip install -r requirements.txt

# Copy env backup to .env file
if [ -f ".env.example" ]; then
    echo "Copying .env.example to .env..."
    cp .env.example .env
else
    echo "No .env.example file found. Creating a new .env file..."
    touch .env
fi

# Prompt user to fill the .env file
echo "Please fill in the .env file with the necessary environment variables."

echo "Setup completed successfully!"

Enter fullscreen mode Exit fullscreen mode

Coding the AI agent

Start by importing all the necessary libraries and modules.

from composio import Composio, ComposioToolSet
import os
from dotenv import load_dotenv
from langchain_groq import ChatGroq
from langchain_openai import ChatOpenAI
from langgraph.checkpoint.memory import MemorySaver
from typing import Annotated
from langchain_core.messages import BaseMessage
from typing_extensions import TypedDict
from composio_langgraph import Action, ComposioToolSet, App
from langgraph.graph import StateGraph, START, END
from langgraph.graph.message import add_messages
from langgraph.prebuilt import ToolNode, tools_condition
load_dotenv()

Enter fullscreen mode Exit fullscreen mode

1. State Management and Initialization

pythonCopyclass State(TypedDict):
    messages: Annotated[list, add_messages]

graph_builder = StateGraph(State)
Enter fullscreen mode Exit fullscreen mode

This sets up our agent's state management system. Think of it as a structured way to track conversations - it maintains a record of all messages and helps manage the flow of information throughout the system.


2. Tool Integration

pythonCopytoolset = ComposioToolSet()
tools = toolset.get_tools(apps=[
    App.CODEINTERPRETER, 
    App.FILETOOL, 
    App.HACKERNEWS, 
    App.SHELLTOOL, 
    App.WEBTOOL
])
Enter fullscreen mode Exit fullscreen mode

Here, we're setting up our agent's capabilities using Composio's tools:

  • CodeInterpreter: For implementing MVP code
  • HackerNews: For researching ideas
  • WebTool: For web interactions
  • ShellTool: For executing commands
  • FileTool: For file operations

3. LLM Configuration

pythonCopyllm = ChatOpenAI(model="gpt-4o")
#llm = ChatGroq(model='llama3.3-70b-versatile')
llm_with_tools = llm.bind_tools(tools)
Enter fullscreen mode Exit fullscreen mode

We configure our LLM (OpenAI or Groq) and bind our tools to it, enabling the model to understand and use the available tools.

4. Chatbot Node Implementation

pythonCopydef chatbot(state: State):
    return {"messages": [llm_with_tools.invoke(state["messages"])]}

graph_builder.add_node("chatbot", chatbot)
Enter fullscreen mode Exit fullscreen mode

This defines our central chatbot node, which processes messages and decides what actions to take. It uses the LLM with bound tools to generate responses and make decisions.

5. Tool Node and Edge Configuration

pythonCopytool_node = ToolNode(tools=tools)
graph_builder.add_node("tools", tool_node)

graph_builder.add_conditional_edges(
    "chatbot",
    tools_condition,
)
graph_builder.add_edge("tools", "chatbot")
graph_builder.add_edge(START, "chatbot")
Enter fullscreen mode Exit fullscreen mode

The above code blocks Create a node for tool execution,
Sets up conditional routing based on whether tools are needed,
Establishes the flow between chatbot and tools
and finally defines the entry point.

6. Memory and Graph Compilation

pythonCopymemory = MemorySaver()
graph = graph_builder.compile(checkpointer=memory)
Enter fullscreen mode Exit fullscreen mode

We add memory capabilities to our agent and compile the graph, preparing it for execution.

7. Execution Configuration

pythonCopyconfig = {"configurable": {"thread_id": "1"}, "recursion_limit": 50}
Enter fullscreen mode Exit fullscreen mode

This sets up execution parameters, including:

Thread identification for tracking conversations
Recursion limits to prevent infinite loops

8. User Interaction

pythonCopyuser_input = """You are an Indie Hacker Agent..."""
events = graph.stream(
    {"messages": [("user", user_input)]}, 
    config, 
    stream_mode="values"
)
Enter fullscreen mode Exit fullscreen mode

This initializes the interaction process. It sets up event streaming and manages the real-time processing of user input and agent responses.

Now, run the main.py file to see the agent in action.

Get the complete code here: AI IndieHacker

Check out how it works.


Join our Discord Channel to gain access to an exclusive AI builder community!

Thank you for reading! Have a lovely week ahead.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (4)

Collapse
 
morgan-123 profile image
Morgan β€’

This is great.

Collapse
 
johnywalker21 profile image
johny walker β€’

Awesome keep it up

Collapse
 
johncook1122 profile image
John Cook β€’

AI is eating software. Btw nice blog.

Collapse
 
time121212 profile image
tim brandom β€’

Nice gotta try this.

Heroku

This site is powered by Heroku

Heroku was created by developers, for developers. Get started today and find out why Heroku has been the platform of choice for brands like DEV for over a decade.

Sign Up

πŸ‘‹ Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay