# senghoo/golang-design-pattern architecture

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

- Interactive diagram: https://gitdiagram.com/senghoo/golang-design-pattern
- Repository: https://github.com/senghoo/golang-design-pattern

## Overview

##### Project type and purpose
- This repository is not a standalone application or service, but an educational “catalog” of Go (Golang) design‐pattern implementations.
- Its purpose is to demonstrate each pattern (creational, structural, behavioral) in idiomatic Go, with code examples and unit tests.

##### File structure
- Top‐level items:
- 23 numbered directories (00_simple_factory … 23_visitor), each implementing one design pattern
- LICENSE, README.md (project overview)
- .travis.yml (CI configuration)
- .gitignore
- Within each pattern directory:
- A .go source file (pattern implementation)
- A _test.go file (unit tests exercising the implementation)
- Often a README.md describing the pattern in that folder
- There is no frontend/backend split—each folder is a self‐contained module illustrating one pattern.
- The CI config (.travis.yml) runs Go test on every pattern.

##### README for additional insights
- The README groups patterns into three categories:
a. Creational (00–07)
b. Structural (01,02,09,13,18,20,22)
c. Behavioral (08,10–12,14–17,19,21,23)
- No runtime or deployment sections; focus is on code examples.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Category Containers
    subgraph "Creational Patterns"
        direction TB
        CF["00_simple_factory"]:::creational
        SING["03_singleton"]:::creational
        FM["04_factory_method"]:::creational
        AF["05_abstract_factory"]:::creational
        BLD["06_builder"]:::creational
        PRO["07_prototype"]:::creational
    end

    subgraph "Structural Patterns"
        direction TB
        FCD["01_facade"]:::structural
        ADP["02_adapter"]:::structural
        PRX["09_proxy"]:::structural
        CMP["13_composite"]:::structural
        FLY["18_flyweight"]:::structural
        DEC["20_decorator"]:::structural
        BRG["22_bridge"]:::structural
    end

    subgraph "Behavioral Patterns"
        direction TB
        MED["08_mediator"]:::behavioral
        OBS["10_observer"]:::behavioral
        CMD["11_command"]:::behavioral
        ITR["12_iterator"]:::behavioral
        TMM["14_template_method"]:::behavioral
        STR["15_strategy"]:::behavioral
        STA["16_state"]:::behavioral
        MEM["17_memento"]:::behavioral
        INT["19_interpreter"]:::behavioral
        CHN["21_chain_of_responsibility"]:::behavioral
        VIS["23_visitor"]:::behavioral
    end

    %% Infrastructure Components
    CI["CI Pipeline\n(.travis.yml)"]:::ci
    Test["Test Harness\n(go test ./...)"]:::test
    Doc["Documentation\n(README.md & per-pattern)"]:::doc
    License["LICENSE"]:::doc
    Ignore[".gitignore"]:::doc

    %% Relationships
    CI -->|"runs go test"| Test
    Test -->|"imports & tests"| CF
    Test -->|"imports & tests"| SING
    Test -->|"imports & tests"| FM
    Test -->|"imports & tests"| AF
    Test -->|"imports & tests"| BLD
    Test -->|"imports & tests"| PRO
    Test -->|"imports & tests"| FCD
    Test -->|"imports & tests"| ADP
    Test -->|"imports & tests"| PRX
    Test -->|"imports & tests"| CMP
    Test -->|"imports & tests"| FLY
    Test -->|"imports & tests"| DEC
    Test -->|"imports & tests"| BRG
    Test -->|"imports & tests"| MED
    Test -->|"imports & tests"| OBS
    Test -->|"imports & tests"| CMD
    Test -->|"imports & tests"| ITR
    Test -->|"imports & tests"| TMM
    Test -->|"imports & tests"| STR
    Test -->|"imports & tests"| STA
    Test -->|"imports & tests"| MEM
    Test -->|"imports & tests"| INT
    Test -->|"imports & tests"| CHN
    Test -->|"imports & tests"| VIS

    Doc -->|"describes usage"| CF
    Doc -->|"describes usage"| SING
    Doc -->|"describes usage"| FM
    Doc -->|"describes usage"| AF
    Doc -->|"describes usage"| BLD
    Doc -->|"describes usage"| PRO
    Doc -->|"describes usage"| FCD
    Doc -->|"describes usage"| ADP
    Doc -->|"describes usage"| PRX
    Doc -->|"describes usage"| CMP
    Doc -->|"describes usage"| FLY
    Doc -->|"describes usage"| DEC
    Doc -->|"describes usage"| BRG
    Doc -->|"describes usage"| MED
    Doc -->|"describes usage"| OBS
    Doc -->|"describes usage"| CMD
    Doc -->|"describes usage"| ITR
    Doc -->|"describes usage"| TMM
    Doc -->|"describes usage"| STR
    Doc -->|"describes usage"| STA
    Doc -->|"describes usage"| MEM
    Doc -->|"describes usage"| INT
    Doc -->|"describes usage"| CHN
    Doc -->|"describes usage"| VIS

    Doc --> License
    Doc --> Ignore

    %% Click Events
    click CF "https://github.com/senghoo/golang-design-pattern/tree/master/00_simple_factory/"
    click SING "https://github.com/senghoo/golang-design-pattern/tree/master/03_singleton/"
    click FM "https://github.com/senghoo/golang-design-pattern/tree/master/04_factory_method/"
    click AF "https://github.com/senghoo/golang-design-pattern/tree/master/05_abstract_factory/"
    click BLD "https://github.com/senghoo/golang-design-pattern/tree/master/06_builder/"
    click PRO "https://github.com/senghoo/golang-design-pattern/tree/master/07_prototype/"
    click FCD "https://github.com/senghoo/golang-design-pattern/tree/master/01_facade/"
    click ADP "https://github.com/senghoo/golang-design-pattern/tree/master/02_adapter/"
    click PRX "https://github.com/senghoo/golang-design-pattern/tree/master/09_proxy/"
    click CMP "https://github.com/senghoo/golang-design-pattern/tree/master/13_composite/"
    click FLY "https://github.com/senghoo/golang-design-pattern/tree/master/18_flyweight/"
    click DEC "https://github.com/senghoo/golang-design-pattern/tree/master/20_decorator/"
    click BRG "https://github.com/senghoo/golang-design-pattern/tree/master/22_bridge/"
    click MED "https://github.com/senghoo/golang-design-pattern/tree/master/08_mediator/"
    click OBS "https://github.com/senghoo/golang-design-pattern/tree/master/10_observer/"
    click CMD "https://github.com/senghoo/golang-design-pattern/tree/master/11_command/"
    click ITR "https://github.com/senghoo/golang-design-pattern/tree/master/12_iterator/"
    click TMM "https://github.com/senghoo/golang-design-pattern/tree/master/14_template_method/"
    click STR "https://github.com/senghoo/golang-design-pattern/tree/master/15_strategy/"
    click STA "https://github.com/senghoo/golang-design-pattern/tree/master/16_state/"
    click MEM "https://github.com/senghoo/golang-design-pattern/tree/master/17_memento/"
    click INT "https://github.com/senghoo/golang-design-pattern/tree/master/19_interpreter/"
    click CHN "https://github.com/senghoo/golang-design-pattern/tree/master/21_chain_of_responsibility/"
    click VIS "https://github.com/senghoo/golang-design-pattern/tree/master/23_visitor/"
    click CI "https://github.com/senghoo/golang-design-pattern/blob/master/.travis.yml"
    click Doc "https://github.com/senghoo/golang-design-pattern/blob/master/README.md"
    click License "https://github.com/senghoo/golang-design-pattern/tree/master/LICENSE"
    click Ignore "https://github.com/senghoo/golang-design-pattern/blob/master/.gitignore"

    %% Styles
    classDef creational fill:#CCE5FF,stroke:#004085,color:#004085;
    classDef structural fill:#D4EDDA,stroke:#155724,color:#155724;
    classDef behavioral fill:#F8D7DA,stroke:#721C24,color:#721C24;
    classDef ci fill:#FFF3CD,stroke:#856404,color:#856404;
    classDef test fill:#D1ECF1,stroke:#0C5460,color:#0C5460;
    classDef doc fill:#E2E3E5,stroke:#6C757D,color:#6C757D;
```
