# joostory/boardgame architecture

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

- Interactive diagram: https://gitdiagram.com/joostory/boardgame
- Repository: https://github.com/joostory/boardgame

## Overview

##### High-Level Architecture Components

The system should be represented with these main components:

a. Frontend Layer (Client-Side)
- Next.js Application
- React Components
- State Management (Recoil - evident from atom directory)
- UI Components Library

b. API Layer (Server-Side)
- Next.js API Routes
- Game Logic Handlers
- Data Storage

##### Detailed Component Breakdown

a. Core Game Modules:
- Memory Game Module
- Modoo (Monopoly) Game Module

b. State Management:
- Recoil Atoms (memory-atom.ts, modoo-atom.ts)
- Local Storage Integration (modoo-storage.ts)

c. Data Layer:
- JSON Data Sources (building.json, command.json, land.json)
- Domain Models (memory.ts, modoo.ts)

##### Interaction Flows

Key interactions:

a. Game Flow:
- Start Game → Player Management → Asset Management
- Command Processing → State Updates → UI Updates

b. Data Flow:
- Client State ↔ Local Storage
- API Routes ↔ Game Logic
- UI Components ↔ State Management

Use these visual elements:

- Rectangles: UI Components
- Hexagons: API Endpoints
- Rounded Rectangles: Game Logic Modules

- Blue: Frontend Components
- Green: API Layer
- Yellow: State Management
- Gray: Data Storage
- Purple: Shared Utilities

**┌─ UI Layer ─────────────────────┐**
- Components (Memory & Modoo)    │
- UI Elements & Forms            │
- State Management ─────────────┤
- Recoil Atoms                   │
- Local Storage                  │
- Business Logic ──────────────┤
- Game Rules & Calculations     │
- API Layer ──────────────────┤
- Next.js API Routes           │
- Data Layer ─────────────────┘

##### Key Relationships to Highlight

- Component Hierarchy:
- SubPageLayout → Game Components
- Game Components → Shared Components
- UI Components → State Management

- Data Flow:
- API Routes → Game Logic → State
- User Actions → Commands → State Updates

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Layer"
        UI[UI Components]
        MC[Memory Components]:::frontend
        MDC[Modoo Components]:::frontend
        SL[SubPageLayout]:::frontend
        GF[Game Flow Components]:::frontend
    end

    subgraph "State Management"
        MA[Memory Atom]:::state
        MDA[Modoo Atom]:::state
        LS[Local Storage]:::state
    end

    subgraph "Business Logic"
        MM[Memory Module]:::logic
        MDM[Modoo Module]:::logic
        Utils[Utility Functions]:::logic
    end

    subgraph "API Layer"
        BA["Building API"]:::api
        CA["Command API"]:::api
        LA["Land API"]:::api
    end

    subgraph "Data Layer"
        BD[(Building Data)]:::data
        CD[(Command Data)]:::data
        LD[(Land Data)]:::data
        MD[(Memory Domain)]:::data
        MDD[(Modoo Domain)]:::data
    end

    %% Relationships
    UI --> SL
    SL --> MC
    SL --> MDC
    MDC --> GF
    
    MC --> MA
    MDC --> MDA
    MDA --> LS
    
    MM --> MD
    MDM --> MDD
    
    BA --> BD
    CA --> CD
    LA --> LD
    
    GF --> BA
    GF --> CA
    GF --> LA
    
    Utils --> MM
    Utils --> MDM

    %% Click Events
    click MC "https://github.com/joostory/boardgame/tree/main//src/components/memory"
    click MDC "https://github.com/joostory/boardgame/tree/main//src/components/modoo"
    click SL "https://github.com/joostory/boardgame/blob/main//src/components/layout/SubPageLayout.tsx"
    click GF "https://github.com/joostory/boardgame/blob/main//src/components/modoo/game/Game.tsx"
    click MA "https://github.com/joostory/boardgame/blob/main//src/atom/memory-atom.ts"
    click MDA "https://github.com/joostory/boardgame/blob/main//src/atom/modoo-atom.ts"
    click LS "https://github.com/joostory/boardgame/blob/main//src/storage/modoo-storage.ts"
    click MM "https://github.com/joostory/boardgame/blob/main//src/domain/memory.ts"
    click MDM "https://github.com/joostory/boardgame/blob/main//src/domain/modoo.ts"
    click Utils "https://github.com/joostory/boardgame/blob/main//src/lib/utils.ts"
    click BA "https://github.com/joostory/boardgame/blob/main//src/app/modoo/api/building/route.ts"
    click CA "https://github.com/joostory/boardgame/blob/main//src/app/modoo/api/command/route.ts"
    click LA "https://github.com/joostory/boardgame/blob/main//src/app/modoo/api/land/route.ts"
    click BD "https://github.com/joostory/boardgame/blob/main//src/data/modoo/building.json"
    click CD "https://github.com/joostory/boardgame/blob/main//src/data/modoo/command.json"
    click LD "https://github.com/joostory/boardgame/blob/main//src/data/modoo/land.json"
    click MD "https://github.com/joostory/boardgame/blob/main//src/domain/memory.ts"
    click MDD "https://github.com/joostory/boardgame/blob/main//src/domain/modoo.ts"

    %% Styling
    classDef frontend fill:#4299e1,color:#fff
    classDef state fill:#ecc94b,color:#000
    classDef logic fill:#805ad5,color:#fff
    classDef api fill:#48bb78,color:#fff
    classDef data fill:#a0aec0,color:#fff

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        S[State]:::state
        L[Logic]:::logic
        A[API]:::api
        D[Data]:::data
    end
```
