# dened/svg2dart architecture

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

- Interactive diagram: https://gitdiagram.com/dened/svg2dart
- Repository: https://github.com/dened/svg2dart

## Overview

##### Project type and purpose
- This is an open-source command-line tool and build_runner plugin (“svg2dart”) that reads SVG data and generates high-performance Flutter widgets in pure Dart.
- It ships as a global CLI (`bin/svg2dart.dart`) and as a builder for `build_runner` (in `lib/src/svg2dart_builder.dart`).

##### File structure
- Top-level:
- bin/ : entry point for the CLI
- lib/ : core code under lib/src
- tool/ : helper scripts (e.g., finish_feature.dart)
- build.yaml : builder configuration defaults
- example/ : a full Flutter app demonstrating usage on Android, iOS, macOS, Linux, Windows, Web
- test/ : unit tests
- .github/ : CI workflows (checkout, deploy, tests-report)
- Inside `lib/src`:
- svg_reader.dart : parses SVG paths, fills, gradients
- code_generator.dart : turns parsed SVG data into Dart widget code
- generator_options.dart : CLI and builder flags/options
- svg2dart_builder.dart : defines the build_runner Builder

##### README
- Describes two usage modes:
a. CLI: reads input path, outputs Dart files
b. build_runner plugin: integrated into Dart/Flutter dev workflow
- Mentions preserved directory structure, self-contained widgets, and configuration via build.yaml.

##### Detail
- How `build.yaml` configures the builder’s input/output defaults
- `generator_options` as the central orchestrator linking CLI flags or builder options to the pipeline
- Example’s multi-platform structure to demonstrate end-to-end workflow

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Entry Points"
        CLI["CLI Runner (svg2dart)"]:::external
        Facade["Global Activation Facade"]:::external
        BuilderPlugin["build_runner Plugin"]:::external
    end

    subgraph "Core Library"
        Options["Generator Options"]:::core
        Reader["SVG Reader"]:::core
        Generator["Code Generator"]:::core
        FSAdapter["File System Adapter"]:::core
    end

    subgraph "Configuration"
        Config["Builder Configuration Defaults (build.yaml)"]:::core
    end

    subgraph "Output Artifacts"
        DartFiles["Generated Dart Widgets"]:::core
    end

    subgraph "Example App"
        ExampleMain["example/lib/main.dart"]:::external
        ExampleGen["example/lib/generated/"]:::external
    end

    subgraph "CI/CD Workflows"
        W1["checkout.yml"]:::ci
        W2["tests-report.yml"]:::ci
        W3["deploy.yml"]:::ci
    end

    subgraph "Testing"
        Tests["Unit Tests"]:::ci
    end

    CLI -->|"imports"| Facade
    CLI -->|"flags/input path"| Options
    Facade -->|"invokes"| Options
    BuilderPlugin -->|"builder options"| Options
    Config -->|"configures"| BuilderPlugin

    Options -->|"parsing orchestration"| Reader
    Reader -->|"in-memory SVG model"| Generator
    Generator -->|"Dart widget code"| FSAdapter
    FSAdapter -->|"writes files"| DartFiles

    DartFiles -->|"consumed by"| ExampleGen
    ExampleMain -->|"imports widgets"| ExampleGen

    W1 --> W2
    W2 --> W3
    W3 --> Tests
    W3 --> ExampleMain

    Tests -->|"tests core functionality"| Options
    Tests -->|"tests reader & generator"| Reader
    Tests -->|"tests end-to-end"| Generator

    classDef core fill:#D6EAF8,stroke:#21618C,color:#1B4F72
    classDef external fill:#D5F5E3,stroke:#1D8348,color:#145A32
    classDef ci fill:#FAD7A0,stroke:#B9770E,color:#7B241C

    click CLI "https://github.com/dened/svg2dart/blob/master/bin/svg2dart.dart"
    click Facade "https://github.com/dened/svg2dart/blob/master/lib/svg2dart.dart"
    click BuilderPlugin "https://github.com/dened/svg2dart/blob/master/lib/src/svg2dart_builder.dart"
    click Config "https://github.com/dened/svg2dart/blob/master/build.yaml"
    click Options "https://github.com/dened/svg2dart/blob/master/lib/src/generator_options.dart"
    click Reader "https://github.com/dened/svg2dart/blob/master/lib/src/svg_reader.dart"
    click Generator "https://github.com/dened/svg2dart/blob/master/lib/src/code_generator.dart"
    click FSAdapter "https://github.com/dened/svg2dart/blob/master/lib/generator.dart"
    click ExampleMain "https://github.com/dened/svg2dart/blob/master/example/lib/main.dart"
    click ExampleGen "https://github.com/dened/svg2dart/tree/master/example/lib/generated/"
    click Tests "https://github.com/dened/svg2dart/blob/master/test/svg2dart_test.dart"
    click W1 "https://github.com/dened/svg2dart/blob/master/.github/workflows/checkout.yml"
    click W2 "https://github.com/dened/svg2dart/blob/master/.github/workflows/tests-report.yml"
    click W3 "https://github.com/dened/svg2dart/blob/master/.github/workflows/deploy.yml"
```
