Skip to content

Latest commit

Β 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 AutoForge

⚑ Autonomous AI Software Engineer β€” Powered by LangGraph & Multi-Model LLMs (Groq, Gemini, OpenAI, Claude)

Plan β†’ Code β†’ Validate β†’ Execute β†’ Self-Heal

Python 3.9+ Groq LangGraph FastAPI Next.js Docker PostgreSQL License: MIT

A fully autonomous, multi-agent software engineering system that plans, writes, validates, executes, and self-heals Python code inside an isolated Docker sandbox β€” powered by your choice of LLM (Groq, Gemini Free Tier, OpenAI GPT-4o, or Anthropic Claude).


πŸ”₯ Key Features

Feature Description
🧠 Multi-Model Support Choose your engine: Lightning-fast Groq (Llama), Free Tier Google Gemini, OpenAI GPT-4o, or Anthropic Claude 3.5. Configure seamlessly via .env.
🐳 Docker Sandbox Execution All generated code runs inside ephemeral python:3.11-slim containers with 10s timeouts β€” your host machine is never at risk
⚑ WebSocket Live Terminal Real-time streaming of Docker sandbox output directly to the UI, providing an interactive terminal experience
πŸ”¬ AST-Powered Validator Self-healing code pipeline β€” an ast.NodeVisitor statically analyzes every generated script for unsafe operations, hardcoded secrets, and missing try/except blocks before execution
πŸ™ GitHub Integration Autonomous repository navigation β€” the Coder can browse directories and read files from any GitHub repo using built-in PyGithub tools
πŸ” Tavily Web Search Real-time API documentation lookup via Tavily β€” with strict intent-routing to prevent tool over-triggering
πŸ”„ Self-Healing Debugger If code crashes in the sandbox, tracebacks are automatically fed back to a Debugger agent that rewrites stdlib-only fixes in a closed loop
πŸ’Ύ Persistent Memory PostgreSQL-backed checkpointing β€” conversation state survives page reloads with sliding-window context injection
πŸ–₯️ Pro IDE Frontend Modern Next.js frontend with live pipeline graph, syntax-highlighted code editor, real-time terminal, and seamless chat experience

πŸ—οΈ Architecture β€” The ReAct Pipeline

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    LangGraph State Machine                          β”‚
β”‚                                                                     β”‚
β”‚  START ──▸ Router ──┬──▸ Planner ──▸ Coder ──▸ Validator ──┬──▸ Terminal  β”‚
β”‚                     β”‚         β–²              β”‚               β”‚      β”‚      β”‚
β”‚                     β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  (reject)     β”‚      β”‚      β”‚
β”‚                     β”‚         (self-reflection loop)         β”‚      β–Ό      β”‚
β”‚                     β”‚                                        β”‚  Debugger   β”‚
β”‚                     β”‚                                        β”‚      β”‚      β”‚
β”‚                     β”‚                                        β””β”€β”€β”€β”€β”€β”€β”˜      β”‚
β”‚                     β”œβ”€β”€β–Έ Research Agent ──▸ END                            β”‚
β”‚                     └──▸ Knowledge Agent ──▸ END                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚     Docker Sandbox (ephemeral)      β”‚
                   β”‚     python:3.11-slim Β· 10s timeout  β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ” How the Pipeline Works

  1. 🧭 Router β€” Classifies user intent (coding / research / generic) to avoid unnecessary Docker spin-ups
  2. πŸ“‹ Planner β€” Generates a mission brief with artifact targeting and strategy selection
  3. πŸ’» Coder β€” Groq Llama 3.3 generates Python code using a ReAct tool-calling loop (GitHub + Tavily)
  4. βœ… Validator β€” AST-based static analysis catches dangerous ops, secrets, and missing error handling
  5. 🐳 Terminal β€” Executes validated code inside an ephemeral Docker container
  6. πŸ”§ Debugger β€” Feeds tracebacks back for autonomous self-healing repairs (up to 5 attempts)

πŸ“‹ Prerequisites

Requirement Version Purpose
Python 3.9+ Runtime
Node.js 18+ Frontend Runtime
Docker Desktop Latest Sandboxed code execution
PostgreSQL 16+ (via Docker Compose) LangGraph state persistence
Groq API Key β€” 🧠 Primary LLM engine (get one free)
Tavily API Key β€” πŸ” Web search tool (get one free)
GitHub Token β€” πŸ™ Repository access (optional)

πŸš€ Quick Start

1️⃣ Clone & Install

git clone https://github.com/Harsh-Sharma29/AutoForge.git
cd AutoForge

python -m venv .venv

# Windows
.venv\Scripts\activate

# macOS / Linux
source .venv/bin/activate

pip install -r requirements.txt

2️⃣ Configure Environment

cp .env.example .env

Edit .env with your API keys:

# LLM Configuration (groq, gemini, openai, anthropic)
LLM_PROVIDER=gemini
LLM_MODEL=gemini-2.5-flash

# API Keys (Provide the one corresponding to your LLM_PROVIDER)
GEMINI_API_KEY=AIza...
GROQ_API_KEY=gsk_your_groq_api_key_here
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...

TAVILY_API_KEY=tvly-your_tavily_key_here
GITHUB_ACCESS_TOKEN=ghp_your_github_token_here

# Database (auto-configured by Docker Compose)
DATABASE_URL=postgresql://autoforge:autoforge@localhost:5432/autoforge?sslmode=disable
AUTOFORGE_API_URL=http://localhost:8005
NEXT_PUBLIC_API_URL=http://localhost:8005

