# xriku/react-queens-blood architecture

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

- Interactive diagram: https://gitdiagram.com/xriku/react-queens-blood
- Repository: https://github.com/xriku/react-queens-blood

## Overview

##### Client-Side Architecture
- React Components Layer (showing key components like Board, Card, Hand)
- State Management Layer (Zustand stores)
- Socket Client Layer
- Assets Management (sounds)

##### Server-Side Architecture
- Socket.io Server
- Game Logic Handler
- Room Management System

##### Communication Layer
- Socket.io WebSocket connection between client and server
- Real-time event flow for game actions

**┌─────────────────────────────────────────────┐**
- Client (React Application)                  │
- ┌─────────────┐ ┌─────────────┐            │
- UI Layer  │ │State Layer  │            │
- (Zustand)  │            │
- ┘ └─────────────┘            │
- ┌─────────────┐ ┌─────────────┐            │
- Socket Client│ │   Assets    │            │

- ┘ └─────────────┘            │
- ┘
- ↕ WebSocket Connection
**┌─────────────────────────────────────────────┐**
- Server (Socket.io)                          │
- ┌─────────────┐ ┌─────────────┐            │
- Room Manager │ │ Game Logic  │            │

- ┘ └─────────────┘            │
- ┘

##### Client-Side Components
- Relationship between pages (Home, CreateGame, WaitingRoom, Game)
- How components interact with stores
- Sound asset management system

##### State Management
- Detail all Zustand stores (BoardStore, CardStore, GameStore, etc.)
- Their relationships and data flow

##### Socket Communication
- Real-time event flow
- Room management system
- Game state synchronization

##### Game Logic
- Card placement system
- Turn management
- Scoring system

Additional Recommendations:

- Data flow between components
- Socket event communication
- State updates

- Game state machine
- Card placement logic
- Score calculation system

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        subgraph UI
            RC[React Components]
            BC[Board Component]
            CC[Card Component]
            HC[Hand Component]
            MC[Modal System]
            LC[Layout System]
        end

        subgraph Pages
            HP[Home Page]
            CGP[Create Game Page]
            WRP[Waiting Room Page]
            GP[Game Page]
        end

        subgraph State
            BS[Board Store]
            CS[Card Store]
            GS[Game Store]
            TS[Turn Store]
            PS[Points Store]
        end

        subgraph Assets
            SFX[Sound Effects]
        end

        subgraph Utils
            DM[Deck Management]
            MT[Matrix Transformations]
        end

        SC[Socket Client]
    end

    subgraph Server
        SS[Socket.io Server]
        RM[Room Manager]
        GL[Game Logic]
    end

    %% Relationships
    RC --> BC & CC & HC
    BC & CC & HC --> State
    Pages --> State
    State --> SC
    SC <--> SS
    SS --> RM & GL
    Utils --> State

    %% Click Events
    click RC "https://github.com/xRiku/react-queens-blood/tree/main/src/components"
    click BC "https://github.com/xRiku/react-queens-blood/blob/main/src/components/Board.tsx"
    click CC "https://github.com/xRiku/react-queens-blood/blob/main/src/components/Card.tsx"
    click HC "https://github.com/xRiku/react-queens-blood/blob/main/src/components/Hand.tsx"
    click MC "https://github.com/xRiku/react-queens-blood/tree/main/src/components/Modals"
    click LC "https://github.com/xRiku/react-queens-blood/blob/main/src/layout/DefaultLayout.tsx"
    
    click HP "https://github.com/xRiku/react-queens-blood/blob/main/src/pages/Home/index.tsx"
    click CGP "https://github.com/xRiku/react-queens-blood/blob/main/src/pages/CreateGame/index.tsx"
    click WRP "https://github.com/xRiku/react-queens-blood/blob/main/src/pages/WaitingRoom/index.tsx"
    click GP "https://github.com/xRiku/react-queens-blood/blob/main/src/pages/Game/index.tsx"
    
    click BS "https://github.com/xRiku/react-queens-blood/blob/main/src/store/BoardStore.ts"
    click CS "https://github.com/xRiku/react-queens-blood/blob/main/src/store/CardStore.ts"
    click GS "https://github.com/xRiku/react-queens-blood/blob/main/src/store/GameStore.ts"
    click TS "https://github.com/xRiku/react-queens-blood/blob/main/src/store/TurnStore.ts"
    click PS "https://github.com/xRiku/react-queens-blood/blob/main/src/store/PointsStore.ts"
    
    click SFX "https://github.com/xRiku/react-queens-blood/tree/main/src/assets/sounds"
    click DM "https://github.com/xRiku/react-queens-blood/blob/main/src/utils/deck.ts"
    click MT "https://github.com/xRiku/react-queens-blood/blob/main/src/utils/transformMatrix.ts"
    click SC "https://github.com/xRiku/react-queens-blood/blob/main/src/socket.ts"
    click SS "https://github.com/xRiku/react-queens-blood/blob/main/server/index.ts"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef state fill:#f1c40f,stroke:#f39c12,color:black
    classDef server fill:#2ecc71,stroke:#27ae60,color:white
    classDef assets fill:#9b59b6,stroke:#8e44ad,color:white
    classDef utils fill:#e67e22,stroke:#d35400,color:white
    
    class RC,BC,CC,HC,MC,LC,HP,CGP,WRP,GP frontend
    class BS,CS,GS,TS,PS state
    class SS,RM,GL server
    class SFX assets
    class DM,MT utils
```
