# tapcartinc/custom-block-templates architecture

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

- Interactive diagram: https://gitdiagram.com/tapcartinc/custom-block-templates
- Repository: https://github.com/tapcartinc/custom-block-templates

## Overview

##### Project type and purpose
- This repo is an open-source collection of front-end template “Custom Blocks” for the Tapcart platform. Each top-level folder is a self-contained HTML/JS/CSS snippet (and sometimes JSON sample data) that implements a specific UI or integration pattern for Tapcart mobile apps.
- The goal is to help developers quickly scaffold and customize reusable block components (e.g., accordions, carousels, payment badges) in the Tapcart Custom Blocks Editor.

##### File structure
- Top-level: dozens of folders named after individual block templates (e.g., “Accordion”, “Add To Cart Replacement”, “YouTube Video”). Every folder contains its own README.md plus the source files (`index.html`, `scripts.js`/`index.js`, `styles.css`, and occasionally `variable-preview-values.json`).
- Root also contains a global README.md explaining the repo’s purpose.
- No build scripts or backend code—this is purely front-end assets meant to be copy-pasted into the Tapcart Editor.

##### README for additional insights
- Custom Blocks are drag-and-drop UI components inside the Tapcart app builder.
- Developers pick a template folder, follow its README to import HTML/CSS/JS into the Tapcart Custom Blocks Editor, then OAuth-protected API calls deliver these blocks into a live mobile app.
- There is an implied flow: local template → Custom Blocks Editor → Tapcart CMS → published mobile app.

##### Capturing essential elements
- Break out each piece of the pipeline as its own component.
- Both the authoring (designer/developer) flow and the runtime (end-user) flow.
- Extensibility point: each folder = pluggable block.
- Don’t overcomplicate: keep external integrations as “optional” branches off the runtime path.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Local Templates"
        direction TB
        Repo["Developer Machine (Local Templates Repo)"]:::developer
        Docs["Root Documentation"]:::developer
        subgraph "Accordion Block"
            direction TB
            AccReadme["README.md"]:::developer
            AccHTML["index.html"]:::developer
            AccJS["index.js"]:::developer
            AccCSS["styles.css"]:::developer
        end
        subgraph "Add To Cart Replacement Block"
            direction TB
            CartReadme["README.md"]:::developer
            CartHTML["index.html"]:::developer
            CartJS["scripts.js"]:::developer
            CartCSS["styles.css"]:::developer
            CartJSON["variable-preview-values.json"]:::developer
        end
        Generic["Other Block Templates"]:::developer
    end

    Editor["Tapcart Custom Blocks Editor"]:::infrastructure
    API["Tapcart Backend/API"]:::infrastructure
    CDN["CDN/Storage"]:::infrastructure

    subgraph "Mobile App Runtime"
        direction TB
        App["Mobile App (iOS/Android)"]:::client
    end

    ExtService["External Services"]:::external

    Repo -->|"selects & copies templates"| Editor
    Docs -->|"guides usage"| Repo
    AccReadme --> Editor
    AccHTML --> Editor
    AccJS --> Editor
    AccCSS --> Editor
    CartReadme --> Editor
    CartHTML --> Editor
    CartJS --> Editor
    CartCSS --> Editor
    CartJSON --> Editor
    Generic --> Editor

    Editor -->|"publish via OAuth/API"| API
    API -->|"store assets"| CDN
    App -->|"fetch assets"| CDN
    App -->|"fetch config"| API
    App -->|"runtime calls"| ExtService

    click Repo "https://github.com/tapcartinc/custom-block-templates/tree/main//"
    click Docs "https://github.com/tapcartinc/custom-block-templates/blob/main//README.md"
    click AccReadme "https://github.com/tapcartinc/custom-block-templates/blob/main//Accordion/README.md"
    click AccHTML "https://github.com/tapcartinc/custom-block-templates/blob/main//Accordion/index.html"
    click AccJS "https://github.com/tapcartinc/custom-block-templates/blob/main//Accordion/index.js"
    click AccCSS "https://github.com/tapcartinc/custom-block-templates/blob/main//Accordion/styles.css"
    click CartReadme "https://github.com/tapcartinc/custom-block-templates/blob/main//Add To Cart Replacement/README.md"
    click CartHTML "https://github.com/tapcartinc/custom-block-templates/blob/main//Add To Cart Replacement/index.html"
    click CartJS "https://github.com/tapcartinc/custom-block-templates/blob/main//Add To Cart Replacement/scripts.js"
    click CartCSS "https://github.com/tapcartinc/custom-block-templates/blob/main//Add To Cart Replacement/styles.css"
    click CartJSON "https://github.com/tapcartinc/custom-block-templates/blob/main//Add To Cart Replacement/variable-preview-values.json"
    click Editor "https://github.com/tapcartinc/custom-block-templates/blob/main//REACT/CustomHooks.md"

    classDef developer fill:#D0E6FF,stroke:#0366d6,color:#0366d6
    classDef infrastructure fill:#DFFFE0,stroke:#16a34a,color:#16a34a
    classDef client fill:#FFE7C2,stroke:#ea580c,color:#ea580c
    classDef external fill:#E5E7EB,stroke:#6B7280,color:#6B7280
```
