# lspriv/wx-calendar architecture

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

- Interactive diagram: https://gitdiagram.com/lspriv/wx-calendar
- Repository: https://github.com/lspriv/wx-calendar

## Overview

##### Project type and purpose
- This is a WeChat Mini-Program UI component library (“wx-calendar”) packaged as an NPM module.
- Its purpose is to provide a highly configurable calendar component with multiple views (month, week, schedule) and a plugin architecture for extending functionality (e.g., lunar calendar, ICS imports).

##### File structure
- Top-level:
- build / — custom build‐and‐pack scripts (clean, pack, watch, handler).
- dev / — a mini-program sandbox (app.js, pages/index, config.json) used for local development & preview.
- scripts / — convenience scripts (dev, publish) invoked by npm run.
- src / — primary component source:
- src/basic: core calendar logic, layout, drag/drop, printing, service layer.
- src/interface: TypeScript interfaces, decorators, component API definitions.
- src/plugins: built-in plugins (e.g., mark.ts).
- src/utils: shared helpers (calc, shared).
- src/style, src/tpls, src/wxs: style definitions, template fragments (wxml), and mini-program JS snippets.
- tmpls / — JSON templates for packaging into mini-program apps (skyline, webview).
- build artifacts (dist) are generated under package.json’s main/lib directories at publish time.
- Config files: tsconfig.json, .eslintrc.js, gulpfile.js, .prettierrc.js, plus CI workflows under .github.

##### README for additional insights
- Confirms feature set: year/month/week/schedule views, plugin system, multi-render modes (Skyline vs Webview).
- Describes NPM usage, development (npm run dev triggers build/watch into dev/), packaging (npm run build, npm run package).
- Highlights dependency on WeChat SDK ≥ 3.0.0, and integration points: import component in page config, bindload/bindclick events, selectComponent API.
- Multi-platform support sections: Donut, UniApp, Taro.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build & Development
    subgraph "Build System"
        Gulpfile["gulpfile.js"]:::build
        BuildScripts["build/*.js"]:::build
    end

    subgraph "NPM CLI Scripts"
        DevCLI["dev.js"]:::scripts
        PublishCLI["publish.js"]:::scripts
        PackageJSON["package.json"]:::scripts
    end

    %% Source Modules
    subgraph "Source Modules"
        CoreService["Core Calendar Service"]:::core
        Interfaces["Interface Definitions"]:::core
        PluginFW["Plugin Framework"]:::plugin
        TemplateEngine["Template Engine"]:::presentation
        StyleSystem["Style System"]:::presentation
        Utils["Utility Functions"]:::utils
        WXSHelpers["WXS Helpers"]:::utils
        EntryPoint["Component Entry"]:::entry
    end

    %% Packaging & Distribution
    subgraph "Packaging"
        DistOutput["Dist / npm package"]:::packaging
        AppTemplates["App Scaffolding Templates"]:::packaging
    end

    %% CI/CD
    subgraph "CI/CD (GitHub Actions)"
        CIAlpha["alpha-package.yml"]:::ci
        CIRelease["release-please.yml"]:::ci
    end

    %% Runtime & Host
    subgraph "Runtime & Dev Sandbox"
        DevSandbox["Dev Sandbox (WeChat Mini-Program)"]:::host
        WeChatHost["WeChat Mini-Program Runtime"]:::host
    end

    ConsumerApp["Consumer Application"]:::host

    %% Flows
    CoreService -->|consumed by| BuildScripts
    Interfaces -->|consumed by| BuildScripts
    PluginFW -->|consumed by| BuildScripts
    TemplateEngine -->|consumed by| BuildScripts
    StyleSystem -->|consumed by| BuildScripts
    Utils -->|consumed by| BuildScripts
    WXSHelpers -->|consumed by| BuildScripts
    EntryPoint -->|consumed by| BuildScripts

    Gulpfile -->|runs| BuildScripts
    DevCLI -->|build & watch→| DevSandbox
    PublishCLI -->|pack→| DistOutput
    PackageJSON -->|defines| DevCLI
    PackageJSON -->|defines| PublishCLI

    BuildScripts -->|output→| DistOutput
    BuildScripts -->|output→| DevSandbox
    DistOutput -->|npm install→| ConsumerApp
    AppTemplates -->|scaffold→| ConsumerApp

    CIAlpha -->|publishes→| DistOutput
    CIRelease -->|releases→| DistOutput

    ConsumerApp -->|import calendar→| EntryPoint
    ConsumerApp -->|runs on→| WeChatHost
    DevSandbox -->|preview app→| WeChatHost

    %% Runtime Interaction
    ConsumerApp -->|user tap/swipe→| PluginFW
    PluginFW -->|hooks→| CoreService
    CoreService -->|renders via| TemplateEngine
    TemplateEngine -->|styled by→| StyleSystem
    TemplateEngine -->|logic uses→| Utils

    %% Click Events
    click Gulpfile "https://github.com/lspriv/wx-calendar/blob/master/gulpfile.js"
    click BuildScripts "https://github.com/lspriv/wx-calendar/tree/master/build"
    click DevCLI "https://github.com/lspriv/wx-calendar/blob/master/scripts/dev.js"
    click PublishCLI "https://github.com/lspriv/wx-calendar/blob/master/scripts/publish.js"
    click PackageJSON "https://github.com/lspriv/wx-calendar/blob/master/package.json"
    click CoreService "https://github.com/lspriv/wx-calendar/tree/master/src/basic"
    click Interfaces "https://github.com/lspriv/wx-calendar/tree/master/src/interface"
    click PluginFW "https://github.com/lspriv/wx-calendar/blob/master/src/plugins/mark.ts"
    click TemplateEngine "https://github.com/lspriv/wx-calendar/tree/master/src/tpls"
    click StyleSystem "https://github.com/lspriv/wx-calendar/tree/master/src/style"
    click Utils "https://github.com/lspriv/wx-calendar/tree/master/src/utils"
    click WXSHelpers "https://github.com/lspriv/wx-calendar/tree/master/src/wxs"
    click EntryPoint "https://github.com/lspriv/wx-calendar/blob/master/src/index.ts"
    click AppTemplates "https://github.com/lspriv/wx-calendar/tree/master/tmpls"
    click CIAlpha "https://github.com/lspriv/wx-calendar/blob/master/.github/workflows/alpha-package.yml"
    click CIRelease "https://github.com/lspriv/wx-calendar/blob/master/.github/workflows/release-please.yml"

    %% Styles
    classDef build fill:#cccccc,stroke:#333
    classDef scripts fill:#e5e5e5,stroke:#333
    classDef core fill:#b3cde3,stroke:#333
    classDef presentation fill:#ccebc5,stroke:#333
    classDef plugin fill:#fdae61,stroke:#333
    classDef utils fill:#b3e2cd,stroke:#333
    classDef entry fill:#ffffcc,stroke:#333
    classDef packaging fill:#fed9a6,stroke:#333
    classDef ci fill:#fbb4ae,stroke:#333
    classDef host fill:#decbe4,stroke:#333
```
