# sakamachi-hideyuki/meteors architecture

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

- Interactive diagram: https://gitdiagram.com/sakamachi-hideyuki/meteors
- Repository: https://github.com/sakamachi-hideyuki/meteors

## Overview

##### Project type and purpose
- This is a static-site build repository for the Japanese mythology book “流星と昴の日本神話” by 坂町英之.
- Purpose: manage source HTML and image assets, run build scripts (Node.js + batch/PowerShell), generate the final site under `docs/`, and publish via GitHub Pages.

##### File structure
- Top-level:
- package.json / package-lock.json: Node.js dependencies and build entry points
- html/: site-generation scripts and modules
- images/: image-processing scripts and raw/processed image directories
- docs/: generated site output (chapters, TOC, assets, CSS)
- README.md: project description and hosting URL
- html/modules/: individual transform functions (render-header, link-pages, validate-links, etc.)
- images/*: per-figure and per-photo processing scripts (batch, MJS, PowerShell) plus raw assets
- docs/: final HTML pages grouped by chapter, site index, style.css, sitemap, etc.

##### Additional insights from README
- The repo automates image editing and HTML conversion for Web publishing (20th edition onward).
- Deployed to GitHub Pages at `sakamachi-hideyuki.github.io/meteors/`.

a. Main components
- Source Content
– Raw HTML templates (html/流星と昴の日本神話.htm)
– Raw image assets (images/*/src/*.zip, charts, PDFs)
- Build Engines
– Node.js scripts (html/build-html.mjs, html/modules/*.js)
– Batch/PowerShell wrappers (build-html.bat, word2html.ps1, images/*.bat, .mjs)
- Processors
– HTML transformer modules (render-*.js, split-pages.js, validate-*.js)
– Image pipelines (build-images-web, build-images-ebook, cover, fig-*, photo-*)
- Output
– Generated static site in docs/ (chapter pages, TOC, assets folder)
– Built image outputs in images/build/{web,ebook,png}
- Hosting
– GitHub Pages serves docs/ on each push

b. Relationships and interactions
- Source Content fed into Build Engines
- Build Engines orchestrate Processors
- Processors write to Output directories
- Output/docs deployed automatically by GitHub Pages
- Local CLI (npm scripts) invokes batch/MJS scripts in sequence

c. Architectural patterns & design principles
- Pipeline pattern: discrete transform modules chained to produce final HTML
- Convention-over-configuration: folder naming dictates processing (e.g., images/fig-*/)
- Modular design: each transform in html/modules is single-responsibility
- Separation of concerns: HTML build logic vs. image build logic vs. hosting config

d. Key technologies and libraries
- Node.js (package.json)
- Vanilla JavaScript modules for HTML processing
- Batch (.bat) and PowerShell (.ps1) scripts for cross-platform wrappers
- GitHub Pages for hosting
- Static file conventions (CSS, sitemap.xml)

