# lunartown/dgrr architecture

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

- Interactive diagram: https://gitdiagram.com/lunartown/dgrr
- Repository: https://github.com/lunartown/dgrr

## Overview

##### Main Components

a. Client-Side (Frontend):
- React/TypeScript Application Layer
- WebSocket/STOMP Client
- OpenVidu Client (Video Streaming)
- User Interface Components (Game, Profile, Auth)

b. Server-Side Components:
- Spring Boot Backend Server
- Python FastAPI Server (Emotion Analysis)
- WebSocket/STOMP Server
- OpenVidu Server
- Security Layer (JWT, OAuth)

c. External Services:
- Kakao OAuth Service
- AWS S3 (File Storage)
- MariaDB Database

##### Component Relationships

- Frontend ↔️ Spring Backend (REST APIs)
- Frontend ↔️ WebSocket Server (Real-time game state)
- Frontend ↔️ OpenVidu Server (Video streaming)
- Spring Backend ↔️ Python Backend (Emotion analysis)
- Spring Backend ↔️ MariaDB (Data persistence)
- Spring Backend ↔️ AWS S3 (File storage)

##### Key Architectural Patterns to Highlight

a. Domain-Driven Design:
- Clear separation of domains (battle, game, member, rating)
- Domain services, repositories, and entities

b. Microservices Architecture:
- Java Spring Backend (Main service)
- Python FastAPI (ML/AI service)
- OpenVidu (Video streaming service)

##### Data Flow Visualization

Flow for key processes:

##### Additional Elements

Include:
- Load balancers
- Docker containers
- Jenkins CI/CD pipeline
- Security layers (JWT, Spring Security)
- WebSocket connections
- REST API endpoints

##### Specific Implementation Details

Specialized components:
- Game state management
- Real-time video processing
- Emotion analysis pipeline
- Rating system
- Battle management

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE[React Frontend]:::frontend
        GC[Game Components]:::frontend
        WC[WebSocket Client]:::frontend
        OVC[OpenVidu Client]:::frontend
        AC[Auth Components]:::frontend
    end

    subgraph "Spring Backend"
        SB[Spring Boot Core]:::backend
        WS[WebSocket Server]:::backend
        SEC[Security Layer]:::security
        
        subgraph "Domain Services"
            BD[Battle Domain]:::domain
            GD[Game Domain]:::domain
            MD[Member Domain]:::domain
            RD[Rating Domain]:::domain
            FM[File Management]:::domain
            OVS[OpenVidu Service]:::domain
        end
        
        AWS[AWS Integration]:::external
    end

    subgraph "External Services"
        PY[Python FastAPI<br>Emotion Analysis]:::python
        OVE[OpenVidu Server]:::external
        S3[AWS S3]:::storage
        DB[(MariaDB)]:::database
        KO[Kakao OAuth]:::external
    end

    %% Client-side connections
    FE --> GC
    FE --> WC
    FE --> OVC
    FE --> AC

    %% Frontend to Backend connections
    GC --> WS
    WC --> WS
    OVC --> OVS
    AC --> SEC

    %% Backend internal connections
    SB --> BD & GD & MD & RD & FM & OVS
    SEC --> MD
    FM --> AWS
    AWS --> S3

    %% External service connections
    BD --> PY
    SEC --> KO
    MD --> DB
    GD --> DB
    RD --> DB
    BD --> DB

    %% Click events
    click FE "https://github.com/lunartown/dgrr/blob/main/frontend/src/App/App.tsx"
    click GC "https://github.com/lunartown/dgrr/tree/main/frontend/src/components/Game/"
    click WC "https://github.com/lunartown/dgrr/blob/main/frontend/src/components/Game/stomp.ts"
    click OVC "https://github.com/lunartown/dgrr/blob/main/frontend/src/components/Game/openVidu.ts"
    click AC "https://github.com/lunartown/dgrr/tree/main/frontend/src/pages/LoginPages/"
    click SB "https://github.com/lunartown/dgrr/blob/main/backend/dgrr/src/main/java/live/dgrr/DgrrApplication.java"
    click PY "https://github.com/lunartown/dgrr/blob/main/backend/python/emotion_analyze_module/analyzingImage.py"
    click WS "https://github.com/lunartown/dgrr/blob/main/backend/dgrr/src/main/java/live/dgrr/global/config/stomp/WebSocketConfig.java"
    click SEC "https://github.com/lunartown/dgrr/tree/main/backend/dgrr/src/main/java/live/dgrr/global/security/"
    click BD "https://github.com/lunartown/dgrr/tree/main/backend/dgrr/src/main/java/live/dgrr/domain/battle/"
    click GD "https://github.com/lunartown/dgrr/tree/main/backend/dgrr/src/main/java/live/dgrr/domain/game/"
    click MD "https://github.com/lunartown/dgrr/tree/main/backend/dgrr/src/main/java/live/dgrr/domain/member/"
    click RD "https://github.com/lunartown/dgrr/tree/main/backend/dgrr/src/main/java/live/dgrr/domain/rating/"
    click FM "https://github.com/lunartown/dgrr/tree/main/backend/dgrr/src/main/java/live/dgrr/domain/file/"
    click OVS "https://github.com/lunartown/dgrr/tree/main/backend/dgrr/src/main/java/live/dgrr/domain/openvidu/"
    click AWS "https://github.com/lunartown/dgrr/blob/main/backend/dgrr/src/main/java/live/dgrr/global/config/AmazonConfig.java"

    %% Styling
    classDef frontend fill:#2196F3,color:white
    classDef backend fill:#4CAF50,color:white
    classDef python fill:#FFC107,color:black
    classDef external fill:#9E9E9E,color:white
    classDef security fill:#F44336,color:white
    classDef database fill:#9C27B0,color:white
    classDef storage fill:#9C27B0,color:white
    classDef domain fill:#81C784,color:black
```
