# hsuifang/senior-memes-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/hsuifang/senior-memes-frontend
- Repository: https://github.com/hsuifang/senior-memes-frontend

## Overview

##### Project type and purpose
- This is a single-page, full-frontend application built with React (TypeScript) and Vite.
- It’s a design tool (“長輩圖”) that lets users upload photos, place and style text in real time, and is integrated with LINE LIFF for authentication or messaging.

##### File structure
- Top-level configuration and infra:
- Dockerfile / Dockerfile.dev / docker-compose.yml(.dev) / nginx.conf → Docker-based build & deployment containers.
- .env.sample → runtime environment variables.
- Source code under src/:
- src/main.tsx + index.html → Vite entry point.
- src/lib/ → API client (axios + interceptors), validation, test utils.
- src/pages/home/ → core feature: components (Canvas, TextEditor, PhotoUploader, Controls), hooks (useHomeLogic, useCanvas…), service/api.ts.
- src/layout/ → app-wide layout, header, modal.
- src/components/, src/theme/, src/store/ → shared UI elements, styling, state (LIFF store).
- src/routes/ → route definitions including a PrivateRoute for LIFF-secured pages.

##### Integrations and runtime flow
- Dev mode: Vite serves the SPA on localhost:3000.
- Production: SPA is built, served by an Nginx container.
- External dependencies: LINE LIFF SDK (loaded in the browser), plus any backend REST APIs invoked via src/lib/api / src/pages/home/service/api.ts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    User["User"]:::external

    %% Dev & Prod Environments
    subgraph "Dev Environment" 
        Vite["Vite Dev Server\n(pnpm run dev)"]:::infra
    end
    subgraph "Prod Environment"
        Nginx["Nginx Server"]:::infra
    end

    %% Browser Container
    subgraph "Browser (React SPA)" 
        %% Entry Points
        Main["Vite Entry Point\nsrc/main.tsx"]:::frontend
        HTML["HTML Template\nindex.html"]:::frontend

        %% UI Layer
        subgraph "UI Layer"
            Layout["Application Layout\nLayout.tsx"]:::frontend
            Header["Header Component\nHeader.tsx"]:::frontend
            Modal["Modal Component\nModal.tsx"]:::frontend
            HomeContainer["Home Page Container\nHome.tsx"]:::frontend
            HomeIndex["Home Page Index\nindex.tsx"]:::frontend
            subgraph "Components"
                Canvas["Design Canvas\nDesignCanvas.tsx"]:::frontend
                TextOverlay["Canvas Text Overlay\nTextOverlay.tsx"]:::frontend
                PhotoUploader["Photo Uploader\nPhotoUploader.tsx"]:::frontend
                TextEditorComp["Text Editor\nTextEditor.tsx"]:::frontend
                Toolbar["Editor Toolbar\nEditorToolbar.tsx"]:::frontend
                ItemsPicker["Items Picker\nItemsPicker.tsx"]:::frontend
                TextConst["TextEditor Constants\nTextEditorConstant.ts"]:::frontend
                TextStyle["TextEditor Styles\nTextEditorStyled.tsx"]:::frontend
                ControlPanel["Control Panel\nControlPanel.tsx"]:::frontend
                InstructionList["Instruction List\nInstructionList.tsx"]:::frontend
                SliderComp["Slider Component\nSlider.tsx"]:::frontend
                SliderStyle["Slider Styles\nSliderStyled.tsx"]:::frontend
                LoadingOverlay["Shared Loading Overlay\nLoadingOverlay.tsx"]:::frontend
            end
        end

        %% Data Layer
        subgraph "Data Layer"
            Hooks["Home Feature Hooks"]:::frontend
            Store["LIFF State Store\nuseLiffStore.ts"]:::data
            APIClient["Global HTTP Client\napi.ts"]:::frontend
            Interceptor["HTTP Interceptors\ninterceptor.ts"]:::frontend
            HomeService["Home Service API\napi.ts"]:::frontend
        end
    end

    %% External Dependencies
    LIFFSDK["LINE LIFF SDK"]:::external
    RESTAPI["Backend REST API"]:::external

    %% Infrastructure Files
    Dockerfile["Dockerfile"]:::infra
    DockerfileDev["Dockerfile.dev"]:::infra
    Compose["docker-compose.yml\nand .dev"]:::infra
    NginxConf["nginx.conf"]:::infra
    EnvSample[".env.sample"]:::infra
    ViteConfig["vite.config.ts"]:::infra
    TSDecl["vite-env.d.ts"]:::infra

    %% Connections
    User --> Main
    Main --> HTML
    Main --> Layout
    Layout --> Header
    Layout --> Modal
    Layout --> HomeContainer
    HomeContainer --> HomeIndex

    HomeIndex --> Canvas
    Canvas --> TextOverlay
    HomeIndex --> PhotoUploader
    HomeIndex --> TextEditorComp
    TextEditorComp --> Toolbar
    TextEditorComp --> ItemsPicker
    TextEditorComp --> TextConst
    TextEditorComp --> TextStyle
    HomeIndex --> ControlPanel
    HomeIndex --> InstructionList
    HomeIndex --> SliderComp
    SliderComp --> SliderStyle
    Components --> LoadingOverlay

    Canvas --> Hooks
    TextOverlay --> Hooks
    PhotoUploader --> Hooks
    TextEditorComp --> Hooks
    ControlPanel --> Hooks
    InstructionList --> Hooks
    SliderComp --> Hooks

    Hooks --> Store
    Hooks --> APIClient
    APIClient --> Interceptor
    APIClient --> HomeService
    HomeService --> RESTAPI

    Browser --> LIFFSDK
    Browser --> RESTAPI

    Vite --> Browser
    Nginx --> Browser

    %% Click Events
    click Main "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/main.tsx"
    click HTML "https://github.com/hsuifang/senior-memes-frontend/blob/main/index.html"
    click Layout "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/layout/Layout.tsx"
    click Header "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/layout/components/Header.tsx"
    click Modal "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/layout/components/Modal.tsx"
    click HomeContainer "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/Home.tsx"
    click HomeIndex "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/index.tsx"
    click Canvas "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/components/DesignCanvas/DesignCanvas.tsx"
    click TextOverlay "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/components/DesignCanvas/TextOverlay.tsx"
    click PhotoUploader "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/components/PhotoUploader.tsx"
    click TextEditorComp "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/components/TextEditor/TextEditor.tsx"
    click Toolbar "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/components/TextEditor/EditorToolbar.tsx"
    click ItemsPicker "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/components/TextEditor/ItemsPicker.tsx"
    click TextConst "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/components/TextEditor/TextEditorConstant.ts"
    click TextStyle "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/components/TextEditor/TextEditorStyled.tsx"
    click ControlPanel "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/components/ControlPanel.tsx"
    click InstructionList "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/components/InstructionList.tsx"
    click SliderComp "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/components/Slider/Slider.tsx"
    click SliderStyle "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/components/Slider/SliderStyled.tsx"
    click LoadingOverlay "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/components/LoadingOverlay.tsx"
    click HomeService "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/pages/home/service/api.ts"
    click APIClient "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/lib/api.ts"
    click Interceptor "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/lib/interceptor.ts"
    click Store "https://github.com/hsuifang/senior-memes-frontend/blob/main/src/store/useLiffStore.ts"
    click Dockerfile "https://github.com/hsuifang/senior-memes-frontend/tree/main/Dockerfile"
    click DockerfileDev "https://github.com/hsuifang/senior-memes-frontend/blob/main/Dockerfile.dev"
    click Compose "https://github.com/hsuifang/senior-memes-frontend/blob/main/docker-compose.yml"
    click NginxConf "https://github.com/hsuifang/senior-memes-frontend/blob/main/nginx.conf"
    click EnvSample "https://github.com/hsuifang/senior-memes-frontend/blob/main/.env.sample"
    click ViteConfig "https://github.com/hsuifang/senior-memes-frontend/blob/main/vite.config.ts"
    click TSDecl "https://github.com/hsuifang/senior-memes-frontend/blob/main/vite-env.d.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef infra fill:#F0F0F0,stroke:#888888,color:#333333
    classDef external fill:#FFE0B2,stroke:#FF9800,color:#E65100
    classDef data fill:#C8E6C9,stroke:#388E3C,color:#2E7D32
```
