# rishikeshsv/mini-page-builder architecture

> Architecture diagram of the GitHub repository rishikeshsv/mini-page-builder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rishikeshsv/mini-page-builder
- Repository: https://github.com/rishikeshsv/mini-page-builder

## Overview

##### Project type + purpose (from README + file tree)
This is a **single-page React application** (Create React App–style) called **“Mini Page Builder”**. Its purpose is to let a user **visually assemble a simple webpage** by selecting elements (via a sidebar) and configuring them (via a canvas/config panel). It’s deployed as a static site (README links Surge).

- **Client-only UI runtime** (React in browser)
- **Internal UI modules**: `Sidebar` (element palette) + `Canvas` (render/configure page)
- **State/data flow** between those modules (selection → configuration → rendering)
- **Build/serve pipeline** (npm scripts → CRA dev server / static build → Surge)

There’s no backend directory, no API client, no DB. Treat it as a **front-end app with internal components and state management**.

##### File structure → architectural clues
Top-level:
- `package.json`, `package-lock.json`: npm-managed React app dependencies + scripts
- `public/`: static HTML shell and assets (`index.html`, `manifest.json`, etc.)
- `src/`: actual application code
- `src/styles/`: SCSS styling, including a CSS generator theme (`cssGenerator.scss`)

Key modules:
- `src/App.js`: top-level app composition (likely lays out sidebar + canvas)
- `src/index.js`: React entrypoint mounting into `public/index.html`
- `src/modules/sidebar/*`: sidebar UI + sidebar data model (`SidebarData.js`)
- `src/modules/canvas/*`: canvas UI + element configuration UI (`ConfigureElement.jsx`)
- `src/styles/modules/*.scss`: per-module styling (app/canvas/sidebar)

This is a **feature/module-oriented component structure** (modules grouped by feature rather than by pure component type).

##### What
For this project, “system design” is best represented as **containers + components + runtime data flow**.

##### Static hosting / Dev server
- Dev: CRA dev server (`npm start`)
- Prod: static bundle deployed to Surge (implied by README URL)
##### React SPA
- Entry: `public/index.html` + `src/index.js`
- Root component: `src/App.js`

##### Sidebar module
- `src/modules/sidebar/index.jsx`
- Data source: `src/modules/sidebar/SidebarData.js` (the “catalog” of available elements)
- Responsibilities to label:
- Element palette
- Emit “user selected element type” events
##### Canvas module
- `src/modules/canvas/index.jsx`
- Configuration component: `src/modules/canvas/ConfigureElement.jsx`
- Responsibilities to label:
- Render current page layout
- Manage selected element
- Provide configuration UI (ConfigureElement)
- Apply configuration to element representation
##### Styles subsystem
- Global + shared: `src/styles/index.scss`, `common.scss`
- CSS generator: `src/styles/cssGenerator.scss` (important: implies the app can produce CSS output or style rules)
- Module-scoped styles: `src/styles/modules/{app,canvas,sidebar}.scss`

##### “State / model” (even if not explicit in files)
Even if there’s no explicit `store/` directory, the app definitely has an internal “page model” concept:
- **Element definitions** (from `SidebarData.js`)
- **Page layout state** (list/tree of elements placed on canvas)
- **Selected element state**
- **Element properties/config** (edited in `ConfigureElement.jsx`)
This as either:
- A **central App state** (owned by `App.js` and passed down), or
- Local state split across `Canvas`/`Sidebar` with callbacks

##### User → Sidebar
- User clicks an element type in the sidebar palette.
##### Sidebar → App/State
- Sidebar emits “add element of type X”
- App/state updates the page layout model.
##### State → Canvas
- Canvas renders the updated layout model.
##### User → Canvas
- User selects an element on the canvas.
##### Canvas → State
- Update “selectedElementId”
##### State → ConfigureElement
- ConfigureElement receives selected element + props
##### ConfigureElement → State
- Persist new props/styles into the page model
##### (Optional, if applicable) State → CSS Generator
- Generate CSS output or computed styles based on config
##### Styles (SCSS) → Rendered UI
- SCSS compiled into CSS during build; used by Sidebar/Canvas/App

