# rarandeyo/yumemi-frontend-coding-test architecture

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

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

## Overview

##### Project Type & Purpose
- The project is a full-stack web application built with Next.js. It focuses on visualizing the population trends of various Japanese prefectures.
- The README emphasizes that this is a coding challenge using technologies like Next.js, React, TypeScript, Tailwind CSS, and Recharts for the front end, while Hono (with Zod) is leveraged for API route handling in the server/edge layer.

##### Key Components from the File Structure
a. Frontend (Client-side/UI):
- Located in the “src/app” directory with React components for the UI. This includes “layout.tsx,” “page.tsx,” and several UI components (PopulationDashboard, PopulationGraph, PrefectureCheckboxes, SelectPopulationLabel) in the “src/components” folder.
- Styling is handled by Tailwind CSS (see “src/styles/globals.css” and “tailwind.config.ts”).
- The app uses Next.js’s App Router for page composition and dynamic routing.

b. API/Backend:
- Found under “src/app/api” where you see dynamic API routes (using [[...route]] conventions).
- The API endpoint for the population dashboard (including route handlers and tests) is defined here along with integration of Hono for handling requests at the Edge runtime.
- API request data handling is supported by API configuration (in “src/config”) and data fetching utilities (in “src/utils/yumemiApiFetcher.ts” and others).

c. Business Logic & Data Handling:
- “src/libs/apiClient.ts” and utility functions in “src/utils” help in fetching data, formatting chart data, and applying graph styles.
- Domain models and schemas are defined in “src/types” and “src/constants” to ensure correct data structure and consistency when processing population data.

d. State & Custom Hooks:
- Custom React hooks in “src/hooks” are used for managing UI state like selected prefectures or population labels, encapsulating business logic for frontend interactions.

e. Testing & Configuration:
- Every major module (app, API endpoints, components, config, hooks, utils) has associated “__tests__” directories, stressing solid unit testing practices with Vitest.
- Additional project configs include TypeScript (tsconfig.json), Biome, and PNPM configuration files along with CI workflows in “.github/workflows.”

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser/User"]:::browser

    subgraph "Frontend (Next.js & React UI)"
        subgraph "Pages"
            Layout["Layout.tsx"]:::frontend
            Page["Page.tsx"]:::frontend
            Layout --> Page
            click Layout "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/app/layout.tsx"
            click Page "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/app/page.tsx"
        end
        subgraph "UI Components"
            PD["PopulationDashboard.tsx"]:::frontend
            PG["PopulationGraph.tsx"]:::frontend
            PC["PrefectureCheckboxes.tsx"]:::frontend
            SL["SelectPopulationLabel.tsx"]:::frontend
            PD --> PG
            PG --> PC
            PC --> SL
            click PD "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/components/PopulationDashboard.tsx"
            click PG "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/components/PopulationGraph.tsx"
            click PC "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/components/PrefectureCheckboxes.tsx"
            click SL "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/components/SelectPopulationLabel.tsx"
        end
        subgraph "Styling"
            GS["globals.css"]:::frontend
            TC["tailwind.config.ts"]:::frontend
            GS --> TC
            click GS "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/styles/globals.css"
            click TC "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/tailwind.config.ts"
        end
    end

    subgraph "API Layer (Hono + Zod)"
        AR["API Routes"]:::backend
        AE["Entry Point route.ts"]:::backend
        AR --> AE
        click AR "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/app/api/[[...route]]"
        click AE "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/app/api/[[...route]]/route.ts"
    end

    subgraph "Business Logic & Data"
        AC["API Client"]:::logic
        click AC "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/libs/apiClient.ts"
        subgraph "Utility Functions"
            YF["yumemiApiFetcher.ts"]:::logic
            GCD["getChartData.ts"]:::logic
            GGS["getGraphStyle.ts"]:::logic
            GPD["getPopulationData.ts"]:::logic
            GP["getPrefectures.ts"]:::logic
            YF --> GCD
            GCD --> GGS
            GGS --> GPD
            GPD --> GP
            click YF "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/utils/yumemiApiFetcher.ts"
            click GCD "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/utils/getChartData.ts"
            click GGS "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/utils/getGraphStyle.ts"
            click GPD "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/utils/getPopulationData.ts"
            click GP "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/utils/getPrefectures.ts"
        end
        AC --> YF
    end

    subgraph "Configuration & Models"
        CFG["API Config"]:::config
        click CFG "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/config/apiConfig.ts"
        DM["Domain Models & Schemas"]:::config
        click DM "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/types/Errors.ts"
        click DM "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/types/PopulationLabelSchema.ts"
        click DM "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/types/PopulationSchema.ts"
        click DM "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/types/PrefecturesSchema.ts"
        CFG --> DM
        CC["Chart & Graph Constants"]:::config
        click CC "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/constants/chartStyles.ts"
        click CC "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/constants/graphColorPalette.ts"
        DM --> CC
    end

    subgraph "State & Custom Hooks"
        CH["Custom Hooks"]:::hooks
        click CH "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/hooks/usePrefectureCheckboxes.ts"
        click CH "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/hooks/useSelectPopulationLabel.ts"
        click CH "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/src/hooks/useSelectedPopulationData.ts"
    end

    subgraph "Testing & Project Configuration"
        TEST["Test Suites & Config Files"]:::test
        click TEST "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/tsconfig.json"
        click TEST "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/vitest.config.mts"
        click TEST "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/vitest.setup.ts"
        click TEST "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/package.json"
        click TEST "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/pnpm-lock.yaml"
        click TEST "https://github.com/rarandeyo/yumemi-frontend-coding-test/blob/main/.github/workflows/ci.yml"
    end

    %% Main Data Flow Connections
    Browser --> Layout
    Layout --> PD
    SL --> AR
    AE --> AC
    AC --> CFG
    CH --> PD

    %% Dotted arrows for testing association
    Layout --- TEST
    AR --- TEST
    AC --- TEST
    CFG --- TEST
    CH --- TEST

    %% Class Definitions
    classDef frontend fill:#cfe2f3,stroke:#000,stroke-width:1px;
    classDef backend fill:#d9ead3,stroke:#000,stroke-width:1px;
    classDef logic fill:#fff2cc,stroke:#000,stroke-width:1px;
    classDef config fill:#f4cccc,stroke:#000,stroke-width:1px;
    classDef hooks fill:#ead1dc,stroke:#000,stroke-width:1px;
    classDef test fill:#fce5cd,stroke:#000,stroke-width:1px;
    classDef browser fill:#d0e0e3,stroke:#000,stroke-width:1px;
```
