# okysky1121/qu-iz architecture

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

- Interactive diagram: https://gitdiagram.com/okysky1121/qu-iz
- Repository: https://github.com/okysky1121/qu-iz

## Overview

##### Main Components

Frontend (qu-iz-client):
- React Application Layer
- Component Layer
- Types Layer

Backend (qu-iz-server):
- Express Server Layer
- Module Layer (Music & Users)
- Database Layer (MongoDB/Mongoose)
- Security Layer (JWT)
- Middleware Layer (Guards, Filters, Pipes)

**Client Layer → API Layer → Server Layer → Database Layer**

##### Specific Elements

a. Client-Side:
- React component hierarchy
- TypeScript type definitions
- UI/UX components
- State management flow

b. Server-Side:
- Express.js routing layer
- Controller → Service → Model pattern
- Security middleware (JWT, Guards)
- Exception handling flow
- Database connections

##### Connection Flows

- HTTP/API requests between client and server
- Database operations
- Authentication flows
- Music quiz game logic flow

##### Important Architectural Patterns to Highlight

- MVC pattern in the backend
- Component-based architecture in React frontend
- DTO pattern for data transfer
- Repository pattern for database operations
- Guard pattern for authentication
- Decorator pattern for validation

##### Technical Stack Indicators

- TypeScript
- React
- Express
- MongoDB/Mongoose
- JWT
- Styled-components

## 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 security fill:#e74c3c,stroke:#c0392b,color:white
    classDef api fill:#9b59b6,stroke:#8e44ad,color:white
    classDef utility fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Frontend Layer
    subgraph Frontend
        ReactApp["React Application"]:::frontend
        click ReactApp "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-client/src/App.tsx"
        
        subgraph Components
            ChallengeItem["Challenge Item"]:::frontend
            click ChallengeItem "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-client/src/components/ChallengeItem.tsx"
            ChallengeList["Challenge List"]:::frontend
            click ChallengeList "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-client/src/components/ChallengeList.tsx"
            CircleGraph["Circle Graph"]:::frontend
            click CircleGraph "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-client/src/components/CircleGraph.tsx"
            Profile["Profile"]:::frontend
            click Profile "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-client/src/components/Profile.tsx"
            QuestionBar["Question Bar"]:::frontend
            click QuestionBar "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-client/src/components/QuestionBar.tsx"
            Ranking["Ranking"]:::frontend
            click Ranking "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-client/src/components/Ranking.tsx"
        end

        subgraph Types
            ChallengeType["Challenge Type"]:::frontend
            click ChallengeType "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-client/src/types/Challenge.ts"
            ModeType["Mode Type"]:::frontend
            click ModeType "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-client/src/types/Mode.ts"
            SongType["Song Type"]:::frontend
            click SongType "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-client/src/types/Song.ts"
        end

        Assets["Asset Management"]:::frontend
        click Assets "https://github.com/okysky1121/qu-iz/tree/master/qu-iz-client/src/icons"
    end

    %% Backend Layer
    subgraph Backend
        ExpressServer["Express Server"]:::backend
        click ExpressServer "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-server/src/app.ts"

        subgraph MusicModule
            MusicController["Music Controller"]:::backend
            click MusicController "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-server/src/modules/musics/music.controller.ts"
            MusicService["Music Service"]:::backend
            click MusicService "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-server/src/modules/musics/music.service.ts"
            AlbumModel["Album Model"]:::backend
            click AlbumModel "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-server/src/modules/musics/model/album.model.ts"
            SongModel["Song Model"]:::backend
            click SongModel "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-server/src/modules/musics/model/song.model.ts"
        end

        subgraph UsersModule
            UserController["User Controller"]:::backend
            click UserController "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-server/src/modules/users/user.controller.ts"
            UserService["User Service"]:::backend
            click UserService "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-server/src/modules/users/user.service.ts"
            UserModel["User Model"]:::backend
            click UserModel "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-server/src/modules/users/user.model.ts"
        end

        subgraph Security
            AuthGuard["Auth Guard"]:::security
            click AuthGuard "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-server/src/guards/auth.guard.ts"
            ValidateGuard["Validate Guard"]:::security
            click ValidateGuard "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-server/src/guards/validate.guard.ts"
            JWTPipe["JWT Pipe"]:::security
            click JWTPipe "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-server/src/pipes/jwt.pipe.ts"
        end

        subgraph Middleware
            ExceptionFilter["Exception Filter"]:::utility
            click ExceptionFilter "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-server/src/filters/exception.filter.ts"
            CORSPipe["CORS Pipe"]:::utility
            click CORSPipe "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-server/src/pipes/cors.pipe.ts"
            NotBlankDecorator["NotBlank Decorator"]:::utility
            click NotBlankDecorator "https://github.com/okysky1121/qu-iz/blob/master/qu-iz-server/src/decorators/notblank.decorator.ts"
        end
    end

    %% Database Layer
    MongoDB[("MongoDB")]:::database
    click MongoDB "https://github.com/okysky1121/qu-iz/tree/master/qu-iz-server/src/modules/musics/model"

    %% Relationships
    ReactApp --> Components
    ReactApp --> Types
    ReactApp --> Assets
    Components --> ExpressServer
    ExpressServer --> Security
    Security --> Middleware
    ExpressServer --> MusicModule
    ExpressServer --> UsersModule
    MusicModule --> MongoDB
    UsersModule --> MongoDB

    %% Legend
    subgraph Legend
        Frontend_["Frontend"]:::frontend
        Backend_["Backend"]:::backend
        Database_["Database"]:::database
        Security_["Security"]:::security
        API_["API"]:::api
        Utility_["Utility"]:::utility
    end
```
