# bbmt0/musigame architecture

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

- Interactive diagram: https://gitdiagram.com/bbmt0/musigame
- Repository: https://github.com/bbmt0/musigame

## Overview

##### Project Type and Purpose
- Musigame is a multiplayer Progressive Web Application (PWA) built as a mono-repo with two primary projects:
- A React-based frontend (located in the “front” directory) handling the user interface.
- A Spring Boot “Back-End For Frontend” (BFF) (located in the “bff” directory) that manages server-side logic, REST endpoints, and integration with external services.
- The overall purpose is to deliver an interactive music game that supports multiple players and leverages music-related APIs and Firebase for some data storage/interaction.

##### File Structure Analysis and Architectural Clues
- The mono-repo is clearly split into “front” and “bff”, representing the two application layers.
- The “bff” part adheres to a layered architecture that reflects elements of both Domain Driven Design (DDD) and Hexagonal Architecture. Notice:
- Package structure under “com.masterproject.musigame” is segmented into adapters, configuration, and core business components (artists, rooms, songs, images…) which likely represent domain models and services.
- “adapter/db” packages are used to interact with external databases (Firebase, Genius API) and “adapter/rest” packages offer controller endpoints for the frontend.
- Infrastructure details, like the presence of Gradle build files, indicate a well-structured Java application.

##### Examining README for Additional Insights
- README states the use of React on the frontend and Spring Boot (Java 21) on the backend.

a. Main Components to Include:
- Frontend: A React-based UI that includes various pages (HomeScreen, GameCreationScreen, Game screens for different player roles, etc.) and components (buttons, grids, cards).
- Backend (BFF): A Spring Boot API layering several sub-components:
- REST API layer: Controllers for artists, images, rooms, and songs.
- Application/Service Layer: Domain services for managing artists, images, rooms, songs and associated business logic.
- Adapter/Repository Layer: Adapters for database interactions, including integration with external services like Genius API and Firebase. Note the separate repositories for handling operations on artists, songs, images, and rooms.
- Configuration: Firebase service configuration and other application settings.
- External Services and APIs:
- Genius API for music and artist data.
- Firebase as a backend service to manage images and room data.
- CI/CD Pipeline: Represent that the project uses GitHub Actions for building and releasing.

b. Relationships and Interactions:
- The frontend communicates with the BFF via REST API calls.
- Within the backend, show directional flows from the Controllers to the Service layer, and from there to the Adapter/Repository layer.
- Data flow from the BFF directly to external services (Firebase, Genius API) through dedicated adapters.
- Optionally, include interconnections like configuration management (through configuration packages) to external APIs.

c. Highlighting Architectural Patterns and Design Principles:
- Be sure to annotate that the BFF follows a Hexagonal Architecture/Doman Driven Design. The Controllers are “ports” and the adapters are “driven ports/secondary adapters.”
- Layered separation: REST API (adapter/rest) → Business Domain (services/domain code) → Persistence/External integration (adapter/db).
- Use layers to emphasize separation of concerns and testability (with integration/in-memory repositories for testing).

d. Technologies and Frameworks:
- Frontend: React (with its supporting libraries, e.g., possibly React Router, custom component libraries).
- Backend: Spring Boot (Java 21), Gradle, and integration with Firebase and Genius API.
- CI/CD tooling: GitHub Actions, with workflow YAML files located under the “.github/workflows” directory.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Supporting Tools
    CICD["CI/CD Pipeline\n(GitHub Actions)"]:::cicd
    ArchDoc["Architectural Documentation"]:::doc

    %% Frontend Subgraph
    subgraph "React Frontend"
        FE_Pages["UI Pages"]:::frontend
        FE_Components["UI Components"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Spring Boot BFF"
        BFF_Main["Main Application"]:::bff-main
        subgraph "REST API Layer"
            Controllers["REST API Controllers"]:::controllers
        end
        subgraph "Business Logic"
            Domain["Domain Services & Business Logic"]:::domain
        end
        subgraph "Adapter Layer"
            DB_Adapters["DB & External API Adapters"]:::adapters
        end
        Config["Firebase & External Config"]:::config
    end

    %% External Services
    Firebase["Firebase Service"]:::external
    Genius["Genius API"]:::external

    %% Connections for Data Flow
    FE_Pages -->|"calls"| Controllers
    FE_Components -->|"triggers"| Controllers
    BFF_Main -->|"initializes"| Controllers
    Controllers -->|"invokes"| Domain
    Domain -->|"uses"| DB_Adapters
    DB_Adapters -->|"fetches from"| Firebase
    DB_Adapters -->|"fetches from"| Genius
    BFF_Main -->|"loads"| Config
    Config -->|"configures"| DB_Adapters

    %% Supporting Tools Connections (dotted lines)
    CICD --- FE_Pages
    CICD --- BFF_Main
    ArchDoc --- BFF_Main

    %% Click Events
    click FE_Pages "https://github.com/bbmt0/musigame/tree/main/front/src/pages"
    click FE_Components "https://github.com/bbmt0/musigame/tree/main/front/src/components"
    click BFF_Main "https://github.com/bbmt0/musigame/blob/main/bff/src/main/java/com/masterproject/musigame/Application.java"
    click Controllers "https://github.com/bbmt0/musigame/tree/main/bff/src/main/java/com/masterproject/musigame/adapter/rest"
    click Domain "https://github.com/bbmt0/musigame/tree/main/bff/src/main/java/com/masterproject/musigame"
    click DB_Adapters "https://github.com/bbmt0/musigame/tree/main/bff/src/main/java/com/masterproject/musigame/adapter/db"
    click Config "https://github.com/bbmt0/musigame/tree/main/bff/src/main/java/com/masterproject/musigame/configuration/firebase"
    click CICD "https://github.com/bbmt0/musigame/tree/main/.github/workflows"
    click ArchDoc "https://github.com/bbmt0/musigame/tree/main/doc/architecture"

    %% Classes Styles
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef bff-main fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef controllers fill:#8fd3f4,stroke:#333,stroke-width:2px;
    classDef domain fill:#fff3cd,stroke:#333,stroke-width:2px;
    classDef adapters fill:#ffcc99,stroke:#333,stroke-width:2px;
    classDef config fill:#f5c6cb,stroke:#333,stroke-width:2px;
    classDef cicd fill:#d1ecf1,stroke:#333,stroke-width:2px;
    classDef doc fill:#d6d8db,stroke:#333,stroke-width:2px;
    classDef external fill:#e2e3e5,stroke:#333,stroke-width:2px;
```
