# kimchanho97/sunsuwedding_fe architecture

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

## Overview

##### Main Components
- Frontend Application: Representing the overall React SPA. This includes:
- The “public” folder (manifest, service worker, PWA offline page) that enables PWA and mobile-like features.
- The “src” directory that contains all the core source code.
- UI / Presentation Layer: Include:
- Layouts (e.g., MainLayout, RequiredAuthLayout, etc.)
- Pages (organized under /pages like Chat, Login, Portfolio Detail, Quotation, Review, etc.)
- Components grouped by feature (chat, portfolio, review, etc.)
- Common components (atoms, modals, bottom sheets) that provide shared UI/UX.
- APIS & Data Layer:
- The APIs folder (modules for chat, favorite, payments, portfolio, quotation, review, user) which encapsulates interactions with backend REST endpoints.
- Integration with React Query for data fetching and caching.
- Global State Management:
- Redux store and slices (e.g., userSlice, bottomSheetSlice) to manage application state.
- Redux Persist ensuring state persistence.
- Custom Hooks & Utils:
- Several hooks (e.g., usePreventRefresh, useDefaultErrorHandler, useOpenBottomSheet) that control browser behavior and UI state.
- Utilities for common constant and conversion logic.
- External Services & Integrations:
- Payment Integration: Toss Payments integrated for transaction processing.
- File/Image Handling: Client-side image compression (using compressorjs) and direct uploads to AWS S3.
- Third-party libraries: Axios (for API requests), React Router (client routing), Tailwind CSS (styling), and Material UI.

##### Relationships and Interactions
- Data Flow:
- The UI components trigger actions (e.g., submitting a portfolio or initiating a chat) which then call API methods.
- API methods (in the “src/apis” folder) invoke backend endpoints and return results managed by React Query.
- External Integration Flow:
- File Upload flow: Image compression on client → Form data submission → Direct upload to S3.
- UI State & Feedback:
- Global bottom sheets and modals (managed via Redux and custom hooks) present error, confirmation and informational UIs triggered by various events.

##### Architectural Patterns
- Component-Based Design & Separation of Concerns:
- Clearly split into presentation (components), routing/layouts, business logic (API, hooks, utils), and state (Redux).
- PWA and Responsive Design:
- Leverage service worker and manifest from the “public” folder.
- Transactional Integrity:
- Payment processing and error handling strategies are built with transaction based operations (as discussed in the README).

