# narlae/refresh architecture

> Architecture diagram of the GitHub repository narlae/refresh, 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/narlae/refresh
- Repository: https://github.com/narlae/refresh

## Overview

##### Main Components

a. Frontend Layer:
- Static Resources (CSS, JS, Images)
- Thymeleaf Templates
- Client-side JavaScript modules

b. Security Layer:
- JWT Authentication/Authorization
- Custom Filters (JwtAuthenticationFilter, JwtIdPwdAuthenticationFilter)
- Security Config

c. Backend Layer (Controllers):
- Product Management
- Order Processing
- User Management
- Cart Management
- Address Management
- Board Management

d. Service Layer:
- Business Logic Services
- Payment Integration (KakaoPay)

e. Data Access Layer:
- JPA Repositories
- Domain Entities

##### Component Relationships

- User requests → Security Layer → Controllers
- Controllers → Services → Repositories
- Authentication flow with JWT tokens
- Payment processing flow

##### Specific Implementation Details

a. Authentication Flow:
- JWT token generation and validation
- Cookie management (httponly for access/refresh tokens)
- Security filters chain

b. Product Management:
- Category hierarchy
- Product listing and details
- Review system

c. Order Processing:
- Cart management
- Payment integration
- Order status tracking

d. Address Management:
- CRUD operations
- Address validation

##### External Integrations

- KakaoPay Payment Gateway
- Kakao Maps API

##### Additional Elements

Annotations for:
- Security configurations
- Database relationships
- API endpoints
- Cache layers (if any)

##### MVC Pattern
- Controllers in web package
- Views in templates
- Models in domain package

##### Repository Pattern
- Clear separation of data access layer
- JPA implementation

##### Service Layer Pattern
- Business logic encapsulation
- Transaction management

##### Security Pattern
- JWT-based authentication
- Role-based authorization

Remember to include notes about:
- Docker containerization
- MariaDB database
- Spring Security implementation
- JWT token flow
- Async operations for the review board

This will provide a comprehensive view of the system while highlighting the key architectural decisions and security implementations.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#E6F3FF,stroke:#000
    classDef security fill:#FFE6E6,stroke:#000
    classDef controller fill:#E6FFE6,stroke:#000
    classDef service fill:#FFFDE6,stroke:#000
    classDef repository fill:#F3E6FF,stroke:#000
    classDef external fill:#FFE0CC,stroke:#000

    %% Frontend Layer
    subgraph Frontend
        StaticRes["Static Resources"]:::frontend
        Templates["Thymeleaf Templates"]:::frontend
        JavaScript["Client JS"]:::frontend
        CSS["CSS Styles"]:::frontend
    end
    click StaticRes "https://github.com/narlae/reFresh/tree/main/src/main/resources/static/"
    click Templates "https://github.com/narlae/reFresh/tree/main/src/main/resources/templates/"
    click JavaScript "https://github.com/narlae/reFresh/tree/main/src/main/resources/static/js/"
    click CSS "https://github.com/narlae/reFresh/tree/main/src/main/resources/static/css/"

    %% Security Layer
    subgraph Security
        SecConfig["Security Config"]:::security
        JwtProvider["JWT Provider"]:::security
        AuthFilters["Security Filters"]:::security
        AuthManager["Auth Manager"]:::security
    end
    click SecConfig "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/config/SecurityConfig.java"
    click JwtProvider "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/web/auth/JwtTokenProvider.java"
    click AuthFilters "https://github.com/narlae/reFresh/tree/main/src/main/java/com/onlyfresh/devkurly/web/auth/filter/"
    click AuthManager "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/web/auth/CustomAuthenticationManager.java"

    %% Controllers Layer
    subgraph Controllers
        ProductCtrl["Product Controller"]:::controller
        OrderCtrl["Order Controller"]:::controller
        UserCtrl["Member Controller"]:::controller
        CartCtrl["Cart Controller"]:::controller
        AddressCtrl["Address Controller"]:::controller
        PaymentCtrl["Payment Controller"]:::controller
        LoginCtrl["Login Controller"]:::controller
    end
    click ProductCtrl "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/web/controller/ProductController.java"
    click OrderCtrl "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/web/controller/OrderController.java"
    click UserCtrl "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/web/controller/MemberController.java"
    click CartCtrl "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/web/controller/CartController.java"
    click AddressCtrl "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/web/controller/AddressController.java"
    click PaymentCtrl "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/web/controller/PaymentController.java"
    click LoginCtrl "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/web/controller/LoginController.java"

    %% Service Layer
    subgraph Services
        ProductSvc["Product Service"]:::service
        OrderSvc["Order Service"]:::service
        MemberSvc["Member Service"]:::service
        KakaoPaySvc["KakaoPay Service"]:::service
    end
    click ProductSvc "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/web/service/ProductService.java"
    click OrderSvc "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/web/service/OrderService.java"
    click MemberSvc "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/web/service/MemberService.java"
    click KakaoPaySvc "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/web/service/KakaoPay.java"

    %% Data Access Layer
    subgraph Repositories
        ProductRepo[(Product Repository)]:::repository
        OrderRepo[(Order Repository)]:::repository
        MemberRepo[(Member Repository)]:::repository
    end
    click ProductRepo "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/repository/ProductRepository.java"
    click OrderRepo "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/repository/OrderRepository.java"
    click MemberRepo "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/repository/MemberRepository.java"

    %% Domain Entities
    subgraph Domain
        ProductDomain["Product Domain"]:::repository
        OrderDomain["Order Domain"]:::repository
        MemberDomain["Member Domain"]:::repository
    end
    click ProductDomain "https://github.com/narlae/reFresh/tree/main/src/main/java/com/onlyfresh/devkurly/domain/product/"
    click OrderDomain "https://github.com/narlae/reFresh/tree/main/src/main/java/com/onlyfresh/devkurly/domain/order/"
    click MemberDomain "https://github.com/narlae/reFresh/tree/main/src/main/java/com/onlyfresh/devkurly/domain/member/"

    %% External Services
    KakaoPay{"KakaoPay Gateway"}:::external
    KakaoMaps{"Kakao Maps API"}:::external

    %% Exception Handling
    ExceptionHandler["Global Exception Handler"]:::controller
    click ExceptionHandler "https://github.com/narlae/reFresh/blob/main/src/main/java/com/onlyfresh/devkurly/web/exception/GlobalExceptionHandler.java"

    %% Relationships
    Frontend --> Security
    Security --> Controllers
    Controllers --> Services
    Services --> Repositories
    Repositories --> Domain
    PaymentCtrl --> KakaoPaySvc
    KakaoPaySvc --> KakaoPay
    AddressCtrl --> KakaoMaps

    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        Security_L["Security"]:::security
        Controller_L["Controllers"]:::controller
        Service_L["Services"]:::service
        Repository_L["Data Access"]:::repository
        External_L["External Services"]:::external
    end
```
