# mobile-innowise-group/devpilot architecture

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

- Interactive diagram: https://gitdiagram.com/mobile-innowise-group/devpilot
- Repository: https://github.com/mobile-innowise-group/devpilot

## Overview

##### Project type and purpose
- DevPilot is a command-line interface (CLI) code generator written in Dart.
- Purpose: Prompt the user for specifications, then scaffold a multi-module Flutter project (Core, Core UI, Domain, Data, Navigation, Features).

##### File structure
- bin/dev_pilot.dart – the CLI entrypoint; invokes the generation workflow.
- lib/src/ – core source:
– services/ (DirectoryService, FileService, InputService, ScriptService)
– validators/ (Validator)
– constants/ (AppConstants)
– templates/ (feature templates, prebuild scripts)
- example/ – demo usage
- doc/api/ – generated API docs
- .github/ – CI pipeline (publish.yml)
- pubspec.yaml – dependencies (dcli, mason_logger, args)

##### README for additional insights
- Key external libraries: dcli (prompting, file I/O), mason_logger (logging).
- Workflow phases: Input → Validation → Directory scaffolding → File writing → Script execution.
- Outputs: a fully scaffolded Flutter project with a fixed module layout.

##### Diagramming the main components
a. Components
1. CLI Entrypoint
– bin/dev_pilot.dart
– Uses args package to parse “create” command
2. Input & Validation Layer
– InputService (prompts user via dcli)
– Validator (ensures valid module names, flavors)
3. Core Services
– DirectoryService (creates folders)
– FileService (writes templates into target directories)
– ScriptService (runs any prebuild scripts)
4. Template Store
– lib/src/templates (feature templates, pubspec stub, prebuild script)
5. External Libraries
– dcli (I/O, prompting)
– mason_logger (console logging)
6. Output Artifact
– Generated Flutter project (module directories: core, domain, data, core_ui, navigation, features)
7. CI/Publishing
– .github/workflows/publish.yml (publishes to pub.dev)

b. Relationships & Data Flow
1. User runs “dev_pilot create” → CLI Entrypoint
2. Entrypoint calls InputService → collects project name, modules, flavors
3. InputService passes data to Validator → ensures constraints
4. On success, Entrypoint orchestrates:
- DirectoryService → create root project folder and sub-folders
- FileService → copy and render template files (pubspec.yaml, lib stubs)
- ScriptService → execute prebuild scripts (shell script)
5. Throughout, mason_logger logs status and errors to console
6. Final: user inspects the generated Flutter project

c. Architectural Patterns & Principles
– Layered design: CLI layer → service layer → template engine → persistence (file system)
– Single‐responsibility: each Service class does one job
– Template‐driven code generation
– External libs abstract away I/O and logging

d. Key Technologies & Frameworks
– Dart (language)
– dcli (I/O, prompts, directory/file helpers)
– mason_logger (structured console output)
– args (command parsing)

