# sebas-man/vipervision architecture

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

- Interactive diagram: https://gitdiagram.com/sebas-man/vipervision
- Repository: https://github.com/sebas-man/vipervision

## Overview

##### Project Type and Purpose
- This is a single‐application, full‐featured desktop game (SnakeAI) written in Java, using the Processing 4 library for rendering and input.
- Its primary goal is to implement and train an AI agent to play Snake, but in its current form it offers the classic human‐vs‐computer or human‐only gameplay loop with state management (menu, paused, playing, game over).

##### File Structure
- Top level:
- README.md & .gitignore – project metadata and exclusions
- resources/ – static assets (fonts, images)
- src/ – Java source code
- src/Elements/ – domain entities and UI widgets:
- Snake.java, Apple.java – game entities
- Button.java, ButtonAction.java – interactive menu elements
- src/Vo/ – “value object” or state model:
- GameState.java – enum or class managing current game phase (MENU, PLAYING, PAUSED, GAME_OVER)
- src/SnakeGame.java – the entry point and main game loop, ties everything together.

##### README for Additional Insights
- Confirms use of Processing 4 for rendering and input handling.
- Describes future AI/ML extensions: AI Agent, Decision Making, Reinforcement Learning.
- Mentions game mechanics (grid‐based movement, collision detection, input buffering, score tracking).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        PROC["Processing Engine"]:::external
        SNK["SnakeGame"]:::core
    end

    %% Core Game Engine & State & Resources
    subgraph "Core Game & State"
        CORE["Core Game Engine / Main Loop"]:::core
        GS["GameState"]:::core
        RL["Resource Loader"]:::core
    end

    %% Domain Entities
    subgraph "Domain Entities"
        SNAKE["Snake"]:::domain
        APPLE["Apple"]:::domain
    end

    %% UI Components
    subgraph "UI Components"
        BTN["Button"]:::ui
        BA["ButtonAction"]:::ui
    end

    %% Static Resources
    subgraph "Resources"
        FONTS["Fonts"]:::data
        IMAGES["Images"]:::data
    end

    %% External Libraries & Metadata
    LIB["Processing Core Library"]:::external
    MD["README.md"]:::external
    GI[".gitignore"]:::external

    %% Future AI Module
    subgraph "Future AI Module"
        AI["AI Agent"]:::future
        DM["Decision Maker"]:::future
    end

    %% Relationships
    PROC -->|"setup/draw/keyPressed"| SNK
    PROC -->|"uses"| RL
    SNK -->|"dispatch update/render"| CORE
    SNK -->|"handles input"| BTN
    SNK -->|"handles actions"| BA
    CORE -->|"manages"| SNAKE
    CORE -->|"manages"| APPLE
    CORE -->|"queries"| GS
    CORE -->|"loads assets via"| RL
    RL -->|"loads"| FONTS
    RL -->|"loads"| IMAGES
    LIB -->|"provides API to"| PROC
    LIB -->|"provides API to"| SNK
    AI -->|"controls via setDirection"| CORE
    DM -->|"drives"| AI
    MD --- GI

    %% Click Events
    click SNK "https://github.com/sebas-man/vipervision/blob/main/src/SnakeGame.java"
    click CORE "https://github.com/sebas-man/vipervision/blob/main/src/SnakeGame.java"
    click SNAKE "https://github.com/sebas-man/vipervision/blob/main/src/Elements/Snake.java"
    click APPLE "https://github.com/sebas-man/vipervision/blob/main/src/Elements/Apple.java"
    click BTN "https://github.com/sebas-man/vipervision/blob/main/src/Elements/Button.java"
    click BA "https://github.com/sebas-man/vipervision/blob/main/src/Elements/ButtonAction.java"
    click GS "https://github.com/sebas-man/vipervision/blob/main/src/Vo/GameState.java"
    click FONTS "https://github.com/sebas-man/vipervision/tree/main/resources/fonts/"
    click IMAGES "https://github.com/sebas-man/vipervision/tree/main/resources/images/"
    click MD "https://github.com/sebas-man/vipervision/blob/main/README.md"
    click GI "https://github.com/sebas-man/vipervision/blob/main/.gitignore"

    %% Styles
    classDef core fill:#cfe2f3,stroke:#0b5394,stroke-width:2px;
    classDef domain fill:#d9ead3,stroke:#38761d,stroke-width:2px;
    classDef ui fill:#fff2cc,stroke:#b45f06,stroke-width:2px;
    classDef data fill:#fce5cd,stroke:#ca5010,stroke-width:2px;
    classDef external fill:#e0e0e0,stroke:#666666,stroke-width:2px,stroke-dasharray: 5 5;
    classDef future fill:#f4cccc,stroke:#cc0000,stroke-width:2px;
```
