Skip to content

Transform natural language into production-ready code with AI-powered multi-agent architecture

License

Notifications You must be signed in to change notification settings

Muskkaniyer/AI-Code-Architect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– AI Code Architect

Python Version LangChain LangGraph

Transform natural language into production-ready code with AI-powered multi-agent architecture

Features β€’ Installation β€’ Usage β€’ Architecture β€’ Examples


🌟 Overview

AI Code Architect is an intelligent code generation system that uses a multi-agent architecture to convert natural language descriptions into fully functional applications. Powered by LangChain and LangGraph, it orchestrates three specialized AI agents working in harmony:

  • 🎯 Planner Agent: Analyzes requirements and creates high-level plans
  • πŸ—οΈ Architect Agent: Designs file structure and implementation steps
  • πŸ’» Coder Agent: Writes actual code with tool-use capabilities

✨ Features

  • 🧠 Multi-Agent Collaboration: Three specialized agents work together for optimal results
  • πŸ“ Natural Language Input: Describe what you want in plain English
  • πŸ”§ Tool-Augmented Generation: Agents can read, write, and navigate files intelligently
  • 🎨 Structured Output: Type-safe planning and execution using Pydantic models
  • πŸ”„ Iterative Development: Agents iterate until all tasks are complete
  • πŸ“¦ File System Management: Automatic file creation and organization
  • πŸš€ Production Ready: Built with LangChain and LangGraph for reliability

Use Cases

  • Generate complete web applications (HTML, CSS, JavaScript)
  • Create Python scripts and utilities
  • Build API endpoints and services
  • Develop data processing pipelines
  • Prototype applications rapidly
  • Generate boilerplate code

Installation

Prerequisites

  • Python 3.9 or higher
  • OpenAI API key

Setup

  1. Clone the repository
git clone https://github.com/yourusername/ai-code-architect.git
cd ai-code-architect
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Configure environment Create a .env file in the root directory:
OPENAI_API_KEY=your_openai_api_key_here

πŸ’‘ Usage

Basic Usage

from main import agent

# Describe what you want to build
user_prompt = "Create a simple working calculator web application in HTML, CSS and js."

# Let the AI agents do the work
result = agent.invoke({"user_prompt": user_prompt}, {"recursion_limit": 100})

Running the Example

python main.py

This will generate a complete calculator web application with HTML, CSS, and JavaScript files.

Custom Prompts

# Todo App Example
user_prompt = """
Create a todo list application with the following features:
- Add new tasks
- Mark tasks as complete
- Delete tasks
- Save to localStorage
Use vanilla JavaScript, HTML, and CSS
"""

result = agent.invoke({"user_prompt": user_prompt}, {"recursion_limit": 100})

πŸ—οΈ Architecture

graph LR
    A[User Prompt] --> B[Planner Agent]
    B --> C[Architect Agent]
    C --> D[Coder Agent]
    D --> E{All Tasks Done?}
    E -->|No| D
    E -->|Yes| F[Complete]
    
    style B fill:#ff6b6b
    style C fill:#4ecdc4
    style D fill:#45b7d1
Loading

Agent Flow

  1. Planner Agent 🎯

    • Analyzes user requirements
    • Creates structured plan with objectives
    • Defines success criteria
  2. Architect Agent πŸ—οΈ

    • Designs file structure
    • Breaks down into implementation steps
    • Creates task dependencies
  3. Coder Agent πŸ’»

    • Implements each step sequentially
    • Uses tools to read/write files
    • Iterates until completion

State Management

The system uses LangGraph's state management to maintain context across agents:

State = {
    "user_prompt": str,
    "plan": Plan,
    "task_plan": TaskPlan,
    "coder_state": CoderState,
    "status": str
}

πŸ“ Project Structure

ai-code-architect/
β”‚
β”œβ”€β”€ main.py                 # Main orchestration logic
β”œβ”€β”€ prompts.py             # Agent prompts and instructions
β”œβ”€β”€ states.py              # Pydantic state models
β”œβ”€β”€ tool.py                # File system tools
β”œβ”€β”€ requirements.txt       # Project dependencies
β”œβ”€β”€ .env                   # Environment variables (create this)
β”œβ”€β”€ .gitignore            # Git ignore rules
└── README.md             # This file

πŸ› οΈ Tools Available to Agents

Tool Description Usage
write_file Write content to a file Creates or overwrites files
read_file Read file contents Retrieves existing code
list_files List directory contents Navigate file system
get_current_directory Get working directory Verify location

πŸ“Š Examples

Example 1: Calculator App

Input:

user_prompt = "Create a simple working calculator web application"

Output:

  • calculator.html - HTML structure
  • calculator.css - Styling
  • calculator.js - Calculator logic
image

πŸ”§ Configuration

Model Selection

Change the LLM model in main.py:

llm = ChatOpenAI(
    model="gpt-4o",  # Options: gpt-4o, gpt-4-turbo, gpt-3.5-turbo
    temperature=1.0
)

Recursion Limit

Adjust the number of iterations:

result = agent.invoke(
    {"user_prompt": user_prompt},
    {"recursion_limit": 100}  # Increase for complex projects
)

Debug Mode

Enable detailed logging:

from langchain.globals import set_verbose, set_debug

set_debug(True)
set_verbose(True)

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ™ Acknowledgments

πŸ“§ Contact

For questions and support:


⭐ Star this repo if you find it helpful!

Made with ❀️ by AI enthusiast

About

Transform natural language into production-ready code with AI-powered multi-agent architecture

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published