# ddan-dda-ra/ddan-ddan-server architecture

> Architecture diagram of the GitHub repository ddan-dda-ra/ddan-ddan-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ddan-dda-ra/ddan-ddan-server
- Repository: https://github.com/ddan-dda-ra/ddan-ddan-server

## Overview

##### Project type and purpose
- From the file tree and minimal README, this is a Kotlin‐based Spring Boot server application (“ddan-ddan-server”) that provides RESTful endpoints supporting user authentication (OAuth via Kakao/Apple), user/pet management, ranking, daily info, and push notifications. It uses MongoDB as its primary data store, integrates with Firebase Cloud Messaging (FCM) and Slack webhooks, and schedules background jobs.

##### File structure
- Top-level build files (Gradle, Dockerignore, GitHub workflows) indicate containerization and CI/CD.
- src/main/kotlin/notbe/tmtm/ddanddanserver is organized by layers:
- presentation (controllers, DTOs, filters, schedulers)
- application (Processor and Service classes)
- domain (use cases, gateways, models, exceptions)
- infrastructure (API clients, database repositories/entities, gateway implementations)
- common and config modules for cross‐cutting concerns (security, JWT, Swagger, Mongo converters).
- src/main/resources holds YAML configs for multiple environments.
- Tests mirror domain/use cases for unit testing.