##### Relevant Technologies and Libraries
- React (for rendering UI)
- Redux and Redux Persist (global state management)
- React Query (data fetching and caching)
- React Router (routing between pages)
- Tailwind CSS & Material UI (styling)
- Axios (network requests)
- CompressorJS (image compression)
- Toss Payments & AWS S3 (external services)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Layer: Client Browser with PWA support
    Browser("Client Browser (PWA)"):::browser

    %% Frontend Application
    subgraph "Frontend Application"
        direction TB
        Public("Public Assets (manifest.json, service-worker.js, offline.html)"):::pwa
        Src("Core Source Code (React SPA)"):::code
    end

    Browser --> Public
    Browser --> Src

    %% UI / Presentation Layer
    subgraph "UI / Presentation Layer"
        direction TB
        Layouts("Layouts (MainLayout, RequiredAuthLayout, RootLayout, ...)"):::layouts
        Pages("Pages"):::pages
        Components("Components (Feature-specific & Common UI)"):::components
    end

    Src --> Layouts
    Src --> Pages
    Src --> Components

    %% Detailed Pages Structure
    subgraph "Pages"
        direction TB
        ChatPages("Chat Pages"):::pages
        CommonPages("Common Pages (Login, NotFound, Signup, PaymentComplete, PaymentFail)"):::pages
        CreatePortfolio("Create Portfolio"):::pages
        FavoritePages("Favorite Pages"):::pages
        MainProfile("Main & Profile Pages"):::pages
        PortfolioDetail("Portfolio Detail"):::pages
        PortfoliosSearch("Portfolios & Search"):::pages
        QuotationPages("Quotation Pages"):::pages
        ReviewPages("Review Pages"):::pages
    end

    %% Detailed Components Structure
    subgraph "Components"
        direction TB
        ChatComponents("Chat Components"):::components
        PortfolioDetailComp("Portfolio Detail Components"):::components
        QuotationComponents("Quotation Components"):::components
        ReviewComponents("Review Components"):::components
        FavoriteComponents("Favorite Components"):::components
        CommonComponents("Common UI Components (Atoms, Modal, BottomSheet, ImageUploadZone)"):::components
    end

    %% API & Data Layer
    subgraph "API & Data Layer"
        direction TB
        APIModules("API Modules (chat.js, favorite.js, payments.js, portfolio.js, quotation.js, review.js, user.js)"):::apis
        ReactQuery("React Query Integration"):::apis
    end

    Src --> APIModules
    APIModules --> ReactQuery

    %% Global State Management
    subgraph "Global State (Redux)"
        direction TB
        ReduxStore("Redux Store Setup"):::redux
        ReduxSlices("Redux Slices (userSlice, bottomSheetSlice)"):::redux
        ReduxAtoms("Redux Atoms (portfolio, quotation, etc.)"):::redux
    end

    Src --> ReduxStore
    ReduxStore --> ReduxSlices
    ReduxStore --> ReduxAtoms

    %% Custom Hooks & Utils
    subgraph "Custom Hooks & Utils"
        direction TB
        CustomHooks("Custom Hooks (usePreventRefresh, useDefaultErrorHandler, useOpenBottomSheet)"):::hooks
        Utilities("Utilities (constants, convert)"):::hooks
    end

    Src --> CustomHooks
    Src --> Utilities

    %% External Services & Integrations
    subgraph "External Services"
        direction TB
        TossPayments("Toss Payments"):::external
        AWS_S3("AWS S3 (Image Uploads)"):::external
        ThirdParty("Third-Party Libraries (Axios, React Router, Tailwind CSS, Material UI)"):::external
    end

    %% Interactions and Data Flow
    Pages -->|"triggers"| APIModules
    Components -->|"triggers"| APIModules
    Components -->|"updates"| ReduxStore
    CustomHooks -->|"assists"| Components
    ReduxStore -->|"updates state to"| Layouts

    %% External interactions
    APIModules -->|"Payment API"| TossPayments
    APIModules -->|"File Upload API"| AWS_S3
    Components -->|"initiates Payment"| TossPayments
    CommonComponents -->|"handles image upload"| AWS_S3

    %% Click Events Mapping
    click Public "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/public/"
    click Src "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/"
    click Layouts "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/layouts/"
    click ChatPages "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/pages/chat/"
    click CommonPages "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/pages/common/"
    click CreatePortfolio "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/pages/createportfolio/"
    click FavoritePages "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/pages/favorite/"
    click MainProfile "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/pages/main/"
    click PortfolioDetail "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/pages/portfoliodetail/"
    click PortfoliosSearch "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/pages/portfolios/"
    click QuotationPages "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/pages/quotation/"
    click ReviewPages "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/pages/review/"
    click ChatComponents "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/components/chat/"
    click PortfolioDetailComp "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/components/portfoliodetail/"
    click QuotationComponents "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/components/quotation/"
    click ReviewComponents "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/components/review/"
    click FavoriteComponents "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/components/favorite/"
    click CommonComponents "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/components/common/"
    click APIModules "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/apis/"
    click ReduxStore "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/store/"
    click ReduxSlices "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/store/slices/"
    click ReduxAtoms "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/store/atoms/"
    click CustomHooks "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/hooks/"
    click Utilities "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/utils/"
    click TossPayments "https://github.com/kimchanho97/sunsuwedding_fe/blob/main/src/apis/payments.js"
    click CommonComponents "https://github.com/kimchanho97/sunsuwedding_fe/tree/main/src/components/common/bottomsheet/"
    click CommonComponents "https://github.com/kimchanho97/sunsuwedding_fe/blob/main/src/components/common/ImageUploadZone.jsx"

    %% Styles
    classDef browser fill:#f7f7a1,stroke:#333,stroke-width:2px;
    classDef pwa fill:#a1d6f7,stroke:#333,stroke-width:2px;
    classDef code fill:#9ef7a1,stroke:#333,stroke-width:2px;
    classDef layouts fill:#f7a1d6,stroke:#333,stroke-width:2px;
    classDef pages fill:#f7d6a1,stroke:#333,stroke-width:2px;
    classDef components fill:#d6a1f7,stroke:#333,stroke-width:2px;
    classDef apis fill:#a1f7d6,stroke:#333,stroke-width:2px;
    classDef redux fill:#f7a1a1,stroke:#333,stroke-width:2px;
    classDef hooks fill:#a1f7f7,stroke:#333,stroke-width:2px;
    classDef external fill:#f7f7f7,stroke:#333,stroke-width:2px;
```
