# river0077/guesspincode architecture

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

- Interactive diagram: https://gitdiagram.com/river0077/guesspincode
- Repository: https://github.com/river0077/guesspincode

## Overview

##### Project Type and Purpose
- This is a small desktop application built with Java Swing following an MVC-inspired structure.
- Purpose: A “Guess the 4-digit PIN” game with visual feedback (green/yellow/red) on each guess.

##### File Structure
- Top-level: Main.java (application entry point)
- src/controller: GameController.java (handles user events & coordinates between view and logic)
- src/view:
- GamePanel.java (the main Swing panel composing buttons, labels, feedback)

##### Key Architectural Elements from README
- GUI layer built in Swing (no web/API layers).
- Separation of concerns:
- View renders UI, fires events
- Controller listens & routes events
- Logic encapsulates game rules
- No external services or databases.

##### Main Components
a. View Layer
- Components: GamePanel, CustomButton
b. Controller Layer
- Component: GameController
c. Logic Layer
- Component: GameLogic
d. Application Entry
- Component: Main
- Role: Initialize Swing frame, instantiate GameController & GamePanel, wire everything

##### Interactions & Data Flows
→ Event propagates to GameController
→ Controller calls GameLogic.checkGuess(…)
→ Logic returns an array of statuses (GREEN/YELLOW/RED)
- Restart/Exit flow similarly handled by Controller.

##### Architectural Patterns & Design Principles
- MVC-inspired layering: clear separation between View, Controller, Logic
- Single Responsibility: each class has one well-defined role
- Event-driven flow: UI events trigger business logic without direct coupling

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::external
    subgraph "Entry Point"
        Main["Main (Application Entry)"]:::entry
    end
    subgraph "View Layer"
        GamePanel["GamePanel"]:::view
        CustomButton["CustomButton"]:::view
    end
    subgraph "Controller Layer"
        GameController["GameController"]:::controller
    end
    subgraph "Logic Layer"
        GameLogic["GameLogic"]:::logic
    end

    User -->|"clicks UI"| GamePanel
    Main -->|"init"| GameController
    Main -->|"init"| GamePanel
    GamePanel -->|"handleButtonClick()"| GameController
    GameController -->|"checkGuess() / generatePin()"| GameLogic
    GameLogic -->|"result array"| GameController
    GameController -->|"updateView()"| GamePanel

    click Main "https://github.com/river0077/guesspincode/blob/main/src/Main.java"
    click GameController "https://github.com/river0077/guesspincode/blob/main/src/controller/GameController.java"
    click GameLogic "https://github.com/river0077/guesspincode/blob/main/src/logic/GameLogic.java"
    click GamePanel "https://github.com/river0077/guesspincode/blob/main/src/view/GamePanel.java"
    click CustomButton "https://github.com/river0077/guesspincode/blob/main/src/view/CustomButton.java"

    classDef view fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef controller fill:#90EE90,stroke:#000,stroke-width:1px
    classDef logic fill:#FFFFE0,stroke:#000,stroke-width:1px
    classDef entry fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef external fill:#F5F5F5,stroke:#000,stroke-width:1px
```
