# hem9984/azlon-demo architecture

> Architecture diagram of the GitHub repository hem9984/azlon-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hem9984/azlon-demo
- Repository: https://github.com/hem9984/azlon-demo

## Overview

##### Main Components
- Frontend UI:
- Located in the “frontend” directory.
- Built with React (using TypeScript and Vite), Tailwind CSS, and a rich set of UI components.
- Main entry point is in frontend/src/main.tsx, with additional pages/components forming the user interface (including workflow forms and result displays).
- Backend Engine:
- Found in the “backend” directory.
- Contains a Python application (likely based on FastAPI or a similar framework) that implements the autonomous coding workflow.
- Key files include backend/main.py, as well as modular functionality in backend/src (with separate modules for client, functions, workflows, prompts, and services).
- Docker Infrastructure:
- The docker-compose.yml file orchestrates multiple services such as:
- The “restack-engine” service (exposing a UI likely on port 5233).
- The “docker-dind” service, which enables Docker-in-Docker for container builds.
- The backend service.
- The frontend service.
- External Dependencies:
- OpenAI API Key integration (configured via a .env file).
- OpenAI’s GPT models that underpin the autonomous code generation.

##### Relationships and Interactions
- The Frontend <--> Backend Interaction:
- The React UI is used to collect user prompts and testing conditions. These are sent to the backend service via a REST API.
- The backend processes incoming requests, invokes code generation using GPT models, and manages workflow execution.
- The Backend <--> Docker Infrastructure:
- The backend coordinates with Docker-in-Docker to dynamically build and run generated code within containerized environments.
- It also integrates with the Restack engine to display workflow state/status and manage the continuous feedback loop.
- Data Flow Overview:
- User enters a prompt and test conditions in the Frontend.
- The request is handled by the Backend, which generates code and triggers corresponding Docker container build/run operations.
- Processed workflow stages and results are routed back to both the Frontend and the Restack UI for monitoring.

##### Architectural Patterns & Design Principles
- Modularization:
- Both frontend and backend are organized into distinct modules/components, aiding maintainability.
- The backend separates concerns with folders for client communication, functions, services, and workflows.
- Containerization & Microservices:
- Using Docker Compose shows an architectural choice towards a microservices-like design, where each service (e.g., backend, frontend, restack-engine) is decoupled but interdependent.
- API-driven Communication:
- There is a clear API layer between the frontend (user input and display) and the backend (processing, orchestration, and monitoring).

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["User"]:::external

    subgraph "Frontend"
        FUI["Frontend UI (React/Vite + Tailwind)"]:::frontend
        FMain["Main Entry (frontend/src/main.tsx)"]:::frontend
        FUI -->|"initializes"| FMain
    end

    subgraph "Backend"
        BS["Backend Service (Python/FastAPI)"]:::backend
        BMain["Main Application (backend/main.py)"]:::backend
        Client["Client Module (backend/src/client.py)"]:::backend
        Functions["Functions Module (backend/src/functions)"]:::backend
        Prompts["Prompts Module (backend/src/prompts.py)"]:::backend
        Services["Services Module (backend/src/services.py)"]:::backend
        Workflows["Workflows Module (backend/src/workflows)"]:::backend
        BS --> BMain
        BS --> Client
        BS --> Functions
        BS --> Prompts
        BS --> Services
        BS --> Workflows
    end

    subgraph "Docker Infrastructure"
        DC["Docker Compose (docker-compose.yml)"]:::container
        Dind["Docker-in-Docker Container"]:::container
        Restack["Restack Engine Container (Port 5233)"]:::container
        BDockerfile["Backend Dockerfile (backend/Dockerfile)"]:::container
        FDockerfile["Frontend Dockerfile (frontend/Dockerfile)"]:::container
        DC --> Dind
        DC --> Restack
        DC --> BDockerfile
        DC --> FDockerfile
    end

    OAI["OpenAI API Integration"]:::external

    %% Interactions between components
    U -->|"submits_prompt"| FUI
    FUI -->|"REST_API_call"| BS
    BS -->|"build_run"| Dind
    BS -->|"workflow_status"| Restack
    BS -->|"code_generation"| OAI

    %% Click Events for Frontend Components
    click FUI "https://github.com/hem9984/azlon-demo/tree/master/frontend/"
    click FMain "https://github.com/hem9984/azlon-demo/blob/master/frontend/src/main.tsx"

    %% Click Events for Backend Components
    click BS "https://github.com/hem9984/azlon-demo/tree/master/backend/"
    click BMain "https://github.com/hem9984/azlon-demo/blob/master/backend/main.py"
    click Client "https://github.com/hem9984/azlon-demo/blob/master/backend/src/client.py"
    click Functions "https://github.com/hem9984/azlon-demo/tree/master/backend/src/functions"
    click Prompts "https://github.com/hem9984/azlon-demo/blob/master/backend/src/prompts.py"
    click Services "https://github.com/hem9984/azlon-demo/blob/master/backend/src/services.py"
    click Workflows "https://github.com/hem9984/azlon-demo/tree/master/backend/src/workflows"

    %% Click Events for Docker Infrastructure
    click DC "https://github.com/hem9984/azlon-demo/blob/master/docker-compose.yml"
    click BDockerfile "https://github.com/hem9984/azlon-demo/tree/master/backend/Dockerfile"
    click FDockerfile "https://github.com/hem9984/azlon-demo/tree/master/frontend/Dockerfile"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef container fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef external fill:#FFD700,stroke:#000,stroke-width:2px;
```
