# kimjunpyo/buyte architecture

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

- Interactive diagram: https://gitdiagram.com/kimjunpyo/buyte
- Repository: https://github.com/kimjunpyo/buyte

## Overview

##### Main Components Identification
- Frontend Client: This includes the React application (pages, components, hooks, redux state management, routing, etc.). Emphasize that it handles multiple presentation layers (main, custom design, store list/detail pages, chat interface, map view, user input forms, etc.) and makes REST API calls.
- Backend Server: Built with Spring Boot. This layer includes multiple modules or packages such as:
- Member Management & Authentication: Covers user registration, JWT-based security, OAuth with Google, and related Spring Security configuration.
- Product & Customization Module: Manages standard products and custom product design including image uploads handled via S3 integration.
- Order & Payment Processing: Handles carts, orders, and integrates with iamport for payment simulation.
- Chat Service: Provides real-time chat capabilities using WebSocket (as indicated by the “chat/config” and related controller, DTO, and entity classes).
- Store & Ingredient Management: Supports listing stores, mapping to locations, managing ingredients, and logging.
- Database: Likely a MySQL instance that persists member, order, product, store, and chat data.
- External Services:
- AWS S3 for image storage (as seen by the S3Service and S3Config classes).
- Payment gateways (iamport/KakaoPay simulation).
- Kakao Map API for geolocation and mapping features.

##### Relationships and Data Flow
- The Frontend (React) communicates with the Backend (Spring Boot) through RESTful APIs for most operations like user authentication, product and order management.
- Real-time features (chat) are facilitated via WebSockets where a dedicated controller/service handles message broadcasting (e.g., using Redis-based pub/sub as indicated by RedisPublisher and RedisSubscriber).
- Authentication and authorization flow involves JWT, with several filters (JwtAuthenticationFilter, JwtVerificationFilter) and associated security configuration.
- Custom product design components on the frontend interact with backend endpoints to save or update designs, then store images using the S3 integration.
- And store components fetch geolocation and store detail data from the backend (possibly with additional external map API integration).

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear division between frontend and backend responsibilities.
- MVC Pattern on the server side: Controllers (for handling requests), Services (business logic), and Repositories/Entities (for database interaction).
- Use of WebSockets and Redis for chat functionality.
- API-driven design: All communications between frontend and backend occur over well-defined APIs.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Frontend Cluster
    subgraph "Frontend (React Client)"
        ReactClient["React Client\n(React, TypeScript, Redux)"]:::frontend
        ChatInterface["Chat Interface"]:::frontend
        CustomDesign["Custom Product Design"]:::frontend
        OrderPayment["Order & Payment"]:::frontend
        MemberAuthFE["Member Management"]:::frontend
        StoreMap["Store & Map"]:::frontend

        ReactClient --> ChatInterface
        ReactClient --> CustomDesign
        ReactClient --> OrderPayment
        ReactClient --> MemberAuthFE
        ReactClient --> StoreMap
    end

    %% Backend Cluster
    subgraph "Backend (Spring Boot Server)"
        SpringBoot["Spring Boot Server\n(Java, Spring Boot)"]:::backend
        ChatBackend["Chat Service"]:::backend
        ProductBackend["Product & Customization"]:::backend
        OrderBackend["Order Processing"]:::backend
        AuthConfig["Auth Config"]:::backend
        MemberManagement["Member Management"]:::backend
        StoreBackend["Store Management"]:::backend
        IngredientBackend["Ingredient Management"]:::backend
        S3Integration["AWS S3 Integration"]:::backend
        RedisPubSub["Redis Pub/Sub"]:::backend

        SpringBoot --> ChatBackend
        SpringBoot --> ProductBackend
        SpringBoot --> OrderBackend
        SpringBoot --> AuthConfig
        SpringBoot --> MemberManagement
        SpringBoot --> StoreBackend
        SpringBoot --> IngredientBackend
        SpringBoot --> S3Integration

        ChatBackend --> RedisPubSub
    end

    %% Database and External Services
    DB["MySQL Database"]:::database
    S3["AWS S3"]:::external
    Payment["Payment Gateway\n(iamport/KakaoPay)"]:::external
    KakaoMaps["Kakao Maps API"]:::external

    %% Connections from Backend to Database and External Services
    SpringBoot -->|"CRUD"| DB
    ProductBackend -->|"ImageUpload"| S3
    OrderBackend -->|"ProcessPayment"| Payment
    StoreBackend -->|"Geolocation"| KakaoMaps

    %% Direct Frontend to Backend Interactions
    ChatInterface -->|"WebSocket"| ChatBackend
    CustomDesign -->|"REST"| ProductBackend
    OrderPayment -->|"REST"| OrderBackend
    MemberAuthFE -->|"REST"| AuthConfig
    MemberAuthFE -->|"REST"| MemberManagement
    StoreMap -->|"REST"| StoreBackend
    StoreMap -->|"Map"| KakaoMaps

    %% Overall API Flow
    ReactClient -->|"API"| SpringBoot

    %% Click Event Bindings for Frontend Components
    click ReactClient "https://github.com/kimjunpyo/buyte/tree/main/client/"
    click ChatInterface "https://github.com/kimjunpyo/buyte/tree/main/client/src/pages/Chat"
    click ChatInterface "https://github.com/kimjunpyo/buyte/blob/main/client/src/api/chatApis.ts"
    click CustomDesign "https://github.com/kimjunpyo/buyte/tree/main/client/src/components/Custom"
    click CustomDesign "https://github.com/kimjunpyo/buyte/blob/main/client/src/api/customApis.ts"
    click OrderPayment "https://github.com/kimjunpyo/buyte/tree/main/client/src/pages/order"
    click OrderPayment "https://github.com/kimjunpyo/buyte/blob/main/client/src/api/orderApis.ts"
    click MemberAuthFE "https://github.com/kimjunpyo/buyte/tree/main/client/src/pages/users"
    click MemberAuthFE "https://github.com/kimjunpyo/buyte/blob/main/client/src/api/authApis.ts"
    click MemberAuthFE "https://github.com/kimjunpyo/buyte/blob/main/client/src/api/memberApis.ts"
    click StoreMap "https://github.com/kimjunpyo/buyte/tree/main/client/src/pages/store"
    click StoreMap "https://github.com/kimjunpyo/buyte/tree/main/client/src/pages/map"

    %% Click Event Bindings for Backend Components
    click ChatBackend "https://github.com/kimjunpyo/buyte/tree/main/server/src/main/java/com/buyte/chat"
    click ProductBackend "https://github.com/kimjunpyo/buyte/tree/main/server/src/main/java/com/buyte/product"
    click OrderBackend "https://github.com/kimjunpyo/buyte/tree/main/server/src/main/java/com/buyte/order"
    click AuthConfig "https://github.com/kimjunpyo/buyte/tree/main/server/src/main/java/com/buyte/member/auth"
    click MemberManagement "https://github.com/kimjunpyo/buyte/tree/main/server/src/main/java/com/buyte/member"
    click StoreBackend "https://github.com/kimjunpyo/buyte/tree/main/server/src/main/java/com/buyte/store"
    click IngredientBackend "https://github.com/kimjunpyo/buyte/tree/main/server/src/main/java/com/buyte/ingredient"
    click S3Integration "https://github.com/kimjunpyo/buyte/tree/main/server/src/main/java/com/buyte/config"

    %% Styling
    classDef frontend fill:#C6E2FF,stroke:#333,stroke-width:2px;
    classDef backend fill:#FFDEAD,stroke:#333,stroke-width:2px;
    classDef database fill:#FFE4E1,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
    classDef external fill:#E6E6FA,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
```
