# aakriti1318/crew-agent-generator architecture

> Architecture diagram of the GitHub repository aakriti1318/crew-agent-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aakriti1318/crew-agent-generator
- Repository: https://github.com/aakriti1318/crew-agent-generator

## Overview

##### Project Type & Purpose
- Type: Full‐stack (lightweight) web application, built with Streamlit as both frontend and backend.
- Purpose: Accept user prompts in natural language, call OpenAI’s GPT API to generate a structured “CrewAI” configuration (agents + tasks), and display ready‐to‐use Python code.

##### File Structure
- app.py (entry point for Streamlit UI & controller logic)
- multi‐agent‐generator.py / multi‐agent‐generator‐adv.py (service modules implementing prompt engineering & response parsing)
- requirements.txt (.env for API key via python‐dotenv)
- crew_generator.mp4 (demo asset, not part of runtime)

a. Streamlit UI Layer
- Browser Client (user’s web browser)
- Streamlit Server (app.py)
b. Business Logic Layer
- Prompt Handler (in app.py)
- Generation Modules (multi‐agent‐generator.py & adv)
c. External Service
- OpenAI GPT‐4o‐mini API
d. Local Configuration
- .env storage (OPENAI_API_KEY)

##### Relationships & Data Flows
1. User enters prompt in Browser → hits “Generate Crew.”
2. Streamlit Server (app.py) receives request → passes prompt to Generation Modules.
3. Generation Modules format prompt → call OpenAI API via openai-python client (using API key from .env).
4. OpenAI returns JSON response (agents + tasks).
5. Modules parse response → return structured code snippets to Streamlit Server.
6. Streamlit renders generated code back in the Browser UI.

##### Architectural Patterns & Design Principles
- Three‐Tier Pattern: Presentation (Streamlit), Application Logic (Generation Modules), External Service (OpenAI API).
- Single Page App: Server & frontend coupled via Streamlit’s rerun model.
- Environment Configuration: 12‐factor “config in environment” via python‐dotenv.

- Clear component names: Browser (User UI), Streamlit App (app.py), Generation Service (multi-agent modules), OpenAI API, Config Store (.env)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    Browser["Browser (User UI)"]:::blue
    Streamlit["Streamlit App (app.py)"]:::blue

    %% Logic Layer
    subgraph "Generation Modules"
        Basic["Basic Generator\n(multi-agent-generator.py)"]:::green
        Adv["Advanced Generator\n(multi-agent-generator-adv.py)"]:::green
    end

    %% External & Config
    OpenAI["OpenAI GPT-4 API"]:::orange
    Env[".env (Config Store)"]:::gray
    Req["Dependencies\n(requirements.txt)"]:::gray
    Demo["Demo Asset\n(crew_generator.mp4)"]:::gray

    %% Data Flows
    Browser -->|"User Prompt"| Streamlit
    Streamlit -->|"Invoke Prompt Handler"| Basic
    Streamlit -->|"Invoke Prompt Handler"| Adv
    Basic -->|"API Request\n(with API Key)"| OpenAI
    Adv -->|"API Request\n(with API Key)"| OpenAI
    Env -->|"Loads API Key"| Streamlit
    Req -->|"Dependency List"| Streamlit
    OpenAI -->|"JSON Response"| Basic
    OpenAI -->|"JSON Response"| Adv
    Basic -->|"Parsed Code Snippets"| Streamlit
    Adv -->|"Parsed Code Snippets"| Streamlit
    Streamlit -->|"Rendered Code"| Browser

    %% Click Events
    click Streamlit "https://github.com/aakriti1318/crew-agent-generator/blob/main/app.py"
    click Basic "https://github.com/aakriti1318/crew-agent-generator/blob/main/multi-agent-generator.py"
    click Adv "https://github.com/aakriti1318/crew-agent-generator/blob/main/multi-agent-generator-adv.py"
    click Req "https://github.com/aakriti1318/crew-agent-generator/blob/main/requirements.txt"
    click Demo "https://github.com/aakriti1318/crew-agent-generator/blob/main/crew_generator.mp4"

    %% Styling
    classDef blue fill:#cce5ff,stroke:#004085,color:#004085;
    classDef green fill:#d4edda,stroke:#155724,color:#155724;
    classDef orange fill:#ffe5b4,stroke:#ff8c00,color:#ff8c00;
    classDef gray fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
```
