How sinotca529/zakki works
Project Type and Purpose
• zakki is a CLI-based static site generator written in Rust.
• It reads Markdown from a source directory (public, private, draft), applies a configurable pipeline of renderer passes, manages assets and templates, optionally encrypts pages, builds a search index using a Bloom filter, and writes pure HTML/CSS/JS to a build directory.
High-Level Components
• CLI Layer
• src/main.rs + src/command/* (init, build, clean)
• Dispatches subcommands and parses flags (e.g. -d for drafts).
• Configuration Loader
• zakki.toml → parsed by src/config.rs.
• Source File System
• src/public/, src/private/, src/draft/ (per README)
• Markdown + optional assets per page folder.
• Build Pipeline (Build Command)
• Entry: src/command/build.rs → build::renderer::RenderingContext
• Template Engine: html_template.rs + asset HTML fragments under asset/
• Pipeline of Passes (under renderer/pass/):
• assign_header_id, get_title, toc_pass, convert_math (KaTeX), highlight_code, image_convert, link_adjust, table_wrapper, read_header, etc.
• Utility Modules
• util/file_io.rs, util/path_ext.rs (I/O & path helpers)
• util/aes_256_cbc.rs (encryption for private pages)
• util/bloom_filter.rs + util/segmenter.rs (search index generator)
• util/fxhash.rs, util/vec_ext.rs (performance helpers).
• Asset Manager
• Static assets (asset/style.css, asset/script.js, fonts, KaTeX assets).
• Copied wholesale into output or injected into templates.
• Output File System
• build/ directory mirroring the final site structure with HTML/CSS/JS.
• Continuous Integration / Release
• .github/workflows/release.yml handles build & publish to crates.io/GitHub Releases.
Relationships & Data Flow
• User invokes zakki build → CLI Layer
→ Configuration Loader reads zakki.toml
→ Source File System scan
→ Build Pipeline:
• For each Markdown page, pass through Renderer Context → sequence of Pass modules → HTML string injected into page template → encryption module (if in private) → write to Output FS
→ Asset Manager copies over CSS/JS/fonts → generate Bloom filter index → write index to Output FS
• zakki init scaffolds new project tree.
• CI Workflow triggers on tag → runs tests, builds binary, publishes.
Architectural Patterns & Principles
• Command Pattern (one module per subcommand).
• Pipeline / Chain-of-Responsibility for renderer passes.
• Modular utilities for cross-cutting concerns (I/O, crypto, hashing, filtering).
• Template-driven code generation (HTML fragments under asset/).
• Separation of concerns: parsing, rendering, templating, encryption, search indexing, asset management.