- “Select element type”
- “Add element”
- “Select element instance”
- “Edit properties”
- “Re-render layout”
- “Generate CSS / apply styles”

##### Architectural patterns / principles to call out
- **SPA / client-only architecture**: everything runs in the browser; no server-side domain logic.
- **Feature-module organization**: `modules/sidebar` and `modules/canvas` are bounded UI contexts.
- **Unidirectional data flow** (typical React): UI events → state update → render.
- **Separation of concerns**:
- Sidebar = element catalog + selection UX
- Canvas = layout rendering + selection
- ConfigureElement = editing UI for a selected element
- Styles separated into SCSS files (global + module-level)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% =========================================================
    %% Context: delivery + runtime
    %% =========================================================
    User(["User"]):::external

    subgraph "Static Delivery"
        DevServer(["CRA Dev Server\n(npm start)"]):::hosting
        Surge(["Surge Static Hosting\n(static build)"]):::hosting
        BuildArtifacts[/"Static Build Artifacts\n(JS/CSS/Assets)"/]:::artifact
    end

    subgraph "Browser Runtime"
        Browser(["Web Browser"]):::external
        IndexHtml["Static HTML Shell\n(public/index.html)"]:::static
        ReactEntry["React Entry / Bootstrap\n(src/index.js)"]:::entry
    end

    User -->|"interacts"| Browser
    DevServer -->|"serves"| IndexHtml
    Surge -->|"serves"| IndexHtml
    IndexHtml -->|"loads bundle"| ReactEntry

    %% =========================================================
    %% React SPA (C4-ish container + component hybrid)
    %% =========================================================
    subgraph "React SPA: Mini Page Builder (Client-only)"
        direction TB

        AppRoot["App Root / Composition\n(src/App.js)"]:::ui

        subgraph "UI State / Model (in-memory)"
            direction TB
            SidebarCatalog[("Element Definitions Catalog\n(SidebarData)")]:::data
            PageLayout[("Page Layout State\n(list/tree of elements)")]:::data
            SelectionState[("Selected Element State\n(selectedElementId)")]:::data
            ElementProps[("Element Properties + Styles\n(per element config)")]:::data
        end

        subgraph "Sidebar Module"
            direction TB
            Sidebar["Sidebar UI\n(src/modules/sidebar/index.jsx)"]:::ui
        end

        subgraph "Canvas Module"
            direction TB
            Canvas["Canvas UI\n(src/modules/canvas/index.jsx)"]:::ui
            ConfigureElement["Element Configuration UI\n(src/modules/canvas/ConfigureElement.jsx)"]:::ui
        end

        subgraph "Styles (SCSS -> CSS at build time)"
            direction TB
            StylesIndex["Global Styles\n(src/styles/index.scss)"]:::sty
            StylesCommon["Shared/Common Styles\n(src/styles/common.scss)"]:::sty
            CssGenerator["CSS Generator / Theme Rules\n(src/styles/cssGenerator.scss)"]:::sty
            StylesApp["App Module Styles\n(src/styles/modules/app.scss)"]:::sty
            StylesCanvas["Canvas Module Styles\n(src/styles/modules/canvas.scss)"]:::sty
            StylesSidebar["Sidebar Module Styles\n(src/styles/modules/sidebar.scss)"]:::sty
        end
    end

    ReactEntry -->|"mounts"| AppRoot

    %% =========================================================
    %% Runtime data/event flow (unidirectional React-ish)
    %% =========================================================
    SidebarCatalog -->|"provides palette data"| Sidebar

    User -->|"select element type"| Sidebar
    Sidebar -->|"AddElement(type)"| PageLayout

    User -->|"select element instance"| Canvas
    Canvas -->|"update selection"| SelectionState

    PageLayout -->|"render layout"| Canvas
    SelectionState -->|"selected element"| ConfigureElement
    ElementProps -->|"props/styles"| ConfigureElement

    User -->|"edit properties"| ConfigureElement
    ConfigureElement -->|"persist config"| ElementProps

    ElementProps -->|"apply styles/props"| Canvas
    PageLayout -->|"re-render layout"| Canvas

    %% Optional style generation linkage (conceptual)
    ElementProps -.->|"generate CSS / computed styles"| CssGenerator

    %% =========================================================
    %% Styles usage (runtime effect; compiled at build)
    %% =========================================================
    StylesIndex -.->|"styles"| AppRoot
    StylesCommon -.->|"styles"| AppRoot
    StylesApp -.->|"styles"| AppRoot
    StylesSidebar -.->|"styles"| Sidebar
    StylesCanvas -.->|"styles"| Canvas
    CssGenerator -.->|"theme rules"| Canvas

    %% =========================================================
    %% Build / Serve pipeline (build-time)
    %% =========================================================
    PackageJson["Build/Serve Config\n(package.json)"]:::build
    PackageJson -->|"npm start"| DevServer
    PackageJson -->|"npm run build"| BuildArtifacts
    BuildArtifacts -->|"deploy"| Surge
    BuildArtifacts -.->|"static assets"| IndexHtml

    %% =========================================================
    %% Click events (from component mapping)
    %% =========================================================
    click ReactEntry "https://github.com/rishikeshsv/mini-page-builder/blob/main/src/index.js"
    click IndexHtml "https://github.com/rishikeshsv/mini-page-builder/blob/main/public/index.html"
    click AppRoot "https://github.com/rishikeshsv/mini-page-builder/blob/main/src/App.js"
    click Sidebar "https://github.com/rishikeshsv/mini-page-builder/blob/main/src/modules/sidebar/index.jsx"
    click SidebarCatalog "https://github.com/rishikeshsv/mini-page-builder/blob/main/src/modules/sidebar/SidebarData.js"
    click Canvas "https://github.com/rishikeshsv/mini-page-builder/blob/main/src/modules/canvas/index.jsx"
    click ConfigureElement "https://github.com/rishikeshsv/mini-page-builder/blob/main/src/modules/canvas/ConfigureElement.jsx"
    click StylesIndex "https://github.com/rishikeshsv/mini-page-builder/blob/main/src/styles/index.scss"
    click StylesCommon "https://github.com/rishikeshsv/mini-page-builder/blob/main/src/styles/common.scss"
    click CssGenerator "https://github.com/rishikeshsv/mini-page-builder/blob/main/src/styles/cssGenerator.scss"
    click StylesApp "https://github.com/rishikeshsv/mini-page-builder/blob/main/src/styles/modules/app.scss"
    click StylesCanvas "https://github.com/rishikeshsv/mini-page-builder/blob/main/src/styles/modules/canvas.scss"
    click StylesSidebar "https://github.com/rishikeshsv/mini-page-builder/blob/main/src/styles/modules/sidebar.scss"
    click PackageJson "https://github.com/rishikeshsv/mini-page-builder/blob/main/package.json"

    %% =========================================================
    %% Styles (colors)
    %% =========================================================
    classDef external fill:#f3f4f6,stroke:#6b7280,stroke-width:1px,color:#111827
    classDef hosting fill:#eef2ff,stroke:#4338ca,stroke-width:1px,color:#111827
    classDef artifact fill:#ecfdf5,stroke:#059669,stroke-width:1px,color:#064e3b
    classDef static fill:#f9fafb,stroke:#9ca3af,stroke-width:1px,color:#111827
    classDef entry fill:#dbeafe,stroke:#2563eb,stroke-width:1px,color:#0f172a
    classDef ui fill:#bfdbfe,stroke:#1d4ed8,stroke-width:1px,color:#0b1220
    classDef data fill:#fed7aa,stroke:#c2410c,stroke-width:1px,color:#7c2d12
    classDef sty fill:#e9d5ff,stroke:#7c3aed,stroke-width:1px,color:#2e1065
    classDef build fill:#bbf7d0,stroke:#16a34a,stroke-width:1px,color:#052e16
```
