# glitchworker/aislewire architecture

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

- Interactive diagram: https://gitdiagram.com/glitchworker/aislewire
- Repository: https://github.com/glitchworker/aislewire

## Overview

##### Main Components
- Build System & Task Runner: Represent gulp (with its gulpfile.js and tasks subdirectories) and webpack (webpack.config.js with reference to different modules). Also note the integration of DartSass (and its helper modules under tasks/modules/dart-sass-functions and dart-sass-glob).
- Template Engine: A Handlebars component that processes the multiple .hbs templates (layouts, components, pages, partials) found within src/templates. Indicate also the preprocessing of configuration files (like src/config.jsonc and data in /_modules/import).
- Style Processing: A SCSS system that uses DartSass, along with a separation of common styles (under src/common/stylesheets), mixins, vars, and page-specific styling (src/stylesheets for PC and SP).
- JavaScript Bundling: The source JavaScript is divided between “pc” and “sp” in src/javascripts, with module files in TypeScript (e.g. sample.ts, Caller.ts, etc.) that are all bundled with webpack (using Babel & possibly TypeScript support).
- Data/API Mock Server: A RESTful API server feature is available (when enabled in config.jsonc) that serves JSON files from src/_modules/api. Indicate ports (default: 9000) and typical API endpoints.
- Asset Management & Import Copy Data: There is a mechanism for copying external/folder assets into the build (under src/_modules/import) and the final output in /htdocs (assets, css, js and images) as well as folders for PC and SP.
- Local Git Environment: Under _setup/git, a local Git repository is set up optionally to use as version control during development.

##### Relationships and Data Flow
- The gulp tasks take the source files and apply preprocessing (handling SCSS -> CSS, compiling Handlebars templates, and bundling JavaScript via webpack) to produce the final output in htdocs.
- The API Mock Server reads JSON files from src/_modules/api and provides RESTful endpoints for front-end developers.
- That configuration files (src/config.jsonc) are passed through Gulp tasks (gulpfile.js) to influence both templating and style variables.
- External libraries and plugins (Handlebars, Sass, Babel, webpack, Browsersync) as influencing components that provide core functionality.

##### Architectural Patterns & Principles
- Modularity: The project architecture is divided into modular directories (data, common, templates, tasks, and modules) which should be diagrammatically separated.
- Separation of Concerns: Frontend templating, style processing, JavaScript bundling, and asset management are clearly separated. Represent this by grouping related directories (for example, “Templates” for hbs files, “Styles” for SCSS, “Scripts” for JavaScript, and “Data/API” for JSON modules).
- Configurable & Extensible: The use of config.jsonc and import data allows for customization and extension. Show this configuration as the central “settings” module that feeds into multiple pipelines.

##### Relevant Technologies, Frameworks, and Tools
- NodeJS (runtime) and npm/yarn for package management.
- Gulp for task automation.
- Webpack and Babel (and possibly TypeScript support) for JavaScript bundling.
- Handlebars.js for SSR or static page templating.
- Sass (DartSass) for style pre-processing, with PostCSS as an additional tool.
- Browsersync for live reloading.
- json-server (or similar) for the API mock server.

