# deivao06/ranked-paper-scissor architecture

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

- Interactive diagram: https://gitdiagram.com/deivao06/ranked-paper-scissor
- Repository: https://github.com/deivao06/ranked-paper-scissor

## Overview

##### Main Components
- Backend (Laravel):
- Core Application: The Laravel framework handles routing, controllers, middleware, and services. The “app” folder contains subdirectories such as Http (for controllers and middleware), Models, Providers, Exceptions, and Game logic (in app/Game).
- Console Commands: Commands like RunWebsocketServer.php in app/Console/Commands indicate custom CLI commands.
- Configuration & Database: The config directory holds all configuration settings. The database folder includes migrations, seeders, and factories, representing your relational database structure.
- Frontend (VueJS):
- Assets and Build: The public and resources directories house your VueJS assets (JS, CSS, and view templates). The package.json and webpack.mix.js files coordinate asset compilation.
- Views: Blade templates in resources/views (including game, login, and others) serve as the frontend entry points where Vue components are likely integrated.
- Websocket Server:
- Dedicated Server: The app/Websocket directory includes the WebsocketHandler, and the README instructs to run “php artisan run:websocket” on port 5050. This component will manage real-time communications between players.

##### Relationships and Interactions
- The Frontend interacts with the Backend via standard HTTP routes (defined in routes/web.php, routes/api.php, etc.) for actions such as user login, registration, and game matchmaking.
- The Backend communicates with the Database using Laravel’s Eloquent ORM, as set up via migrations and models (app/Models, database/migrations).
- Controllers and Repositories (e.g., GameController, UserRepository) serve as the intermediary between HTTP requests and business logic implemented in classes like app/Game/Game.php.

##### Architectural Patterns and Design Principles
- MVC Pattern: The Laravel project follows the Model-View-Controller paradigm. Models, Views (Blade templates), and Controllers are clearly separated.
- Modularization: Clear separation of concerns exists through dedicated directories like “Game” for game logic, “Websocket” for handling real-time events, and “Console” for scheduled or invoked commands.
- Real-Time Communication: The integration of a Websocket server indicates a focus on live interactions and event-driven architecture.

##### Technologies and Frameworks
- Laravel (Backend Framework) with its built-in components for routing, middleware, and service providers.
- VueJS for building reactive frontend interfaces.
- Websocket server (custom Laravel command and handler) for low-latency, real-time data exchange.
- PHP (version 7.4.29 as noted) and NPM (for managing JS dependencies).
- Database (likely MySQL or another supported relational database) managed through Laravel migrations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        F1["VueJS Assets (resources/js/)"]:::frontend
        F2["Blade Templates (resources/views/)"]:::frontend
        F3["Compiled Assets (public/)"]:::frontend
    end

    subgraph "Backend Layer"
        R1["Routes: web.php"]:::backend
        R2["Routes: api.php"]:::backend
        M["Middleware (app/Http/Middleware/)"]:::backend
        C["Controllers (app/Http/Controllers/)"]:::backend
        MD["Models (app/Models/)"]:::backend
        subgraph "Game Logic"
            G1["Game.php"]:::backend
            G2["Room.php"]:::backend
        end
        CC["Console Command: RunWebsocketServer.php"]:::backend
        UR["UserRepository (app/Http/Repositories/UserRepository.php)"]:::backend
        CONF["Config (config/)"]:::backend
        DBS["Database Structure (database/)"]:::backend
        P["Providers (app/Providers/)"]:::backend
    end

    subgraph "Websocket Server"
        W1["WebsocketHandler (app/Websocket/WebsocketHandler.php)"]:::websocket
    end

    D["RDBMS (Database)"]:::database

    %% Internal Backend Flow
    R1 --> M
    M --> C
    R2 --> C
    C --> UR
    C --> G1
    G1 --> G2
    C --> MD
    CONF --> P

    %% Layered Interactions
    F1 -->|"HTTP_Request"| R1
    F2 -->|"Page_Request"| C
    F1 <-->|"RealTime"| W1
    G1 -->|"Game_Event"| W1
    CC -->|"Starts"| W1
    MD -->|"EloquentORM"| D
    C -->|"CRUD"| D

    %% Click Events
    click F1 "https://github.com/deivao06/ranked-paper-scissor/tree/master/resources/js/"
    click F2 "https://github.com/deivao06/ranked-paper-scissor/tree/master/resources/views/"
    click F3 "https://github.com/deivao06/ranked-paper-scissor/tree/master/public/"
    click R1 "https://github.com/deivao06/ranked-paper-scissor/blob/master/routes/web.php"
    click R2 "https://github.com/deivao06/ranked-paper-scissor/blob/master/routes/api.php"
    click M "https://github.com/deivao06/ranked-paper-scissor/tree/master/app/Http/Middleware/"
    click C "https://github.com/deivao06/ranked-paper-scissor/tree/master/app/Http/Controllers/"
    click MD "https://github.com/deivao06/ranked-paper-scissor/tree/master/app/Models/"
    click G1 "https://github.com/deivao06/ranked-paper-scissor/blob/master/app/Game/Game.php"
    click G2 "https://github.com/deivao06/ranked-paper-scissor/blob/master/app/Game/Room.php"
    click CC "https://github.com/deivao06/ranked-paper-scissor/blob/master/app/Console/Commands/RunWebsocketServer.php"
    click UR "https://github.com/deivao06/ranked-paper-scissor/blob/master/app/Http/Repositories/UserRepository.php"
    click CONF "https://github.com/deivao06/ranked-paper-scissor/tree/master/config/"
    click DBS "https://github.com/deivao06/ranked-paper-scissor/tree/master/database/"
    click P "https://github.com/deivao06/ranked-paper-scissor/tree/master/app/Providers/"
    click W1 "https://github.com/deivao06/ranked-paper-scissor/blob/master/app/Websocket/WebsocketHandler.php"

    %% Styles
    classDef frontend fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef backend fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef websocket fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef database fill:#ffffcc,stroke:#333,stroke-width:2px;
```
