# amankr01/rock-paper-scissor-game architecture

> Architecture diagram of the GitHub repository amankr01/rock-paper-scissor-game, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amankr01/rock-paper-scissor-game
- Repository: https://github.com/amankr01/rock-paper-scissor-game

## Overview

##### Project type and purpose
- This is a single-page, frontend-only web game (“Rock Paper Scissors”) implemented purely in HTML, CSS, and JavaScript.
- There is no backend or database; all logic and state live in the browser.

##### File structure
- index.html: hosts the DOM skeleton (buttons, score display, result area).
- rps.js: contains the core game logic (event handlers, random computer choice, score tracking, DOM updates).
- README.md: explains features, tech stack, and usage.

##### README for additional insights
- Confirms the tech stack (HTML5, CSS3, JS).
- Describes gameplay flow and features (clean UI, randomized computer move, score tracking).
- No mention of external APIs or services.

a. Main components
- UI Layer (index.html + style.css)
- Game Logic Layer (rps.js)
- Browser Runtime (JavaScript engine + DOM API + Event Loop)
- Game State (in-memory JS objects for scores, selections)
b. Relationships & interactions
1. User clicks one of the three buttons in the UI.
2. Browser propagates a click event to rps.js’s event handler.
3. Game Logic determines the computer’s choice (random function).
4. Logic updates the in-memory game state (scores, last result).
5. Logic invokes DOM APIs to update the view (scoreboard, result text).
c. Architectural patterns / design principles
- MVC‐style separation (View=HTML/CSS, Controller=event handlers in rps.js, Model=JS objects holding scores and selections).
- Single responsibility per file: styling, markup, behavior are clearly partitioned.
d. Key technologies & libraries
- Native DOM API for rendering and event handling
- JavaScript’s Math.random() for computer choice
- CSS Flexbox/Grid (if used) for responsive layout

## Diagram (Mermaid)

```mermaid
flowchart TB
    User(["User"]):::external
    Runtime["Browser Runtime (JS Engine + DOM API + Event Loop)"]:::runtime

    subgraph "UI Layer"
        UI_HTML["UI: index.html"]:::presentation
        UI_CSS["Styling: style.css"]:::presentation
    end

    Controller["Game Logic: rps.js"]:::logic
    State["Game State (scores, selections)"]:::state
    Doc["Documentation: README.md"]:::doc

    User --> UI_HTML
    Runtime --> UI_HTML
    Runtime --> Controller
    Runtime --> State

    UI_CSS -.-> UI_HTML
    UI_HTML -->|"click event"| Controller
    Controller -->|"randomizes choice & compares"| State
    State -->|"provides state data"| Controller
    Controller -->|"updates DOM"| UI_HTML

    click UI_HTML "https://github.com/amankr01/rock-paper-scissor-game/blob/main/index.html"
    click UI_CSS "https://github.com/amankr01/rock-paper-scissor-game/blob/main/style.css"
    click Controller "https://github.com/amankr01/rock-paper-scissor-game/blob/main/rps.js"
    click Doc "https://github.com/amankr01/rock-paper-scissor-game/blob/main/README.md"

    classDef presentation fill:#ccffcc,stroke:#2d572c;
    classDef logic fill:#cce5ff,stroke:#2a5caa;
    classDef state fill:#fff5cc,stroke:#a67c00;
    classDef runtime fill:#f2f2f2,stroke:#666;
    classDef external fill:#e0e0e0,stroke:#333,stroke-dasharray:2 2;
    classDef doc fill:#f9e6ff,stroke:#a64ca6;
```