##### Detailed capture of architectural elements
– Show error handling: Validator can route back to InputService on invalid input.
– Annotate any major methods or data structures if space permits (e.g., “Template variables: projectName, modulesList”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Layer
    subgraph "CLI Layer"
        CLIEntrypoint["CLI Entrypoint\n(bin/dev_pilot.dart)"]:::internal
    end

    %% Input & Validation Layer
    subgraph "Input & Validation"
        InputService["InputService\n(lib/src/services/input_service.dart)"]:::internal
        Validator["Validator\n(lib/src/validators/validator.dart)"]:::internal
        Decision{"Valid Input?"}:::decision
    end

    %% Service Layer
    subgraph "Core Services"
        DirectoryService["DirectoryService\n(lib/src/services/directory_service.dart)"]:::internal
        FileService["FileService\n(lib/src/services/file_service.dart)"]:::internal
        ScriptService["ScriptService\n(lib/src/services/script_service.dart)"]:::internal
        AppConstants["AppConstants\n(lib/src/constants/app_constants.dart)"]:::internal
    end

    %% Template Store
    subgraph "Template Store"
        PubspecTemplate["pubspec.yaml\n(lib/src/templates/feature/pubspec.yaml)"]:::template
        PrebuildScript["prebuild_script.sh\n(lib/src/templates/prebuild/prebuild_script.sh)"]:::template
    end

    %% External Libraries
    subgraph "External Libraries"
        DCli["dcli"]:::external
        MasonLogger["mason_logger"]:::external
        ArgsLib["args"]:::external
    end

    %% CI Pipeline
    subgraph "CI / Publishing" 
        CIWorkflow["publish.yml\n(.github/workflows/publish.yml)"]:::ci
    end

    %% Artifact
    GeneratedProject["Generated Flutter Project\n(modules: core, domain, data, core_ui, navigation, features)"]:::artifact

    %% Example & Docs
    ExampleUsage["Example Usage\n(example/README.md)"]:::artifact
    APIDocs["API Documentation\n(doc/api)"]:::artifact

    %% Flow
    CLIEntrypoint -->|"runs create"| InputService
    InputService -->|"collect specs"| Validator
    Validator -->|Yes| Decision
    Decision -->|Valid| DirectoryService
    Decision -->|Invalid| InputService
    DirectoryService -->|"make folders"| FileService
    FileService -->|"render & write"| ScriptService
    ScriptService -->|"run scripts"| GeneratedProject
    FileService -->|"load templates"| PubspecTemplate
    FileService -->|"load templates"| PrebuildScript

    %% Services use constants
    DirectoryService -->|uses| AppConstants
    FileService -->|uses| AppConstants
    ScriptService -->|uses| AppConstants

    %% External Lib calls
    InputService -->|uses| DCli
    FileService -->|uses| DCli
    ScriptService -->|uses| DCli
    CLIEntrypoint -->|parses args| ArgsLib
    CLIEntrypoint -->|logs status| MasonLogger
    DirectoryService -->|logs status| MasonLogger
    FileService -->|logs status| MasonLogger
    ScriptService -->|logs status| MasonLogger

    %% CI triggers on repo push
    CIWorkflow -->|"on push to master"| CIWorkflow
    CIWorkflow -->|"runs dart pub publish"| CIWorkflow

    %% Example & Docs relationship
    CLIEntrypoint --> ExampleUsage
    CLIEntrypoint --> APIDocs

    %% Click Events
    click CLIEntrypoint "https://github.com/mobile-innowise-group/devpilot/blob/main/bin/dev_pilot.dart"
    click InputService "https://github.com/mobile-innowise-group/devpilot/blob/main/lib/src/services/input_service.dart"
    click Validator "https://github.com/mobile-innowise-group/devpilot/blob/main/lib/src/validators/validator.dart"
    click DirectoryService "https://github.com/mobile-innowise-group/devpilot/blob/main/lib/src/services/directory_service.dart"
    click FileService "https://github.com/mobile-innowise-group/devpilot/blob/main/lib/src/services/file_service.dart"
    click ScriptService "https://github.com/mobile-innowise-group/devpilot/blob/main/lib/src/services/script_service.dart"
    click AppConstants "https://github.com/mobile-innowise-group/devpilot/blob/main/lib/src/constants/app_constants.dart"
    click PubspecTemplate "https://github.com/mobile-innowise-group/devpilot/blob/main/lib/src/templates/feature/pubspec.yaml"
    click PrebuildScript "https://github.com/mobile-innowise-group/devpilot/blob/main/lib/src/templates/prebuild/prebuild_script.sh"
    click CIWorkflow "https://github.com/mobile-innowise-group/devpilot/blob/main/.github/workflows/publish.yml"
    click ExampleUsage "https://github.com/mobile-innowise-group/devpilot/blob/main/example/README.md"
    click APIDocs "https://github.com/mobile-innowise-group/devpilot/tree/main/doc/api"

    %% Legend
    subgraph Legend
        style Legend fill:#ffffff,stroke:#fff
        Internal["Internal Component"]:::internal
        External["External Library"]:::external
        Template["Template Asset"]:::template
        CIComp["CI Component"]:::ci
        ArtifactComp["Artifact / Output"]:::artifact
        DecisionComp["Decision"]:::decision
    end

    %% Styles
    classDef internal fill:#D0E8FF,stroke:#0366d6,stroke-width:1px;
    classDef external fill:#DFFFE0,stroke:#28a745,stroke-width:1px;
    classDef template fill:#FFF5BA,stroke:#f4c20d,stroke-width:1px;
    classDef ci fill:#E0E0E0,stroke:#6a737d,stroke-width:1px;
    classDef artifact fill:#FFE0B2,stroke:#FF9800,stroke-width:1px;
    classDef decision fill:#FFCDD2,stroke:#e53935,stroke-width:1px,stroke-dasharray: 5 5;
```
