# gustavoctrlplay/pypet architecture

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

- Interactive diagram: https://gitdiagram.com/gustavoctrlplay/pypet
- Repository: https://github.com/gustavoctrlplay/pypet

## Overview

PyPet is a terminal-driven virtual-pet simulator. Its loop loads or creates a pet, advances its needs, accepts care actions, checks whether it remains alive, and displays status; users can also save and reload pet state. Iguana and Cobra specialize play behavior, while status and play can display species-specific images through OpenCV. The only source file is sampled, so the relationships shown are directly supported by it.

Main entry points: [`pypet2.py`](https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py) (Menu loop), [`imagens`](https://github.com/gustavoctrlplay/pypet/tree/main/imagens) (Pet images)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Pet simulation"]
  node_loop["Menu loop<br/>[pypet2.py]"]
  node_pet["Pet lifecycle<br/>[pypet2.py]"]
  node_iguana["Iguana play<br/>[pypet2.py]"]
  node_cobra["Cobra play<br/>[pypet2.py]"]
end

subgraph group_persistence["Pet persistence"]
  node_save["Save pet<br/>[pypet2.py]"]
  node_load["Load pet<br/>[pypet2.py]"]
end

subgraph group_presentation["Status and imagery"]
  node_status["Status display<br/>[pypet2.py]"]
  node_images["Pet images"]
end

node_user(("Player"))

node_user -->|"chooses actions"| node_loop
node_loop -->|"loads pet"| node_load
node_loop -->|"advances and checks"| node_pet
node_loop -->|"creates or plays"| node_iguana
node_loop -->|"creates or plays"| node_cobra
node_loop -->|"saves pet"| node_save
node_loop -->|"shows status"| node_status
node_pet -->|"displays state"| node_status
node_iguana -->|"reads images"| node_images
node_cobra -->|"reads images"| node_images
node_status -->|"reads images"| node_images
node_save -->|"writes and reads pet.json"| node_load

click node_loop "https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py"
click node_pet "https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py"
click node_iguana "https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py"
click node_cobra "https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py"
click node_save "https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py"
click node_load "https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py"
click node_status "https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py"
click node_images "https://github.com/gustavoctrlplay/pypet/tree/main/imagens"

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_loop,node_pet,node_iguana,node_cobra toneBlue
class node_save,node_load toneAmber
class node_status,node_images toneMint
class node_user toneIndigo
```

## Components

### Pet simulation

- [Menu loop](https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py): `pypet2.py`
- [Pet lifecycle](https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py): `pypet2.py`
- [Iguana play](https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py): `pypet2.py`
- [Cobra play](https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py): `pypet2.py`

### Pet persistence

- [Save pet](https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py): `pypet2.py`
- [Load pet](https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py): `pypet2.py`

### Status and imagery

- [Status display](https://github.com/gustavoctrlplay/pypet/blob/main/pypet2.py): `pypet2.py`
- [Pet images](https://github.com/gustavoctrlplay/pypet/tree/main/imagens): `imagens`

### Other components

- **Player**

## Connections

- Player → Menu loop: chooses actions (evidence: `pypet2.py`)
- Menu loop → Load pet: loads pet (evidence: `pypet2.py`)
- Menu loop → Pet lifecycle: advances and checks (evidence: `pypet2.py`)
- Menu loop → Iguana play: creates or plays (evidence: `pypet2.py`)
- Menu loop → Cobra play: creates or plays (evidence: `pypet2.py`)
- Menu loop → Save pet: saves pet (evidence: `pypet2.py`)
- Menu loop → Status display: shows status (evidence: `pypet2.py`)
- Pet lifecycle → Status display: displays state (evidence: `pypet2.py`)
- Iguana play → Pet images: reads images (evidence: `pypet2.py`)
- Cobra play → Pet images: reads images (evidence: `pypet2.py`)
- Status display → Pet images: reads images (evidence: `pypet2.py`)
- Save pet → Load pet: writes and reads pet.json (evidence: `pypet2.py`)
