# mahesh-r-mesta/pro_pilot_cli architecture

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

- Interactive diagram: https://gitdiagram.com/mahesh-r-mesta/pro_pilot_cli
- Repository: https://github.com/mahesh-r-mesta/pro_pilot_cli

## Overview

##### Project Type & Purpose
- This is a CLI tool built in Dart that uses AI to generate boilerplate/scaffolding code for Flutter and React projects.
- The tool’s core features include generating full Flutter or React project structures as well as adding boilerplate code to an existing project.

##### File Structure
- The project is organized with key directories:
- "bin": Contains the CLI entry point (pro_pilot.dart and its compiled executables).
- "lib": Includes the main logic separated into submodules.
▪ "lib/ai": Holds services for AI integration (base_ai_service.dart, gemini_service.dart, openai_service.dart) that abstract away API calls to different AI providers.
▪ "lib/builder": Contains builder classes for scaffolding code generation (base_builder, boiletplate_builder, flutter build, react build). This shows an architectural pattern where different builders implement the same interface for handling various project types.
▪ Additional utility files (folder_setup_tool.dart, model.dart, prompt.dart) support project scaffolding and command-line functionalities.
- Other files such as pubspec.yaml, analysis_options.yaml, and change logs indicate standard Dart project management and versioning, but they play a supporting role in the overall architecture.

##### README for Additional Insights
- The README clarifies that the CLI supports generating new Flutter and React projects as well as inserting boilerplate code for existing projects.
- It also lists the required dependencies (Dart, Node.js & npm, Flutter SDK), suggesting that the CLI interacts with external systems and libraries for these frameworks.

a. Main Components:
- CLI Entry Point (bin/pro_pilot.dart): Acts as the interface that accepts user commands.
- AI Service Layer (lib/ai): Abstracts access to different AI systems like Gemini and OpenAI.
- Builder Module (lib/builder): Contains separate builder implementations (Flutter, React, and a generic boilerplate builder) that generate the project scaffolding.
- Utility and Support Components: Folder setup tool, model and prompt handlers that support scaffolding tasks.
- External Dependencies: Command-line interactions, SDKs (Dart, Flutter, Node.js/npm) and potentially network calls to AI APIs.

b. Relationships & Interactions:
- The CLI receives commands (e.g., “flutter”, “react”, “boilerplate”) and dispatches these to the corresponding builder module.
- The builder module, based on the project type, might invoke specific methods from the AI service layer to generate or refine content.
- The utility components (like folder setup and prompt generation) support both the CLI and builder modules.

c. Important Architectural Patterns/Design Principles:
- Modularity: Separation between AI services, builders, and CLI entry point.
- Strategy/Factory Pattern: The builder module likely uses a factory or strategy pattern to choose the appropriate builder (Flutter, React, or boilerplate) based on user input.
- Abstraction: AI interactions are abstracted behind a base AI service, allowing easy switching or integration of different AI providers.

d. Relevant Technologies:
- Dart as the primary programming language.
- Flutter SDK for Flutter project scaffolding.
- Node.js & npm for React project setup.
- External AI APIs (Gemini, OpenAI) for generating the required code via AI-powered scaffolding.

##### Elements
- Use clear and descriptive labels for each component:
- "CLI Entry (bin/pro_pilot.dart)"
- "AI Service Layer" with services such as Gemini Service and OpenAI Service
- "Builder Modules" with subdivisions like "Flutter Builder", "React Builder", and "Boilerplate Builder"
- "Utility Components" such as Folder Setup Tool, Model, and Prompt Handler
- "External Dependencies" such as Dart SDK, Flutter SDK, Node.js/npm, and external AI APIs.
- User commands flowing from the CLI to the Builder modules.
- Data flow between modules (e.g., the builder invoking AI services and processing responses).
- Dependencies on external services.
- User interface (CLI) components.
- Business logic modules (builders and AI services).
- External systems/integrations.
- Utility/support tools.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CLI Layer
    CLI["CLI Entry (bin/pro_pilot.dart)"]:::cli

    %% Builder Modules Layer
    subgraph "Builder Modules"
        BB["Boilerplate Builder"]:::builder
        FB["Flutter Builder"]:::builder
        RB["React Builder"]:::builder
    end

    %% AI Service Layer
    subgraph "AI Service Layer"
        BaseAI["Base AI Service"]:::ai
        Gemini["Gemini Service"]:::ai
        OpenAI["OpenAI Service"]:::ai
    end

    %% Utility Components Layer
    subgraph "Utility Components"
        FolderSetup["Folder Setup Tool"]:::utility
        ModelHandler["Model Handler"]:::utility
        PromptHandler["Prompt Handler"]:::utility
    end

    %% External Dependencies Layer
    subgraph "External Dependencies"
        DartSDK["Dart SDK"]:::external
        FlutterSDK["Flutter SDK"]:::external
        NodeSdk["Node.js/npm"]:::external
        ExternalAI["External AI APIs"]:::external
    end

    %% Relationships: CLI dispatches commands to Builder Modules
    CLI -->|"commands"| BB
    CLI -->|"commands"| FB
    CLI -->|"commands"| RB

    %% Builder Modules use AI Service Layer via Base AI Service
    BB -->|"usesBaseAI"| BaseAI
    FB -->|"usesBaseAI"| BaseAI
    RB -->|"usesBaseAI"| BaseAI

    %% Base AI Service delegates to specific providers
    BaseAI -->|"delegates"| Gemini
    BaseAI -->|"delegates"| OpenAI

    %% Builder Modules use Utility Components
    BB -->|"setupFiles"| FolderSetup
    FB -->|"useModel"| ModelHandler
    RB -->|"usePrompt"| PromptHandler

    %% External Dependencies for CLI and Builders
    CLI -->|"requires"| DartSDK
    FB -->|"requires"| FlutterSDK
    RB -->|"requires"| NodeSdk

    %% AI Service Layer calling External AI APIs
    Gemini -->|"calls"| ExternalAI
    OpenAI -->|"calls"| ExternalAI

    %% Click Events
    click CLI "https://github.com/mahesh-r-mesta/pro_pilot_cli/blob/master/bin/pro_pilot.dart"
    click BaseAI "https://github.com/mahesh-r-mesta/pro_pilot_cli/blob/master/lib/ai/base_ai_service.dart"
    click Gemini "https://github.com/mahesh-r-mesta/pro_pilot_cli/blob/master/lib/ai/gemini_service.dart"
    click OpenAI "https://github.com/mahesh-r-mesta/pro_pilot_cli/blob/master/lib/ai/openai_service.dart"
    click BB "https://github.com/mahesh-r-mesta/pro_pilot_cli/blob/master/lib/builder/boilerplate_builder.dart"
    click FB "https://github.com/mahesh-r-mesta/pro_pilot_cli/blob/master/lib/builder/fl_build.dart"
    click RB "https://github.com/mahesh-r-mesta/pro_pilot_cli/blob/master/lib/builder/react_build.dart"
    click FolderSetup "https://github.com/mahesh-r-mesta/pro_pilot_cli/blob/master/lib/folder_setup_tool.dart"
    click ModelHandler "https://github.com/mahesh-r-mesta/pro_pilot_cli/blob/master/lib/model.dart"
    click PromptHandler "https://github.com/mahesh-r-mesta/pro_pilot_cli/blob/master/lib/prompt.dart"

    %% Styling
    classDef cli fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef builder fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef ai fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef utility fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef external fill:#F5CBA7,stroke:#D35400,stroke-width:2px;
```
