# nahuelhds/cards-against-humanity-web architecture

> Architecture diagram of the GitHub repository nahuelhds/cards-against-humanity-web, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nahuelhds/cards-against-humanity-web
- Repository: https://github.com/nahuelhds/cards-against-humanity-web

## Overview

##### Project type and purpose
- This is a single-page web application built with Create React App that lets friends play Cards Against Humanity online.
- It combines a React-based UI with Boardgame.io’s client/server game engine to manage multiplayer state and turns.
- Tailwind CSS is used for styling; auxiliary services include local storage (“lobby” service) and Bugsnag for error monitoring.

##### File structure
- Top-level files:
- expose.js – likely a small Node.js entrypoint to expose the Boardgame.io server or serve the built app
- package.json, .env.example, configuration files for linting/prettier, CI, changelog
- public/ – static HTML, manifest, robots.txt
- src/
- App.js, index.js – React entry points
- assets/decks/… – JSON and text for black/white card decks (ES locale)
- components/ – React UI organized by feature:
— CardsAgainstHumanity/Board (game board views)
— GameAuthContainer, LobbyContainer, GameCreateComponent, etc. (lobby and game flow)
- services/ – wrappers around Bugsnag, localStorage (“storage.js”), and “lobby.js” for room management
- game.js, moves.js, constants.js – Boardgame.io game logic and rules
- styling: Tailwind config, PostCSS, CSS modules
- No separate “backend” folder implies the Boardgame.io server is either embedded in expose.js or runs as a remote service.

##### README for additional insights
- Confirms use of Boardgame.io, React, Tailwind CSS.
- No explicit multi-service architecture beyond client ↔ Boardgame.io server.

##### Essential elements
– User → Browser → React App
– React App ↔ Boardgame.io Client ↔ Boardgame.io Server
– Server → Game Logic → Server → Client
– React App → Services (storage, Bugsnag)
– Blue for UI components
– Green for game engine and logic
– Orange for services (storage, Bugsnag, lobby)
– Gray for static assets (decks)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client Side"
        direction TB
        Browser["Browser"]:::external

        subgraph "React App"
            direction TB
            Index["index.js"]:::ui
            AppJS["App.js"]:::ui
            BoardClient["Boardgame.io Client"]:::engine
        end

        subgraph "UI Components - Game Board"
            direction TB
            BoardContainer["BoardContainer"]:::ui
            BlackCardView["BlackCardView"]:::ui
            WhiteCards["WhiteCards"]:::ui
            MyHand["MyHand"]:::ui
            PositionsTable["PositionsTable"]:::ui
            Status["Status"]:::ui
            TurnOf["TurnOf"]:::ui
        end

        subgraph "UI Components - Lobby & Flow"
            direction TB
            LobbyContainer["LobbyContainer"]:::ui
            GameCreate["GameCreateComponent"]:::ui
            GameAvailable["GameAvailableComponent"]:::ui
            GameNotReady["GameNotReadyComponent"]:::ui
            GamesList["GamesListComponent"]:::ui
            Invitation["InvitationContainer"]:::ui
            GameAuth["GameAuthContainer"]:::ui
        end

        subgraph "Services"
            direction TB
            LobbyServ["Lobby Service"]:::service
            StorageServ["Storage Service"]:::service
            BugsnagServ["Bugsnag Service"]:::service
        end

        subgraph "Assets"
            direction TB
            Decks["Deck Assets"]:::asset
        end
    end

    %% Server Side
    subgraph "Server Side"
        direction TB
        Expose["expose.js"]:::engine

        subgraph "Game Logic"
            direction TB
            LogicGame["game.js"]:::engine
            Moves["moves.js"]:::engine
            Constants["constants.js"]:::engine
        end
    end

    %% Connections
    Browser -->|loads| Index
    Index -->|renders| AppJS
    AppJS -->|uses| BoardClient
    BoardClient --"WebSocket/HTTP"| Expose
    Expose --> LogicGame
    LogicGame --> Moves
    LogicGame --> Constants
    LogicGame --> Expose
    Expose --> BoardClient
    LogicGame -->|loads decks| Decks

    AppJS --> BoardContainer
    BoardContainer --> BlackCardView
    BoardContainer --> WhiteCards
    BoardContainer --> MyHand
    BoardContainer --> PositionsTable
    BoardContainer --> Status
    BoardContainer --> TurnOf

    AppJS --> LobbyContainer
    LobbyContainer --> GameAuth
    LobbyContainer --> GameCreate
    LobbyContainer --> GameAvailable
    LobbyContainer --> GameNotReady
    LobbyContainer --> GamesList
    LobbyContainer --> Invitation

    AppJS --> LobbyServ
    AppJS --> StorageServ
    AppJS --> BugsnagServ

    %% Click Events
    click Index "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/index.js"
    click AppJS "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/App.js"
    click BoardContainer "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/CardsAgainstHumanity/Board/BoardContainer.js"
    click BlackCardView "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/CardsAgainstHumanity/Board/BlackCardView.js"
    click WhiteCards "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/CardsAgainstHumanity/Board/WhiteCards.js"
    click MyHand "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/CardsAgainstHumanity/Board/MyHand.js"
    click PositionsTable "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/CardsAgainstHumanity/Board/PositionsTable.js"
    click Status "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/CardsAgainstHumanity/Board/Status.js"
    click TurnOf "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/CardsAgainstHumanity/Board/TurnOf.js"
    click LobbyContainer "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/LobbyContainer.js"
    click GameCreate "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/GameCreateComponent.js"
    click GameAvailable "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/GameAvailableComponent.js"
    click GameNotReady "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/GameNotReadyComponent.js"
    click GamesList "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/GamesListComponent.js"
    click Invitation "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/InvitationContainer.js"
    click GameAuth "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/GameAuthContainer.js"
    click LobbyServ "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/services/lobby.js"
    click StorageServ "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/services/storage.js"
    click BugsnagServ "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/services/bugsnag.js"
    click Decks "https://github.com/nahuelhds/cards-against-humanity-web/tree/master/src/assets/decks/es_AR/"
    click Expose "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/expose.js"
    click LogicGame "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/CardsAgainstHumanity/game.js"
    click Moves "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/CardsAgainstHumanity/moves.js"
    click Constants "https://github.com/nahuelhds/cards-against-humanity-web/blob/master/src/components/CardsAgainstHumanity/constants.js"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef engine fill:#DFFFE0,stroke:#22863A,color:#22863A
    classDef service fill:#FFE8A1,stroke:#D29922,color:#D29922
    classDef asset fill:#E0E0E0,stroke:#6A737D,color:#6A737D
    classDef external stroke-dasharray: 5 5,fill:#F0F0F0,stroke:#A0A0A0;color:#6A737D
```
