# daniellecuppen/bootstrap5-webpack-boilerplate architecture

> Architecture diagram of the GitHub repository daniellecuppen/bootstrap5-webpack-boilerplate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/daniellecuppen/bootstrap5-webpack-boilerplate
- Repository: https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate

## Overview

##### Project type and purpose
- This is a front-end boilerplate template combining Bootstrap 5 and Webpack 5.
- It provides a ready-to-use asset pipeline: SCSS → CSS, ES6+ JS → bundle, font management, environment injection, and a custom responsive-image CLI.

##### File structure
- Top-level configuration and metadata:
– webpack.config.js, .babelrc, postcss.config.js, images.config.js, .env, package.json
- Source directories:
– src/js (bootstrap.js, main.js) → main application scripts
– src/scss (variables, mixins, components, main.scss) → style definitions
- Assets and fonts:
– fonts/Rob​​oto and fonts/Besley → static font files eot/woff/woff2
– bin/images.js & images.config.js → custom Node.js script for resizing images
- Build outputs:
– dist/ folder containing bundled JS/CSS and generated images
– index.html as entry point referencing compiled assets

##### Extract insights from the README
- Describes the dev workflow: npm run dev (watch mode), npm run build (production build)
- Uses dotenv-webpack for environment variables loaded at compile-time
- Explains how to add Google Fonts via SCSS mixins and how to configure and run the image resizing command

##### Main components
A. Developer Workstation
– Source files: src/js, src/scss, fonts/, index.html, images.config.js, .env
– CLI tools: npm scripts (dev, build, images)
B. Build Process (Webpack pipeline)
– Entry: webpack.config.js
– Loaders and plugins:
- babel-loader (transpile ES6+)
- sass-loader + postcss-loader (compile SCSS → CSS, autoprefix/minify)
- file-loader / url-loader (embed or emit fonts and images)
- dotenv-webpack (inject env variables into JS)
– Output: hashed/minified JS, CSS files, copied or optimized assets in dist/
C. Image Resizing Script (bin/images.js)
– Reads images.config.js
– Uses Sharp or similar library to generate multiple image sizes
– Writes to dist/images/*
D. Deployment / Browser
– index.html loads compiled CSS/JS
– User’s browser renders assets

##### Relationships and data flow
- Developer triggers npm run dev or build
- Webpack reads webpack.config.js →
– Processes JS and SCSS through loaders/plugins → bundles into /dist/js and /dist/css
– Copies or optimizes fonts and static assets from /fonts to /dist/fonts
– Injects .env variables into the bundle
- If npm run images is invoked → bin/images.js reads images.config.js → generates resized images under /dist/images
- The final /dist folder is served to the browser

##### Architectural patterns and principles
- Modular pipeline: each file type (JS, SCSS, fonts, images) handled by a specific loader or script
- Separation of concerns: build configuration (webpack.config.js), environment management (.env + dotenv plugin), asset generation (images.config.js + Node script)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Swimlane: Source & Configuration
    subgraph "Source & Configuration"
        direction TB
        JS_Bootstrap["bootstrap.js"]:::source
        JS_Main["main.js"]:::source
        SCSS_Main["main.scss"]:::source
        SCSS_Vars["_variables.scss"]:::source
        SCSS_GFonts["google-fonts.scss"]:::source
        SCSS_Slider["slider.scss"]:::source
        Fonts["fonts/"]:::source
        HTML_Entry["index.html"]:::config
        EnvFile[".env"]:::config
        Images_Config["images.config.js"]:::config
        NPM_Scripts["package.json"]:::config
    end

    %% Swimlane: Build & Processing
    subgraph "Build & Processing"
        direction TB
        Webpack["Webpack Pipeline"]:::tool
        subgraph "Loaders & Plugins"
            direction TB
            Babel["babel-loader"]:::tool
            Sass["sass-loader + postcss-loader"]:::tool
            File["file-loader / url-loader"]:::tool
            DotEnv["dotenv-webpack"]:::tool
        end
        ImageGen["Responsive-Image Generator"]:::tool
    end

    %% Swimlane: Output & Deployment
    subgraph "Output & Deployment"
        direction TB
        Dist_JS["dist/js/"]:::output
        Dist_CSS["dist/css/"]:::output
        Dist_Fonts["dist/fonts/"]:::output
        Dist_Images["dist/images/"]:::output
        HTML_Served["index.html"]:::output
        Browser["Browser"]:::external
    end

    %% Connections: Source to Build
    JS_Bootstrap -->|"enters"| Babel
    JS_Main -->|"enters"| Babel
    Babel -->|"transpiles"| Webpack

    SCSS_Main -->|"enters"| Sass
    SCSS_Vars -->|"enters"| Sass
    SCSS_GFonts -->|"enters"| Sass
    SCSS_Slider -->|"enters"| Sass
    Sass -->|"compiles"| Webpack

    Fonts -->|"copied/optimized"| File
    File -->|"handles assets"| Webpack

    EnvFile -->|"injected"| DotEnv
    DotEnv -->|"provides env"| Webpack

    Images_Config -->|"configures"| ImageGen
    ImageGen -->|"generates"| Dist_Images

    %% NPM Scripts triggers
    NPM_Scripts -->|"npm run dev/build"| Webpack
    NPM_Scripts -->|"npm run images"| ImageGen

    %% Build to Output
    Webpack -->|"outputs JS"| Dist_JS
    Webpack -->|"outputs CSS"| Dist_CSS
    Webpack -->|"outputs fonts"| Dist_Fonts

    %% Deployment to Browser
    Dist_JS --> Browser
    Dist_CSS --> Browser
    Dist_Fonts --> Browser
    Dist_Images --> Browser
    HTML_Served --> Browser

    %% Click Events
    click JS_Bootstrap "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/blob/main/src/js/bootstrap.js"
    click JS_Main "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/blob/main/src/js/main.js"
    click SCSS_Main "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/blob/main/src/scss/main.scss"
    click SCSS_Vars "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/blob/main/src/scss/_variables.scss"
    click SCSS_GFonts "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/blob/main/src/scss/mixins/google-fonts.scss"
    click SCSS_Slider "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/blob/main/src/scss/components/slider.scss"
    click Fonts "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/tree/main/fonts/"
    click HTML_Entry "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/blob/main/index.html"
    click EnvFile "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/blob/main/.env"
    click Images_Config "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/blob/main/images.config.js"
    click NPM_Scripts "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/blob/main/package.json"
    click Webpack "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/blob/main/webpack.config.js"
    click Babel "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/blob/main/.babelrc"
    click Sass "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/blob/main/postcss.config.js"
    click ImageGen "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/blob/main/bin/images.js"
    click Dist_JS "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/tree/main/dist/"
    click Dist_CSS "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/tree/main/dist/"
    click Dist_Fonts "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/tree/main/dist/"
    click Dist_Images "https://github.com/daniellecuppen/bootstrap5-webpack-boilerplate/tree/main/dist/"

    %% Styles
    classDef config fill:lightcyan,stroke:#333,stroke-width:1px
    classDef source fill:lightgreen,stroke:#333,stroke-width:1px
    classDef tool fill:orange,stroke:#333,stroke-width:1px,shape:hexagon
    classDef output fill:lightblue,stroke:#333,stroke-width:1px
    classDef external fill:lavender,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
