# dened/svg_iconfont_benchmark architecture

> Architecture diagram of the GitHub repository dened/svg_iconfont_benchmark, 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/svg_iconfont_benchmark
- Repository: https://github.com/dened/svg_iconfont_benchmark

## Overview

##### Project Type & Purpose
- This is a cross‐platform Flutter benchmarking application.
- It compares rendering performance of:
- SVG via flutter_svg
- Custom IconFont via icon_font_generator
- Pre‐compiled vector graphics (.vec) via vector_graphics_compiler
- Compiled Flutter Widgets via svg2dart
- Manual custom painters, Picture/RenderBox implementations

##### File Structure Analysis
- Top‐level “android/ ios/ linux/ macos/ windows/ web” → Flutter platform hosts
- “lib/” → App source:
- main.dart and “_screen.dart” files → UI entry points & benchmarking screens
- “lib/widgets_bench/…” → Widgets generated by svg2dart for widget‐based benchmark
- “assets/” → Graphic input & outputs:
- assets/icons_vec/ → .vec files from vector_graphics_compiler
- “bin/” → Dart code‐generation scripts:
- generate_svg.dart
- symbols_gen.dart
- widgets_all_gen.dart
- “create_report/” → Python reporting tool (uv, main.py) reading JSON metrics & plotting charts
- “integration_test/” & “test_driver/” → Flutter Driver test harness for performance measurement

##### README Insights
- Benchmarks are driven by `flutter drive …` producing timeline_summary JSON for both iconfont & SVG.
- Scripts to compile SVG → .vec, generate iconfont, generate widget classes.
- Reporting: create_report reads measured metrics and generates comparative charts under create_report/output.

