# pedro-ivo-neves/classy architecture

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

- Interactive diagram: https://gitdiagram.com/pedro-ivo-neves/classy
- Repository: https://github.com/pedro-ivo-neves/classy

## Overview

##### Project type and purpose
- This is a Dart macro‐based code‐generation package (`classy`) that provides annotations (`@data`, `@constructor`, `@fromJson`, `@toJson`, `@toString`) to automatically generate boilerplate for Dart classes at compile time.

##### File structure
- Top‐level:
- `lib/classy.dart`: public entrypoint that exports or wires up all macros
- `lib/src/constructors`, `lib/src/data`, `lib/src/methods`: the three macro‐module areas
- `example`: shows how a consuming project writes code using `classy`
- `test`: unit tests driving each macro’s behavior
- Configuration files:
- `analysis_options.yaml`: enables the Dart macro experiment
- `pubspec.yaml`: declares package metadata and macro dependencies

##### README for additional insights
- The README confirms this is purely a compile‐time code generator.
- It calls out the need to run Dart with `--enable-experiment=macros` and how to apply the annotations in user code.

##### Important detail capture
- Delegation relationship of `@data` to the sub‐macros.
- That all codegen happens before the final compilation step.

- Highlights each macro component
- Shows exactly how annotations flow through the macro engine
- Maps directly to the `lib/src/...` folders and their responsibilities
- Guides both new and experienced engineers in understanding and extending the `classy` architecture

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User code
    subgraph "User Space"
        UC["User Code (annotated classes)"]:::user
    end

    %% Macro engine
    ME["Dart Macro Engine"]:::engine

    %% Classy package modules
    subgraph "Classy Package"
        EP["classy.dart"]:::module
        CM["Constructor Module"]:::module
        CImp["constructor.dart"]:::module
        CJSON["from_json.dart"]:::module
        DM["Data Module (@data)"]:::module
        MM1["to_json.dart"]:::module
        MM2["to_string.dart"]:::module
    end

    %% Generated code and compiler
    GC["Generated Code"]:::user
    DC["Dart Compiler"]:::engine

    %% Test suite
    subgraph "Test Suite"
        TRoot["test/classy_test.dart"]:::test
        TCons["test/src/constructors"]:::test
        TFrom["test/src/constructors/fromJson"]:::test
        TData["test/src/data"]:::test
        TToJson["test/src/methods/toJson"]:::test
        TToString["test/src/methods/toString"]:::test
    end

    %% Configuration
    subgraph "Configuration"
        AO["analysis_options.yaml"]:::config
        PS["pubspec.yaml"]:::config
    end

    %% Data flow
    UC -->|"annotation input"| ME
    ME -->|"discovers macros"| EP
    EP -->|"wires entrypoints"| CM
    EP -->|"wires entrypoints"| DM
    EP -->|"wires entrypoints"| MM1
    EP -->|"wires entrypoints"| MM2

    %% delegation from data module
    DM -->|"delegates to"| CM
    DM -->|"delegates to"| CJSON
    DM -->|"delegates to"| MM1
    DM -->|"delegates to"| MM2

    %% constructors and methods generate AST
    CM -->|"generates constructor AST"| ME
    CImp -->|"generates constructor AST"| ME
    CJSON -->|"generates fromJson AST"| ME
    MM1 -->|"generates toJson AST"| ME
    MM2 -->|"generates toString AST"| ME

    ME -->|"emits generated AST"| GC
    GC -->|"compiles all code"| DC

    %% Click events
    click UC "https://github.com/pedro-ivo-neves/classy/blob/main/example/classy_example.dart"
    click EP "https://github.com/pedro-ivo-neves/classy/blob/main/lib/classy.dart"
    click CM "https://github.com/pedro-ivo-neves/classy/tree/main/lib/src/constructors"
    click CImp "https://github.com/pedro-ivo-neves/classy/blob/main/lib/src/constructors/constructor.dart"
    click CJSON "https://github.com/pedro-ivo-neves/classy/blob/main/lib/src/constructors/from_json.dart"
    click DM "https://github.com/pedro-ivo-neves/classy/blob/main/lib/src/data.dart"
    click MM1 "https://github.com/pedro-ivo-neves/classy/blob/main/lib/src/methods/to_json.dart"
    click MM2 "https://github.com/pedro-ivo-neves/classy/blob/main/lib/src/methods/to_string.dart"
    click TRoot "https://github.com/pedro-ivo-neves/classy/blob/main/test/classy_test.dart"
    click TCons "https://github.com/pedro-ivo-neves/classy/tree/main/test/src/constructors"
    click TFrom "https://github.com/pedro-ivo-neves/classy/tree/main/test/src/constructors/fromJson"
    click TData "https://github.com/pedro-ivo-neves/classy/tree/main/test/src/data"
    click TToJson "https://github.com/pedro-ivo-neves/classy/tree/main/test/src/methods/toJson"
    click TToString "https://github.com/pedro-ivo-neves/classy/tree/main/test/src/methods/toString"
    click AO "https://github.com/pedro-ivo-neves/classy/blob/main/analysis_options.yaml"
    click PS "https://github.com/pedro-ivo-neves/classy/blob/main/pubspec.yaml"

    %% Styles
    classDef user fill:#e0ffe0,stroke:#009900
    classDef module fill:#e0f0ff,stroke:#0066cc
    classDef engine fill:#ffd080,stroke:#cc6600
    classDef test fill:#f0f0f0,stroke:#999999
    classDef config fill:#fff0f5,stroke:#cc6699
```
