# rifannurmuhammad/design-pattern architecture

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

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

## Overview

This Go repository is a set of independent design-pattern examples, not a single application. Its main runnable demonstration creates food through the factory example and constructs a workspace through the builder example; other patterns illustrate their own behaviors independently. The tree documents creational, structural, and behavioral pattern families, plus an option-pattern example. Sampled source supports several internal interactions; other pattern modules are represented from their paths, without inferring connections between them.

Main entry points: [`main.go`](https://github.com/rifannurmuhammad/design-pattern/blob/main/main.go) (Example main), [`structural_pattern/bridge/bridge.go`](https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/bridge/bridge.go) (Device bridge), [`behavioral_pattern/strategy/context.go`](https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/strategy/context.go) (Trip strategy), [`creational_pattern/factory/factory.go`](https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/factory/factory.go) (Factory method)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Runnable examples"]
  node_demo["Example main<br/>[main.go]"]
end

subgraph group_creational["Creational patterns"]
  node_factory["Factory method<br/>[factory.go]"]
  node_food["Food products<br/>[factory.go]"]
  node_builder["Workspace builder<br/>[builder.go]"]
  node_abstract["Abstract factory"]
  node_xiaomi["Xiaomi factory<br/>[factory.go]"]
  node_xiaomi_products["Xiaomi products"]
  node_prototype["Prototype<br/>[prototype.go]"]
  node_singleton["Singleton<br/>[singleton.go]"]
end

subgraph group_structural["Structural patterns"]
  node_adapter["Currency adapter<br/>[adapter.go]"]
  node_bridge["Device bridge<br/>[bridge.go]"]
  node_bridge_os["OS implementations<br/>[bridge_os.go]"]
  node_bridge_color["Color implementations<br/>[bridge_color.go]"]
  node_composite["Product composite<br/>[composite.go]"]
  node_decorator["Coffee decorator<br/>[decorator.go]"]
  node_facade["Facade<br/>[facade.go]"]
  node_proxy["Logistics proxy<br/>[proxy.go]"]
  node_logistics["Logistics service<br/>[proxy.go]"]
end

subgraph group_behavioral["Behavioral patterns"]
  node_chain["Registration chain"]
  node_profile["Profile handler"]
  node_experience["Experience handler"]
  node_education["Education handler"]
  node_strategy["Trip strategy<br/>[context.go]"]
  node_road["Road strategy<br/>[road.go]"]
  node_flight["Flight strategy<br/>[flight.go]"]
  node_command["Command<br/>[command.go]"]
  node_state["State pattern"]
  node_visitor["Visitor<br/>[interface.go]"]
end

subgraph group_options["Option pattern"]
  node_options["Car options<br/>[main.go]"]
end

node_developer(("Go caller"))

node_developer -->|"runs"| node_demo
node_demo -->|"calls"| node_factory
node_demo -->|"calls"| node_builder
node_factory -->|"creates"| node_food
node_abstract --> node_xiaomi
node_xiaomi -->|"creates"| node_xiaomi_products
node_bridge -->|"installs"| node_bridge_os
node_bridge -->|"uses"| node_bridge_color
node_proxy -->|"delegates"| node_logistics
node_chain -->|"starts"| node_profile
node_profile -->|"dispatches"| node_experience
node_experience -->|"dispatches"| node_education
node_strategy -->|"selects"| node_road
node_strategy -->|"selects"| node_flight

click node_demo "https://github.com/rifannurmuhammad/design-pattern/blob/main/main.go"
click node_factory "https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/factory/factory.go"
click node_food "https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/factory/factory.go"
click node_builder "https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/builder/builder.go"
click node_abstract "https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/abstract_factory/abstract_factory.go"
click node_xiaomi "https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/abstract_factory/xiaomi/factory.go"
click node_xiaomi_products "https://github.com/rifannurmuhammad/design-pattern/tree/main/creational_pattern/abstract_factory/xiaomi/product"
click node_prototype "https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/prototype/prototype.go"
click node_singleton "https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/singleton/singleton.go"
click node_adapter "https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/adapter/adapter.go"
click node_bridge "https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/bridge/bridge.go"
click node_bridge_os "https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/bridge/bridge_os.go"
click node_bridge_color "https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/bridge/bridge_color.go"
click node_composite "https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/composite/composite.go"
click node_decorator "https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/decorator/decorator.go"
click node_facade "https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/facade/facade.go"
click node_proxy "https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/proxy/proxy.go"
click node_logistics "https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/proxy/proxy.go"
click node_chain "https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/chain_of_responsibility/chain_of_responsibility.go"
click node_profile "https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/chain_of_responsibility/chain_of_responsibility.go"
click node_experience "https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/chain_of_responsibility/chain_of_responsibility.go"
click node_education "https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/chain_of_responsibility/chain_of_responsibility.go"
click node_strategy "https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/strategy/context.go"
click node_road "https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/strategy/road.go"
click node_flight "https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/strategy/flight.go"
click node_command "https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/command/command.go"
click node_state "https://github.com/rifannurmuhammad/design-pattern/tree/main/behavioral_pattern/state"
click node_visitor "https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/visitor/interface.go"
click node_options "https://github.com/rifannurmuhammad/design-pattern/blob/main/option_pattern/main.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_demo toneBlue
class node_factory,node_food,node_builder,node_abstract,node_xiaomi,node_xiaomi_products,node_prototype,node_singleton toneAmber
class node_adapter,node_bridge,node_bridge_os,node_bridge_color,node_composite,node_decorator,node_facade,node_proxy,node_logistics toneMint
class node_chain,node_profile,node_experience,node_education,node_strategy,node_road,node_flight,node_command,node_state,node_visitor toneRose
class node_options,node_developer toneIndigo
```

## Components

### Runnable examples

- [Example main](https://github.com/rifannurmuhammad/design-pattern/blob/main/main.go): `main.go`

### Creational patterns

- [Factory method](https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/factory/factory.go): `creational_pattern/factory/factory.go`
- [Food products](https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/factory/factory.go): `creational_pattern/factory/factory.go`
- [Workspace builder](https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/builder/builder.go): `creational_pattern/builder/builder.go`
- [Abstract factory](https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/abstract_factory/abstract_factory.go): `creational_pattern/abstract_factory/abstract_factory.go`
- [Xiaomi factory](https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/abstract_factory/xiaomi/factory.go): `creational_pattern/abstract_factory/xiaomi/factory.go`
- [Xiaomi products](https://github.com/rifannurmuhammad/design-pattern/tree/main/creational_pattern/abstract_factory/xiaomi/product): `creational_pattern/abstract_factory/xiaomi/product`
- [Prototype](https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/prototype/prototype.go): `creational_pattern/prototype/prototype.go`
- [Singleton](https://github.com/rifannurmuhammad/design-pattern/blob/main/creational_pattern/singleton/singleton.go): `creational_pattern/singleton/singleton.go`

### Structural patterns

- [Currency adapter](https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/adapter/adapter.go): `structural_pattern/adapter/adapter.go`
- [Device bridge](https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/bridge/bridge.go): `structural_pattern/bridge/bridge.go`
- [OS implementations](https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/bridge/bridge_os.go): `structural_pattern/bridge/bridge_os.go`
- [Color implementations](https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/bridge/bridge_color.go): `structural_pattern/bridge/bridge_color.go`
- [Product composite](https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/composite/composite.go): `structural_pattern/composite/composite.go`
- [Coffee decorator](https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/decorator/decorator.go): `structural_pattern/decorator/decorator.go`
- [Facade](https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/facade/facade.go): `structural_pattern/facade/facade.go`
- [Logistics proxy](https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/proxy/proxy.go): `structural_pattern/proxy/proxy.go`
- [Logistics service](https://github.com/rifannurmuhammad/design-pattern/blob/main/structural_pattern/proxy/proxy.go): `structural_pattern/proxy/proxy.go`

### Behavioral patterns

- [Registration chain](https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/chain_of_responsibility/chain_of_responsibility.go): `behavioral_pattern/chain_of_responsibility/chain_of_responsibility.go`
- [Profile handler](https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/chain_of_responsibility/chain_of_responsibility.go): `behavioral_pattern/chain_of_responsibility/chain_of_responsibility.go`
- [Experience handler](https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/chain_of_responsibility/chain_of_responsibility.go): `behavioral_pattern/chain_of_responsibility/chain_of_responsibility.go`
- [Education handler](https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/chain_of_responsibility/chain_of_responsibility.go): `behavioral_pattern/chain_of_responsibility/chain_of_responsibility.go`
- [Trip strategy](https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/strategy/context.go): `behavioral_pattern/strategy/context.go`
- [Road strategy](https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/strategy/road.go): `behavioral_pattern/strategy/road.go`
- [Flight strategy](https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/strategy/flight.go): `behavioral_pattern/strategy/flight.go`
- [Command](https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/command/command.go): `behavioral_pattern/command/command.go`
- [State pattern](https://github.com/rifannurmuhammad/design-pattern/tree/main/behavioral_pattern/state): `behavioral_pattern/state`
- [Visitor](https://github.com/rifannurmuhammad/design-pattern/blob/main/behavioral_pattern/visitor/interface.go): `behavioral_pattern/visitor/interface.go`

### Option pattern

- [Car options](https://github.com/rifannurmuhammad/design-pattern/blob/main/option_pattern/main.go): `option_pattern/main.go`

### Other components

- **Go caller**

## Connections

- Go caller → Example main: runs
- Example main → Factory method: calls
- Example main → Workspace builder: calls
- Factory method → Food products: creates
- Abstract factory → Xiaomi factory
- Xiaomi factory → Xiaomi products: creates
- Device bridge → OS implementations: installs
- Device bridge → Color implementations: uses
- Logistics proxy → Logistics service: delegates
- Registration chain → Profile handler: starts
- Profile handler → Experience handler: dispatches
- Experience handler → Education handler: dispatches
- Trip strategy → Road strategy: selects
- Trip strategy → Flight strategy: selects
