# hihayk/shaper architecture

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

- Interactive diagram: https://gitdiagram.com/hihayk/shaper
- Repository: https://github.com/hihayk/shaper

## Overview

##### File structure
- Top-level:
- package.json – lists React and build tools
- public/ – static entry point (index.html, manifest, robots.txt)
- src/ – all React source code, CSS, utilities, and tests
- src/index.js boots the React app and registers the service worker.
- src/App.js is the root component, importing CSS, subcomponents, and utilities.
- src/components/ – domain components:
- demo-email – UI to preview email styling
- specs – UI to list and edit style specifications
- settings – UI for application-level settings
- src/utilities.js, variables.js – shared logic and design tokens.
- serviceWorker.js – manages offline caching.

##### README
- Confirms it’s a client-side, in-browser interface style editor, with no external services.

a. Main components
- Web Browser (entry point)
- Static Assets (public/index.html, CSS, JS bundles)
- Service Worker (optional caching layer)
- React Root (App.js)
- Component Modules:
– DemoEmail Component
– Specs Component
– Settings Component
- Shared Libraries & Utilities (utilities.js, variables.js, CSS files)

b. Relationships and interactions
- Browser requests index.html → loads JS bundle
- Service Worker intercepts requests, serves cached assets if available
- index.js mounts App.js into the DOM
- App.js orchestrates state and passes props into DemoEmail, Specs, Settings
- Components import and apply CSS modules and consume tokens from variables.js
- Utilities provide helper functions to components (e.g., parsing style specs)

c. Architectural patterns & design principles
- Component-based UI (React)
- Single source of truth for design tokens (variables.js)
- Separation of concerns: styling (CSS), logic (utilities.js), presentation (components)
- Offline capability via service worker

d. Key technologies & libraries
- React (via package.json)
- create-react-app conventions (public/, serviceWorker.js)
- CSS modules and global CSS files (common.css, demo.css, settings.css, etc.)
- Jest + React Testing Library (App.test.js, setupTests.js)

##### Summary of essential elements
- Top-level components (public vs. src, service worker, root component, subcomponents, utilities)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers and Components
    Browser["Web Browser"]:::browserGray
    ServiceWorker["Service Worker"]:::swGray
    Cache["Cache Storage"]:::swGray
    Static["Static Assets"]:::assetsOrange
    Index["index.js"]:::reactBlue
    App["App.js"]:::reactBlue

    subgraph "UI Components"
        DE["DemoEmail"]:::reactBlue
        SP["Specs"]:::reactBlue
        SE["Settings"]:::reactBlue
    end

    subgraph "Styles & Utilities"
        CommonCSS["Common CSS"]:::assetsOrange
        Utilities["Utilities"]:::utilGreen
        Variables["Design Tokens"]:::utilGreen
    end

    DemoCSS["demo-email.css"]:::assetsOrange
    SpecsCSS["specs.css"]:::assetsOrange
    SettingsCSS["settings.css"]:::assetsOrange

    subgraph "Testing"
        Setup["setupTests.js"]:::utilGreen
        TestApp["App.test.js"]:::utilGreen
    end

    %% Data and Dependency Flows
    Browser --> ServiceWorker
    ServiceWorker -->|caches/serves| Cache
    ServiceWorker -->|intercepts| Static
    Browser -->|requests| Static
    Static -->|serves bundles| Index
    Index --> App
    App --> DE
    App --> SP
    App --> SE
    Utilities --> App
    Variables --> App
    CommonCSS --> App
    Utilities --> DE
    Variables --> DE
    DE --> DemoCSS
    Utilities --> SP
    Variables --> SP
    SP --> SpecsCSS
    Utilities --> SE
    Variables --> SE
    SE --> SettingsCSS
    Setup --> App
    TestApp --> App

    %% Click Events
    click Static "https://github.com/hihayk/shaper/tree/master/public/"
    click ServiceWorker "https://github.com/hihayk/shaper/blob/master/src/serviceWorker.js"
    click Index "https://github.com/hihayk/shaper/blob/master/src/index.js"
    click App "https://github.com/hihayk/shaper/blob/master/src/App.js"
    click DE "https://github.com/hihayk/shaper/blob/master/src/components/demo-email/demo-email.js"
    click DemoCSS "https://github.com/hihayk/shaper/blob/master/src/components/demo-email/demo-email.css"
    click SP "https://github.com/hihayk/shaper/blob/master/src/components/specs/specs.js"
    click SpecsCSS "https://github.com/hihayk/shaper/blob/master/src/components/specs/specs.css"
    click SE "https://github.com/hihayk/shaper/blob/master/src/components/settings.js"
    click SettingsCSS "https://github.com/hihayk/shaper/blob/master/src/settings.css"
    click Utilities "https://github.com/hihayk/shaper/blob/master/src/utilities.js"
    click Variables "https://github.com/hihayk/shaper/blob/master/src/variables.js"
    click CommonCSS "https://github.com/hihayk/shaper/blob/master/src/common.css"
    click Setup "https://github.com/hihayk/shaper/blob/master/src/setupTests.js"
    click TestApp "https://github.com/hihayk/shaper/blob/master/src/App.test.js"

    %% Styles
    classDef browserGray fill:#cccccc,stroke:#666666,color:#000000
    classDef swGray fill:#dddddd,stroke:#888888,color:#000000
    classDef assetsOrange fill:#ffe5b4,stroke:#cc7a00,color:#000000
    classDef reactBlue fill:#cce5ff,stroke:#3399ff,color:#000000
    classDef utilGreen fill:#d9f2d9,stroke:#33cc33,color:#000000
```
