# amo0725/mahjong-pick-seat-nextjs-pwa architecture

> Architecture diagram of the GitHub repository amo0725/mahjong-pick-seat-nextjs-pwa, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amo0725/mahjong-pick-seat-nextjs-pwa
- Repository: https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa

## Overview

##### Project type and purpose
- This is a full-stack PWA web application built with Next.js (App Router).

##### File structure
- Top-level directories:
- src/app/ → Next.js App Router entry points (layout.tsx, page.tsx, globals.css)
- Configuration files for Next.js, Tailwind, PostCSS, TypeScript, ESLint, and package management indicate the build/deploy pipeline.
- next.config.ts includes PWA plugin settings, enabling service worker registration and caching policies.

##### Insights from the README
- Confirms PWA features: service worker offline fallback, manifest.json, installability.
- Tech stack: Next.js SSR/ISR, React, TypeScript, Tailwind CSS, next-pwa, next-themes, localStorage for persistence, Google Fonts, and a static asset pipeline.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Build Layer
    subgraph "Build Layer"
        direction TB
        IconScript["Icon Generation Script"]:::build
        TailwindConfig["tailwind.config.ts"]:::build
        PostCSSConfig["postcss.config.mjs"]:::build
        TSConfig["tsconfig.json"]:::build
        ESLintConfig["eslint.config.mjs"]:::build
        PackageMgmt["package.json / package-lock.json"]:::build
    end

    %% Server / Hosting Layer
    subgraph "Server / Hosting Layer"
        direction TB
        NextConfig["next.config.ts\n(next-pwa config)"]:::server
        NextServer["Next.js Server\n(SSR / ISR)"]:::server
        CDN["Static CDN"]:::server
    end

    %% Client Layer
    subgraph "Client Layer"
        direction TB
        Browser["Web Browser"]:::client
        SW["Service Worker"]:::client
        subgraph "Next.js App Router"
            direction TB
            Layout["layout.tsx"]:::client
            Page["page.tsx"]:::client
            GlobalsCSS["globals.css"]:::client
        end
        subgraph "UI Components"
            direction TB
            EastIcon["EastIcon.tsx"]:::client
            NorthIcon["NorthIcon.tsx"]:::client
            SouthIcon["SouthIcon.tsx"]:::client
            WestIcon["WestIcon.tsx"]:::client
            ThemeWrapper["ThemeTransitionWrapper.tsx"]:::client
        end
        HistoryDB["localStorage\n(draw history)"]:::clientStorage
    end

    %% Static Assets
    subgraph "Static Assets Store"
        direction TB
        Manifest["manifest.json"]:::assets
        OfflinePage["offline.html"]:::assets
        Icons["public/icons/*"]:::assets
        Sounds["draw-sound.mp3"]:::assets
    end

    %% External Services
    subgraph "External Services"
        direction TB
        GoogleFonts["Google Fonts CDN"]:::external
        ReactIcons["React Icons Package"]:::external
        Deployment["Vercel / Netlify"]:::external
    end

    %% Connections
    Browser -->|"GET HTML/JS"| NextServer
    Browser -->|"GET Static Files"| CDN
    Browser -->|"register"| SW
    SW -->|"cache fetch"| CDN
    SW -->|"serve offline fallback"| OfflinePage
    Browser -->|"read/write"| HistoryDB
    Browser -->|"fetch Manifest"| Manifest
    Browser -->|"play sound"| Sounds
    Browser -->|"load icons"| Icons
    Browser -->|"fetch fonts"| GoogleFonts
    Browser -->|"bundle icons"| ReactIcons
    NextServer -->|"serves assets"| CDN
    IconScript -->|"generates icons"| Icons
    Browser -->|"hydrates UI"| Layout
    Layout --> Page
    Page --> EastIcon & NorthIcon & SouthIcon & WestIcon & ThemeWrapper
    Page --> HistoryDB

    %% Config flows
    NextConfig --> NextServer
    TailwindConfig --> Layout
    PostCSSConfig --> Layout
    TSConfig --> Layout
    ESLintConfig --> Layout
    PackageMgmt --> Layout

    %% Click Events
    click Layout "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/src/app/layout.tsx"
    click Page "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/src/app/page.tsx"
    click GlobalsCSS "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/src/app/globals.css"
    click EastIcon "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/src/components/MahjongTile/EastIcon.tsx"
    click NorthIcon "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/src/components/MahjongTile/NorthIcon.tsx"
    click SouthIcon "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/src/components/MahjongTile/SouthIcon.tsx"
    click WestIcon "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/src/components/MahjongTile/WestIcon.tsx"
    click ThemeWrapper "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/src/components/ThemeTransitionWrapper.tsx"
    click NextConfig "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/next.config.ts"
    click Manifest "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/public/manifest.json"
    click OfflinePage "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/public/offline.html"
    click Icons "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/tree/master/public/icons"
    click Sounds "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/public/sounds/draw-sound.mp3"
    click IconScript "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/scripts/generate-icons.mjs"
    click TailwindConfig "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/tailwind.config.ts"
    click PostCSSConfig "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/postcss.config.mjs"
    click TSConfig "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/tsconfig.json"
    click ESLintConfig "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/eslint.config.mjs"
    click PackageMgmt "https://github.com/amo0725/mahjong-pick-seat-nextjs-pwa/blob/master/package.json"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef server fill:#D0FFD6,stroke:#333,stroke-width:1px
    classDef build fill:#C8FACC,stroke:#333,stroke-width:1px
    classDef assets fill:#FFE3B3,stroke:#333,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#333,stroke-width:1px
    classDef clientStorage fill:#D0E8FF,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
