# monoharada/simple-jsx-ssg architecture

> Architecture diagram of the GitHub repository monoharada/simple-jsx-ssg, 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/monoharada/simple-jsx-ssg
- Repository: https://github.com/monoharada/simple-jsx-ssg

## Overview

##### Main Components
- Source Layer – This consists of the core application code:
- src/ directory: Contains assets (CSS, images, JS), components (UI elements like Header, Card, etc.), frame (Frame.tsx, Head.tsx, Layout.tsx), pages (the actual JSX pages), and data (page_metadata and image details).
- site_setting.ts and types.d.ts set up global settings and type definitions.
- Build/Compiler/Dev Tools Layer – Managed under tools/:
- tools/build: Scripts for HTML compilation, image conversion (from png/jpg to avif), preview server, and production/staging builds.
- tools/compiler: Contains separate compilers/transpilers (css-compile.ts, jsx-dev-runtime.ts, jsx-runtime.ts) that process JSX files into static HTML.
- tools/dev & tools/utils: Support local development with dev servers (bunserver.ts, dev.sh, watcher.ts) and utility scripts.
- Linting/Quality Assurance – Under lint-tools/:
- Contains configurations (.ls-lint.yml, .stylelintrc.json, etc.) and a linting script (linting.ts) for ensuring code/style quality.
- Functions/Middleware Layer:
- The functions/ directory (including _middleware.js) indicates support for server-side functions, middleware processing, or APIs that might be used locally or even in deployment scenarios.
- Public Assets/Deployment Output:
- public/ directory likely holds files served as static assets.

##### Relationships and Data Flow
- During development, changes in the src/ directory (primarily JSX/TSX files and CSS) are detected by the watcher under tools/dev, triggering the build pipeline in tools/build.
- The build process (using tools/compiler) converts the JSX templates into static HTML and outputs to a directory such as dist/www. The output is then monitored (possibly by a live-reload mechanism) to update the browser automatically.
- Static assets (CSS and images) are organized under src/assets, where CSS files are split into layered cascade files (reset, tokens, base, etc.) and are processed through postcss-import. The CSS layering approach (configured via site_setting.ts) should be highlighted.
- The functions layer (functions/) may handle middleware or backend-like behavior (for example, handling SSI or Cloudflare adaptations) and interacts with the build/server environment.
- Lint-tools provide static analysis both for code (TypeScript, JSX) and markup (HTML/CSS) to ensure a consistent style and quality throughout the development lifecycle.

##### Architectural Patterns & Technology Choices
- Separation of Concerns: Notice the clear separation between the source code (frontend components, pages, and assets) and the build/compilation tools.
- Compile-Time Transformation: The use of JSX solely as a template engine that transforms into static HTML, ensuring a rapid build process with immediate browser reloading.

- “SRC (Components, Pages, Data)” – a central block.
- “Assets (CSS, Images, JS)” – inside the src folder, highlight sublayers or cascading layers.
- “Build & Compiler Tools” – grouping tools/build, tools/compiler, and tools/dev.
- “Linting & QA” – block for lint-tools.
- “Middleware / Functions” – block from the functions/ directory.
- “Static Output (dist/www)” – show the result of the build process that is served to users.
- Source code (rectangles)

##### Capturing Essential Architectural Elements
- “Compiler & Build Pipeline”: Show how tools in the “tools” directory intercept, process, and compile source files.
- CSS layering policy as a side note in the assets region to remind developers about the cascade layers order defined in site_setting.ts.
- Integration points with external services (for example, handling SSI, Cloudflare deployment hints, etc.) as per the README’s directions.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Source Layer
    subgraph "Source Layer"
        A["src/ (Components, Pages, Data)"]:::source
        B["Assets (CSS, Images, JS)"]:::source
        C["site_setting.ts"]:::source
        D["types.d.ts"]:::source
        E["CSS Layer: _import"]:::asset
        F["CSS Layer: common"]:::asset
    end

    %% Build & Compiler Tools Layer
    subgraph "Build & Compiler Tools"
        I["tools/dev/ (dev servers, watcher)"]:::build
        G["tools/build/ (HTML build, image conversion, preview server)"]:::build
        H["tools/compiler/ (JSX compilers)"]:::build
        J["tools/utils/ (utility scripts)"]:::build
    end

    %% Support Utilities & Middleware
    subgraph "Support & Middleware"
        K["Linting/QA (lint-tools/)"]:::utility
        L["Functions/Middleware (functions/)"]:::utility
    end

    %% Output & Deployment
    subgraph "Output & Deployment"
        M["Public Assets (public/)"]:::output
        N["Static Output (dist/www)"]:::output
        O["Browser Reload"]:::output
    end

    %% Relationships and Data Flow
    A -->|"triggers"| I
    I -->|"initiates"| G
    G -->|"invokes"| H
    H -->|"generates"| N
    N -->|"updates"| O
    
    %% Additional Interactions
    A -->|"checked by"| K
    L -->|"interfaces with"| G
    M -->|"integrated into"| N

    %% CSS Cascade Layering Connections
    B -->|"includes"| E
    B -->|"includes"| F
    C -->|"configures"| E
    C -->|"configures"| F

    %% Classes for styling
    classDef source fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef asset fill:#D5F5E3,stroke:#145A32,stroke-width:2px;
    classDef build fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef utility fill:#FADBD8,stroke:#922B21,stroke-width:2px,stroke-dasharray: 5 5;
    classDef output fill:#E8DAEF,stroke:#6C3483,stroke-width:2px;

    %% Build Commands annotations (for informational purposes)
    I ---|"Dev Mode: bun run dev"| X[ ]
    G ---|"Production Build: bun run build"| Y[ ]

    %% Click Events
    click A "https://github.com/monoharada/simple-jsx-ssg/tree/main/src/"
    click C "https://github.com/monoharada/simple-jsx-ssg/blob/main/src/site_setting.ts"
    click D "https://github.com/monoharada/simple-jsx-ssg/blob/main/src/types.d.ts"
    click B "https://github.com/monoharada/simple-jsx-ssg/tree/main/src/assets/"
    click E "https://github.com/monoharada/simple-jsx-ssg/tree/main/src/assets/css/_import"
    click F "https://github.com/monoharada/simple-jsx-ssg/tree/main/src/assets/css/common"
    click G "https://github.com/monoharada/simple-jsx-ssg/tree/main/tools/build/"
    click H "https://github.com/monoharada/simple-jsx-ssg/tree/main/tools/compiler/"
    click I "https://github.com/monoharada/simple-jsx-ssg/tree/main/tools/dev/"
    click J "https://github.com/monoharada/simple-jsx-ssg/tree/main/tools/utils/"
    click K "https://github.com/monoharada/simple-jsx-ssg/tree/main/lint-tools/"
    click L "https://github.com/monoharada/simple-jsx-ssg/tree/main/functions/"
    click M "https://github.com/monoharada/simple-jsx-ssg/tree/main/public/"
```
