# myeonggeuncho/smartpay architecture

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

- Interactive diagram: https://gitdiagram.com/myeonggeuncho/smartpay
- Repository: https://github.com/myeonggeuncho/smartpay

## Overview

##### Project type and purpose
- Smartpay is a full‑stack payment and card‑recommendation platform.
- The backend is a Spring Boot monolith providing REST and WebSocket APIs, security (JWT + OAuth2), AI integration (OpenAI/ChatGPT), SMS notifications, and persistence.
- The frontend (separate repo) is a React app that interacts via HTTP and WebSockets.
- There’s also an external “card company” server for payment‑gateway validation.

##### File structure
- Top‑level: Gradle build scripts, a single Spring Boot application (`SmartpayApplication.java`), `config`, `controller`, `service`, `repository`, `entity`, `security`, `websocket`.
- Layers follow classical MVC + service + repository + entity architecture.
- Spring Security is configured for JWT and OAuth2 (Kakao).
- Integration modules for Redis (caching or session store), ChatGPT (WebClient), CoolSMS, and WebSocket.
- Static resources under `src/main/resources/static` and Thymeleaf templates under `templates`.
- Tests mirror production packages.

##### README for additional insights
- Infra uses Docker on AWS/Ubuntu with MySQL and Redis.
- Payment flow uses WebSockets for buyer‑seller real‑time interaction.

##### Be detailed and capture essential elements
- Don’t just group as “backend”—show its major internal modules and their interactions.
- Redis cache for session or rate‑limiting next to the DB.
- OAuth2 handshake as part of the security layer.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend" 
        direction TB
        ReactBuyer["React Client (Buyer)"]:::ui
        ReactSeller["React Client (Seller)"]:::ui
    end

    %% Backend Layer
    subgraph "Backend (Spring Boot API)"
        direction TB
        SmartpayApp["SmartpayApplication"]:::app
        Controllers["Controllers"]:::app
        Services["Services"]:::app
        Repositories["Repositories"]:::app
        SecurityMod["Security Module"]:::app
        WebSocketMod["WebSocket Module"]:::app
        Configs["Configuration"]:::app
    end

    %% Data & External Layer
    subgraph "Data & External"
        direction TB
        MySQL["MySQL RDS"]:::data
        RedisCache["Redis (ElastiCache)"]:::data
        OpenAI["OpenAI / ChatGPT API"]:::ext
        CoolSMS["CoolSMS API"]:::ext
        Kakao["OAuth2 Provider (Kakao)"]:::ext
        CardCompany["Card Company Server"]:::ext
    end

    %% Frontend to Backend
    ReactBuyer -->|HTTP| Controllers
    ReactSeller -->|HTTP| Controllers
    ReactBuyer --.-|WebSocket| WebSocketMod

    %% Backend Internal Flow
    SmartpayApp --> Controllers
    SmartpayApp --> Configs
    Controllers --> Services
    Services --> Repositories
    Services --> RedisCache
    Services -.->|JWT/OAuth2| SecurityMod

    %% Specific service flows
    Controllers -->|card APIs| Services
    Controllers -->|chat APIs| Services
    Controllers -->|sms APIs| Services
    Controllers -->|payment APIs| Services
    WebSocketMod -->|real-time payment| Services

    %% External integrations
    Services -.->|calls ChatGPT| OpenAI
    Services -.->|sends SMS| CoolSMS
    SecurityMod -.->|OAuth2 login| Kakao
    Services -.->|validate transaction| CardCompany

    %% Persistence
    Repositories -->|JPA| MySQL

    %% Click events
    click SmartpayApp "https://github.com/myeonggeuncho/smartpay/blob/codebase/src/main/java/org/shds/smartpay/SmartpayApplication.java"
    click Controllers "https://github.com/myeonggeuncho/smartpay/tree/codebase/src/main/java/org/shds/smartpay/controller/"
    click Services "https://github.com/myeonggeuncho/smartpay/tree/codebase/src/main/java/org/shds/smartpay/service/"
    click Repositories "https://github.com/myeonggeuncho/smartpay/tree/codebase/src/main/java/org/shds/smartpay/repository/"
    click SecurityMod "https://github.com/myeonggeuncho/smartpay/tree/codebase/src/main/java/org/shds/smartpay/security/"
    click WebSocketMod "https://github.com/myeonggeuncho/smartpay/tree/codebase/src/main/java/org/shds/smartpay/websocket/"
    click Configs "https://github.com/myeonggeuncho/smartpay/tree/codebase/src/main/java/org/shds/smartpay/config/"

    %% Styles
    classDef ui fill:#E0F7FA,stroke:#006064,color:#006064
    classDef app fill:#E8F5E9,stroke:#1B5E20,color:#1B5E20
    classDef data fill:#FFF3E0,stroke:#E65100,color:#E65100
    classDef ext fill:#ECEFF1,stroke:#455A64,color:#455A64
```
