# ahsan-chy/next-ui-with-next-js architecture

> Architecture diagram of the GitHub repository ahsan-chy/next-ui-with-next-js, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahsan-chy/next-ui-with-next-js
- Repository: https://github.com/ahsan-chy/next-ui-with-next-js

## Overview

##### Main Components

A. Client-Side Layer
- Pages & Routes (src/app directory structure)
- Components (src/components)
- Client-State Management (src/store)
- Hooks (src/hooks)

B. Server-Side Layer
- Next.js Server Components
- API Routes (if any)
- Server-Side Rendering Logic

C. Infrastructure Layer
- Build System
- Static Asset Handling
- Font Optimization

**[Client Layer]**

- Pages (src/app)
- Home (/)
- Blog (/blog)
- NFT (/nft)

- Components
- UI Components
- Layout Components
- Shared Components

- Application Logic
- Hooks
- Store
- Services

**[Server Layer]**

- Next.js Server
- Server Components
- API Routes

**[Infrastructure]**

- Build System
- Asset Optimization

##### Specific Implementation Details

- Rectangles: Main architectural layers
- Rounded rectangles: Components and modules
- Hexagons: Services and utilities
- Diamonds: Decision points in data flow

- Blue: Client-side components
- Green: Server-side components
- Orange: Infrastructure components
- Purple: State management and data flow
- Gray: External services/APIs

##### Key Relationships to Highlight

a. App Router Structure:
- Relationship between the root layout (src/app/layout.tsx) and page components
- NextUIProvider wrapper
- Demonstrate the nested routing structure with (pages) group

b. Component Architecture:
- How UI components (Button, Input, Title) are composed
- Relationship between layout components and pages
- Theme switching mechanism

c. Data Flow:
- State management patterns using the store
- Service integration points
- Demonstrate hook usage patterns

##### Important Architectural Patterns to Emphasize

- Next.js App Router architecture
- Component composition pattern
- Server/Client component separation
- Utility-first CSS with Tailwind
- Type safety with TypeScript

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Pages["Pages & Routes"]
        RootLayout["Root Layout"]
        UIProvider["UI Provider"]
        
        subgraph Components
            UIComponents["UI Components"]
            LayoutComps["Layout Components"]
            Nav["Navigation"]
            ThemeSwitch["Theme Management"]
        end
        
        subgraph AppLogic
            Store["State Management"]
            Hooks["Custom Hooks"]
            Services["Services Layer"]
        end
        
        subgraph Config
            Fonts["Font Configuration"]
            SiteConfig["Site Configuration"]
            Types["Type Definitions"]
            Utils["Utility Functions"]
            Helpers["Helper Functions"]
        end
    end
    
    subgraph Server
        NextServer["Next.js Server"]
        ServerComps["Server Components"]
        APIRoutes["API Routes"]
    end
    
    subgraph Infrastructure
        BuildSystem["Build Configuration"]
        Assets["Asset Optimization"]
        Styles["Global Styles"]
        LayoutWrapper["Layout Wrapper"]
    end
    
    %% Relationships
    RootLayout --> UIProvider
    UIProvider --> Pages
    Pages --> Components
    Components --> AppLogic
    NextServer --> ServerComps
    NextServer --> APIRoutes
    BuildSystem --> Assets
    
    %% Component Relationships
    LayoutComps --> Nav
    LayoutComps --> ThemeSwitch
    UIProvider --> ThemeSwitch
    
    %% Configuration Flow
    Config --> AppLogic
    Config --> Components
    
    %% Infrastructure Integration
    BuildSystem --> NextServer
    LayoutWrapper --> Components
    Styles --> Components
    
    %% Click Events
    click Pages "https://github.com/ahsan-chy/next-ui-with-next-js/tree/master/src/app/(pages)"
    click RootLayout "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/src/app/layout.tsx"
    click UIProvider "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/src/app/NextUIProvider.tsx"
    click UIComponents "https://github.com/ahsan-chy/next-ui-with-next-js/tree/master/src/components/ui"
    click LayoutComps "https://github.com/ahsan-chy/next-ui-with-next-js/tree/master/src/components/layout"
    click Nav "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/src/components/layout/Navbar.tsx"
    click ThemeSwitch "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/src/components/theme-switch.tsx"
    click Store "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/src/store/index.ts"
    click Hooks "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/src/hooks/hook.tsx"
    click Services "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/src/services/index.ts"
    click Fonts "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/src/config/fonts.ts"
    click SiteConfig "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/src/config/site.ts"
    click Types "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/src/types/index.ts"
    click Utils "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/src/utils/index.ts"
    click Helpers "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/src/helpers/textFormater.ts"
    click BuildSystem "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/next.config.mjs"
    click LayoutWrapper "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/src/layouts/LayoutWrapper.tsx"
    click Styles "https://github.com/ahsan-chy/next-ui-with-next-js/blob/master/src/app/globals.css"
    
    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef client fill:#e1f5fe,stroke:#0288d1
    classDef server fill:#e8f5e9,stroke:#388e3c
    classDef infra fill:#fff3e0,stroke:#f57c00
    classDef config fill:#f3e5f5,stroke:#7b1fa2
    
    class Pages,RootLayout,UIProvider,Components,AppLogic client
    class NextServer,ServerComps,APIRoutes server
    class BuildSystem,Assets,Styles,LayoutWrapper infra
    class Config,Fonts,SiteConfig,Types,Utils,Helpers config
```
