# miiyama/nextjs architecture

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

- Interactive diagram: https://gitdiagram.com/miiyama/nextjs
- Repository: https://github.com/miiyama/nextjs

## Overview

##### Project Type & Purpose
- This is a **front-end design system** built on **React/Next.js** to accelerate creation of landing/marketing pages.
- There is a local server (Next.js) and a documentation site (Storybook), plus build/deploy via Netlify and CI (GitHub Actions).

##### File Structure
- Top-level config: Babel, ESLint, Prettier, Tailwind, tsconfig, Netlify, GitHub Workflows.
- /public: static assets.
- /src:
- /content: page-specific content definitions (hero, content blocks).
- /library/components: Atomic-Design hierarchy.
- /library/layout & navigation: layout primitives (ColumnLayout, Meta, Navbar).
- /pages: Next.js entry points (_app.tsx, _document.tsx, index.js).
- /styles: global CSS.
- /storybook: component documentation and preview setup.
- Build scripts: figma.js (token sync), generate-stories, react-docgen.

##### Extract Key Insights from README
- Stack: React, Next.js, Material-UI, TailwindCSS, Node.js (for build scripts).
- Features: theme tokens, 8px grid, modular header/footer slots, Storybook docs.
- Roadmap: CMS integration, legacy browser support.

##### Main Components & Their Relationships
a. Next.js App
- Pages (_app, _document, index)
- Renders components from /library using content from /content
- Wraps in ThemeProvider (tokens) and global CSS
b. Design System Library
- Tokens layer → Atoms → Molecules → Organisms → PageBuilder
- Layout & Navigation primitives
c. Storybook
- Imports same library to render & document each component
d. Build & Token Sync
- figma.js syncs design tokens from Figma → updates /library/tokens
- generate-stories & react-docgen auto-generate stories/config
e. CI/CD & Deployment
- GitHub Actions triggers on push → runs lint/tests → deploy to Netlify
- Netlify serves compiled Next.js app (SSG/SSR) and Storybook (if configured)

##### Architectural Patterns & Principles
- Atomic Design hierarchy for UI reusability
- Theming via tokens for client-specific customization
- Next.js conventions for SSR/SSG, custom _app & _document
- Separation of concerns: content vs. presentation
- CI pipeline enforcing linting, testing, deploying

##### Final Checklist
- Clear component names: Next.js App, Storybook, Figma Sync, CI/CD, Netlify.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User & Browser
    subgraph "User & Browser"
        User["User"]:::frontend
        Browser["Browser"]:::frontend
    end
    User -->|interacts with| Browser

    %% Next.js App
    subgraph "Next.js App"
        NextApp["Next.js App"]:::frontend
        subgraph "Pages"
            App["_app.tsx"]:::frontend
            Doc["_document.tsx"]:::frontend
            Index["index.js"]:::frontend
        end
        NextApp --> App
        NextApp --> Doc
        NextApp --> Index
        NextApp --> ThemeProvider
        NextApp --> GlobalCSS
        NextApp --> PageBuilder
        NextApp --> ContentDefinitions
    end
    Browser -->|requests| NextApp

    %% Content Definitions
    ContentDefinitions["Content Definitions"]:::frontend

    %% Design System Library
    subgraph "Design System Library"
        Tokens["Theme & Tokens"]:::tooling
        Atoms["Atoms"]:::frontend
        Molecules["Molecules"]:::frontend
        Organisms["Organisms"]:::frontend
        Layout["Layout & Navigation"]:::frontend
        PageBuilder["PageBuilder Utility"]:::frontend
    end

    NextApp -->|uses| Atoms
    NextApp -->|uses| Molecules
    NextApp -->|uses| Organisms
    NextApp -->|wraps in| Tokens
    PageBuilder --> Organisms
    Organisms --> Molecules
    Molecules --> Atoms
    Organisms --> Layout
    NextApp --> PageBuilder

    %% Storybook
    subgraph "Storybook"
        Storybook["Storybook"]:::tooling
    end
    Storybook -->|imports| Atoms
    Storybook -->|imports| Molecules
    Storybook -->|imports| Organisms
    Storybook -->|imports| Tokens
    Storybook -->|documents| Components

    %% Figma Sync & Build Scripts
    subgraph "Token Sync & Build Tools"
        FigmaSync["figma.js"]:::tooling
        GenStories["generate-stories.mjs"]:::tooling
        DocGen["react-docgen.js"]:::tooling
        FigmaAPI["Figma API"]:::external
    end
    FigmaSync -->|fetch tokens| FigmaAPI
    FigmaSync --> Tokens
    GenStories --> Storybook
    DocGen --> Storybook

    %% CI/CD & Deployment
    subgraph "CI/CD & Deployment"
        GHActions["GitHub Actions"]:::ci
        Netlify["Netlify"]:::ci
    end
    GHActions -->|runs lint/tests/build| NextApp
    GHActions -->|builds storybook| Storybook
    GHActions --> Netlify
    Netlify -->|deploys| NextApp
    Netlify -->|hosts| Storybook

    %% Click Events
    click App "https://github.com/miiyama/nextjs/blob/master/src/pages/_app.tsx"
    click Doc "https://github.com/miiyama/nextjs/blob/master/src/pages/_document.tsx"
    click Index "https://github.com/miiyama/nextjs/blob/master/src/pages/index.js"
    click ContentDefinitions "https://github.com/miiyama/nextjs/blob/master/src/content/content.js"
    click ContentDefinitions "https://github.com/miiyama/nextjs/blob/master/src/content/hero.js"
    click ContentDefinitions "https://github.com/miiyama/nextjs/blob/master/src/content/utils/AppConfig.ts"
    click ThemeProvider "https://github.com/miiyama/nextjs/blob/master/src/library/components/tokens/ThemeProvider.js"
    click Tokens "https://github.com/miiyama/nextjs/blob/master/src/library/components/tokens/colors.js"
    click Tokens "https://github.com/miiyama/nextjs/blob/master/src/library/components/tokens/typography.js"
    click Tokens "https://github.com/miiyama/nextjs/blob/master/src/library/components/tokens/theme.js"
    click Atoms "https://github.com/miiyama/nextjs/tree/master/src/library/components/atoms"
    click Molecules "https://github.com/miiyama/nextjs/tree/master/src/library/components/molecules"
    click Organisms "https://github.com/miiyama/nextjs/tree/master/src/library/components/organisms"
    click PageBuilder "https://github.com/miiyama/nextjs/blob/master/src/library/utils/PageBuilder.js"
    click Layout "https://github.com/miiyama/nextjs/tree/master/src/library/layout"
    click Storybook "https://github.com/miiyama/nextjs/blob/master/ .storybook/main.ts"
    click FigmaSync "https://github.com/miiyama/nextjs/blob/master/figma.js"
    click GenStories "https://github.com/miiyama/nextjs/blob/master/generate-stories.mjs"
    click DocGen "https://github.com/miiyama/nextjs/blob/master/react-docgen.js"
    click GHActions "https://github.com/miiyama/nextjs/tree/master/.github/workflows"
    click Netlify "https://github.com/miiyama/nextjs/blob/master/netlify.toml"
    click GlobalCSS "https://github.com/miiyama/nextjs/blob/master/src/styles/global.css"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#000,color:#000
    classDef tooling fill:#DFFFD0,stroke:#000,color:#000
    classDef ci fill:#FFE8A0,stroke:#000,color:#000
    classDef external fill:#F0F0F0,stroke:#000,color:#000
```
