# alainmnts/adapter-pattern architecture

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

- Interactive diagram: https://gitdiagram.com/alainmnts/adapter-pattern
- Repository: https://github.com/alainmnts/adapter-pattern

## Overview

This is a small Java Adapter-pattern demonstration: `Main` creates three device/adapter pairs, then invokes each through the `PowerOutlet` interface. Each adapter translates `plugIn()` into its adaptee’s device-specific operation, which prints a status message. Although the README describes compatibility and safety concerns, the sampled implementation does not model voltage or amperage checks.

Main entry points: [`src/Main.java`](https://github.com/alainmnts/adapter-pattern/blob/main/src/Main.java) (Application entry), [`src/PowerOutlet.java`](https://github.com/alainmnts/adapter-pattern/blob/main/src/PowerOutlet.java) (PowerOutlet), [`src/LaptopAdapter.java`](https://github.com/alainmnts/adapter-pattern/blob/main/src/LaptopAdapter.java) (LaptopAdapter), [`src/Laptop.java`](https://github.com/alainmnts/adapter-pattern/blob/main/src/Laptop.java) (Laptop)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_user(("User"))
node_main["Application entry<br/>[Main.java]"]
node_outlet["PowerOutlet<br/>[PowerOutlet.java]"]
node_laptop_adapter["LaptopAdapter<br/>[LaptopAdapter.java]"]
node_laptop["Laptop<br/>[Laptop.java]"]
node_fridge_adapter["RefrigeratorAdapter"]
node_fridge["Refrigerator<br/>[Refrigerator.java]"]
node_phone_adapter["SmartphoneAdapter"]
node_charger["SmartphoneCharger"]
node_console["Console output"]

node_user -->|"runs"| node_main
node_main -->|"constructs"| node_laptop_adapter
node_main -->|"constructs"| node_laptop
node_main -->|"constructs"| node_fridge_adapter
node_main -->|"constructs"| node_fridge
node_main -->|"constructs"| node_phone_adapter
node_main -->|"constructs"| node_charger
node_main -->|"invokes plugIn"| node_outlet
node_outlet -->|"dispatches"| node_laptop_adapter
node_outlet -->|"dispatches"| node_fridge_adapter
node_outlet -->|"dispatches"| node_phone_adapter
node_laptop_adapter -->|"calls charge"| node_laptop
node_fridge_adapter -->|"calls startCooling"| node_fridge
node_phone_adapter -->|"calls chargePhone"| node_charger
node_laptop -->|"prints status"| node_console
node_fridge -->|"prints status"| node_console
node_charger -->|"prints status"| node_console

click node_main "https://github.com/alainmnts/adapter-pattern/blob/main/src/Main.java"
click node_outlet "https://github.com/alainmnts/adapter-pattern/blob/main/src/PowerOutlet.java"
click node_laptop_adapter "https://github.com/alainmnts/adapter-pattern/blob/main/src/LaptopAdapter.java"
click node_laptop "https://github.com/alainmnts/adapter-pattern/blob/main/src/Laptop.java"
click node_fridge_adapter "https://github.com/alainmnts/adapter-pattern/blob/main/src/RefrigeratorAdapter.java"
click node_fridge "https://github.com/alainmnts/adapter-pattern/blob/main/src/Refrigerator.java"
click node_phone_adapter "https://github.com/alainmnts/adapter-pattern/blob/main/src/SmartphoneAdapter.java"
click node_charger "https://github.com/alainmnts/adapter-pattern/blob/main/src/SmartphoneCharger.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_user toneBlue
class node_main,node_outlet,node_laptop_adapter,node_laptop,node_fridge_adapter,node_fridge,node_phone_adapter,node_charger toneTeal
class node_console toneIndigo
```

## Components

### Other components

- **User**
- [Application entry](https://github.com/alainmnts/adapter-pattern/blob/main/src/Main.java): `src/Main.java`
- [PowerOutlet](https://github.com/alainmnts/adapter-pattern/blob/main/src/PowerOutlet.java): `src/PowerOutlet.java`
- [LaptopAdapter](https://github.com/alainmnts/adapter-pattern/blob/main/src/LaptopAdapter.java): `src/LaptopAdapter.java`
- [Laptop](https://github.com/alainmnts/adapter-pattern/blob/main/src/Laptop.java): `src/Laptop.java`
- [RefrigeratorAdapter](https://github.com/alainmnts/adapter-pattern/blob/main/src/RefrigeratorAdapter.java): `src/RefrigeratorAdapter.java`
- [Refrigerator](https://github.com/alainmnts/adapter-pattern/blob/main/src/Refrigerator.java): `src/Refrigerator.java`
- [SmartphoneAdapter](https://github.com/alainmnts/adapter-pattern/blob/main/src/SmartphoneAdapter.java): `src/SmartphoneAdapter.java`
- [SmartphoneCharger](https://github.com/alainmnts/adapter-pattern/blob/main/src/SmartphoneCharger.java): `src/SmartphoneCharger.java`
- **Console output**

## Connections

- User → Application entry: runs
- Application entry → LaptopAdapter: constructs
- Application entry → Laptop: constructs
- Application entry → RefrigeratorAdapter: constructs
- Application entry → Refrigerator: constructs
- Application entry → SmartphoneAdapter: constructs
- Application entry → SmartphoneCharger: constructs
- Application entry → PowerOutlet: invokes plugIn
- PowerOutlet → LaptopAdapter: dispatches
- PowerOutlet → RefrigeratorAdapter: dispatches
- PowerOutlet → SmartphoneAdapter: dispatches
- LaptopAdapter → Laptop: calls charge
- RefrigeratorAdapter → Refrigerator: calls startCooling
- SmartphoneAdapter → SmartphoneCharger: calls chargePhone
- Laptop → Console output: prints status
- Refrigerator → Console output: prints status
- SmartphoneCharger → Console output: prints status
