# prgrms-web-devcourse/team-darknight-kkini-be architecture

> Architecture diagram of the GitHub repository prgrms-web-devcourse/team-darknight-kkini-be, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prgrms-web-devcourse/team-darknight-kkini-be
- Repository: https://github.com/prgrms-web-devcourse/team-darknight-kkini-be

## Overview

##### Main Components

a. Client Layer:
- Frontend Application (React/Next.js based on the frontend repository mention)
- Mobile/Web Clients

b. API Gateway Layer:
- Nginx (as shown in the configuration files)
- Load Balancer

c. Application Layer:
- Spring Boot Application with following core modules:
- Authentication Module (OAuth2.0, JWT)
- User Management
- Crew Management
- Chat System
- Store Management
- Review System
- Notification System
- Proposal Management

d. Data Layer:
- MySQL Database
- Redis Cache
- AWS S3 (for file storage)

e. External Services:
- OAuth Providers (Google, Kakao)
- AWS Services (EC2, S3, CloudWatch)
- Monitoring Systems

##### Relationships and Data Flow

- Client-to-Server communication via REST APIs
- WebSocket connections for real-time chat
- Database interactions
- Cache access patterns
- External service integrations

##### Specific Implementation Details

a. Security Flow:
- OAuth2.0 authentication flow
- JWT token management
- Security filters

b. Data Management:
- JPA repositories
- Flyway migrations
- Redis caching

c. Real-time Features:
- WebSocket connections for chat
- SSE for notifications

##### Architectural Patterns to Highlight

- Domain-Driven Design (evident from the package structure)
- Microservices-ready architecture
- Event-driven architecture (for notifications)
- Layered architecture within each domain

##### Deployment Components

- GitHub Actions workflows
- Docker containers
- AWS infrastructure
- Nginx configuration

**[Client Layer]**
- ↓
**[API Gateway/Load Balancer]**
- ↓
**[Application Layer (Spring Boot)]**
- ↓
**[Data Layer]**
- ↓
**[Infrastructure Layer]**

- Line types (REST, WebSocket, Internal calls)
- Component types (Services, Databases, External APIs)
- Security boundaries

Keep the abstraction level high enough to show the overall architecture while including crucial implementation details that make the system unique, such as the location-based features and real-time communication components.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef client fill:#B2DFDB,stroke:#004D40
    classDef gateway fill:#80CBC4,stroke:#004D40
    classDef core fill:#4DB6AC,stroke:#004D40
    classDef data fill:#26A69A,stroke:#004D40
    classDef external fill:#00897B,stroke:#004D40
    classDef legend fill:#E0F2F1,stroke:#004D40

    %% Client Layer
    subgraph Clients
        Web["Web Client"]:::client
        Mobile["Mobile Client"]:::client
    end

    %% API Gateway Layer
    subgraph Gateway
        NGINX["NGINX API Gateway"]:::gateway
        LB["Load Balancer"]:::gateway
    end
    click NGINX "https://github.com/prgrms-web-devcourse/Team-DarkNight-Kkini-BE/blob/develop/.platform/nginx/nginx.conf"

    %% Application Layer
    subgraph Core["Application Core"]
        Auth["Authentication Module"]:::core
        User["User Management"]:::core
        Crew["Crew Management"]:::core
        Chat["Chat System"]:::core
        Store["Store Management"]:::core
        Review["Review System"]:::core
        Notif["Notification System"]:::core
        Proposal["Proposal Management"]:::core
    end

    click Auth "https://github.com/prgrms-web-devcourse/Team-DarkNight-Kkini-BE/tree/develop/src/main/java/com/prgrms/mukvengers/global/auth/oauth"
    click User "https://github.com/prgrms-web-devcourse/Team-DarkNight-Kkini-BE/tree/develop/src/main/java/com/prgrms/mukvengers/domain/user"
    click Crew "https://github.com/prgrms-web-devcourse/Team-DarkNight-Kkini-BE/tree/develop/src/main/java/com/prgrms/mukvengers/domain/crew"
    click Chat "https://github.com/prgrms-web-devcourse/Team-DarkNight-Kkini-BE/tree/develop/src/main/java/com/prgrms/mukvengers/domain/chat"
    click Store "https://github.com/prgrms-web-devcourse/Team-DarkNight-Kkini-BE/tree/develop/src/main/java/com/prgrms/mukvengers/domain/store"
    click Review "https://github.com/prgrms-web-devcourse/Team-DarkNight-Kkini-BE/tree/develop/src/main/java/com/prgrms/mukvengers/domain/review"
    click Notif "https://github.com/prgrms-web-devcourse/Team-DarkNight-Kkini-BE/tree/develop/src/main/java/com/prgrms/mukvengers/domain/notification"
    click Proposal "https://github.com/prgrms-web-devcourse/Team-DarkNight-Kkini-BE/tree/develop/src/main/java/com/prgrms/mukvengers/domain/proposal"

    %% Data Layer
    subgraph Data
        MySQL[(MySQL DB)]:::data
        Redis[(Redis Cache)]:::data
        S3["AWS S3"]:::data
    end

    click MySQL "https://github.com/prgrms-web-devcourse/Team-DarkNight-Kkini-BE/blob/develop/src/main/resources/application-db.yml"
    click Redis "https://github.com/prgrms-web-devcourse/Team-DarkNight-Kkini-BE/blob/develop/src/main/java/com/prgrms/mukvengers/global/config/infra/redis/RedisConfig.java"
    click S3 "https://github.com/prgrms-web-devcourse/Team-DarkNight-Kkini-BE/blob/develop/src/main/java/com/prgrms/mukvengers/global/config/infra/s3/AwsConfig.java"

    %% External Services
    subgraph External["External Services"]
        OAuth["OAuth Providers"]:::external
        AWS["AWS Services"]:::external
        Monitor["Monitoring"]:::external
    end

    click OAuth "https://github.com/prgrms-web-devcourse/Team-DarkNight-Kkini-BE/blob/develop/src/main/java/com/prgrms/mukvengers/global/auth/oauth/service/CustomOAuth2UserService.java"
    click AWS "https://github.com/prgrms-web-devcourse/Team-DarkNight-Kkini-BE/blob/develop/src/main/java/com/prgrms/mukvengers/global/infra/storage/service/AwsS3Service.java"

    %% Connections
    Web & Mobile --> NGINX
    NGINX --> LB
    LB --> Core
    Core --> Data
    Auth --> OAuth
    Core --> AWS
    Core --> Monitor

    %% Legend
    subgraph Legend
        L1["Client Components"]:::client
        L2["Gateway Components"]:::gateway
        L3["Core Services"]:::core
        L4["Data Stores"]:::data
        L5["External Services"]:::external
    end
```
