# hmaddocks/pohqer_ruby architecture

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

- Interactive diagram: https://gitdiagram.com/hmaddocks/pohqer_ruby
- Repository: https://github.com/hmaddocks/pohqer_ruby

## Overview

##### Main Components

a. Frontend Layer:
- Phlex View Components hierarchy
- ApplicationComponent as the root
- Specialized components (GameComponent, RoundComponent, etc.)
- JavaScript Controllers (using Stimulus.js based on the controllers directory)
- Assets (CSS/Tailwind, Images)

b. Backend Layer:
- Controllers (GamesController, RoundsController)
- Models Layer showing relationships:
- Game
- Player
- Round
- Vote
- Application Controller & Base Classes

c. Infrastructure Components:
- Database (PostgreSQL, indicated by database.yml)
- Action Cable (WebSocket, indicated by cable.yml)
- Cache Layer (indicated by cache.yml)
- Job Queue System (indicated by queue.yml)

**[Client Layer]**
- ↕
**[Application Layer]**
- ↕
**[Data Layer]**

##### Component Relationships

a. Client Layer (Top):
- How View Components interact with JavaScript controllers
- WebSocket connections for real-time features
- Asset pipeline flow

b. Application Layer (Middle):
- MVC pattern implementation
- Routing flow from routes.rb to controllers
- Component rendering pipeline
- Action Cable channels for real-time updates

c. Data Layer (Bottom):
- Model relationships
- Database interactions
- Caching mechanism
- Background job processing

##### Specific Elements

- PWA capabilities (indicated by pwa directory)
- Deployment flow (indicated by Kamal configuration)
- Testing infrastructure (RSpec)
- Background job processing
- Caching strategy
- Database migrations and schema

**[PWA Shell]**
- ↓
**[View Components] ←→ [JavaScript Controllers]**
- ↓
**[Controllers] ←→ [Action Cable]**
- ↓
**[Models] ←→ [Background Jobs]**
- ↓
**[Database/Cache/Queue]**

##### Additional Notes

- Annotations for key architectural decisions
- Scaling points and potential bottlenecks

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        PWA["PWA Shell"]
        SW["Service Worker"]:::pwa
        Manifest["PWA Manifest"]:::pwa
        
        subgraph ViewComponents["View Components"]
            AppComp["Application Component"]:::component
            GameComp["Game Component"]:::component
            RoundComp["Round Component"]:::component
            PlayerComp["Player Component"]:::component
            VoteComp["Voting Component"]:::component
        end
        
        subgraph JSControllers["JavaScript Controllers"]
            MainJS["Main Controller"]:::js
            ClipboardJS["Clipboard Controller"]:::js
            HelloJS["Hello Controller"]:::js
        end
        
        Assets["Assets (CSS/Tailwind)"]:::asset
    end
    
    subgraph Application["Application Layer"]
        subgraph Controllers["Controllers"]
            AppController["Application Controller"]:::controller
            GamesController["Games Controller"]:::controller
            RoundsController["Rounds Controller"]:::controller
        end
        
        ActionCable["Action Cable"]:::infra
        Cache["Cache Layer"]:::infra
        Queue["Job Queue"]:::infra
    end
    
    subgraph Data["Data Layer"]
        subgraph Models["Models"]
            Game["Game Model"]:::model
            Player["Player Model"]:::model
            Round["Round Model"]:::model
            Vote["Vote Model"]:::model
        end
        
        DB[(PostgreSQL)]:::db
        Migrations["Database Migrations"]:::db
    end
    
    %% Relationships
    PWA --> SW
    PWA --> Manifest
    PWA --> ViewComponents
    ViewComponents --> JSControllers
    ViewComponents --> Assets
    
    JSControllers --> ActionCable
    ViewComponents --> Controllers
    Controllers --> Models
    Models --> DB
    Models --> Migrations
    
    ActionCable --> Models
    Cache --> Models
    Queue --> Models
    
    %% Click Events
    click AppComp "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/views/components/application_component.rb"
    click GameComp "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/views/components/game_component.rb"
    click RoundComp "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/views/components/round_component.rb"
    click PlayerComp "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/views/components/player_card_component.rb"
    click VoteComp "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/views/components/voting_component.rb"
    
    click MainJS "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/javascript/controllers/application.js"
    click ClipboardJS "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/javascript/controllers/clipboard_controller.js"
    click HelloJS "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/javascript/controllers/hello_controller.js"
    
    click AppController "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/controllers/application_controller.rb"
    click GamesController "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/controllers/games_controller.rb"
    click RoundsController "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/controllers/rounds_controller.rb"
    
    click Game "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/models/game.rb"
    click Player "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/models/player.rb"
    click Round "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/models/round.rb"
    click Vote "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/models/vote.rb"
    
    click SW "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/views/pwa/service-worker.js"
    click Manifest "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/views/pwa/manifest.json.erb"
    click Assets "https://github.com/hmaddocks/pohqer_ruby/blob/main/app/assets/stylesheets/application.tailwind.css"
    click Migrations "https://github.com/hmaddocks/pohqer_ruby/tree/main/db/migrate"
    
    %% Styling
    classDef component fill:#3498db,stroke:#2980b9,color:white
    classDef js fill:#f1c40f,stroke:#f39c12,color:black
    classDef controller fill:#2ecc71,stroke:#27ae60,color:white
    classDef model fill:#e67e22,stroke:#d35400,color:white
    classDef db fill:#8e44ad,stroke:#6c3483,color:white
    classDef infra fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef asset fill:#1abc9c,stroke:#16a085,color:white
    classDef pwa fill:#e74c3c,stroke:#c0392b,color:white
```
