# hackershackofficial/smart-bartender architecture

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

- Interactive diagram: https://gitdiagram.com/hackershackofficial/smart-bartender
- Repository: https://github.com/hackershackofficial/smart-bartender

## Overview

##### Main Components
- Hardware Layer:
- Raspberry Pi 3: Acts as the central controller.
- OLED Display and optional keyboard/screen (or VNC connection).
- Electronic pumps (up to 6, configurable) connected via GPIO pins.
- Relay circuitry controlling the pumps.
- Software/Application Layer:
- bartender.py: The main entry point that orchestrates the operation.
- drinks.py: Holds the drink recipes and filtering logic based on pump configuration.
- menu.py: Manages the OLED menu interface and user interactions.
- pump_config.json: Contains pump setup details (name, GPIO pin, assigned beverage).

##### Relationships and Interactions
- Startup/Initialization:
- The system starts by executing bartender.py.
- bartender.py loads the pump configuration from pump_config.json.
- It then imports drink options from drinks.py and setups the interactive menu (menu.py).
- User Interaction Flow:
- A user selects a drink from the OLED menu on the Raspberry Pi.
- The menu logic (menu.py) matches the drink selection with available recipes (from drinks.py) and present pump options.
- Once a drink is selected, bartender.py activates the relays (based on information from pump_config.json) that control the pumps.
- Maintenance and Cleaning:
- The menu provides a cleaning option that activates all pumps for flushing.

##### Architectural Patterns and Design Principles
- Modular Design: The system is split into clear modules (main controller, drink recipes, user interface, configuration) which makes it easy to update or expand functionality.
- Separation of Concerns: Each file has a distinct responsibility (logic, UI, configuration) which enhances maintainability.
- Configuration-Driven: The pump behavior is data-driven via pump_config.json, allowing simple updates without code modifications.
- Hardware-Software Interaction: Clear mapping from software commands (in Python) to hardware outputs (GPIO operations controlling the pumps).

##### Relevant Technologies and Frameworks
- Python 2.7 is used, along with pip for dependency management.
- Raspberry Pi’s native GPIO libraries (or similar) for hardware communication.
- The OLED and I2C/SPI libraries/drivers required for the screen’s operation.
- VNC for remote desktop access, as suggested in the README.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Raspberry Pi"
        subgraph "Software/Application Layer"
            MC["Main Controller (bartender.py)"] 
            DR["Drink Recipes (drinks.py)"]
            UI["Menu/User Interface (menu.py)"]
            PC["Pump Configuration (pump_config.json)"]
        end
        subgraph "Hardware Actuation Layer"
            PRC["Pump Relay Circuitry"]
            OLED["OLED Display"]
            Pumps["Pumps"]
        end
    end

    %% Software Connections
    MC -->|"loads"| PC
    MC -->|"imports"| DR
    MC -->|"initializes"| UI
    UI -->|"selects_drink"| DR

    %% Hardware Connections
    MC -->|"controls"| PRC
    MC -->|"updates_display"| OLED
    PRC -->|"activates"| Pumps

    %% Click Events
    click MC "https://github.com/hackershackofficial/smart-bartender/blob/master//bartender.py"
    click DR "https://github.com/hackershackofficial/smart-bartender/blob/master//drinks.py"
    click UI "https://github.com/hackershackofficial/smart-bartender/blob/master//menu.py"
    click PC "https://github.com/hackershackofficial/smart-bartender/blob/master//pump_config.json"

    %% Styles
    classDef software fill:#c2f0c2,stroke:#333,stroke-width:2px;
    classDef hardware fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef config fill:#ffeb99,stroke:#333,stroke-width:2px;

    class MC,DR,UI software;
    class PC config;
    class PRC,OLED,Pumps hardware;
```
