# huynhnguyen1906/yumemi-frontend-test architecture

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

- Interactive diagram: https://gitdiagram.com/huynhnguyen1906/yumemi-frontend-test
- Repository: https://github.com/huynhnguyen1906/yumemi-frontend-test

## Overview

##### Main Components
- Frontend Application (Next.js): Represented by the “src/app” directory. This is where the Next.js layout and routing take place (e.g., layout.tsx and page.tsx).
- UI Components: Found largely in “src/components”. This includes:
‒ Layout components (in components/layout, e.g., AppLayout.tsx)
‒ Domain-specific UI components (in components/prefecture, e.g., PrefectureCheckbox.tsx and PrefectureSelector.tsx)
- API Layer: Located in “src/apis”. For instance, getPrefectures.ts and the corresponding TypeScript types in getPrefectures.ts.
- Utility Libraries: “src/libs” contains helper functions like apiClient.ts which are utilized by API calls.
- Styling: “src/styles” holds global styles (GlobalStyles.scss, _variables.scss) plus component-specific SCSS modules.
- Testing: “src/__tests__” holds tests for both APIs and components, illustrating that the project has a dedicated test suite.

##### Understand Relationships and Interactions
- The Next.js app (in “src/app”) serves as the entry point. It loads the overall application layout and determines routing.
- The page components (in the “app” directory) then incorporate UI components from “src/components” to build the user interface.
- Within these components, API calls (from “src/apis”) might be made using the client in “src/libs/apiClient.ts” to fetch data, such as prefecture data.
- Styling from the “src/styles” folder is applied within the components, ensuring a consistent look and feel.
- The test suite in “src/__tests__” is used to verify the behavior of both API logic and UI components, adhering to Test-Driven Development principles.

##### Important Architectural Patterns or Principles
- Component-Based Architecture: Following React’s paradigm, breaking down the UI into reusable, testable components.
- Separation of Concerns: Distinct directories for APIs, libraries, and UI components.
- Modern Next.js Features: The “app” directory structure suggests that the project is leveraging Next.js’s latest routing and layout capabilities.
- Testing Strategy: The presence of Jest configuration files and tests implies a strong emphasis on unit and integration testing.
- Consistent Styling: Use of SCSS modules allows for scoped CSS on a per-component basis.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        A["Next.js Application (src/app)"]:::runtime
        B["Layout Components (AppLayout)"]:::runtime
        C["PrefectureCheckbox"]:::runtime
        D["PrefectureSelector"]:::runtime
    end

    %% Business Layer
    subgraph "Business Layer"
        E["API Layer (getPrefectures & types)"]:::runtime
        F["Utility Libraries (apiClient)"]:::runtime
    end

    %% Styling
    subgraph "Styling"
        G["Global Styles (SCSS)"]:::runtime
        H["Component Styles (SCSS Modules)"]:::runtime
    end

    %% Testing
    subgraph "Testing"
        I["Testing (Jest tests)"]:::dev
    end

    %% Development Tools & Configurations
    subgraph "Development Tools"
        J["Dev Tools (ESLint, Prettier, Jest)"]:::dev
    end

    %% Connections - Presentation Layer to UI Components
    A -->|"renders"| B
    A -->|"renders"| C
    A -->|"renders"| D

    %% Domain components fetch data from API Layer
    C -->|"fetches"| E
    D -->|"fetches"| E

    %% API Layer uses Utility Libraries
    E -->|"uses"| F

    %% Styling applied to components
    A -->|"styled"| G
    B -->|"styled"| H
    C -->|"styled"| H
    D -->|"styled"| H

    %% Testing relationships
    B -->|"tested"| I
    C -->|"tested"| I
    D -->|"tested"| I
    E -->|"tested"| I

    %% Development Tools support the application
    A -->|"devsupport"| J

    %% Click Events
    click A "https://github.com/huynhnguyen1906/yumemi-frontend-test/tree/dev/src/app"
    click B "https://github.com/huynhnguyen1906/yumemi-frontend-test/blob/dev/src/components/layout/AppLayout.tsx"
    click C "https://github.com/huynhnguyen1906/yumemi-frontend-test/blob/dev/src/components/prefecture/PrefectureCheckbox.tsx"
    click D "https://github.com/huynhnguyen1906/yumemi-frontend-test/blob/dev/src/components/prefecture/PrefectureSelector.tsx"
    click E "https://github.com/huynhnguyen1906/yumemi-frontend-test/blob/dev/src/apis/getPrefectures.ts"
    click F "https://github.com/huynhnguyen1906/yumemi-frontend-test/blob/dev/src/libs/apiClient.ts"
    click G "https://github.com/huynhnguyen1906/yumemi-frontend-test/blob/dev/src/styles/GlobalStyles.scss"
    click H "https://github.com/huynhnguyen1906/yumemi-frontend-test/blob/dev/src/styles/components/AppLayout.module.scss"
    click I "https://github.com/huynhnguyen1906/yumemi-frontend-test/blob/dev/src/__tests__/apis/getPrefectures.test.ts"
    click J "https://github.com/huynhnguyen1906/yumemi-frontend-test/blob/dev/eslint.config.mjs"

    %% Styles
    classDef runtime fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef dev fill:#ffe0b2,stroke:#e65100,stroke-width:2px;
```
