# miwashutaro0611/front-base architecture

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

- Interactive diagram: https://gitdiagram.com/miwashutaro0611/front-base
- Repository: https://github.com/miwashutaro0611/front-base

## Overview

##### Project Overview and Purpose
- This is a front-end development environment built around generating non-SPA pages. It uses Pug for templating, Dart-sass (SCSS) for styling, and TypeScript for JavaScript, with a build process powered by webpack. The project also includes automated testing (Jest), linting, CI/CD configurations (CircleCI, GitHub Actions), Docker deployment support, and image processing scripts.

##### Main Components
a. Source Code and Assets:
- Templates: Located in src/pug – where Pug templates are maintained. Sub-directories like _data, _mixin, _modules, and _templates indicate modular template components.
- Styles: Found in src/assets/scss – using a structured approach with foundation, layouts, objects, and utilities (variables and mixins).
- Scripts/Modules: In src/assets/js – with common scripts, modules (alert, barba, etc.), and utilities (device checks, WebP support).
- Media Assets: Images, fonts, and other static assets are in src/assets/img, fonts, and static directories.
- Content: The src/posts folder (even though it appears empty) can be considered as a placeholder for content.

b. Build System:
- Webpack Configuration: Multiple webpack configuration files (webpack.common.js, webpack.dev.js, webpack.prod.js, and additional ones like webpack.pages.js, webpack.htmlinjector.js) indicate separate concerns for development, build optimizations, and HTML injection.
- TypeScript and Babel: tsconfig.json and .babelrc for JavaScript/TypeScript compilation.
- Bundling and Testing: Jest configuration (jest.config.js) and linting with ESLint, Prettier, and stylelint (stylelint.config.js).

c. Automation, Testing, and Deployment:
- Automated Scripts: Under the script folder, automated image processing (squoosh-min.mjs and squoosh-webp-avif.mjs) for image compression and format conversion.
- Testing: The spec directory contains TypeScript test specs (e.g. alert.spec.ts, device.spec.ts).
- Deployment/Environment: Dockerfile, docker-compose.yml, netlify.toml provide deployment details. Additionally, CI/CD setups with CircleCI (.circleci/config.yml) and GitHub Actions (in the .github folder) are present.
- Other configurations: Files for commit linting (commitlint.config.js, .husky hooks), editor configurations (.editorconfig), and ESLint/Prettier settings.

##### Relationships and Data Flow
– Webpack transformations may involve tasks such as HTML injection (with webpack.htmlinjector.js) and page-level bundling (webpack.pages.js).
– Image processing scripts are invoked during asset preparation, likely as a pre-build step or as part of the build process.
– Linting and testing (Jest-based unit tests in spec) occur simultaneously to ensure code quality. These components influence and sometimes integrate with the CI/CD pipeline (GitHub Actions and CircleCI).
– Deployment components (Dockerfile, docker-compose.yml, netlify.toml) indicate that upon a successful build, the output is containerized or deployed to platforms like Netlify.

##### Architectural Patterns or Design Principles
– The project is modular: Each asset type (templates, styles, scripts) is organized into its own directory, emphasizing separation of concerns.
– The build system’s multiple webpack configurations highlight environment-specific optimizations and a clear build separation between development and production.
– The presence of CI/CD and deployment files indicates a DevOps-oriented approach rather than a monolithic build-and-deploy process.
– There is an emphasis on extensibility with image optimization scripts and upgradeable libraries, suggesting a focus on modern front-end practices.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Source Code & Assets"
        A("Templates (Pug)"):::source
        B("Styles (SCSS)"):::source
        C("Scripts (TypeScript/JS Modules)"):::source
        D("Media Assets"):::source
        E("Content/Posts"):::source
    end

    subgraph "Build & Config"
        F("Webpack Build System"):::build
        G("TypeScript & Babel Config"):::build
        H("Automated Image Processing Scripts"):::build
    end

    subgraph "Quality & Testing"
        I("Testing & Linting"):::testing
    end

    subgraph "Deployment & CI/CD"
        J("CI/CD & Deployment"):::deploy
    end

    %% Data Flow Connections
    A --> F
    B --> F
    C --> F
    D --> F
    E --> F
    G --> F
    H --> F
    F --> I
    I --> J

    %% Click Events for Source Code & Assets
    click A "https://github.com/miwashutaro0611/front-base/tree/develop/src/pug"
    click B "https://github.com/miwashutaro0611/front-base/tree/develop/src/assets/scss"
    click C "https://github.com/miwashutaro0611/front-base/tree/develop/src/assets/js"
    click D "https://github.com/miwashutaro0611/front-base/tree/develop/src/assets/img"
    click E "https://github.com/miwashutaro0611/front-base/tree/develop/src/posts"

    %% Click Events for Webpack Build System
    click F "https://github.com/miwashutaro0611/front-base/blob/develop/webpack.common.js"
    click F "https://github.com/miwashutaro0611/front-base/blob/develop/webpack.dev.js"
    click F "https://github.com/miwashutaro0611/front-base/blob/develop/webpack.pages.js"
    click F "https://github.com/miwashutaro0611/front-base/blob/develop/webpack.htmlinjector.js"
    click F "https://github.com/miwashutaro0611/front-base/blob/develop/webpack.prod.js"

    %% Click Events for TypeScript & Babel Configuration
    click G "https://github.com/miwashutaro0611/front-base/blob/develop/tsconfig.json"
    click G "https://github.com/miwashutaro0611/front-base/blob/develop/.babelrc"

    %% Click Events for Automated Image Processing Scripts
    click H "https://github.com/miwashutaro0611/front-base/blob/develop/script/squoosh-min.mjs"
    click H "https://github.com/miwashutaro0611/front-base/blob/develop/script/squoosh-webp-avif.mjs"

    %% Click Events for Testing & Linting
    click I "https://github.com/miwashutaro0611/front-base/blob/develop/jest.config.js"
    click I "https://github.com/miwashutaro0611/front-base/blob/develop/spec/alert.spec.ts"
    click I "https://github.com/miwashutaro0611/front-base/blob/develop/spec/device.spec.ts"
    click I "https://github.com/miwashutaro0611/front-base/blob/develop/.eslintrc"
    click I "https://github.com/miwashutaro0611/front-base/blob/develop/stylelint.config.js"
    click I "https://github.com/miwashutaro0611/front-base/blob/develop/.prettierrc"
    click I "https://github.com/miwashutaro0611/front-base/blob/develop/commitlint.config.js"
    click I "https://github.com/miwashutaro0611/front-base/blob/develop/.husky"

    %% Click Events for CI/CD & Deployment
    click J "https://github.com/miwashutaro0611/front-base/blob/develop/.circleci/config.yml"
    click J "https://github.com/miwashutaro0611/front-base/blob/develop/.github"
    click J "https://github.com/miwashutaro0611/front-base/tree/develop/Dockerfile"
    click J "https://github.com/miwashutaro0611/front-base/blob/develop/docker-compose.yml"
    click J "https://github.com/miwashutaro0611/front-base/blob/develop/netlify.toml"

    %% Styles
    classDef source fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef build fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef testing fill:#ffeeba,stroke:#856404,stroke-width:2px;
    classDef deploy fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