3️⃣ Start Infrastructure

The quickest way to start the entire stack (Database, Backend, and Frontend) is via Docker Compose:

docker compose up -d --build

⚠️ Make sure Docker Desktop is running before this step.

4️⃣ Launch the Application (Manual Method)

If you prefer to run the components manually instead of using Docker Compose for everything:

Open two separate terminals:

Terminal 1 β€” πŸ–₯️ FastAPI Backend:

cd backend
python -m uvicorn src.api.server:app --host 127.0.0.1 --port 8005

Terminal 2 β€” 🎨 Next.js Frontend:

cd frontend
npm install
npm run dev

5️⃣ Open the IDE

Navigate to http://localhost:3005, enter a coding prompt, and click πŸš€ Execute Pipeline.


πŸ€– Multi-Agent System

Agent Responsibility
🧭 Router Intent classification β€” coding / research / generic β€” before any expensive work
πŸ“‹ Planner Mission brief, artifact targeting, and strategy selection
πŸ’» Coder Groq Llama 3.3 code synthesis with ReAct tool-calling loop and multi-file workspace output
βœ… Validator Pre-sandbox AST-based static analysis (dangerous ops, secrets, error handling)
🐳 Terminal Docker sandbox execution with 10-second timeout
πŸ”§ Debugger Traceback-driven self-healing repair loop (stdlib-only rewrites)
πŸ“š Research Technical research answers (no sandbox)
πŸ’‘ Knowledge Generic Q&A (no sandbox)

πŸ”’ Cyclic Loop Safeguards

Loop Cap Exit Condition
Coder ↔ Validator 3 attempts Pass validation, or force Terminal
Coder ↔ ToolNode 3 rounds Max tool-calling rounds reached
Terminal ↔ Debugger 5 attempts is_verified=True, empty errors, or cap reached
LangGraph global recursion_limit=50 Hard ceiling on total node invocations

πŸ“‘ API Reference

Method Endpoint Description
GET /api/v1/health System health: Postgres status, API key status, telemetry
POST /api/v1/session/new Generate a new backend-authoritative thread_id
GET /api/v1/history/{thread_id} Retrieve conversation history for a session
POST /api/v1/execute Execute the LangGraph pipeline (SSE streaming response)

πŸ“ Project Structure

AutoForge/ β”œβ”€β”€ docker-compose.yml # Full stack: Postgres + Backend + Frontend β”œβ”€β”€ .env.example # Environment template β”œβ”€β”€ backend/ β”‚ β”œβ”€β”€ main.py # CLI LangGraph entry point β”‚ β”œβ”€β”€ Dockerfile # FastAPI backend image β”‚ β”œβ”€β”€ requirements.txt # Python dependencies β”‚ └── src/ β”‚ β”œβ”€β”€ api/ β”‚ β”‚ └── server.py # FastAPI backend β€” SSE streaming, endpoints β”‚ β”œβ”€β”€ core/ β”‚ β”œβ”€β”€ agents/ β”‚ └── tools/ └── frontend/ β”œβ”€β”€ Dockerfile # Next.js frontend image β”œβ”€β”€ package.json # Node dependencies └── src/ # Next.js App Router code


βš™οΈ Configuration Reference

Variable Required Description
LLM_PROVIDER βœ… groq, gemini, openai, or anthropic
LLM_MODEL βœ… e.g. gemini-2.5-flash, gpt-4o, llama3-70b-8192
GEMINI_API_KEY ⚠️ Required if LLM_PROVIDER=gemini (Free Tier available)
GROQ_API_KEY ⚠️ Required if LLM_PROVIDER=groq
TAVILY_API_KEY ⚠️ Recommended Tavily web search for real-time docs
GITHUB_ACCESS_TOKEN ❌ Optional GitHub repository access
DATABASE_URL βœ… PostgreSQL connection string
AUTOFORGE_API_URL βœ… FastAPI backend URL (http://localhost:8000)
HUGGINGFACEHUB_API_TOKEN ❌ Optional HuggingFace Hub token for failover LLM

🎯 Example Prompts

Type Example Pipeline Path
πŸ’» Coding Write a Python script that fetches JSON from an API and handles a missing items key. Router β†’ Planner β†’ Coder β†’ Validator β†’ Terminal ↔ Debugger
πŸ™ GitHub Read the README from langchain-ai/langchain and summarize it. Router β†’ Planner β†’ Coder (GitHub tools) β†’ Validator β†’ Terminal
πŸ“š Research Explain how LangGraph conditional routing works. Router β†’ Research β†’ END
πŸ’‘ Generic What are the trade-offs between monoliths and microservices? Router β†’ Knowledge β†’ END

πŸ” Security Model

Control Status
Ephemeral containers (auto-removed) βœ…
Read-only volume mount for scripts βœ…
10-second execution timeout βœ…
AST-based Validator (static analysis) βœ…
API error payload interception βœ…
Dangerous pattern detection (eval, exec, os.remove) βœ…
Hardcoded credential detection βœ…

Threat model: Suitable for trusted developer workflows and portfolio demonstrations.


πŸ“„ License

MIT


Built with ❀️ by Harsh Sharma

Powered by 🧠 Groq Β· 🦜 LangGraph Β· 🐳 Docker Β· πŸ™ PyGithub Β· πŸ” Tavily

About

πŸ€– Autonomous AI Software Engineer using a LangGraph state machine to write, execute, and self-debug Python code inside an isolated Docker sandbox with multi-model LLM failover.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages