Skip to content

BlueHat1993/CodeGenerationSwarm

Repository files navigation

Code Generation Swarm

A full-stack application that implements a swarm-based code generation system with a .NET 8 backend and React frontend. This system enables interactive code generation through a chat interface with support for visualization using Mermaid diagrams.

Architecture

graph TD
    subgraph Frontend [React Frontend]
        UI[User Interface]
        MI[MessageInput Component]
        ML[MessageList Component]
        MB[MermaidBlock Component]
        EB[ErrorBoundary Component]
        UI --> MI
        UI --> ML
        ML --> MB
        UI --> EB
    end

    subgraph Backend [.NET 8 Backend]
        AC[AgentsController]
        AS[AgentService]
        IAS[IAgentService Interface]
        
        AC --> AS
        AS --> IAS
    end

    subgraph DTOs [Data Transfer Objects]
        MD[MessageDto]
        TD[TextMessageDto]
        SR[SwarmResponseDto]
        ER[ErrorResponseDto]
    end

    Frontend -- HTTP/REST --> Backend
    Backend --> DTOs
Loading

Project Overview

The project consists of two main parts:

  1. A React frontend built with Vite for the user interface
  2. A .NET 8 backend that handles the code generation logic

Prerequisites

  • .NET 8.0 SDK
  • Node.js (16+ recommended) and npm

Installation and Setup

Backend Setup

cd AutogenAgentWorkflow/AutogenAgentWorkflow
dotnet restore
dotnet run

Frontend Setup

cd d:/CodeGenerationSwarm
npm install
npm run dev

The frontend will be available at http://localhost:5173, and the backend API at https://localhost:7296.

Project Structure

Frontend Components

  • src/App.jsx - Main application and chat state management
  • src/components/MessageList.jsx - Message history and display
  • src/components/MessageInput.jsx - User input interface
  • src/components/MermaidBlock.jsx - Mermaid diagram rendering
  • src/components/ErrorBoundary.jsx - Error handling

Backend Structure

  • Controllers/AgentsController.cs - API endpoints
  • Agents/AgentService.cs - Core swarm logic
  • Entities/ - Data transfer objects

API Configuration

Backend API Details

  • The application communicates with the backend at /api/Agents/PythonCodingSwarm endpoint
  • The backend implements a RESTful API using .NET 8
  • Supports various message types through DTOs:
    • MessageDto: Base message structure
    • TextMessageDto: Text-based messages
    • SwarmResponseDto: Swarm processing results
    • ErrorResponseDto: Error handling

Development Setup

  • The project uses Vite's dev proxy configuration (vite.config.js) to handle API requests
  • Proxy forwards /api/* requests to the backend server
  • This setup eliminates CORS and certificate issues during development

Security Notes

  • For production deployment, ensure proper SSL/TLS certification
  • Configure appropriate CORS policies in the backend
  • Review and update security settings in appsettings.json

Contributing

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

License

This project is licensed under the MIT License.

About

Python Code Generation Swarm with Autogen Agents

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published