# hana-fe/developer-mbti architecture

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

- Interactive diagram: https://gitdiagram.com/hana-fe/developer-mbti
- Repository: https://github.com/hana-fe/developer-mbti

## Overview

##### Project Type and Purpose
- This is a single-page, front-end React application (built with Vite) that runs entirely in the browser.
- It delivers an MBTI-style “developer personality” test: users input their name, answer 12 questions, see a loading animation with a D3 network graph, and receive a final result they can share or download.

##### File Structure Analysis
- src/
- component/UI: reusable presentation components (Button, AppInput, Progress, NetworkGraph, QuestionText/Image)
- component/layout: Layout and Header (site shell)
- page: top-level “route” pages (Home, InputPage, Test, Loading, Result)
- hook: custom React hooks (useDeviceInfo, useInternalRouter)
- constant: static data (questions, paths, results, animal images)
- lib: small utility functions (copyToClipboard, handleDownload)
- image: assets (animal illustrations, cursor, question images)
- Vite config, index.html, public/, CSS under style/, plus GitHub Actions workflows for CI/CD.

##### README Insights
- Confirms tech stack: React 19, React Router 7, D3.js for visualization, Notistack for toasts, Vite for bundling, CSS for styling.
- Hosted via Amplify (static site deployment) with a GitHub Actions CI/CD pipeline.

##### Key Components
a. User’s Browser (client)
b. CDN/Hosting Layer (AWS Amplify or static-site host)
c. React SPA Bundle (index.html + JS/CSS assets)
d. React Router (route resolution)
e. Page Components (Home, InputPage, Test, Loading, Result)
f. UI Components (Buttons, Inputs, Progress bar, NetworkGraph)
g. Custom Hooks & State Management (useDeviceInfo, internal routing state)
i. Utility Libraries (copyToClipboard, handleDownload)
j. External Libraries (D3.js rendering engine, Notistack notifications)
k. CI/CD Pipeline (GitHub repository → GitHub Actions → AWS Amplify)

##### Relationships and Data Flows
- Browser “GET” to CDN → serves static HTML/JS/CSS.
- React Router loads the correct Page component.
- Page components import UI components and constants to render questions or results.
- User actions (e.g., answering questions) update in-memory state via hooks.
- On “Loading” page, NetworkGraph uses D3 to animate the interim visualization.
- On “Result” page, result logic (constants + computed scores) drives the final display; lib functions handle “copy” and “download”.
- Share/download logic executes entirely client-side.
- Code changes to main branch trigger GitHub Actions, which build and deploy to Amplify.

