# jonaustin/vpet architecture

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

- Interactive diagram: https://gitdiagram.com/jonaustin/vpet
- Repository: https://github.com/jonaustin/vpet

## Overview

##### Main Components
- Command-Line Interface (CLI) Module – Represented by main.go. This is where the interactive mode is started as well as non-interactive stat updates.
- Stat and Lifecycle Management Module – This internal module (within main.go) handles lifecycle phases (Baby, Child, Adult), stat management (health, hunger, energy, happiness, age), and the application of decay rates or care effects.
- Persistence Layer – Although implemented simply, the pet’s state is saved to a configuration file (~/.config/vpet/pet.json). Represent this as a separate component responsible for reading/writing pet state data.
- Tmux Integration – Represented by the “vpet.tmux” file and the “scripts/pet_status.sh.” This component is responsible for interfacing with tmux to display the pet’s current status (happy, hungry, tired, etc.).

##### Relationships and Interactions
- The CLI Component accepts user input (navigating menus, selecting actions such as Feed, Medicine, Play, Discipline, Sleep) which then triggers changes in the pet’s stats.
- The Stat and Lifecycle Management Module calculates these stat changes and the passage of time (simulating aging, health decay, etc.). It also triggers events like sickness or death based on stat thresholds.
- The Persistence Layer is used to save the pet’s state so the pet continues aging even when the program isn’t actively running. This ensures that changes in the pet’s life cycle are permanent.
- The Tmux Integration component pulls the latest pet status (by running the provided script and using the tmux file integration) to visually represent the pet's state in the terminal.
- Testing routines (managed in main_test.go) validate the core logic behind stat management and interaction handling.

##### Architectural Patterns and Design Principles
- Single Responsibility – Each module (user interaction, pet state management, system integration, persistence) performs a clearly defined role.

##### Relevant Technologies, Frameworks, or Libraries
- Go (the programming language) – This is the main language used.
- Tmux – For integrating and displaying the pet’s status in the terminal.
- Shell Scripting – As seen in the "scripts/pet_status.sh," which may be used to interface with or supplement the Go application in the tmux environment.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "User Interface"
        CLI("CLI Module (Interactive Mode)"):::core
    end

    subgraph "Core Logic"
        Stat("Stat & Lifecycle Manager"):::core
    end

    subgraph "Persistence"
        Persist("Pet State Persistence (pet.json)"):::persistence
    end

    subgraph "External Integration"
        Tmux1("Tmux Config (vpet.tmux)"):::integration
        Tmux2("Pet Status Script (pet_status.sh)"):::integration
    end

    subgraph "Testing"
        Test("Testing Suite (main_test.go)"):::testing
    end

    CLI -->|"UserAction"| Stat
    Stat -->|"PersistState"| Persist
    Stat -->|"UpdateDisplay"| Tmux1
    Stat -->|"RunScript"| Tmux2
    Test -->|"VerifyLogic"| Stat

    click CLI "https://github.com/jonaustin/vpet/blob/main/main.go"
    click Stat "https://github.com/jonaustin/vpet/blob/main/main.go"
    click Persist "https://github.com/jonaustin/vpet/blob/main/main.go"
    click Tmux1 "https://github.com/jonaustin/vpet/blob/main/vpet.tmux"
    click Tmux2 "https://github.com/jonaustin/vpet/blob/main/scripts/pet_status.sh"
    click Test "https://github.com/jonaustin/vpet/blob/main/main_test.go"

    classDef core fill:#cce5ff,stroke:#003366,stroke-width:2px;
    classDef persistence fill:#ffddcc,stroke:#cc6600,stroke-width:2px;
    classDef integration fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef testing fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
