# realfascinated/scoresaber-reloaded architecture

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

- Interactive diagram: https://gitdiagram.com/realfascinated/scoresaber-reloaded
- Repository: https://github.com/realfascinated/scoresaber-reloaded

## Overview

##### Main Components

Frontend Layer:
- Next.js Website Application (/projects/website)
- Desktop Application (Tauri-based) (/projects/desktop)
- User Interface Components (React components)

Backend Layer:
- Backend API Server (/projects/backend)
- WebSocket Services (for real-time scores)
- Controllers and Services
- Bot Integration

Data Layer:
- Database Systems (implied by database utilities)
- Caching System
- MinIO Storage (for assets/images)

External Services Integration:
- ScoreSaber API
- BeatLeader API
- BeatSaver API
- Steam Integration

**[Client Layer]**

- Web Application (Next.js)
- Desktop App (Tauri)
- Overlay System

**[API Gateway/Load Balancer]**

**[Backend Services]**
- Authentication Service
- Player Service
- Score Service
- Leaderboard Service
- Statistics Service
- Playlist Service
- Image Service
- Bot Service

**[Data Layer]**
- Cache Service
- Database
- MinIO Storage

**[External Services]**
- ScoreSaber API
- BeatLeader API
- BeatSaver API
- Steam API

##### Key Relationships to Highlight

- Bidirectional communication between frontend and backend using REST APIs
- WebSocket connections for real-time score updates
- Caching layer interaction with external APIs
- Data flow between services and storage systems

##### Implementation Details

- Clear component boundaries
- Service interaction patterns
- Scaling points
- Security boundaries

##### Additional Elements

Annotations for:
- Docker container boundaries
- GitHub Actions deployment flows
- Caching strategies
- Data collection mechanisms
- Score processing pipeline

This system design should effectively communicate the complex architecture while highlighting the scalability and real-time nature of the application.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef websocket fill:#e74c3c,stroke:#c0392b,color:white
    classDef cache fill:#9b59b6,stroke:#8e44ad,color:white

    %% Client Layer
    subgraph ClientLayer
        WebApp["Next.js Website"]
        Desktop["Desktop App (Tauri)"]
        Overlay["Overlay System"]
    end

    %% API Gateway
    Gateway["API Gateway/Load Balancer"]

    %% Backend Services
    subgraph BackendServices
        AuthService["Authentication Service"]
        PlayerService["Player Service"]
        ScoreService["Score Service"]
        LeaderboardService["Leaderboard Service"]
        StatsService["Statistics Service"]
        PlaylistService["Playlist Service"]
        ImageService["Image Service"]
        BotService["Bot Service"]
        WebSocketService["WebSocket Service"]
    end

    %% Data Layer
    subgraph DataLayer
        Cache["Cache Service"]
        Database["Database"]
        MinIO["MinIO Storage"]
    end

    %% External Services
    subgraph ExternalServices
        ScoreSaber["ScoreSaber API"]
        BeatLeader["BeatLeader API"]
        BeatSaver["BeatSaver API"]
        Steam["Steam API"]
    end

    %% Relationships
    ClientLayer --> Gateway
    Gateway --> BackendServices
    BackendServices --> DataLayer
    BackendServices --> ExternalServices
    WebSocketService --> ClientLayer
    Cache --> ExternalServices

    %% Component Styling
    class WebApp,Desktop,Overlay frontend
    class AuthService,PlayerService,ScoreService,LeaderboardService,StatsService,PlaylistService,ImageService,BotService backend
    class Database,MinIO database
    class ScoreSaber,BeatLeader,BeatSaver,Steam external
    class WebSocketService websocket
    class Cache cache

    %% Click Events
    click WebApp "https://github.com/RealFascinated/scoresaber-reloaded/tree/master/projects/website/src/app"
    click Desktop "https://github.com/RealFascinated/scoresaber-reloaded/tree/master/projects/desktop"
    click BotService "https://github.com/RealFascinated/scoresaber-reloaded/tree/master/projects/backend/src/bot"
    click WebSocketService "https://github.com/RealFascinated/scoresaber-reloaded/blob/master/projects/common/src/websocket/scoresaber-websocket.ts"
    click Cache "https://github.com/RealFascinated/scoresaber-reloaded/blob/master/projects/backend/src/service/cache.service.ts"
    click MinIO "https://github.com/RealFascinated/scoresaber-reloaded/blob/master/projects/backend/src/service/minio.service.ts"
    click ScoreSaber "https://github.com/RealFascinated/scoresaber-reloaded/blob/master/projects/common/src/service/impl/scoresaber.ts"
    click BeatLeader "https://github.com/RealFascinated/scoresaber-reloaded/blob/master/projects/common/src/service/impl/beatleader.ts"
    click BeatSaver "https://github.com/RealFascinated/scoresaber-reloaded/blob/master/projects/common/src/service/impl/beatsaver.ts"
    click Database "https://github.com/RealFascinated/scoresaber-reloaded/blob/master/projects/website/src/common/database/database.ts"
    click ScoreService "https://github.com/RealFascinated/scoresaber-reloaded/blob/master/projects/backend/src/service/score.service.ts"
    click PlayerService "https://github.com/RealFascinated/scoresaber-reloaded/blob/master/projects/backend/src/service/player.service.ts"
    click StatsService "https://github.com/RealFascinated/scoresaber-reloaded/blob/master/projects/backend/src/service/statistics.service.ts"
```