##### Architectural Patterns and Principles
- Component-based UI: separation between presentational (UI folder) and container pages.
- Single source of truth for static data (constant folder).
- Custom hooks for cross-cutting concerns (device info, routing).
- Assets and styles decoupled from logic.
- CI/CD as code: workflows defined in .github/workflows.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Request Flow
    Browser["User Browser"]:::browser
    CDN["CDN / AWS Amplify"]:::hosting
    ReactBundle["React SPA Bundle<br/>(index.html + JS/CSS)"]:::bundle
    Router["React Router"]:::router
    subgraph "Page Components" 
        direction TB
        Home["Home"]:::pages
        InputPage["InputPage"]:::pages
        Test["Test"]:::pages
        Loading["Loading"]:::pages
        Result["Result"]:::pages
    end
    subgraph "Layout Components"
        direction TB
        Layout["Layout"]:::ui
        Header["Header"]:::ui
    end
    subgraph "UI Components"
        direction TB
        Button["Button"]:::ui
        AppInput["AppInput"]:::ui
        Progress["Progress Bar"]:::ui
        NetworkGraph["NetworkGraph"]:::ui
        QuestionText["QuestionText"]:::ui
        QuestionImage["QuestionImage"]:::ui
    end
    subgraph "Custom Hooks & State"
        direction TB
        DeviceInfo["useDeviceInfo"]:::hook
        InternalRouter["useInternalRouter"]:::hook
    end
    subgraph "Data Constants"
        direction TB
        Questions["Questions"]:::constant
        ResultLogic["Result Logic"]:::constant
        Paths["Paths"]:::constant
        Animals["Animal Icons/Data"]:::constant
        ConstIndex["Constants Index"]:::constant
    end
    subgraph "Utility Libraries"
        direction TB
        Copy["copyToClipboard"]:::lib
        Download["handleDownload"]:::lib
        LibIndex["Lib Index"]:::lib
    end
    subgraph "External Libraries"
        direction TB
        D3["D3.js"]:::external
        Notistack["Notistack"]:::external
        ReactRouterLib["React Router"]:::external
        ViteLib["Vite"]:::external
    end
    subgraph "Static Assets & Styles"
        direction TB
        Public["public/"]:::assets
        Images["src/image/"]:::assets
        Styles["style/"]:::assets
    end
    subgraph "CI/CD Pipeline"
        direction TB
        GitHub["GitHub Repo"]:::ci
        Actions["GitHub Actions"]:::ci
        AmplifyDeploy["AWS Amplify Deploy"]:::ci
    end

    %% Flow connections
    Browser -->|GET assets| CDN
    CDN -->|serve bundle| ReactBundle
    ReactBundle -->|initialize| Router
    Router -->|route navigation| Home
    Router --> InputPage
    Router --> Test
    Router --> Loading
    Router --> Result

    Home --> Layout
    InputPage --> Layout
    Test --> Layout
    Loading --> Layout
    Result --> Layout

    Layout --> Header
    Layout --> Button
    Layout --> AppInput

    Test --> Progress
    Loading --> NetworkGraph
    Home --> QuestionText
    Home --> QuestionImage
    Result --> Progress
    Result --> Button

    Button --> Copy
    Button --> Download
    NetworkGraph --> D3
    Header --> Notistack

    Home --> Questions
    Test --> Questions
    Result --> ResultLogic
    Router --> Paths
    Result --> Animals
    Paths --> ConstIndex

    ReactBundle --> DeviceInfo
    ReactBundle --> InternalRouter
    ReactBundle --> LibIndex

    ReactBundle --> ViteLib
    ReactBundle --> ReactRouterLib

    CDN --> AmplifyDeploy
    GitHub --> Actions
    Actions --> AmplifyDeploy

    %% Click events
    click ReactBundle "https://github.com/hana-fe/developer-mbti/blob/develop/index.html"
    click ReactBundle "https://github.com/hana-fe/developer-mbti/blob/develop/src/main.jsx"
    click ReactBundle "https://github.com/hana-fe/developer-mbti/blob/develop/vite.config.js"
    click Router "https://github.com/hana-fe/developer-mbti/blob/develop/src/page/Route.jsx"
    click Home "https://github.com/hana-fe/developer-mbti/blob/develop/src/page/Home.jsx"
    click InputPage "https://github.com/hana-fe/developer-mbti/blob/develop/src/page/InputPage.jsx"
    click Test "https://github.com/hana-fe/developer-mbti/blob/develop/src/page/Test.jsx"
    click Loading "https://github.com/hana-fe/developer-mbti/blob/develop/src/page/Loading.jsx"
    click Result "https://github.com/hana-fe/developer-mbti/blob/develop/src/page/Result.jsx"
    click Layout "https://github.com/hana-fe/developer-mbti/blob/develop/src/component/layout/Layout.jsx"
    click Header "https://github.com/hana-fe/developer-mbti/blob/develop/src/component/layout/Header.jsx"
    click Button "https://github.com/hana-fe/developer-mbti/blob/develop/src/component/UI/Button.jsx"
    click AppInput "https://github.com/hana-fe/developer-mbti/blob/develop/src/component/UI/AppInput.jsx"
    click Progress "https://github.com/hana-fe/developer-mbti/blob/develop/src/component/UI/Progress.jsx"
    click NetworkGraph "https://github.com/hana-fe/developer-mbti/blob/develop/src/component/UI/NetworkGraph.jsx"
    click QuestionText "https://github.com/hana-fe/developer-mbti/blob/develop/src/component/UI/QuestionText.jsx"
    click QuestionImage "https://github.com/hana-fe/developer-mbti/blob/develop/src/component/UI/QuestionImage.jsx"
    click DeviceInfo "https://github.com/hana-fe/developer-mbti/blob/develop/src/hook/useDeviceInfo.js"
    click InternalRouter "https://github.com/hana-fe/developer-mbti/blob/develop/src/hook/useInternalRouter.js"
    click Questions "https://github.com/hana-fe/developer-mbti/blob/develop/src/constant/Question.js"
    click ResultLogic "https://github.com/hana-fe/developer-mbti/blob/develop/src/constant/result.js"
    click Paths "https://github.com/hana-fe/developer-mbti/blob/develop/src/constant/path.js"
    click Animals "https://github.com/hana-fe/developer-mbti/blob/develop/src/constant/animals.js"
    click ConstIndex "https://github.com/hana-fe/developer-mbti/blob/develop/src/constant/index.js"
    click Copy "https://github.com/hana-fe/developer-mbti/blob/develop/src/lib/copyToClipboard.js"
    click Download "https://github.com/hana-fe/developer-mbti/blob/develop/src/lib/handleDownload.js"
    click LibIndex "https://github.com/hana-fe/developer-mbti/blob/develop/src/lib/index.js"
    click Public "https://github.com/hana-fe/developer-mbti/tree/develop/public/"
    click Images "https://github.com/hana-fe/developer-mbti/tree/develop/src/image/"
    click Styles "https://github.com/hana-fe/developer-mbti/tree/develop/style/"
    click Actions "https://github.com/hana-fe/developer-mbti/blob/develop/.github/workflows/check-on-pr.yml"

    %% Styles
    classDef browser fill:#E0F7FA,stroke:#00838F,stroke-width:2px
    classDef hosting fill:#E8F5E9,stroke:#2E7D32,stroke-width:2px
    classDef bundle fill:#FFF9C4,stroke:#F9A825,stroke-width:2px
    classDef router fill:#ECEFF1,stroke:#546E7A,stroke-width:2px,stroke-dasharray: 5 5
    classDef pages fill:#BBDEFB,stroke:#1976D2,stroke-width:2px
    classDef ui fill:#F3E5F5,stroke:#8E24AA,stroke-width:2px
    classDef hook fill:#FFF3E0,stroke:#EF6C00,stroke-width:2px
    classDef constant fill:#E1F5FE,stroke:#0288D1,stroke-width:2px
    classDef lib fill:#F1F8E9,stroke:#7CB342,stroke-width:2px
    classDef external fill:#ECEFF1,stroke:#546E7A,stroke-width:2px,stroke-dasharray: 2 2
    classDef assets fill:#FAFAFA,stroke:#B0BEC5,stroke-width:2px
    classDef ci fill:#FFEBEE,stroke:#C62828,stroke-width:2px
```
