# inspedralbes/tr1-type-racer-royale-grup3daw architecture

> Architecture diagram of the GitHub repository inspedralbes/tr1-type-racer-royale-grup3daw, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/inspedralbes/tr1-type-racer-royale-grup3daw
- Repository: https://github.com/inspedralbes/tr1-type-racer-royale-grup3daw

## Overview

##### Project type and purpose
- This is a full-stack, real-time multiplayer game platform built with a Vue.js SPA in the frontend and a Node.js/Express API in the backend. It supports user authentication, room creation/joining, live game sessions via WebSockets, score tracking, and stats.

##### File structure
- Top-level:
- `.github/` – CI/CD workflows (deploy.yml)
- `docker-compose.dev.yml`, `docker-compose.prod.yml` – multi-container configs
- `nginx.Dockerfile`, `nginx.conf` – reverse proxy / static server
- `backend/` – Express app, REST controllers, socket manager, Sequelize (SQL) models & migrations, optional Mongo connection, middleware, state manager
- `frontend/vue-project/` – Vue 3 app scaffolded with Vite, Pinia stores, Vue Router, single-file components, communication manager for HTTP & sockets
- `doc/` – API docs, dev credentials, images
- The backend is organized around controllers & routes, with a clear MVC-style separation of concerns. A `stateManager` holds in-memory game state; Sequelize handles RDBMS persistence; `mongo.js` suggests an additional NoSQL store.

##### Essential details to capture
- Nginx as reverse proxy and static file host
- Vue SPA communicating via both HTTP(S) and WebSocket
- Express controllers versus Socket Manager handling different traffic
- StateManager’s role in persisting transient game state
- Dual persistence layers: SQL for users/scores/info, MongoDB for flexible or ephemeral data
- CI/CD integration with GitHub Actions and Docker Compose deployment

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Tier
    subgraph "Client Tier"
        SPA["Vue SPA (Vue.js 3, Vite)"]:::frontend
    end

    %% Edge Tier
    subgraph "Edge Tier"
        NGINX["Nginx\nReverse Proxy / Static Server"]:::infra
    end

    %% Application Tier
    subgraph "Application Tier"
        EXPRESS["Express REST API\nNode.js, Express"]:::backend
        SocketMgr["Socket Manager\nSocket.io"]:::backend
        StateMgr["StateManager\n(In-memory game state)"]:::backend
    end

    %% Data Tier
    subgraph "Data Tier"
        SQL["PostgreSQL\nvia Sequelize"]:::data
        Mongo["MongoDB"]:::data
    end

    %% CI/CD & Infrastructure
    subgraph "CI/CD & Infrastructure"
        GH["GitHub Actions\n(deploy.yml)"]:::infra
        DC["Docker Compose\n(dev & prod)"]:::infra
    end

    %% Connections
    SPA -->|"HTTP/HTTPS"| NGINX
    SPA -->|"WS/WSS"| NGINX
    NGINX -->|"proxy HTTP"| EXPRESS
    NGINX -->|"proxy WS"| SocketMgr
    EXPRESS -->|"uses"| StateMgr
    SocketMgr -->|"reads/writes"| StateMgr
    EXPRESS -->|"ORM (Sequelize)"| SQL
    StateMgr -->|"optional persistence"| Mongo
    GH -->|"deploy pipeline"| DC
    DC -->|"orchestrates"| NGINX
    DC -->|"orchestrates"| EXPRESS
    DC -->|"orchestrates"| SQL
    DC -->|"orchestrates"| Mongo

    %% Click Events
    click SPA "https://github.com/inspedralbes/tr1-type-racer-royale-grup3daw/tree/main/frontend/vue-project/"
    click NGINX "https://github.com/inspedralbes/tr1-type-racer-royale-grup3daw/blob/main/nginx.conf"
    click NGINX "https://github.com/inspedralbes/tr1-type-racer-royale-grup3daw/blob/main/nginx.Dockerfile"
    click EXPRESS "https://github.com/inspedralbes/tr1-type-racer-royale-grup3daw/blob/main/backend/server.js"
    click SocketMgr "https://github.com/inspedralbes/tr1-type-racer-royale-grup3daw/blob/main/backend/controllers/socketManager.js"
    click StateMgr "https://github.com/inspedralbes/tr1-type-racer-royale-grup3daw/blob/main/backend/state/stateManager.js"
    click SQL "https://github.com/inspedralbes/tr1-type-racer-royale-grup3daw/blob/main/backend/db/config/config.js"
    click Mongo "https://github.com/inspedralbes/tr1-type-racer-royale-grup3daw/blob/main/backend/mongo.js"
    click GH "https://github.com/inspedralbes/tr1-type-racer-royale-grup3daw/blob/main/.github/workflows/deploy.yml"
    click DC "https://github.com/inspedralbes/tr1-type-racer-royale-grup3daw/blob/main/docker-compose.dev.yml"
    click DC "https://github.com/inspedralbes/tr1-type-racer-royale-grup3daw/blob/main/docker-compose.prod.yml"

    %% Styles
    classDef frontend fill:#b2f5ea,stroke:#2c7a7b,color:#1a202c;
    classDef backend fill:#bee3f8,stroke:#2b6cb0,color:#1a202c;
    classDef data fill:#fed7d7,stroke:#c53030,color:#1a202c;
    classDef infra fill:#e2e8f0,stroke:#4a5568,color:#1a202c;
```
