# pierre2103/4x20x15 architecture

> Architecture diagram of the GitHub repository pierre2103/4x20x15, 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/pierre2103/4x20x15
- Repository: https://github.com/pierre2103/4x20x15

## Overview

##### Project type and purpose
- This is a full-stack real-time card-game application.
- Frontend: React single-page app (under src/, public/) that handles UI, routing, game pages, authentication flows.
- Backend: Node.js server (backend/app.js) that currently serves the frontend static files and will host game-rule logic as you migrate off Firebase.
- Database/Auth: Firebase (configured in src/firebaseConfig.js) used for user authentication (Auth) and real-time game state persistence (Firestore or Realtime Database).
- CI/CD: GitHub Actions pipeline defined at .github/workflows/tests.yml for automated tests and code quality checks.

##### File structure
- Top-level directories:
- backend/ – Node.js entry point (app.js). Likely Express for serving static assets and exposing APIs for custom game logic.
- public/ – index.html and other static assets that bootstrap the React app.
- src/ – React source code:
– App.js, index.js – root components and client-side router.
– firebaseConfig.js – Firebase project credentials for Auth/DB.
– pages/ – SPA routes (AuthPage, HomePage, RoomPage, GamePage, ProfilePage).
– styles/ – SCSS modules scoped per page.
- Config & metadata:
- package.json – dependencies (React, Firebase, Express?).
- .gitignore, .gitattributes – VCS config.
- .github/workflows/tests.yml – CI pipeline.

##### README for additional insights
- Startup instructions separate backend (node backend/app.js) and frontend (npm start).
- Todo list suggests adding more rule-engine logic on the backend, replacing Firebase with a self-hosted DB, and unifying startup commands.

##### Key takeaways
- Every moving part: client entry point, static asset server, auth flow, real-time DB, backend rule engine, CI/CD.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CI/CD
    CI["GitHub Actions CI/CD"]:::ci
    CI -->|build & deploy| Server
    CI -->|build| UI

    %% Frontend UI
    subgraph "React SPA (Browser/Client)"
        direction TB
        HTML["public/index.html"]:::ui
        Index["src/index.js"]:::ui
        App["src/App.js"]:::ui
        subgraph "Pages"
            direction TB
            AuthPage["AuthPage.js"]:::ui
            HomePage["HomePage.js"]:::ui
            RoomPage["RoomPage.js"]:::ui
            GamePage["GamePage.js"]:::ui
            ProfilePage["ProfilePage.js"]:::ui
        end
        subgraph "Styles"
            direction TB
            AuthStyle["AuthPage.scss"]:::ui
            HomeStyle["HomePage.scss"]:::ui
            RoomStyle["RoomPage.scss"]:::ui
            GameStyle["GamePage.scss"]:::ui
            ProfileStyle["ProfilePage.scss"]:::ui
        end
        Icons["src/img/icons/"]:::ui
    end

    %% Backend
    subgraph "Backend Layer"
        Server["Node.js/Express Server"]:::logic
    end

    %% Firebase Services
    subgraph "Firebase Services"
        firebaseConfig["src/firebaseConfig.js"]:::data
        Auth["Firebase Auth"]:::data
        DB["Firestore/Realtime DB"]:::data
    end

    %% Data Flows
    Server -->|serves static assets| HTML
    Server -->|serves JS bundle| Index
    Index -->|initializes| App
    App -->|uses config| firebaseConfig
    App -->|HTTP/WebSocket calls| Server
    App -->|Auth requests| Auth
    App -->|real-time listeners & writes| DB
    AuthPage -->|UI renders| App
    HomePage -->|UI renders| App
    RoomPage -->|UI renders| App
    GamePage -->|UI renders| App
    ProfilePage -->|UI renders| App

    %% Future: self-hosted DB via backend
    Server -->|future| DB

    %% Click Events
    click CI "https://github.com/pierre2103/4x20x15/blob/main/.github/workflows/tests.yml"
    click Server "https://github.com/pierre2103/4x20x15/blob/main/backend/app.js"
    click HTML "https://github.com/pierre2103/4x20x15/blob/main/public/index.html"
    click Index "https://github.com/pierre2103/4x20x15/blob/main/src/index.js"
    click App "https://github.com/pierre2103/4x20x15/blob/main/src/App.js"
    click AuthPage "https://github.com/pierre2103/4x20x15/blob/main/src/pages/AuthPage.js"
    click AuthStyle "https://github.com/pierre2103/4x20x15/blob/main/src/styles/AuthPage.scss"
    click HomePage "https://github.com/pierre2103/4x20x15/blob/main/src/pages/HomePage.js"
    click HomeStyle "https://github.com/pierre2103/4x20x15/blob/main/src/styles/HomePage.scss"
    click RoomPage "https://github.com/pierre2103/4x20x15/blob/main/src/pages/RoomPage.js"
    click RoomStyle "https://github.com/pierre2103/4x20x15/blob/main/src/styles/RoomPage.scss"
    click GamePage "https://github.com/pierre2103/4x20x15/blob/main/src/pages/GamePage.js"
    click GameStyle "https://github.com/pierre2103/4x20x15/blob/main/src/styles/GamePage.scss"
    click ProfilePage "https://github.com/pierre2103/4x20x15/blob/main/src/pages/ProfilePage.js"
    click ProfileStyle "https://github.com/pierre2103/4x20x15/blob/main/src/styles/ProfilePage.scss"
    click Icons "https://github.com/pierre2103/4x20x15/tree/main/src/img/icons/"
    click firebaseConfig "https://github.com/pierre2103/4x20x15/blob/main/src/firebaseConfig.js"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,stroke-width:1px,color:#0366d6;
    classDef logic fill:#DFF5D0,stroke:#28A745,stroke-width:1px,color:#28A745;
    classDef data fill:#FFE5B4,stroke:#F66A0A,stroke-width:1px,color:#F66A0A;
    classDef ci fill:#E0E0E0,stroke:#888888,stroke-width:1px,color:#888888;
```
