# ashupanwar10/genai-create-react-app-scaffolder architecture

> Architecture diagram of the GitHub repository ashupanwar10/genai-create-react-app-scaffolder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ashupanwar10/genai-create-react-app-scaffolder
- Repository: https://github.com/ashupanwar10/genai-create-react-app-scaffolder

## Overview

##### Project type and purpose
- This is an open-source scaffolding tool built in Python. It provides a Streamlit-based web UI (“chatbot.py”) that lets users describe the kind of React application they want; it then calls the OpenAI API to generate the corresponding React app boilerplate.

##### File structure
- Top-level files only; no subdirectories.
- chatbot.py – the Streamlit entry point (frontend/UI).
- create_react_app.py – core scaffolding logic (generates file/folder structure).
- prompt.py – builds and manages prompt templates.
- helper_func.py & movie_helpers.py – utility functions and example-specific helpers.
- requirements.txt/.gitignore – environment and dependency management.
- Key patterns: monolithic Python service with clear separation between UI (Streamlit) and business logic (scaffolding modules).

##### Extract architectural insights from README
- The app loads environment variables via python-dotenv (OPENAI_API_KEY).
- On startup, the Streamlit server binds to port 8501.
- When a user submits specifications, the service constructs a prompt, calls OpenAI’s REST API, then parses the response into files/folders and presents them for download.

##### Main components and their interactions
a. Streamlit Frontend (chatbot.py)
- Captures user input, displays progress, and shows download links or previews.
b. Application Logic
- prompt.py: assembles the natural-language prompt.
- create_react_app.py: interprets the LLM’s response, writes files to disk or in-memory zip.
- helper_func.py/movie_helpers.py: shared utilities for formatting, validation, example prompts.
c. External Service
- OpenAI API (via the openai Python client) for code generation.
d. Environment Layer
- python-dotenv loads API keys from .env.
e. File System / Output
- Temporary directory or archive containing generated React app scaffold.

##### Architectural patterns and design principles
- Single-process, modular internal design: separation of concerns between UI, prompt construction, scaffolding engine, and helpers.
- Externalize configuration (dotenv): keeps secrets out of code.
- Synchronous request/response cycle: user → LLM call → code generation → user.

- Clear labels on every component/module.
- Notes on environment variable loading and port binding (Streamlit server).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        User["User Browser"]:::external
        Chatbot["Streamlit UI\n(chatbot.py)"]:::ui
        Download["Download Link / Preview"]:::ui
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Env["python-dotenv\n(load .env)"]:::infra
        Prompt["Prompt Builder\n(prompt.py)"]:::logic
        Scaffolder["Scaffolding Engine\n(create_react_app.py)"]:::logic
        Helpers["Utility Functions\n(helper_func.py)"]:::logic
        Examples["Example Helpers\n(movie_helpers.py)"]:::logic
    end

    %% Integration Layer
    subgraph "Integration Layer"
        direction TB
        OpenAI["OpenAI API"]:::external
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        direction TB
        FileSys["File System / ZIP Archive"]:::storage
        Requirements["Environment Config\n(requirements.txt)"]:::infra
        Docs["Documentation\n(readme.md)"]:::infra
    end

    %% Flow
    User -->|"access via port 8501"| Chatbot
    Chatbot -->|"load env vars"| Env
    Chatbot -->|"user specs"| Prompt
    Prompt -->|"constructed prompt"| OpenAI
    OpenAI -->|"LLM response"| Scaffolder
    Scaffolder -->|"uses helpers"| Helpers
    Scaffolder -->|"uses examples"| Examples
    Scaffolder -->|"writes files"| FileSys
    FileSys -->|"/archive.zip"| Download
    Download -->|"download to"| User

    %% Click Events
    click Chatbot "https://github.com/ashupanwar10/genai-create-react-app-scaffolder/blob/main/chatbot.py"
    click Prompt "https://github.com/ashupanwar10/genai-create-react-app-scaffolder/blob/main/prompt.py"
    click Scaffolder "https://github.com/ashupanwar10/genai-create-react-app-scaffolder/blob/main/create_react_app.py"
    click Helpers "https://github.com/ashupanwar10/genai-create-react-app-scaffolder/blob/main/helper_func.py"
    click Examples "https://github.com/ashupanwar10/genai-create-react-app-scaffolder/blob/main/movie_helpers.py"
    click Requirements "https://github.com/ashupanwar10/genai-create-react-app-scaffolder/blob/main/requirements.txt"
    click Docs "https://github.com/ashupanwar10/genai-create-react-app-scaffolder/blob/main/readme.md"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#000;
    classDef logic fill:#DFF8E1,stroke:#228B22,color:#000;
    classDef external fill:#FFEFD5,stroke:#FF8C00,color:#000;
    classDef storage fill:#F2F2F2,stroke:#666,color:#000;
    classDef infra fill:#F5F5DC,stroke:#A9A9A9,color:#000
```
