# destefanis/design-lint architecture

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

- Interactive diagram: https://gitdiagram.com/destefanis/design-lint
- Repository: https://github.com/destefanis/design-lint

## Overview

1. The UI layer – located under the src/app directory. This is where the React components and styling reside, responsible for displaying the plugin’s interface (components like App.tsx, Banner.tsx, Modal.tsx, etc.) and handling user interactions.

2. The Plugin Logic & Linting Engine – located under the src/plugin directory. This area houses the core functionality that interacts with the Figma API (controller.ts) and runs the linting functions (e.g., lintingFunctions.ts). It handles assessing design node properties and orchestrating the error detection and reporting.

##### Main Components
- Figma Plugin Interface (UI)
- React UI Components (src/app/components)
- Styling (src/app/styles)
- Entry point (index.html and index.tsx)
- Plugin Controller & Linting Engine
- Main Figma API gateway and controller logic (src/plugin/controller.ts)
- Linting functions and custom rules (src/plugin/lintingFunctions.ts, lintingFunctionsforVariables.ts, remoteStyleFunctions.ts, styles.ts)
- Configuration & Build Tools
- Manifest file (manifest.json)
- Build configuration files (webpack.config.js, tsconfig.json, tslint.json)

##### Component Relationships and Data Flow
- Figma Environment: The plugin runs within Figma and interacts with its API (nodes, properties, selection, etc.).
- Plugin Controller:
- Acts as the bridge between Figma’s API and the React-based UI.
- Receives selected layers (nodes) from Figma, applies linting functions based on each node’s type, and collects errors.
- Passes the error information to the UI.
- UI Layer:
- Polls for changes (as indicated in the README) and refreshes on error resolution.
- Displays error details, provides navigation (selecting errors, ignore actions), and may pass user interactions back to the controller.

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- The design separates the user interface, linting logic, and Figma API interactions.
- Modular Design:
- Linting functions are organized by node type (text, frame, rectangle, etc.) and are easily replaceable or extendable.
- Reactive and Event-Driven:
- The UI updates automatically as fixes are applied, with the controller polling for design changes.
- Extensibility:
- The README and file structure indicate that developers can easily add custom linting rules.

##### Relevant Technologies and Frameworks
- React – for the UI.
- TypeScript – ensuring type safety across both UI and plugin logic.
- Webpack – for bundling the project.
- TSLint and Prettier – for code quality and formatting.
- Figma Plugin API – integration layer with Figma designs.

##### Being Detailed Without Overcomplicating
- Related files (like the entire UI component collection or plugin logic functions) under a common banner if needed.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Figma Environment
    subgraph "Figma Environment"
        FE["Figma API (External)"]:::external
    end

    %% Plugin Logic Layer
    subgraph "Plugin Logic"
        PL1["Figma Plugin Controller"]:::backend
        subgraph "Linting Engine"
            LF1["Linting Functions"]:::backend
            LF2["Linting Functions for Variables"]:::backend
            LF3["Remote Style Functions"]:::backend
            LF4["Linting Styles"]:::backend
        end
    end

    %% UI Layer
    subgraph "UI Layer"
        UI1["React UI Components"]:::frontend
        UI2["Styling"]:::frontend
        UI3["Index HTML"]:::frontend
        UI4["Index TSX"]:::frontend
    end

    %% Configuration & Build Tools
    subgraph "Configuration & Build Tools"
        C1["Manifest File"]:::config
        C2["Build Config: Webpack"]:::config
        C3["Build Config: TSConfig"]:::config
        C4["Build Config: TSLint"]:::config
    end

    %% Connections between components
    FE -->|"sendsDesignData"| PL1
    PL1 -->|"executesLinting"| LF1
    PL1 -->|"executesLinting"| LF2
    PL1 -->|"executesLinting"| LF3
    PL1 -->|"executesLinting"| LF4
    LF1 -->|"returnsErrors"| PL1
    LF2 -->|"returnsErrors"| PL1
    LF3 -->|"returnsErrors"| PL1
    LF4 -->|"returnsErrors"| PL1
    PL1 -->|"reportsErrors"| UI1
    UI1 -->|"sendsUserAction"| PL1

    %% Click Events for UI Layer
    click UI1 "https://github.com/destefanis/design-lint/tree/master/src/app/components"
    click UI2 "https://github.com/destefanis/design-lint/tree/master/src/app/styles"
    click UI3 "https://github.com/destefanis/design-lint/blob/master/src/app/index.html"
    click UI4 "https://github.com/destefanis/design-lint/blob/master/src/app/index.tsx"

    %% Click Events for Plugin Logic
    click PL1 "https://github.com/destefanis/design-lint/blob/master/src/plugin/controller.ts"
    click LF1 "https://github.com/destefanis/design-lint/blob/master/src/plugin/lintingFunctions.ts"
    click LF2 "https://github.com/destefanis/design-lint/blob/master/src/plugin/lintingFunctionsforVariables.ts"
    click LF3 "https://github.com/destefanis/design-lint/blob/master/src/plugin/remoteStyleFunctions.ts"
    click LF4 "https://github.com/destefanis/design-lint/blob/master/src/plugin/styles.ts"

    %% Click Events for Configuration & Build Tools
    click C1 "https://github.com/destefanis/design-lint/blob/master/manifest.json"
    click C2 "https://github.com/destefanis/design-lint/blob/master/webpack.config.js"
    click C3 "https://github.com/destefanis/design-lint/blob/master/tsconfig.json"
    click C4 "https://github.com/destefanis/design-lint/blob/master/tslint.json"

    %% Styles
    classDef external fill:#FFCCFF,stroke:#990099,stroke-width:2px;
    classDef frontend fill:#CCEEFF,stroke:#3366CC,stroke-width:2px;
    classDef backend fill:#CCFFCC,stroke:#33AA33,stroke-width:2px;
    classDef config fill:#FFDD99,stroke:#CC6600,stroke-width:2px;
```
