# sky7214sky72/portfolio architecture

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

- Interactive diagram: https://gitdiagram.com/sky7214sky72/portfolio
- Repository: https://github.com/sky7214sky72/portfolio

## Overview

##### Main Components
- API Gateway / Entry Point: Represent the main Spring Boot application (PortfolioApplication.java) that serves as the entry point.
- Module Segments:
– Word Module: Handles user word memorization and vocabulary management (controllers, domain, repository, and service under the “word” package).
– Baseball Module: Includes endpoints and domain logic for calculating baseball statistics, managed under the “baseball” package.
– Lotto Module: Provides lotto prediction functionality, including scheduled tasks, under the “lotto” package.
– Sign / Authentication Module: Manages login, OAuth integration, and token management (using JWT). This module (under “sign”) is critical for user authentication with support for multiple OAuth providers.
– Global Components: Shared annotation-based authorization, configuration of Swagger, Web config, and exception handling. These elements support cross-module features such as security, configuration, and error management.

- Presentation Layer:
– Controllers for each module (e.g., BaseballController, LottoController, WordController, SignController) provide REST APIs.
- Service Layer:
– Services (e.g., StatService, LottoService, SignService, UserService, WordService) encapsulate business logic.
- Data/Repository Layer:
– Repository interfaces (e.g., HitterRepository, LeagueRepository, WordRepository, SignRepository, etc.) abstract database interactions. Note that JPA is used with PostgreSQL (and H2 for local testing) as noted in the README.
- Domain (Model) Layer:
– Domain objects and DTOs represent the data model, with some modules having extra calculators (e.g., OpsCalculator, WrcCalculator for baseball stats).

##### External Systems and Infrastructure
- OAuth Providers: Represent external systems like Kakao (as well as Naver, Google). They interact with the sign module for authentication.
- Monitoring Tools: Include Prometheus, Promtail, Loki, and Grafana for server log monitoring and health tracking. These should be visualized as an external monitoring cluster linked to the running application.
- Docker & CI/CD: The presence of a Dockerfile, docker-compose (compose.yaml), and GitHub workflows for Gradle builds indicate containerization and CI integration.
- Database: PostgreSQL (and H2 for local dev) should be depicted as the persistent data store that interacts with all repository layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Nodes
    Client("Client (User)"):::external
    API("PortfolioApplication"):::entry
    Monitoring("Monitoring Tools (Prometheus, Grafana, Loki)"):::monitoring
    DB("Database (PostgreSQL / H2)"):::db
    DevOps("DevOps/Deployment"):::devops
    Global("Global Config & Security<br/>(Config, Exception, JWT)"):::global

    %% Entry Relationships
    Client -->|"request"| API
    API -->|"initializes"| Global

    %% Word Module Subgraph
    subgraph "Word Module"
        WordCtrl("WordController"):::controller
        WordServ("WordService"):::service
        WordRepo("WordRepository"):::repository
        WordDom("Word Domain"):::domain
    end
    API -->|"routes"| WordCtrl
    WordCtrl -->|"calls"| WordServ
    WordServ -->|"persists via"| WordRepo
    WordServ -->|"uses"| WordDom
    WordRepo -->|"reads/writes"| DB

    %% Baseball Module Subgraph
    subgraph "Baseball Module"
        BaseCtrl("BaseballController"):::controller
        StatServ("StatService"):::service
        BaseRepo("BaseballRepository"):::repository
        BaseDom("Baseball Domain<br/>(OpsCalculator, WrcCalculator)"):::domain
    end
    API -->|"routes"| BaseCtrl
    BaseCtrl -->|"calls"| StatServ
    StatServ -->|"persists via"| BaseRepo
    StatServ -->|"calculates with"| BaseDom
    BaseRepo -->|"reads/writes"| DB

    %% Lotto Module Subgraph
    subgraph "Lotto Module"
        LottoCtrl("LottoController"):::controller
        LottoServ("LottoService"):::service
        LottoRepo("LottoRepository"):::repository
        LottoSched("Lotto Scheduler"):::service
        LottoDom("Lotto Domain"):::domain
    end
    API -->|"routes"| LottoCtrl
    LottoCtrl -->|"calls"| LottoServ
    LottoServ -->|"persists via"| LottoRepo
    LottoServ -->|"schedules"| LottoSched
    LottoServ -->|"processes"| LottoDom
    LottoRepo -->|"reads/writes"| DB

    %% Sign Module Subgraph
    subgraph "Sign Module"
        SignCtrl("SignController"):::controller
        SignServ("SignService"):::service
        SignRepo("SignRepository"):::repository
        OAuthJWT("OAuth/JWT"):::security
        OAuthProv("OAuth Providers<br/>(Kakao, Naver, Google)"):::external
    end
    API -->|"routes"| SignCtrl
    SignCtrl -->|"calls"| SignServ
    SignServ -->|"persists via"| SignRepo
    SignServ -->|"handles"| OAuthJWT
    OAuthJWT -->|"integrates with"| OAuthProv
    SignRepo -->|"reads/writes"| DB

    %% Global integration to Modules (cross-cutting concerns)
    Global ---|"applies to"| WordServ
    Global ---|"applies to"| StatServ
    Global ---|"applies to"| LottoServ
    Global ---|"applies to"| SignServ

    %% Monitoring & DevOps relationships
    API ---|"metrics"| Monitoring
    API ---|"CI/CD triggers"| DevOps

    %% Click Events
    click API "https://github.com/sky7214sky72/portfolio/blob/master/src/main/java/org/example/portfolio/PortfolioApplication.java"
    click WordCtrl "https://github.com/sky7214sky72/portfolio/tree/master/src/main/java/org/example/portfolio/word"
    click BaseCtrl "https://github.com/sky7214sky72/portfolio/tree/master/src/main/java/org/example/portfolio/baseball"
    click LottoCtrl "https://github.com/sky7214sky72/portfolio/tree/master/src/main/java/org/example/portfolio/lotto"
    click SignCtrl "https://github.com/sky7214sky72/portfolio/tree/master/src/main/java/org/example/portfolio/sign"
    click Global "https://github.com/sky7214sky72/portfolio/tree/master/src/main/java/org/example/portfolio/global"
    click DevOps "https://github.com/sky7214sky72/portfolio/blob/master/.github"

    %% Styles
    classDef entry fill:#f9f,stroke:#333,stroke-width:2px;
    classDef controller fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef service fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef repository fill:#d3d3d3,stroke:#000,stroke-width:1px;
    classDef domain fill:#ffeb99,stroke:#000,stroke-width:1px;
    classDef global fill:#ffc0cb,stroke:#000,stroke-width:1px;
    classDef security fill:#ff9999,stroke:#000,stroke-width:1px;
    classDef external fill:#e6e6fa,stroke:#000,stroke-width:1px;
    classDef monitoring fill:#dda0dd,stroke:#000,stroke-width:1px;
    classDef db fill:#ffe4e1,stroke:#000,stroke-width:1px,stroke-dasharray: 4 2;
    classDef devops fill:#f0e68c,stroke:#000,stroke-width:1px;
```