##### Detail
- Layer’s boundaries and Adapters (e.g. JWTAuthFilter as a security adapter, MongoConverter as a data adapter)
- Both synchronous flows (HTTP requests) and asynchronous/scheduled flows (notifications)
- Don’t omit small but critical modules (SwaggerConfig, WebSecurityConfig, OAuthProcessorFactory)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Client["Clients (Mobile/Web)"]:::external
        JWTAuthFilter["JWTAuthFilter"]:::filter
        click JWTAuthFilter "https://github.com/ddan-dda-ra/ddan-ddan-server/blob/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/presentation/filter/JWTAuthFilter.kt"
        Controllers["Controllers"]:::controller
        click Controllers "https://github.com/ddan-dda-ra/ddan-ddan-server/tree/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/presentation/controller"
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Processors["Processors"]:::processor
        click Processors "https://github.com/ddan-dda-ra/ddan-ddan-server/tree/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/application/processor"
        Services["Services"]:::service
        click Services "https://github.com/ddan-dda-ra/ddan-ddan-server/tree/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/application/service"
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        UseCases["UseCase Interfaces"]:::usecase
        click UseCases "https://github.com/ddan-dda-ra/ddan-ddan-server/tree/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/domain/usecase"
        Gateways["Gateway Interfaces"]:::gateway
        click Gateways "https://github.com/ddan-dda-ra/ddan-ddan-server/tree/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/domain/gateway"
        Models["Domain Models"]:::model
        click Models "https://github.com/ddan-dda-ra/ddan-ddan-server/tree/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/domain/model"
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        direction TB
        subgraph Database
            direction TB
            Entities["MongoDB Entities"]:::entity
            click Entities "https://github.com/ddan-dda-ra/ddan-ddan-server/tree/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/infrastructure/database/entity"
            Repos["MongoDB Repositories"]:::repository
            click Repos "https://github.com/ddan-dda-ra/ddan-ddan-server/tree/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/infrastructure/database/repository"
            MongoDB["MongoDB"]:::database
        end
        subgraph "External APIs"
            direction TB
            AppleApi["Apple OAuth API"]:::external_api
            click AppleApi "https://github.com/ddan-dda-ra/ddan-ddan-server/blob/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/infrastructure/api/AppleAuthApi.kt"
            KakaoApi["Kakao OAuth API"]:::external_api
            click KakaoApi "https://github.com/ddan-dda-ra/ddan-ddan-server/blob/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/infrastructure/api/KakaoAuthApi.kt"
            SlackApi["Slack Webhook API"]:::external_api
            click SlackApi "https://github.com/ddan-dda-ra/ddan-ddan-server/blob/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/infrastructure/api/SlackHookApi.kt"
        end
        FcmImpl["FCM Push Gateway Impl"]:::gateway_impl
        click FcmImpl "https://github.com/ddan-dda-ra/ddan-ddan-server/blob/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/infrastructure/gateway/FcmPushGatewayImpl.kt"
    end

    %% Configuration
    subgraph "Configuration"
        direction TB
        WebSecurityConfig["WebSecurityConfig"]:::config
        click WebSecurityConfig "https://github.com/ddan-dda-ra/ddan-ddan-server/blob/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/config/WebSecurityConfig.kt"
        JWTProvider["JWTTokenProvider"]:::config
        click JWTProvider "https://github.com/ddan-dda-ra/ddan-ddan-server/blob/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/common/JWTTokenProvider.kt"
        MongoConfig["MongoConfig"]:::config
        click MongoConfig "https://github.com/ddan-dda-ra/ddan-ddan-server/blob/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/config/MongoConfig.kt"
        FcmConfig["FcmConfig"]:::config
        click FcmConfig "https://github.com/ddan-dda-ra/ddan-ddan-server/blob/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/config/FcmConfig.kt"
        SwaggerConfig["SwaggerConfig"]:::config
        click SwaggerConfig "https://github.com/ddan-dda-ra/ddan-ddan-server/blob/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/config/SwaggerConfig.kt"
        MongoConverter["MongoConverter"]:::config
        click MongoConverter "https://github.com/ddan-dda-ra/ddan-ddan-server/blob/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/config/converter/MongoConverter.kt"
        ExceptionHandler["WebExceptionHandler"]:::config
        click ExceptionHandler "https://github.com/ddan-dda-ra/ddan-ddan-server/blob/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/common/WebExceptionHandler.kt"
    end

    %% Schedulers
    subgraph "Schedulers"
        direction TB
        NotificationScheduler["NotificationScheduler"]:::scheduler
        click NotificationScheduler "https://github.com/ddan-dda-ra/ddan-ddan-server/blob/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/presentation/scheduler/NotificationScheduler.kt"
        UpdateStrictScheduler["UpdateStrictScheduler"]:::scheduler
        click UpdateStrictScheduler "https://github.com/ddan-dda-ra/ddan-ddan-server/blob/develop/src/main/kotlin/notbe/tmtm/ddanddanserver/presentation/scheduler/UpdateStrictScheduler.kt"
    end

    %% Relationships
    Client -->|HTTP Request| JWTAuthFilter -->|Filters & Auth| Controllers
    Controllers -->|"invoke"| Services
    Services -->|"calls"| Processors
    Processors -->|"execute"| UseCases
    UseCases -->|"use gateway"| Gateways
    Gateways -->|"persist"| Entities
    Gateways -->|"access"| Repos --> MongoDB
    Gateways -->|"call API"| AppleApi
    Gateways -->|"call API"| KakaoApi
    Gateways -->|"send"| FcmImpl
    Gateways -->|"post"| SlackApi
    NotificationScheduler -.->|"scheduled"| UseCases
    UpdateStrictScheduler -.->|"scheduled"| UseCases

    %% Styles
    classDef external fill:#FFCCBC,stroke:#E64A19;
    classDef filter fill:#B3E5FC,stroke:#0288D1;
    classDef controller fill:#BBDEFB,stroke:#1976D2;
    classDef processor fill:#90CAF9,stroke:#1565C0;
    classDef service fill:#64B5F6,stroke:#0D47A1;
    classDef usecase fill:#42A5F5,stroke:#0D47A1;
    classDef gateway fill:#1E88E5,stroke:#0D47A1;
    classDef model fill:#2196F3,stroke:#0D47A1;
    classDef entity fill:#80CBC4,stroke:#00695C;
    classDef repository fill:#4DB6AC,stroke:#004D40;
    classDef database fill:#B2DFDB,stroke:#00796B;
    classDef external_api fill:#D7CCC8,stroke:#5D4037;
    classDef gateway_impl fill:#1976D2,stroke:#0D47A1;
    classDef config fill:#AED581,stroke:#558B2F;
    classDef scheduler fill:#FFF176,stroke:#F57F17;
```
