# dana-hong/nation-trivia architecture

> Architecture diagram of the GitHub repository dana-hong/nation-trivia, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dana-hong/nation-trivia
- Repository: https://github.com/dana-hong/nation-trivia

## Overview

##### Main Components Identification
The system should be represented with these key components:

A. Frontend Layer (Client-Side)
- Pages/Routes Structure
- UI Components
- State Management
- Client-Side Features

B. Server Components (Next.js App Router)
- API Routes
- Server-Side Rendering
- Data Fetching Layer

C. External Services/Data Sources
- Countries API Integration
- Static Assets

**┌─ Client Layer ─────────────────────────────┐**
- ┌─ Pages ──────┐  ┌─ Components ────────┐  │
- Home       │  │ - Header           │  │
- Countries  │  │ - Footer           │  │
- Quizzes    │  │ - UI Components    │  │
- ┘  │ - Dropdowns         │  │
- ┘  │
- ┤
- ┌─ Next.js App Router ──────────────────┐  │
- Server Components                   │  │
- API Routes                          │  │
- Data Fetching                       │  │
- ┘ │
- ┤
- ┌─ Data Layer ───────────────────────────┐ │
- Countries Data                       │ │
- Quiz Logic                          │ │
- ┘ │
- ┘

##### Key Features to Highlight

- The app's main features (Countries list, Quizzes - Capitals and Flags)
- The routing structure (/countries, /quizzes/capitals, /quizzes/flags)
- Component relationships and data flow
- Server-side vs. Client-side rendering decisions

##### Specific Implementation Details

Important architectural elements:
- Next.js App Router implementation
- Component hierarchy (shared UI components, page-specific components)
- Data flow for different features (countries list, quizzes)
- Static and dynamic routes

##### Interactions and Data Flow

- User interaction flow
- Data fetching patterns
- Component communication
- State management flow

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Pages["Pages Layer"]
        Components["Components Layer"]
        State["State Management"]
        ClientFeatures["Client Features"]
    end

    subgraph Server
        AppRouter["Next.js App Router"]
        ServerComponents["Server Components"]
        APIRoutes["API Routes"]
        DataFetching["Data Fetching Layer"]
    end

    subgraph DataLayer
        CountriesData["Countries Data"]:::data
        QuizLogic["Quiz Logic"]:::logic
        Types["Types & Interfaces"]:::types
        Utils["Utility Functions"]:::utils
    end

    subgraph Pages
        Layout["Main Layout"]:::component
        Countries["Countries Page"]:::page
        CountryDetail["Country Detail"]:::page
        CapitalsQuiz["Capitals Quiz"]:::page
        FlagsQuiz["Flags Quiz"]:::page
        ErrorPage["Error Page"]:::error
    end

    subgraph Components
        Header["Header"]:::component
        Footer["Footer"]:::component
        UILib["UI Components"]:::component
        Icons["Icons"]:::component
        CountriesList["Countries List"]:::component
        Filter["Filtering"]:::component
        Sort["Sorting"]:::component
        Dropdowns["Dropdowns"]:::component
        DataTable["Data Table"]:::component
    end

    Pages --> Components
    Components --> State
    State --> ClientFeatures
    AppRouter --> ServerComponents
    ServerComponents --> DataFetching
    DataFetching --> DataLayer
    ClientFeatures --> AppRouter

    classDef page fill:#4B83CD
    classDef component fill:#64B5F6
    classDef data fill:#FFB74D
    classDef logic fill:#FF8A65
    classDef types fill:#81C784
    classDef utils fill:#9575CD
    classDef error fill:#E57373

    click Layout "https://github.com/Dana-Hong/nation-trivia/blob/main/src/app/layout.tsx"
    click Header "https://github.com/Dana-Hong/nation-trivia/blob/main/src/components/header.tsx"
    click Footer "https://github.com/Dana-Hong/nation-trivia/blob/main/src/components/footer.tsx"
    click UILib "https://github.com/Dana-Hong/nation-trivia/tree/main/src/components/ui/"
    click Icons "https://github.com/Dana-Hong/nation-trivia/tree/main/src/components/icons/"
    click Countries "https://github.com/Dana-Hong/nation-trivia/blob/main/src/app/countries/page.tsx"
    click CountryDetail "https://github.com/Dana-Hong/nation-trivia/blob/main/src/app/countries/[countryName]/page.tsx"
    click CapitalsQuiz "https://github.com/Dana-Hong/nation-trivia/blob/main/src/app/quizzes/capitals/[region]/page.tsx"
    click FlagsQuiz "https://github.com/Dana-Hong/nation-trivia/blob/main/src/app/quizzes/flags/[region]/page.tsx"
    click CountriesList "https://github.com/Dana-Hong/nation-trivia/blob/main/src/app/countries/components/countrieslist.tsx"
    click Filter "https://github.com/Dana-Hong/nation-trivia/blob/main/src/app/countries/components/filter.tsx"
    click Sort "https://github.com/Dana-Hong/nation-trivia/blob/main/src/app/countries/components/sort.tsx"
    click Dropdowns "https://github.com/Dana-Hong/nation-trivia/blob/main/src/app/components/dropdowns/dropdown.tsx"
    click DataTable "https://github.com/Dana-Hong/nation-trivia/blob/main/src/app/countries/data-table.tsx"
    click Types "https://github.com/Dana-Hong/nation-trivia/blob/main/src/app/types.ts"
    click Utils "https://github.com/Dana-Hong/nation-trivia/blob/main/src/app/utils.ts"
    click ErrorPage "https://github.com/Dana-Hong/nation-trivia/blob/main/src/app/error.tsx"
```
