# rossoandoy/figjson architecture

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

- Interactive diagram: https://gitdiagram.com/rossoandoy/figjson
- Repository: https://github.com/rossoandoy/figjson

## Overview

##### Project type and purpose
- This is an open-source conversion tool (“Figma to eDocument Converter”) that runs both as a browser-based web app (hosted via GitHub Pages) and as a Node.js command-line utility.
- Its sole purpose is to take a JSON export from Figma and transform it into a JSON format importable by Salesforce eDocument, with options for paper size, orientation, preview, and precision mapping.

##### File structure
- Top-level assets and entry points
– index.html, styles.css, app.js, converter-browser.js → the static web UI.
– figma-to-edocument-converter.js → the core converter engine exposed as a CLI module.
– package.json → Node.js metadata, scripts (“npm run convert”), dependencies.
– test-converter.js, edocument-test.js → automated tests validating conversion logic.
- Documentation and workflow
– README.md, Figjson_conversion_workflow.md, DEVLOG.md → usage, internal workflow, dev notes.
- Build / deploy
– No server-side back end: the browser version is purely client-side JS; CLI is pure Node.js.

##### README for additional insights
- There are two runtime environments:
- Browser: real-time preview + UI control.
- CLI: file in → file out.
- Key architectural goals: environment-agnostic core, separation of UI vs conversion logic, extension points for new element types.

##### Elements
- UI → Core → Renderer → UI download
- CLI → Core → File System
- Test Suite → Core
- Green for runtime components (UI, CLI)
- Blue for core conversion engine
- Gray for tests / docs
- Orange for external services (GitHub Pages, NPM)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Subgraphs
    subgraph "Browser UI" 
        direction TB
        UI_HTML["index.html"]:::runtime
        UI_CSS["styles.css"]:::runtime
        UI_JS["app.js"]:::runtime
    end

    subgraph "Preview Renderer" 
        direction TB
        Renderer["converter-browser.js"]:::runtime
    end

    subgraph "Core Conversion Engine"
        direction TB
        Core["figma-to-edocument-converter.js"]:::core
    end

    subgraph "CLI Tool"
        direction TB
        CLI["package.json"]:::runtime
    end

    subgraph "Test Suite"
        direction TB
        Test1["test-converter.js"]:::test
        Test2["edocument-test.js"]:::test
    end

    subgraph "Documentation"
        direction TB
        Doc1["README.md"]:::ext
        Doc2["Figjson_conversion_workflow.md"]:::ext
        Doc3["DEVLOG.md"]:::ext
    end

    %% External Services
    GHPages["GitHub Pages"]:::ext
    NPM["NPM Registry"]:::ext
    FileSys["File System"]:::ext

    %% Data Flows
    UI_JS -->|"uses adapter"| Renderer
    Renderer -->|"calls convertFigmaToEDocument()"| Core
    Core -->|"returns eDocument JSON"| Renderer
    Renderer -->|"renders preview & download"| UI_JS

    CLI -->|"npm run convert"| Core
    Core -->|"writes eDocument JSON"| FileSys

    Test1 -->|"tests conversion logic"| Core
    Test2 -->|"tests conversion logic"| Core

    GHPages -->|"hosts assets"| UI_HTML
    GHPages --> UI_CSS
    GHPages --> UI_JS

    NPM -->|"publishes CLI"| CLI

    %% Click Events
    click UI_HTML "https://github.com/rossoandoy/figjson/blob/main/index.html"
    click UI_CSS "https://github.com/rossoandoy/figjson/blob/main/styles.css"
    click UI_JS "https://github.com/rossoandoy/figjson/blob/main/app.js"
    click Renderer "https://github.com/rossoandoy/figjson/blob/main/converter-browser.js"
    click Core "https://github.com/rossoandoy/figjson/blob/main/figma-to-edocument-converter.js"
    click CLI "https://github.com/rossoandoy/figjson/blob/main/package.json"
    click Test1 "https://github.com/rossoandoy/figjson/blob/main/test-converter.js"
    click Test2 "https://github.com/rossoandoy/figjson/blob/main/edocument-test.js"
    click Doc1 "https://github.com/rossoandoy/figjson/blob/main/README.md"
    click Doc2 "https://github.com/rossoandoy/figjson/blob/main/Figjson_conversion_workflow.md"
    click Doc3 "https://github.com/rossoandoy/figjson/blob/main/DEVLOG.md"

    %% Styles
    classDef runtime fill:#c7f0c7,stroke:#333,stroke-width:1px
    classDef core fill:#c7d9f7,stroke:#333,stroke-width:1px
    classDef test fill:#e0e0e0,stroke:#333,stroke-width:1px
    classDef ext fill:#f7d9c7,stroke:#333,stroke-width:1px
```
