How hana-fe/developer-mbti works
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.