# bitflowcode/webln-boost-widget architecture

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

- Interactive diagram: https://gitdiagram.com/bitflowcode/webln-boost-widget
- Repository: https://github.com/bitflowcode/webln-boost-widget

## Overview

##### Project type and purpose
- This is a front-end Next.js (React + TypeScript) application whose primary goal is twofold:
- Host a small site (routes under `app/`) to configure and preview a Lightning-Network “boost” widget.
- Produce a standalone embeddable widget bundle (`public/widget.bundle.js` + CSS) that developers can drop into any site to accept WebLN donations.

##### File structure
- Top‐level “app” directory uses Next.js 13’s file‐based routing (pages for create, widget-params, and dynamic widget views).
- `app/components/` holds reusable UI pieces (buttons, avatars, tooltips, the core `webln-boost-button`).
- `lib/utils.ts` contains shared helper functions.
- `scripts/` hosts build scripts (Babel config + `build-widget.js`) to generate the standalone widget bundle.
- `public/` contains static assets served by the Next.js server or CDN, including the final widget files.
- Config files: `next.config.js`, `tsconfig.json`, PostCSS/Tailwind, ESLint, Vercel deployment config.

##### README for additional insights
- Confirms the feature set (responsive UI, preset/custom sats, hold-to-boost, WebLN integration).
- Highlights the development workflow (`npm run dev`) and embed usage (`import WebLNBoostButton …`).
- Specifies environment requirements (Node 18+, WebLN wallet).

## Diagram (Mermaid)

```mermaid
flowchart TD
    classDef developer fill:#f9f,stroke:#333,stroke-width:1px
    classDef pipeline fill:#ff9,stroke:#333,stroke-width:1px
    classDef hosting fill:#9f9,stroke:#333,stroke-width:1px
    classDef browser fill:#9ff,stroke:#333,stroke-width:1px
    classDef external fill:#f99,stroke:#333,stroke-width:1px

    Developer["Developer Workstation<br/>IDE + Git"]:::developer
    subgraph "Build Pipeline"
        NextBuild["Next.js Build"]:::pipeline
        Bundler["Widget Bundler<br/>(build-widget.js)"]:::pipeline
        Babel["Babel Config"]:::pipeline
    end
    subgraph "Configuration Files"
        NextConfig["next.config.js"]:::pipeline
        TsConfig["tsconfig.json"]:::pipeline
        Postcss["postcss.config.mjs"]:::pipeline
        Tailwind["tailwind.config.ts"]:::pipeline
        ESLint["eslint.config.mjs"]:::pipeline
        VercelConfig["vercel.json"]:::pipeline
    end
    subgraph "Hosting / CDN (Vercel)"
        CDN["Vercel / CDN"]:::hosting
        AppRoutes["Next.js App Routes<br/>(app/)"]:::hosting
        WidgetJS["public/widget.bundle.js"]:::hosting
        WidgetCSS["public/widget.css"]:::hosting
        StaticImages["Static Assets<br/>(public/assets/images/)"]:::hosting
    end
    subgraph "Client Browser"
        direction TB
        HostedSite["Hosted Site<br/>(React + Next.js)"]:::browser
        ConsumerWidget["Embeddable Widget<br/>(widget.bundle.js + widget.css)"]:::browser
    end
    subgraph "External Services"
        Wallet["WebLN Wallet Extension"]:::external
        Lightning["Lightning Network"]:::external
    end

    Developer -->|"git push / npm run build"| NextBuild
    Developer -->|"npm run build-widget"| Bundler
    NextConfig --> NextBuild
    TsConfig --> NextBuild
    Postcss --> NextBuild
    Tailwind --> NextBuild
    ESLint --> NextBuild
    VercelConfig --> NextBuild
    Babel --> Bundler
    Bundler -->|"widget artifacts"| WidgetJS
    Bundler --> WidgetCSS
    NextBuild -->|"site assets"| CDN

    CDN -->|serves| AppRoutes
    CDN -->|serves| WidgetJS
    CDN -->|serves| WidgetCSS
    CDN -->|serves| StaticImages

    AppRoutes -->|render pages| HostedSite
    StaticImages -->|assets| HostedSite
    StaticImages -->|assets| ConsumerWidget
    WidgetJS -->|bundle loaded| ConsumerWidget
    WidgetCSS -->|styles loaded| ConsumerWidget

    ConsumerWidget -->|"WebLN API"| Wallet
    Wallet -->|"payment routed"| Lightning

    click AppRoutes "https://github.com/bitflowcode/webln-boost-widget/tree/main/app/"
    click Bundler "https://github.com/bitflowcode/webln-boost-widget/blob/main/scripts/build-widget.js"
    click Babel "https://github.com/bitflowcode/webln-boost-widget/blob/main/scripts/babel.config.js"
    click StaticImages "https://github.com/bitflowcode/webln-boost-widget/tree/main/public/assets/images/"
    click WidgetJS "https://github.com/bitflowcode/webln-boost-widget/blob/main/public/widget.bundle.js"
    click WidgetCSS "https://github.com/bitflowcode/webln-boost-widget/blob/main/public/widget.css"
    click NextConfig "https://github.com/bitflowcode/webln-boost-widget/blob/main/next.config.js"
    click TsConfig "https://github.com/bitflowcode/webln-boost-widget/blob/main/tsconfig.json"
    click Postcss "https://github.com/bitflowcode/webln-boost-widget/blob/main/postcss.config.mjs"
    click Tailwind "https://github.com/bitflowcode/webln-boost-widget/blob/main/tailwind.config.ts"
    click ESLint "https://github.com/bitflowcode/webln-boost-widget/blob/main/eslint.config.mjs"
    click VercelConfig "https://github.com/bitflowcode/webln-boost-widget/blob/main/vercel.json"
```
