# e74000/shizuka architecture

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

- Interactive diagram: https://gitdiagram.com/e74000/shizuka
- Repository: https://github.com/e74000/shizuka

## Overview

##### Main Components

A. CLI Layer
- Entry point through main.go
- Command handlers in cmd/ directory
- Core commands: init, build, dev, serve

B. Core Engine (shizuka/ directory)
- Content processing
- Frontmatter parsing
- Indexing system
- Location management

C. File System Interaction
- Input: content/, templates/, static/ directories
- Output: dist/ directory
- Configuration: shizuka_conf.json

**Level 1 (User Interface):**
- CLI Commands (init, build, dev, serve)

**Level 2 (Core Processing):**
- Content Processing → Template Engine → Static Assets

**Level 3 (File System):**
- Input Directories ↔ Output Directory

##### Component Relationships

- CLI commands → Core Engine (direct dependency)
- Core Engine → File System (bidirectional for read/write)
- Template Engine ← Content Processing (content injection)
- Static Assets → Output Directory (direct copy)

##### Specific Implementation Details

Key architectural elements:
- Markdown processing pipeline
- Template rendering system
- Live reload mechanism (dev server)
- File watching system
- Build process flow

##### Important Notes

a. Modular design:
- Separate cmd package for CLI
- Core shizuka package for processing
- Clear separation of concerns

b. Development workflow:
- Init → Content Creation → Development → Build → Serve

c. File structure:
- Content organization
- Template system
- Static asset management

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph CLI
        Main["Main Entry Point"]
        CmdRoot["Command Handler"]
        InitCmd["Init Command"]
        BuildCmd["Build Command"]
        DevCmd["Dev Command"]
        ServeCmd["Serve Command"]
        Utils["Utility Functions"]
    end

    subgraph CoreEngine["Core Engine"]
        BuildProcess["Build Process"]
        FrontMatter["Frontmatter Processing"]
        Indexing["Indexing System"]
        Location["Location Management"]
    end

    subgraph EmbeddedAssets["Embedded Assets"]
        Templates["Default Templates"]
        Styles["Default Styles"]
        SampleContent["Sample Content"]
    end

    subgraph FileSystem["File System"]
        Input["Input Directories<br/>(content/, templates/, static/)"]
        Output["Output Directory<br/>(dist/)"]
        Config["Configuration<br/>(shizuka_conf.json)"]
    end

    Main --> CmdRoot
    CmdRoot --> InitCmd
    CmdRoot --> BuildCmd
    CmdRoot --> DevCmd
    CmdRoot --> ServeCmd

    InitCmd --> EmbeddedAssets
    EmbeddedAssets --> FileSystem

    BuildCmd --> BuildProcess
    DevCmd --> BuildProcess
    ServeCmd --> Output

    BuildProcess --> FrontMatter
    BuildProcess --> Indexing
    BuildProcess --> Location

    FrontMatter --> Input
    Indexing --> Input
    Location --> Input
    BuildProcess --> Output

    %% Click events for component mapping
    click Main "https://github.com/e74000/shizuka/blob/main/main.go"
    click CmdRoot "https://github.com/e74000/shizuka/blob/main/cmd/root.go"
    click InitCmd "https://github.com/e74000/shizuka/blob/main/cmd/init.go"
    click BuildCmd "https://github.com/e74000/shizuka/blob/main/cmd/build.go"
    click DevCmd "https://github.com/e74000/shizuka/blob/main/cmd/dev.go"
    click ServeCmd "https://github.com/e74000/shizuka/blob/main/cmd/serve.go"
    click Utils "https://github.com/e74000/shizuka/blob/main/cmd/utils.go"
    click FrontMatter "https://github.com/e74000/shizuka/blob/main/shizuka/frontmatter.go"
    click Indexing "https://github.com/e74000/shizuka/blob/main/shizuka/indexing.go"
    click Location "https://github.com/e74000/shizuka/blob/main/shizuka/location.go"
    click BuildProcess "https://github.com/e74000/shizuka/blob/main/shizuka/build.go"
    click Templates "https://github.com/e74000/shizuka/tree/main/cmd/embed"
    click Styles "https://github.com/e74000/shizuka/blob/main/cmd/embed/styles.css"
    click SampleContent "https://github.com/e74000/shizuka/tree/main/cmd/embed"

    %% Styling
    classDef cli fill:#2374ab
    classDef core fill:#48a9a6
    classDef embedded fill:#e4d6a7
    classDef filesystem fill:#9b6a6c

    class Main,CmdRoot,InitCmd,BuildCmd,DevCmd,ServeCmd,Utils cli
    class BuildProcess,FrontMatter,Indexing,Location core
    class Templates,Styles,SampleContent embedded
    class Input,Output,Config filesystem
```
