# aredthsanchez/command_design_pattern architecture

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

- Interactive diagram: https://gitdiagram.com/aredthsanchez/command_design_pattern
- Repository: https://github.com/aredthsanchez/command_design_pattern

## Overview

This is a small Java example of the Command pattern. Main creates a light receiver and on/off commands, assigns each command to a remote control, and presses its button. The remote control dispatches execution through the Command interface; each concrete command calls the corresponding LightSwitch operation. The excerpts show this runtime flow, but no broader product capabilities or persistent state.

Main entry points: [`Main.java`](https://github.com/aredthsanchez/command_design_pattern/blob/main/Main.java) (Main), [`RemoteControl.java`](https://github.com/aredthsanchez/command_design_pattern/blob/main/RemoteControl.java) (RemoteControl), [`TurnOn.java`](https://github.com/aredthsanchez/command_design_pattern/blob/main/TurnOn.java) (TurnOn), [`TurnOff.java`](https://github.com/aredthsanchez/command_design_pattern/blob/main/TurnOff.java) (TurnOff)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Control"]
  node_main["Main<br/>[Main.java]"]
  node_remote["RemoteControl<br/>[RemoteControl.java]"]
end

subgraph group_commands["Commands"]
  node_command["Command<br/>[Command.java]"]
  node_turn_on["TurnOn<br/>[TurnOn.java]"]
  node_turn_off["TurnOff<br/>[TurnOff.java]"]
end

subgraph group_receiver["Light receiver"]
  node_light_switch["LightSwitch<br/>[LightSwitch.java]"]
end

node_main -->|"configures and presses"| node_remote
node_main -->|"creates"| node_turn_on
node_main -->|"creates"| node_turn_off
node_remote -->|"dispatches execute"| node_command
node_turn_on -->|"calls on"| node_light_switch
node_turn_off -->|"calls off"| node_light_switch

click node_main "https://github.com/aredthsanchez/command_design_pattern/blob/main/Main.java"
click node_remote "https://github.com/aredthsanchez/command_design_pattern/blob/main/RemoteControl.java"
click node_command "https://github.com/aredthsanchez/command_design_pattern/blob/main/Command.java"
click node_turn_on "https://github.com/aredthsanchez/command_design_pattern/blob/main/TurnOn.java"
click node_turn_off "https://github.com/aredthsanchez/command_design_pattern/blob/main/TurnOff.java"
click node_light_switch "https://github.com/aredthsanchez/command_design_pattern/blob/main/LightSwitch.java"

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_main,node_remote toneBlue
class node_command,node_turn_on,node_turn_off toneAmber
class node_light_switch toneMint
```

## Components

### Control

- [Main](https://github.com/aredthsanchez/command_design_pattern/blob/main/Main.java): `Main.java`
- [RemoteControl](https://github.com/aredthsanchez/command_design_pattern/blob/main/RemoteControl.java): `RemoteControl.java`

### Commands

- [Command](https://github.com/aredthsanchez/command_design_pattern/blob/main/Command.java): `Command.java`
- [TurnOn](https://github.com/aredthsanchez/command_design_pattern/blob/main/TurnOn.java): `TurnOn.java`
- [TurnOff](https://github.com/aredthsanchez/command_design_pattern/blob/main/TurnOff.java): `TurnOff.java`

### Light receiver

- [LightSwitch](https://github.com/aredthsanchez/command_design_pattern/blob/main/LightSwitch.java): `LightSwitch.java`

## Connections

- Main → RemoteControl: configures and presses (evidence: `Main.java`)
- Main → TurnOn: creates (evidence: `Main.java`)
- Main → TurnOff: creates (evidence: `Main.java`)
- RemoteControl → Command: dispatches execute (evidence: `RemoteControl.java`)
- TurnOn → LightSwitch: calls on (evidence: `TurnOn.java`)
- TurnOff → LightSwitch: calls off (evidence: `TurnOff.java`)
