# kristoff-it/zine architecture

> Architecture diagram of the GitHub repository kristoff-it/zine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kristoff-it/zine
- Repository: https://github.com/kristoff-it/zine

## Overview

##### Main System Components

a) Core Engine Components:
- Content Processing Pipeline
- Template Engine
- Asset Management
- Build System

b) Development Tools:
- Development Server
- File Watcher System
- Hot Reload Mechanism

##### Component Relationships

a) Build Pipeline (Central Component):
- Build.zig as the entry point
- To the content processing system
- Link to the templating engine
- To asset management

b) Context System (Core Feature):
- Relationships between different context types (Page, Site, Template, etc.)
- Demonstrate how context feeds into the rendering pipeline

c) Server Component:
- Development server (src/exes/server)
- File watching system with platform-specific implementations
- Hot reload mechanism (zinereload.js)

##### Specific Implementation Details

- Blue Rectangles: Core processing components
- Green Rectangles: File system operations
- Yellow Diamonds: Build tools and utilities
- Purple Hexagons: Platform-specific implementations
- Red Circles: Critical system endpoints

##### Data Flow Visualization

Following flows:

**Source Files → Content Processing → Template Engine → Rendered Output**
- ↓
- Asset Processing → Asset Index
- ↓
- Development Server → Hot Reload

##### Key Technical Elements to Highlight

a) Build System:
- build.zig and build.zig.zon configuration
- Content processing pipeline
- Asset management system

b) Runtime Components:
- Development server
- Platform-specific file watchers (Linux/MacOS/Windows)
- Hot reload functionality

c) Processing Pipeline:
- Markdown rendering
- Template processing
- Asset handling
- Front matter parsing

##### Important Architectural Patterns

- Pipeline Pattern: Content processing flow
- Plugin Architecture: Asset and content processors
- Platform Abstraction: File watching system
- Event-Driven Architecture: Development server and hot reload

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph BuildSystem
        Build["Build System"]:::build
        ContentProc["Content Processing"]:::build
        TemplateProc["Template Processing"]:::build
        Tools["Build Tools"]:::build
    end

    subgraph ContextSystem
        Context["Context Manager"]:::context
        PageCtx["Page Context"]:::context
        SiteCtx["Site Context"]:::context
        TplCtx["Template Context"]:::context
    end

    subgraph ProcessingPipeline
        FrontMatter["Front Matter Parser"]:::processor
        MarkdownRender["Markdown Renderer"]:::processor
        HTMLRender["HTML Renderer"]:::processor
        AssetIndex["Asset Indexer"]:::processor
    end

    subgraph DevServer
        Server["Development Server"]:::server
        subgraph Watchers
            LinuxWatch["Linux Watcher"]:::watcher
            MacWatch["MacOS Watcher"]:::watcher
            WinWatch["Windows Watcher"]:::watcher
        end
        HotReload["Hot Reload"]:::server
        AnsiRender["ANSI Renderer"]:::server
    end

    Build --> ContentProc
    Build --> TemplateProc
    Build --> Tools

    Context --> PageCtx
    Context --> SiteCtx
    Context --> TplCtx

    ContentProc --> FrontMatter
    ContentProc --> MarkdownRender
    ContentProc --> HTMLRender
    ContentProc --> AssetIndex

    Server --> Watchers
    Server --> HotReload
    Server --> AnsiRender

    classDef build fill:#2196F3,stroke:#1565C0,color:white
    classDef context fill:#4CAF50,stroke:#2E7D32,color:white
    classDef processor fill:#FFC107,stroke:#FFA000,color:black
    classDef server fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef watcher fill:#FF5722,stroke:#E64A19,color:white

    click Build "https://github.com/kristoff-it/zine/blob/main/build.zig"
    click ContentProc "https://github.com/kristoff-it/zine/blob/main/build/content.zig"
    click TemplateProc "https://github.com/kristoff-it/zine/blob/main/build/templating.zig"
    click Tools "https://github.com/kristoff-it/zine/blob/main/build/tools.zig"
    click Context "https://github.com/kristoff-it/zine/blob/main/src/context.zig"
    click PageCtx "https://github.com/kristoff-it/zine/blob/main/src/context/Page.zig"
    click SiteCtx "https://github.com/kristoff-it/zine/blob/main/src/context/Site.zig"
    click TplCtx "https://github.com/kristoff-it/zine/blob/main/src/context/Template.zig"
    click Server "https://github.com/kristoff-it/zine/blob/main/src/exes/server/main.zig"
    click HotReload "https://github.com/kristoff-it/zine/blob/main/src/exes/server/Reloader.zig"
    click AnsiRender "https://github.com/kristoff-it/zine/blob/main/src/exes/server/AnsiRenderer.zig"
    click LinuxWatch "https://github.com/kristoff-it/zine/blob/main/src/exes/server/watcher/LinuxWatcher.zig"
    click MacWatch "https://github.com/kristoff-it/zine/blob/main/src/exes/server/watcher/MacosWatcher.zig"
    click WinWatch "https://github.com/kristoff-it/zine/blob/main/src/exes/server/watcher/WindowsWatcher.zig"
    click HTMLRender "https://github.com/kristoff-it/zine/blob/main/src/render/html.zig"
    click MarkdownRender "https://github.com/kristoff-it/zine/blob/main/src/exes/markdown-renderer.zig"
    click AssetIndex "https://github.com/kristoff-it/zine/blob/main/src/exes/index-assets.zig"
    click FrontMatter "https://github.com/kristoff-it/zine/blob/main/frontmatter/frontmatter.zig"
```