A. Development & Code Generation (Dev‐Time)
2. External Generators:
- vector_graphics_compiler → assets/icons_vec/
- svg2dart → lib/widgets_bench/*.dart + lib/widgets_bench/_all.dart
3. bin/*.dart scripts → post‐process or augment generated code (symbols_gen.dart, widgets_all_gen.dart, generate_svg.dart)

B. Flutter Application (Runtime)
- Uses:
- Assets (SVGs, .vec, OTF font)
- UI screens (benchmark_screen.dart, *_screen.dart)
- Runs on multiple platforms (Android, iOS, Linux, MacOS, Windows, Web)

C. Integration Test Harness & Metrics Collection
- Flutter Driver (test_driver/perf_driver.dart) + integration_test/performance_test.dart
- Produces timeline_summary JSON in build/

D. Reporting Module (Post‐Test)
- Python script (create_report/main.py)
- Reads JSON metrics (build/*.timeline_summary.json or create_report/metrics/)
- Generates comparative charts (PNG) under create_report/output

##### Architectural Patterns & Principles
- Separation of Concerns:
- Dev‐time pipeline isolated from runtime
- Benchmark UI decoupled from code generators
- Reporting independent from app code
- Generated‐code strategy to maximize performance parity

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Dev-Time Phase
  subgraph "Dev-Time Pipeline"
    direction TB
    SVG_ASSETS["Raw SVG Assets"]:::assets
    VECTOR_COMPILER["Vector Graphics Compiler"]:::devtime
    ICONFONT_GEN["IconFont Generator"]:::devtime
    WIDGET_GEN["svg2dart Widget Generator"]:::devtime
    BIN_SCRIPTS["bin Scripts"]:::devtime

    SVG_ASSETS -->|"compile .vec"| VECTOR_COMPILER
    VECTOR_COMPILER -->|"output .vec files"| ICONS_VEC["Vector Compiler Output"]:::assets

    SVG_ASSETS -->|"generate OTF & Dart"| ICONFONT_GEN
    ICONFONT_GEN -->|"output OTF"| ICON_FONT_OTF["Symbols.otf"]:::assets
    ICONFONT_GEN -->|"output Dart icons"| SYMBOLS_GEN["symbols.gen.dart"]:::devtime

    SVG_ASSETS -->|"generate widgets"| WIDGET_GEN
    WIDGET_GEN -->|"output widget Dart"| WIDGETS_BENCH["lib/widgets_bench/"]:::devtime

    VECTOR_COMPILER -->|"post-process"| BIN_SCRIPTS
    ICONFONT_GEN -->|"post-process"| BIN_SCRIPTS
    WIDGET_GEN -->|"post-process"| BIN_SCRIPTS
    BIN_SCRIPTS -->|"produce generated code"| ASSETS_GEN["assets.gen.dart"]:::devtime
    BIN_SCRIPTS -->|"produce generated code"| FONTS_GEN["fonts.gen.dart"]:::devtime
    BIN_SCRIPTS -->|"produce generated code"| PAINTER_ALL["lib/gen/painter/_all.dart"]:::devtime
    BIN_SCRIPTS -->|"produce generated code"| PICTURE_ALL["lib/gen/picture/_all.dart"]:::devtime
    BIN_SCRIPTS -->|"produce generated code"| RENDER_BOX_ALL["lib/gen/render_box/_all.dart"]:::devtime
  end

  %% Runtime Phase
  subgraph "Runtime Application"
    direction TB
    FLUTTER_APP["Flutter App"]:::runtime
    FLUTTER_APP -->|"runs on"| PLATFORMS["Platforms"]:::runtime
    SVG_ASSETS -->|"used by"| FLUTTER_APP
    ICONS_VEC -->|"used by"| FLUTTER_APP
    ICON_FONT_OTF -->|"used by"| FLUTTER_APP
    SYMBOLS_GEN -->|"used by"| FLUTTER_APP
    WIDGETS_BENCH -->|"used by"| FLUTTER_APP
    ASSETS_GEN -->|"used by"| FLUTTER_APP
    FONTS_GEN -->|"used by"| FLUTTER_APP
    PAINTER_ALL -->|"used by"| FLUTTER_APP
    PICTURE_ALL -->|"used by"| FLUTTER_APP
    RENDER_BOX_ALL -->|"used by"| FLUTTER_APP
  end

  %% Testing Phase
  subgraph "Testing & Metrics"
    direction TB
    DRIVER_TEST["Driver Test Harness"]:::testing
    INTEGRATION_TEST["Integration Tests"]:::testing
    METRICS_JSON["Metrics JSON"]:::testing

    FLUTTER_APP -->|"run benchmark"| DRIVER_TEST
    FLUTTER_APP -->|"run benchmark"| INTEGRATION_TEST
    DRIVER_TEST -->|"produce JSON"| METRICS_JSON
    INTEGRATION_TEST -->|"produce JSON"| METRICS_JSON
  end

  %% Reporting Phase
  subgraph "Reporting Module"
    direction TB
    REPORT_GEN["Report Generator"]:::reporting
    METRICS_DIR["Metrics Directory"]:::reporting
    OUTPUT_DIR["Charts Output"]:::reporting

    METRICS_JSON -->|"collect metrics"| REPORT_GEN
    REPORT_GEN -->|"reads from"| METRICS_DIR
    REPORT_GEN -->|"produce charts"| OUTPUT_DIR
  end

  %% Click Events
  click SVG_ASSETS "https://github.com/dened/svg_iconfont_benchmark/tree/main/assets/icons/"
  click ICONS_VEC "https://github.com/dened/svg_iconfont_benchmark/tree/main/assets/icons_vec/"
  click ICON_FONT_OTF "https://github.com/dened/svg_iconfont_benchmark/blob/main/assets/iconfont/Symbols.otf"
  click SYMBOLS_GEN "https://github.com/dened/svg_iconfont_benchmark/blob/main/lib/icons/symbols.gen.dart"
  click WIDGETS_BENCH "https://github.com/dened/svg_iconfont_benchmark/tree/main/lib/widgets_bench/"
  click BIN_SCRIPTS "https://github.com/dened/svg_iconfont_benchmark/blob/main/bin/generate_svg.dart"
  click BIN_SCRIPTS "https://github.com/dened/svg_iconfont_benchmark/blob/main/bin/symbols_gen.dart"
  click BIN_SCRIPTS "https://github.com/dened/svg_iconfont_benchmark/blob/main/bin/widgets_all_gen.dart"
  click ASSETS_GEN "https://github.com/dened/svg_iconfont_benchmark/blob/main/lib/gen/assets.gen.dart"
  click FONTS_GEN "https://github.com/dened/svg_iconfont_benchmark/blob/main/lib/gen/fonts.gen.dart"
  click PAINTER_ALL "https://github.com/dened/svg_iconfont_benchmark/blob/main/lib/gen/painter/_all.dart"
  click PICTURE_ALL "https://github.com/dened/svg_iconfont_benchmark/blob/main/lib/gen/picture/_all.dart"
  click RENDER_BOX_ALL "https://github.com/dened/svg_iconfont_benchmark/blob/main/lib/gen/render_box/_all.dart"
  click DRIVER_TEST "https://github.com/dened/svg_iconfont_benchmark/blob/main/test_driver/perf_driver.dart"
  click INTEGRATION_TEST "https://github.com/dened/svg_iconfont_benchmark/blob/main/integration_test/performance_test.dart"
  click REPORT_GEN "https://github.com/dened/svg_iconfont_benchmark/blob/main/create_report/main.py"
  click METRICS_DIR "https://github.com/dened/svg_iconfont_benchmark/tree/main/create_report/metrics/"
  click OUTPUT_DIR "https://github.com/dened/svg_iconfont_benchmark/tree/main/create_report/output/"

  %% Styles
  classDef devtime fill:#cce5ff,stroke:#333,stroke-width:1px;
  classDef runtime fill:#d4edda,stroke:#333,stroke-width:1px;
  classDef testing fill:#ffe5b4,stroke:#333,stroke-width:1px;
  classDef reporting fill:#e2ccff,stroke:#333,stroke-width:1px;
  classDef assets fill:#f0f0f0,stroke:#333,stroke-width:1px;
```