##### Detail
- Processes (e.g., “split-pages.js breaks master HTML into chapter files”).
- Validation steps (validate-links, validate-summaries) to show quality gates.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Source Content
    subgraph "Source Content"
        HTMLTemplates["HTML Templates"]:::rawContent
        HTMLTemplateFiles["HTML Template Assets"]:::rawContent
        RawImages["Raw Image Assets"]:::rawContent
    end

    %% Build Engines
    subgraph "Build Engines"
        subgraph "HTML Pipeline"
            htmlBatch["build-html.bat"]:::engine
            htmlMjs["build-html.mjs"]:::engine
            word2html["word2html.ps1"]:::engine
            sharedJs["shared.js"]:::engine
        end
        subgraph "Image Pipeline"
            imgBatch["build-images.bat"]:::engine
            imgWeb["build-images-web.bat"]:::engine
            imgEbook["build-images-ebook.bat"]:::engine
            imgPng["build-images-png.bat"]:::engine
            screenshotBat["screenshot.bat"]:::engine
            screenshotMjs["screenshot.mjs"]:::engine
        end
    end

    %% Processors
    subgraph "Processors"
        subgraph "HTML Transformer Modules"
            renderHeader["render-header.js"]:::processor
            renderFooter["render-footer.js"]:::processor
            renderHead["render-head.js"]:::processor
            renderPages["render-pages.js"]:::processor
            renderNormal["render-normal-html.js"]:::processor
            renderIndex["render-index-html.js"]:::processor
            renderToc["render-toc-html.js"]:::processor
            splitPages["split-pages.js"]:::processor
            convertPages["convert-pages.js"]:::processor
            linkPages["link-pages.js"]:::processor
            validateLinks["validate-links.js"]:::processor
            validateRelated["validate-related-pages.js"]:::processor
            validateSummaries["validate-summaries.js"]:::processor
            domUtils["dom-utils.js"]:::processor
            buildModule["build.js"]:::processor
        end
        subgraph "Image Pipelines"
            coverPipeline["Cover Pipeline"]:::processor
            figPipeline["Figure Pipelines"]:::processor
            photoPipeline["Photo Pipelines"]:::processor
        end
    end

    %% Outputs
    subgraph "Outputs"
        docsOutput["docs/"]:::output
        imagesWebOut["images/build/web/"]:::output
        imagesEbookOut["images/build/ebook/"]:::output
        imagesPngOut["images/build/png/"]:::output
    end

    %% Hosting
    GHPages["GitHub Pages"]:::external

    %% Connections
    HTMLTemplates -->|provides templates| htmlBatch
    HTMLTemplates --> htmlMjs
    HTMLTemplateFiles --> htmlMjs
    RawImages --> imgBatch
    imgBatch --> imgWeb
    imgBatch --> imgEbook
    imgBatch --> imgPng
    imgBatch --> screenshotBat
    screenshotBat --> screenshotMjs

    htmlBatch --> buildModule
    htmlMjs --> buildModule
    word2html --> buildModule
    sharedJs --> buildModule

    buildModule --> renderHeader
    buildModule --> renderFooter
    buildModule --> renderHead
    buildModule --> splitPages
    splitPages --> renderPages
    renderPages --> convertPages
    convertPages --> linkPages
    linkPages --> renderNormal
    renderNormal --> renderIndex
    renderNormal --> renderToc
    renderIndex --> validateLinks
    renderToc --> validateRelated
    validateRelated --> validateSummaries
    validateSummaries --> domUtils
    domUtils --> docsOutput

    imgWeb --> figPipeline
    imgEbook --> figPipeline
    imgWeb --> photoPipeline
    imgEbook --> photoPipeline
    screenshotMjs --> coverPipeline
    coverPipeline --> imagesWebOut
    figPipeline --> imagesWebOut
    figPipeline --> imagesEbookOut
    photoPipeline --> imagesWebOut
    photoPipeline --> imagesEbookOut
    imgPng --> imagesPngOut

    docsOutput --> GHPages
    imagesWebOut --> GHPages
    imagesEbookOut --> GHPages
    imagesPngOut --> GHPages

    %% Click Events
    click HTMLTemplates "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/流星と昴の日本神話.htm"
    click HTMLTemplateFiles "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/流星と昴の日本神話.files"
    click RawImages "https://github.com/sakamachi-hideyuki/meteors/tree/main/images/fig-milkywayinsummer/src"
    click htmlBatch "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/build-html.bat"
    click htmlMjs "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/build-html.mjs"
    click word2html "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/word2html.ps1"
    click sharedJs "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/shared.js"
    click imgBatch "https://github.com/sakamachi-hideyuki/meteors/blob/main/images/build-images.bat"
    click imgWeb "https://github.com/sakamachi-hideyuki/meteors/blob/main/images/build-images-web.bat"
    click imgEbook "https://github.com/sakamachi-hideyuki/meteors/blob/main/images/build-images-ebook.bat"
    click imgPng "https://github.com/sakamachi-hideyuki/meteors/blob/main/images/build-images-png.bat"
    click screenshotBat "https://github.com/sakamachi-hideyuki/meteors/blob/main/images/screenshot.bat"
    click screenshotMjs "https://github.com/sakamachi-hideyuki/meteors/blob/main/images/screenshot.mjs"
    click renderHeader "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/render-header.js"
    click renderFooter "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/render-footer.js"
    click renderHead "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/render-head.js"
    click renderPages "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/render-pages.js"
    click renderNormal "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/render-normal-html.js"
    click renderIndex "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/render-index-html.js"
    click renderToc "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/render-toc-html.js"
    click splitPages "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/split-pages.js"
    click convertPages "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/convert-pages.js"
    click linkPages "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/link-pages.js"
    click validateLinks "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/validate-links.js"
    click validateRelated "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/validate-related-pages.js"
    click validateSummaries "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/validate-summaries.js"
    click domUtils "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/dom-utils.js"
    click buildModule "https://github.com/sakamachi-hideyuki/meteors/blob/main/html/modules/build.js"
    click docsOutput "https://github.com/sakamachi-hideyuki/meteors/tree/main/docs/"
    click imagesWebOut "https://github.com/sakamachi-hideyuki/meteors/tree/main/images/build/web/"
    click imagesEbookOut "https://github.com/sakamachi-hideyuki/meteors/tree/main/images/build/ebook/"
    click imagesPngOut "https://github.com/sakamachi-hideyuki/meteors/tree/main/images/build/png/"

    %% Styles
    classDef rawContent fill:#d5f5e3,stroke:#27ae60,color:#145a32;
    classDef engine fill:#fcf3cf,stroke:#f1c40f,color:#7d6608;
    classDef processor fill:#d6eaf8,stroke:#3498db,color:#1b4f72;
    classDef output fill:#fdebd0,stroke:#e67e22,color:#7d5102;
    classDef external fill:#f5eef8,stroke:#8e44ad,color:#4a235a;
```