##### Detailed Component Breakdown
- Source Modules:
- Templates: All .hbs files from src/templates
- Styles: SCSS files in src/stylesheets and common/stylesheets
- Scripts: JavaScript/TypeScript files in src/javascripts (pc & sp folders)
- Data & API: JSON and YAML files under src/_modules/api and /data
- Asset Imports: Files in src/_modules/import and images in src/images and common/images
- Build Pipeline:
- Gulp Tasks (defined in gulpfile.js, tasks/* modules) orchestrate compilation, bundling, and Copy Data actions.
- Webpack Configuration processes modern JavaScript (transpilation via Babel/TypeScript).
- Sass (DartSass) plus PostCSS are used to compile and process styles.
- Output & Deployment:
- htdocs folder containing built assets (HTML, CSS, JS, images) with further segmentation for PC vs SP.
- Optional & External Services:
- API Mock Server: Enabled based on configuration (serves endpoints on port 9000).
- Local Git Environment: Provided optionally (under _setup/git) for version control in development.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Source Modules
    subgraph "Source Modules"
        TS["Templates Source"]:::source
        SS["SCSS Sources"]:::source
        JS["Scripts Source"]:::source
        DS["Data/API Files"]:::source
        AS["Asset Import Files"]:::source
        IS["Image Assets"]:::source
        CFG["Configuration (config.jsonc)"]:::source
    end

    %% Build Pipeline
    subgraph "Build Pipeline"
        Gulp["Gulp Build Engine"]:::build
        Webpack["Webpack Bundler"]:::build
        HB["Handlebars Engine"]:::build
        Sass["Sass Compiler"]:::build
        Copy["Copy & Asset Manager"]:::build
        API["API Mock Server (port9000)"]:::build
    end

    %% Build Output
    subgraph "Build Output"
        OUT["Final Output (htdocs)"]:::output
    end

    %% External Tools & Development
    subgraph "External Tools & Dev"
        Git["Local Git Environment"]:::external
        NodeJS["NodeJS"]:::external
        NPM["npm/yarn"]:::external
        BS["Browsersync"]:::external
        Babel["Babel/TypeScript"]:::external
    end

    %% Connections: Source Modules to Build Pipeline
    TS -->|"templates"| HB
    SS -->|"stylesheets"| Sass
    JS -->|"scripts"| Webpack
    DS -->|"data-for-API"| API
    AS -->|"assets"| Copy
    IS -->|"images"| Copy
    CFG -->|"config-feeds"| Gulp

    %% Build Pipeline orchestration
    Gulp -->|"orchestrates"| HB
    Gulp -->|"orchestrates"| Sass
    Gulp -->|"orchestrates"| Webpack
    Gulp -->|"orchestrates"| Copy

    %% Pipeline to Output
    HB -->|"generates"| OUT
    Sass -->|"compiles"| OUT
    Webpack -->|"bundles"| OUT
    Copy -->|"copies"| OUT
    API -->|"serves-API"| OUT

    %% External dependencies influencing the build
    NodeJS -->|"runs"| Gulp
    NPM -->|"installs"| Gulp
    Babel -->|"transpiles"| Webpack
    BS -->|"live-reload"| Gulp
    Gulp -->|"version-control"| Git

    %% Click Events for Component Mapping
    click Gulp "https://github.com/glitchworker/aislewire/blob/master/gulpfile.js"
    click Gulp "https://github.com/glitchworker/aislewire/tree/master/tasks/"
    click Webpack "https://github.com/glitchworker/aislewire/blob/master/tasks/webpack.config.js"
    click TS "https://github.com/glitchworker/aislewire/tree/master/src/templates/"
    click HB "https://github.com/glitchworker/aislewire/tree/master/tasks/modules/handlebars/"
    click SS "https://github.com/glitchworker/aislewire/tree/master/src/stylesheets/"
    click SS "https://github.com/glitchworker/aislewire/tree/master/src/common/stylesheets/"
    click JS "https://github.com/glitchworker/aislewire/tree/master/src/javascripts/"
    click API "https://github.com/glitchworker/aislewire/tree/master/src/_modules/api/"
    click AS "https://github.com/glitchworker/aislewire/tree/master/src/_modules/import/"
    click IS "https://github.com/glitchworker/aislewire/tree/master/src/images/"
    click IS "https://github.com/glitchworker/aislewire/tree/master/src/common/images/"
    click Git "https://github.com/glitchworker/aislewire/tree/master/_setup/git/"
    click Sass "https://github.com/glitchworker/aislewire/tree/master/tasks/modules/dart-sass-functions/"
    click Sass "https://github.com/glitchworker/aislewire/tree/master/tasks/modules/dart-sass-glob/"

    %% Styles
    classDef source fill:#FFCC99,stroke:#000,stroke-width:2px;
    classDef build fill:#CCFFCC,stroke:#000,stroke-width:2px;
    classDef output fill:#99CCFF,stroke:#000,stroke-width:2px;
    classDef external fill:#FFCCCC,stroke:#000,stroke-width:2px;
```
