# dingff/match-kit architecture

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

- Interactive diagram: https://gitdiagram.com/dingff/match-kit
- Repository: https://github.com/dingff/match-kit

## Overview

##### Project type and purpose
- This is an open‑source, full‑stack library for JavaScript/TypeScript that provides a powerful pattern‑matching API.
- Under the hood it implements its core matching logic in Rust, compiles that to WebAssembly (WASM), and exposes a TypeScript/JavaScript facade for NPM consumers.

##### File structure
- Top‑level build and config files: Cargo.toml/Cargo.lock (Rust package), package.json/pnpm-lock.yaml (Node package), rslib.config.ts (TypeScript library bundler config), tsconfig.json.
- .husky, .npmrc, .release-it.json: Git hooks and release automation.
- src/
- lib.rs – Rust core implementation.
- wasm/
– match_kit.ts – glue code that loads/initializes the generated WASM.
- index.ts – TypeScript entry point that re‑exports match(), helpers, and types.
- types.ts – TS definitions and pattern helper interfaces.
- tests/
- web.rs – Rust unit/integration tests of the core matching engine.

##### README for additional insights
- Describes the library’s public API (match, any, not, regex, Some, None).
- Demonstrates the idea of compiling Rust → WASM and then using TypeScript wrappers.
- Emphasizes pattern‑matching priority and usage scenarios.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Rust Layer"
        RC["Rust Core Module\nlib.rs"]:::rust
        RT["Rust Package Config\nCargo.toml\nCargo.lock\nrustfmt.toml"]:::rust
        CT["Rust Tests\ntests/web.rs"]:::rust
    end

    subgraph "WASM & Glue"
        WG["WASM Artifact + JS Glue\n(.wasm + JS)"]:::wasm
        MK["WASM Glue Code\nmatch_kit.ts"]:::wasm
    end

    subgraph "TypeScript Facade & API"
        TSF["TypeScript Entry Point\nindex.ts"]:::ts
        TYP["TS Definitions & Helpers\ntypes.ts"]:::ts
    end

    subgraph "Build Tools & Packaging"
        RB["Library Bundler Config\nrslib.config.ts"]:::ts
        NP["Node/TS Package Config\npackage.json\npnpm-lock.yaml\ntsconfig.json"]:::ts
        HC["Git Hooks\n.husky/"]:::ext
        RL["Release Automation\n.release-it.json"]:::ext
    end

    subgraph "External Systems"
        NPM["NPM Registry"]:::ext
        CONS["Consumer Apps\n(Node.js/Browser)"]:::ext
    end

    RC -->|"wasm-pack compile"| WG
    RT -->|"provides build config"| RC
    CT -->|"tests core logic"| RC

    WG -->|"load/init"| MK
    MK -->|"expose API"| TSF
    TYP -->|"type support"| TSF

    TSF -->|"tsc + rslib bundle"| NP
    RB -->|"bundle config"| NP

    NP -->|"npm publish"| NPM
    HC -->|"pre-commit checks"| NP
    RL -->|"semantic release"| NPM

    NPM -->|"install"| CONS
    CONS -->|"calls match() API"| TSF

    classDef rust fill:#a8ddb5,stroke:#31a354,stroke-width:2px;
    classDef wasm fill:#fdae6b,stroke:#e6550d,stroke-width:2px;
    classDef ts fill:#9ecae1,stroke:#3182bd,stroke-width:2px;
    classDef ext fill:#eeeeee,stroke:#999999,stroke-width:2px;

    click RC "https://github.com/dingff/match-kit/blob/main/src/lib.rs"
    click MK "https://github.com/dingff/match-kit/blob/main/src/wasm/match_kit.ts"
    click TSF "https://github.com/dingff/match-kit/blob/main/src/index.ts"
    click TYP "https://github.com/dingff/match-kit/blob/main/src/types.ts"
    click RT "https://github.com/dingff/match-kit/blob/main/Cargo.toml"
    click RB "https://github.com/dingff/match-kit/blob/main/rslib.config.ts"
    click NP "https://github.com/dingff/match-kit/blob/main/package.json"
    click HC "https://github.com/dingff/match-kit/tree/main/.husky/"
    click RL "https://github.com/dingff/match-kit/blob/main/.release-it.json"
    click CT "https://github.com/dingff/match-kit/blob/main/tests/web.rs"
```
