# shenguanjiejie/workwork architecture

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

- Interactive diagram: https://gitdiagram.com/shenguanjiejie/workwork
- Repository: https://github.com/shenguanjiejie/workwork

## Overview

##### Project type and purpose
- This is a stand‑alone CLI application written in Go (“workwork”), providing a suite of developer/tester utilities (base64, cc, go‑script runner, md5, regex tester, time formatter, translator, URL encoder/decoder, UUID generator).
- There is no web frontend or backend service; all components run in a single binary and are invoked via command line.

##### File structure
- Top‑level files
- main.go – the entry point
- cmd/ – contains all Cobra subcommands (root.go and one file per tool)
- cmd/model/ – shared types for commands and flags
- build.sh, install.sh – build and installation scripts
- resources/ – sample input files and screenshot assets
- go.mod, go.sum – dependency management
- workwork.yaml – (potential future config)
- Patterns
- Cobra CLI framework: root command (cmd/root.go) delegates to subcommands (cmd/base64.go, cmd/cc.go, …).
- Shared “model” package defines command metadata and flag parsing helpers.
- Each subcommand implements its own logic, invoking utility functions or third‑party libs (e.g. any‑rule for regex, HTTP client for translation).

##### README for additional insights
- Lists each tool’s functionality, CLI flags, and sample screenshots.
- Mentions external sources (any86/any-rule) and APIs (for translation).
- Plans for future extension (config file support, unit tests, Alfred integration).

##### Detail level
- Explicitly show external HTTP call from Translator module and external regex library usage

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CLI Entry & Framework"
        Terminal["Terminal / User Shell"]:::entry
        Main["main.go\n(Entry Point)"]:::entry
        Root["Cobra RootCmd\n(cmd/root.go)"]:::entry
        GoMod["go.mod\n(Cobra Dependency)"]:::entry
    end
    Terminal -->|"ww <command>"| Main
    Main -->|"invoke"| Root
    GoMod -->|"provides Cobra"| Root

    subgraph "Command Modules"
        Base64["Base64 Module"]:::commands
        CC["Calculator (cc)"]:::commands
        GoScript["Go‑script Runner"]:::commands
        MD5["MD5 Module"]:::commands
        Regex["Regex Tester"]:::commands
        TimeFmt["Time Formatter"]:::commands
        Trans["Translator"]:::commands
        URL["URL Encoder/Decoder"]:::commands
        UUID["UUID Generator"]:::commands
    end
    Root -->|"dispatch"| Base64
    Root --> CC
    Root --> GoScript
    Root --> MD5
    Root --> Regex
    Root --> TimeFmt
    Root --> Trans
    Root --> URL
    Root --> UUID

    subgraph "Shared Model & Utils"
        ModelCmd["command.go"]:::model
        ModelFlag["flag.go"]:::model
        RegexAdapter["regex.go"]:::model
        TransAdapter["trans.go"]:::model
    end
    Base64 -->|"parse flags"| ModelFlag
    CC --> ModelFlag
    GoScript --> ModelFlag
    MD5 --> ModelFlag
    Regex --> ModelFlag
    TimeFmt --> ModelFlag
    Trans --> ModelFlag
    URL --> ModelFlag
    UUID --> ModelFlag
    Regex -->|"use engine"| RegexAdapter
    Trans -->|"prepare request"| TransAdapter

    subgraph "External Services & Dependencies"
        AnyRule["any86/any-rule"]:::external
        TransAPI["Translation API"]:::external
    end
    RegexAdapter --> AnyRule
    TransAdapter --> TransAPI

    subgraph "I/O & Resources"
        Resources["resources/"]:::io
    end
    Base64 -->|"--file flag"| Resources
    CC --> Resources
    GoScript --> Resources
    MD5 --> Resources
    Regex --> Resources
    TimeFmt --> Resources
    Trans --> Resources
    URL --> Resources
    UUID --> Resources

    subgraph "DevOps Scripts"
        Build["build.sh"]:::devops
        Install["install.sh"]:::devops
    end
    Build --> Main
    Install --> Main

    click Main "https://github.com/shenguanjiejie/workwork/blob/main/main.go"
    click Root "https://github.com/shenguanjiejie/workwork/blob/main/cmd/root.go"
    click GoMod "https://github.com/shenguanjiejie/workwork/blob/main/go.mod"
    click Base64 "https://github.com/shenguanjiejie/workwork/blob/main/cmd/base64.go"
    click CC "https://github.com/shenguanjiejie/workwork/blob/main/cmd/cc.go"
    click GoScript "https://github.com/shenguanjiejie/workwork/blob/main/cmd/go.go"
    click MD5 "https://github.com/shenguanjiejie/workwork/blob/main/cmd/md5.go"
    click Regex "https://github.com/shenguanjiejie/workwork/blob/main/cmd/regex.go"
    click TimeFmt "https://github.com/shenguanjiejie/workwork/blob/main/cmd/time.go"
    click Trans "https://github.com/shenguanjiejie/workwork/blob/main/cmd/trans.go"
    click URL "https://github.com/shenguanjiejie/workwork/blob/main/cmd/url.go"
    click UUID "https://github.com/shenguanjiejie/workwork/blob/main/cmd/uuid.go"
    click ModelCmd "https://github.com/shenguanjiejie/workwork/blob/main/cmd/model/command.go"
    click ModelFlag "https://github.com/shenguanjiejie/workwork/blob/main/cmd/model/flag.go"
    click RegexAdapter "https://github.com/shenguanjiejie/workwork/blob/main/cmd/model/regex.go"
    click TransAdapter "https://github.com/shenguanjiejie/workwork/blob/main/cmd/model/trans.go"
    click Resources "https://github.com/shenguanjiejie/workwork/tree/main/resources/"
    click Build "https://github.com/shenguanjiejie/workwork/blob/main/build.sh"
    click Install "https://github.com/shenguanjiejie/workwork/blob/main/install.sh"

    classDef entry fill:#D6EAF8,stroke:#2980B9,color:#0B5345
    classDef commands fill:#D5F5E3,stroke:#27AE60,color:#145A32
    classDef model fill:#FAE5D3,stroke:#D35400,color:#78281F
    classDef external fill:#EBDEF0,stroke:#8E44AD,color:#4A235A
    classDef io fill:#F2F3F4,stroke:#95A5A6,color:#424949
    classDef devops fill:#FCF3CF,stroke:#F1C40F,color:#7D6608
```
