A modular agent-based system for generating and editing app configurations through AI-driven steps organized in flows.
This project provides an advanced AI-powered platform for automatically generating and editing enterprise application configurations through a series of intelligent agent flows. Built with a modular architecture, it leverages OpenAI's APIs and structured generation to produce consistent, high-quality app specifications.
Repository: https://github.com/vivek100/oneShotCodeGen
- backend/: Modular FastAPI backend with agent flow system
- frontend/: React-based frontend interface with real-time updates
-
Clone the repository:
git clone https://github.com/vivek100/oneShotCodeGen.git cd oneShotCodeGen
-
Set up Python environment:
cd backend python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Create environment file:
cp sample.env .env
-
Configure your environment variables in
.env
:# API Configuration HOST=0.0.0.0 PORT=8000 # Database Configuration DB_URL=sqlite:///./agent.db # OpenAI API Configuration OPENAI_API_KEY=your_openai_api_key_here OPENAI_MODEL_NAME=gpt-4.1-nano # Frontend Configuration (for CORS) FRONTEND_ORIGIN=http://localhost:3000
-
Start the backend server:
# Development mode with auto-reload python main.py # Or using uvicorn directly uvicorn main:app --host 0.0.0.0 --port 8000 --reload
The backend API will be available at http://localhost:8000
.
-
Navigate to the frontend directory:
cd frontend
-
Install Node.js dependencies:
npm install
-
Create environment file:
cp .env.example .env.local
-
Configure your environment variables in
.env.local
:NEXT_PUBLIC_BACKEND_URL=http://localhost:8000
-
Start the development server:
npm run dev
The frontend will be available at http://localhost:3000
.
The backend is built with a modular architecture focused on managing agent flows and step execution:
- Agent Router: Routes user messages to appropriate flows based on the main agent decision.
- Flow Registry: Manages flow definitions and their steps.
- Flow Runner: Orchestrates flow execution by running steps in sequence.
- Step Executor: Executes individual steps (AI or tool calls).
- Tool Call Module: Executes non-AI operations like entity reorganization, merging, etc.
- Prompt & Schema Store: Manages prompt templates, schemas, and examples.
- Message Dispatcher: Handles system messages during flow execution.
- Replay Engine: Re-runs steps with original or modified inputs for testing and debugging.
- WebSocket Manager: Provides real-time communication for chat messages and flow status updates.
- Main Agent Flow: Decides what to do with user input
- Create App Flow: Generates a complete app configuration
- Edit Decision Flow: Decides how to handle edit requests
- Partial Edit Flow: Updates specific parts of an app configuration
The system uses SQLite with the following key tables:
- Projects: Stores project metadata
- Messages: Stores chat messages for each project
- AppVersions: Stores app configuration versions
- Flows: Stores flow definitions
- Steps: Stores step definitions within flows
- FlowRuns: Tracks executions of flows
- StepRuns: Tracks executions of individual steps
- Prompts: Stores prompt templates
- Schemas: Stores JSON schemas for validation
- OneShots: Stores example inputs/outputs for steps
- PydanticSchemas: Stores Pydantic model references
The frontend is built with React and Next.js, providing a modern and responsive user interface:
- Project Management: Create, view, and manage application configuration projects
- Real-time Chat: Interact with the AI agent through a WebSocket-powered chat interface
- Configuration Preview: View and explore generated app configurations
- Flow Visualization: Explore the agent flows and steps
- Step Replay: Debug and experiment with individual AI steps
- Application Preview: Preview the generated application (work in progress)
- React & Next.js: Core frontend framework
- Tailwind CSS: Utility-first CSS framework
- ShadcnUI: Component library based on Radix UI
- React Query: Data fetching and caching
- Zustand: State management
- WebSockets: Real-time communication
The AI ERP App Configuration Generator works through a series of interconnected agent flows:
-
User Interaction: Users interact with the system through a chat interface, describing the application they want to build or the changes they want to make.
-
Main Agent Decision: The main agent analyzes the user's message and decides which specialized flow to execute (create new app, edit existing app, etc.).
-
Flow Execution: The selected flow runs through a series of steps, combining AI reasoning with specialized tool calls.
-
AI Steps: These steps use large language models (via OpenAI's API) to:
- Generate use cases from requirements
- Design entity models and relationships
- Create interface specifications
- Plan data model implementations
-
Tool Call Steps: Non-AI steps perform operations like:
- Reorganizing entities to handle foreign key relationships
- Merging changes into existing configurations
- Validating configuration integrity
- Generating final output structures
-
Structured Generation: The system uses both JSON schema validation and Pydantic models to ensure consistent, well-structured outputs from the AI.
-
Real-time Updates: WebSockets provide real-time chat messages and status updates to the frontend.
The system leverages Pydantic models for structured LLM generation, providing robust type validation:
from typing import List, Optional, Literal
from pydantic import BaseModel, ConfigDict, Field
class Entity(BaseModel):
model_config = ConfigDict(extra="forbid", exclude_none=True)
name: str = Field(..., description="Entity name")
description: str = Field(..., description="Entity description")
fields: List["Field"] = Field(..., description="Entity fields")
class Field(BaseModel):
model_config = ConfigDict(extra="forbid", exclude_none=True)
name: str = Field(..., description="Field name")
type: str = Field(..., description="Field type")
description: str = Field(..., description="Field description")
required: bool = Field(..., description="Whether field is required")
The system uses Jinja2 for flexible prompt templates:
You are designing an entity model for a business application.
# Requirements
{{ requirements | json }}
# Guidelines
- Create entities based on the business domain
- Consider relationships between entities
- Follow naming conventions
# Expected Output
{{ schema | json }}
Run both the frontend and backend in development mode as described in the Quick Start section.
-
Backend:
- Build a Docker container for the FastAPI backend
- Deploy to a cloud service like AWS, GCP, or Azure
- Set up appropriate environment variables
-
Frontend:
- Build the Next.js application:
npm run build
- Deploy to Vercel, Netlify, or another hosting service
- Configure environment variables to point to your deployed backend
- Build the Next.js application:
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- This project uses OpenAI's API for large language model capabilities
- Inspired by the potential of AI-assisted software engineering
- Built with a focus on modular, maintainable architecture