# kea-chunsam/playus-fe architecture

> Architecture diagram of the GitHub repository kea-chunsam/playus-fe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kea-chunsam/playus-fe
- Repository: https://github.com/kea-chunsam/playus-fe

## Overview

##### Main Components
a. Browser / Client
- React application (static HTML/CSS/JS served to the browser)
- React Router (AppRouter.js)
- Context providers (AuthContext, SearchContext)
- UI modules:
- Pages (src/pages/**)
- Reusable Components (src/components/**)
- Utilities (src/utils/**)
- Build tool & config: package.json, tailwind.config.js, postcss.config.js
- Testing: jest.config.js, __mocks__, src/App.test.js, src/setupTests.js
b. CI/CD Pipeline
- GitHub Actions workflows (.github/workflows/*.yml)
- Automated test → build → deploy to GitHub Pages (or S3/Netlify, per deploy.yml)
c. External Services
- OAuth Providers: Kakao Login, Naver Login
- Backend API(s):
- PlayUs-user-service (Spring Boot + Redis)
- Other microservices (party-service, diary-service, community-service, etc.)
- Docker + Redis for session/cache (local/dev environment)

##### Relationships & Data Flows
a. Client Startup Flow
1. User hits index.html (public/index.html) served from CDN/static host
2. React bundle loads (src/index.js → AppRouter)
3. React Router dispatches to Page components → loads data via utility API calls
b. Auth Flow
1. User clicks “Login” (LoginHeader component)
2. Front-end redirects to Kakao/Naver OAuth endpoints
3. OAuth responses returned to front-end redirect URI
4. Front-end exchanges code for JWT via PlayUs-user-service
5. AuthContext stores token, subsequent API calls include Authorization header
c. Data Fetching Flow
- Page components & child components call backend REST endpoints (e.g., GET /matches, POST /diary)
- Responses rendered in components (GameCard, RecordsAccordion, etc.)
d. Real-Time Chat (optional)
- Chatting page may open WebSocket connection to chat server (if implemented)

##### Architectural Patterns
- Single-Page Application
- Component-Based UI (atoms, molecules, organisms)
- Declarative Routing (React Router)
- Context API for global state
- CSS Modules & Tailwind for scoped styling
- CI/CD via GitHub Actions

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Browser / Client" 
        direction TB
        B1["public/index.html"]:::frontend
        B2["src/index.js"]:::frontend
        B3["src/App.css"]:::frontend
        B1 --> B2
        B2 --> B4
        B4["AppRouter (src/routes/AppRouter.js)"]:::frontend
        B4 --> UI
    end

    subgraph "UI Layer" 
        direction TB
        UI["src/pages/"]:::frontend
        UC["src/components/"]:::frontend
    end

    subgraph "Routing & State" 
        direction TB
        R1["AuthContext (src/utils/AuthContext.js)"]:::frontend
        R2["SearchContext (src/components/SearchContext.js)"]:::frontend
        B4 --> R1
        B4 --> R2
    end

    subgraph "Utilities" 
        direction TB
        U1["CropImage (src/utils/CropImage.js)"]:::frontend
        U2["teamInfoMap (src/utils/teamInfoMap.js)"]:::frontend
    end

    subgraph "Public Assets" 
        direction TB
        P1["public/"]:::frontend
    end

    subgraph "Env Config" 
        direction TB
        E1["env-config/local.env.json.example"]:::frontend
    end

    subgraph "Build & Testing" 
        direction TB
        Bcfg["package.json"]:::frontend
        T1["tailwind.config.js"]:::frontend
        T2["postcss.config.js"]:::frontend
        TS1["jest.config.js"]:::frontend
        TS2["__mocks__/fileMock.js"]:::frontend
        TS3["src/App.test.js"]:::frontend
        TS4["src/setupTests.js"]:::frontend
    end

    B2 --> UI
    B2 --> R1
    B2 --> R2
    B2 --> U1
    B2 --> U2
    B2 --> P1
    B2 --> E1
    B2 --> Bcfg
    B2 --> T1
    B2 --> T2
    B2 --> TS1
    B2 --> TS2
    B2 --> TS3
    B2 --> TS4

    %% Backend and External Services
    subgraph "External Services" 
        direction TB
        O1["Kakao OAuth"]:::external
        O2["Naver OAuth"]:::external
        API1["PlayUs-user-service API"]:::backend
        API2["party-service API"]:::backend
        API3["diary-service API"]:::backend
        API4["community-service API"]:::backend
        WS["Chat WebSocket"]:::backend
    end

    R1 -->|redirect to OAuth| O1
    R1 -->|redirect to OAuth| O2
    R1 -->|exchange code for JWT| API1
    UI -->|API calls| API2
    UI -->|API calls| API3
    UI -->|API calls| API4
    UI -->|WebSocket connect| WS

    %% Local Dev
    subgraph "Local Dev Environment" 
        direction TB
        D1["Spring Boot + Redis"]:::backend
    end
    UI -->|"Dev only"| D1

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline" 
        direction TB
        GH1[".github/workflows/deploy.yml"]:::cicd
        GH2[".github/workflows/*.yml"]:::cicd
    end
    Bcfg --> GH2
    TS1 --> GH2
    GH2 -->|build/test/deploy| GH1
    GH1 -->|deploy static assets| B1

    %% Click Events
    click B1 "https://github.com/kea-chunsam/playus-fe/blob/develop/public/index.html"
    click B2 "https://github.com/kea-chunsam/playus-fe/blob/develop/src/index.js"
    click B3 "https://github.com/kea-chunsam/playus-fe/blob/develop/src/App.css"
    click B4 "https://github.com/kea-chunsam/playus-fe/blob/develop/src/routes/AppRouter.js"
    click R1 "https://github.com/kea-chunsam/playus-fe/blob/develop/src/utils/AuthContext.js"
    click R2 "https://github.com/kea-chunsam/playus-fe/blob/develop/src/components/SearchContext.js"
    click UI "https://github.com/kea-chunsam/playus-fe/tree/develop/src/pages/"
    click UC "https://github.com/kea-chunsam/playus-fe/tree/develop/src/components/"
    click U1 "https://github.com/kea-chunsam/playus-fe/blob/develop/src/utils/CropImage.js"
    click U2 "https://github.com/kea-chunsam/playus-fe/blob/develop/src/utils/teamInfoMap.js"
    click Bcfg "https://github.com/kea-chunsam/playus-fe/blob/develop/package.json"
    click T1 "https://github.com/kea-chunsam/playus-fe/blob/develop/tailwind.config.js"
    click T2 "https://github.com/kea-chunsam/playus-fe/blob/develop/postcss.config.js"
    click E1 "https://github.com/kea-chunsam/playus-fe/blob/develop/env-config/local.env.json.example"
    click TS1 "https://github.com/kea-chunsam/playus-fe/blob/develop/jest.config.js"
    click TS2 "https://github.com/kea-chunsam/playus-fe/blob/develop/__mocks__/fileMock.js"
    click TS3 "https://github.com/kea-chunsam/playus-fe/blob/develop/src/App.test.js"
    click TS4 "https://github.com/kea-chunsam/playus-fe/blob/develop/src/setupTests.js"
    click GH1 "https://github.com/kea-chunsam/playus-fe/blob/develop/.github/workflows/deploy.yml"
    click GH2 "https://github.com/kea-chunsam/playus-fe/blob/develop/.github/workflows/*.yml"

    %% Styles
    classDef frontend fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1
    classDef backend fill:#C8E6C9,stroke:#1B5E20,color:#1B5E20
    classDef external fill:#FFE0B2,stroke:#E65100,color:#E65100
    classDef cicd fill:#E0E0E0,stroke:#424242,color:#424242
```
