# jotyy/mantine-admin architecture

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

- Interactive diagram: https://gitdiagram.com/jotyy/mantine-admin
- Repository: https://github.com/jotyy/mantine-admin

## Overview

##### Project type and purpose
- This is a modern, full-stack (primarily front-end) dashboard template built with Next.js 13 App Router.
- Purpose: Provide an admin dashboard UI with authentication, data visualization, forms, theming and state management ready to deploy on Vercel.

##### File structure
- Top-level “public/” holds static assets and a mock JSON (“public/mock/products.json”) used by the data service.
- “src/app/” contains all Next.js routes and layouts:
- (auth) group: login/register pages and a layout.
- (dashboard) group: dashboard pages (table, chart, form, settings) under a shared layout.
- Root layout and homepage.
- “src/components/”: reusable UI components (Auth forms, Dashboard cards, Navbar, Footer, Landing sections).
- “src/services/”: application data-fetching logic (currently “products” service).
- “src/hooks/”: custom React hooks.
- “src/config/”, “src/styles/”, “src/types/”: central config, theme and type definitions.
- No custom backend code—data fetched directly from mock JSON or delegated to external APIs via ky/React Query.

##### README for additional insights
- Uses Next.js (App Router), ky + React Query for data fetching, Zustand for client state, Mantine UI for styling, React Hook Form + Zod for validation.
- Deployment target: Vercel (serverless SSR/SSG).
- Testing with Jest + Testing Library; code quality via ESLint, Prettier, Husky, commitlint.

##### Diagramming the architecture
a. Main components:
- Client Browser (React in Next.js App Router)
- Next.js Serverless Runtime (Vercel Edge/Node)
- Data Service Layer (ky + React Query)
- Mock JSON API (public/mock) or External REST API
- State Management (Zustand store)
b. Relationships and interactions:
- Browser sends HTTP requests → Next.js SSR/SSG / API routes (if any)
- Next.js renders pages (Auth layout, Dashboard layout) and hydrates React
- React components call custom hooks → React Query using ky → fetch mock JSON or external API → updates cache
- Components subscribe to Zustand for global UI state (e.g. theme, user session)
- Static assets served from CDN
c. Architectural patterns / design principles:
- App Router hierarchy (nested layouts for auth vs dashboard)
- Component-driven design with atomic components
- Hooks + services abstraction for data-fetching
- Client-side state via Zustand, server data via React Query
- SSG/SSR on Vercel
d. Key technologies:
- Next.js 13 App Router
- React, React Query, ky
- Zustand
- React Hook Form + Zod
- Jest, Testing Library
- Husky, ESLint, Prettier, commitlint

##### Elements
- Clear labels: Browser, Next.js Runtime, Service Layer, Zustand Store, CDN, Mock/External API.
- Browser → Next.js Runtime (HTTP GET/POST)
- Next.js → CDN (static assets)
- React components → Service Layer (data fetch) → Mock/External API
- Service Layer → React Query Cache → React components
- Components → Zustand Store → Components
- Green for data layer (services, React Query),
- Orange for state management (Zustand),
- Grey for infrastructure (Vercel, CDN, external API).

## Diagram (Mermaid)

```mermaid
graph TB
    %% Infrastructure
    Browser["Client Browser"]:::infra
    NextRuntime["Next.js Serverless Runtime (Vercel)"]:::infra
    CDN["Static Asset CDN"]:::infra
    MockAPI["Mock JSON API"]:::infra
    ExternalAPI["External REST API"]:::infra

    %% Core App Router
    subgraph "Next.js App Router"
        Layout["Root Layout"]:::infra
        HomePage["Homepage"]:::ui
        Provider["App Provider (Zustand Init)"]:::state
        click Layout "https://github.com/jotyy/mantine-admin/blob/main/src/app/layout.tsx"
        click HomePage "https://github.com/jotyy/mantine-admin/blob/main/src/app/page.tsx"
        click Provider "https://github.com/jotyy/mantine-admin/blob/main/src/app/provider.tsx"
    end

    %% Auth Module
    subgraph "Auth Module"
        AuthLayout["Auth Layout"]:::ui
        LoginPage["Login Page"]:::ui
        RegisterPage["Register Page"]:::ui
        LoginForm["LoginForm"]:::ui
        RegisterForm["RegisterForm"]:::ui

        click AuthLayout "https://github.com/jotyy/mantine-admin/blob/main/src/app/(auth)/layout.tsx"
        click LoginPage "https://github.com/jotyy/mantine-admin/blob/main/src/app/(auth)/login/page.tsx"
        click RegisterPage "https://github.com/jotyy/mantine-admin/blob/main/src/app/(auth)/register/page.tsx"
        click LoginForm "https://github.com/jotyy/mantine-admin/blob/main/src/components/Auth/LoginForm.tsx"
        click RegisterForm "https://github.com/jotyy/mantine-admin/blob/main/src/components/Auth/RegisterForm.tsx"
    end

    %% Dashboard Module
    subgraph "Dashboard Module"
        DashboardLayout["Dashboard Layout"]:::ui
        DashboardHome["Dashboard Home"]:::ui
        ChartPage["Chart Page"]:::ui
        TablePage["Table Page"]:::ui
        FormPage["Form Page"]:::ui
        SettingsPage["Settings Page"]:::ui

        click DashboardLayout "https://github.com/jotyy/mantine-admin/blob/main/src/app/(dashboard)/dashboard/layout.tsx"
        click DashboardHome "https://github.com/jotyy/mantine-admin/blob/main/src/app/(dashboard)/dashboard/page.tsx"
        click ChartPage "https://github.com/jotyy/mantine-admin/blob/main/src/app/(dashboard)/dashboard/chart/page.tsx"
        click TablePage "https://github.com/jotyy/mantine-admin/blob/main/src/app/(dashboard)/dashboard/table/page.tsx"
        click FormPage "https://github.com/jotyy/mantine-admin/blob/main/src/app/(dashboard)/dashboard/form/page.tsx"
        click SettingsPage "https://github.com/jotyy/mantine-admin/blob/main/src/app/(dashboard)/dashboard/settings/page.tsx"

        subgraph "Dashboard Components"
            DashboardContent["DashboardContent"]:::ui
            BalanceCard["BalanceCard"]:::ui
            BalanceChart["BalanceChart"]:::ui
            OverviewCard["OverviewCard"]:::ui
            ProfileCard["ProfileCard"]:::ui
            TransactionCard["TransactionCard"]:::ui
            WelcomeCard["WelcomeCard"]:::ui

            click DashboardContent "https://github.com/jotyy/mantine-admin/blob/main/src/components/Dashboard/DashboardContent.tsx"
            click BalanceCard "https://github.com/jotyy/mantine-admin/blob/main/src/components/Dashboard/BalanceCard.tsx"
            click BalanceChart "https://github.com/jotyy/mantine-admin/blob/main/src/components/Dashboard/BalanceChart.tsx"
            click OverviewCard "https://github.com/jotyy/mantine-admin/blob/main/src/components/Dashboard/OverviewCard.tsx"
            click ProfileCard "https://github.com/jotyy/mantine-admin/blob/main/src/components/Dashboard/ProfileCard.tsx"
            click TransactionCard "https://github.com/jotyy/mantine-admin/blob/main/src/components/Dashboard/TransactionCard.tsx"
            click WelcomeCard "https://github.com/jotyy/mantine-admin/blob/main/src/components/Dashboard/WelcomeCard.tsx"
        end
    end

    %% Data Service Layer
    subgraph "Data Service Layer" 
        ProductsService["Products Service"]:::data
        ProductsTypes["Products Types"]:::data
        ReactQueryCache["React Query Cache"]:::data

        click ProductsService "https://github.com/jotyy/mantine-admin/blob/main/src/services/products/index.ts"
        click ProductsTypes "https://github.com/jotyy/mantine-admin/blob/main/src/services/products/types.ts"
        click MockAPI "https://github.com/jotyy/mantine-admin/blob/main/public/mock/products.json"
    end

    %% State Management
    ZustandStore["Zustand Store"]:::state

    %% Hooks
    UseTableHook["use-custom-table Hook"]:::data
    click UseTableHook "https://github.com/jotyy/mantine-admin/blob/main/src/hooks/use-custom-table.ts"

    %% Shared UI Components
    subgraph "Shared UI Components"
        Navbar["Navbar"]:::ui
        Footer["Footer"]:::ui
        PageContainer["PageContainer"]:::ui
        ThemeSwitcher["ThemeSwitcher"]:::ui
        DirectionSwitcher["DirectionSwitcher"]:::ui
        UserButton["UserButton"]:::ui
        StatsGroup["StatsGroup"]:::ui
        SimpleTable["SimpleTable"]:::ui
        PaginationTable["PaginationTable"]:::ui

        click Navbar "https://github.com/jotyy/mantine-admin/blob/main/src/components/Navbar/Navbar.tsx"
        click Footer "https://github.com/jotyy/mantine-admin/blob/main/src/components/Footer/Footer.tsx"
        click PageContainer "https://github.com/jotyy/mantine-admin/blob/main/src/components/PageContainer/PageContainer.tsx"
        click ThemeSwitcher "https://github.com/jotyy/mantine-admin/blob/main/src/components/ThemeSwitcher/ThemeSwitcher.tsx"
        click DirectionSwitcher "https://github.com/jotyy/mantine-admin/blob/main/src/components/DirectionSwitcher/DirectionSwitcher.tsx"
        click UserButton "https://github.com/jotyy/mantine-admin/blob/main/src/components/UserButton/UserButton.tsx"
        click StatsGroup "https://github.com/jotyy/mantine-admin/blob/main/src/components/StatsGroup/StatsGroup.tsx"
        click SimpleTable "https://github.com/jotyy/mantine-admin/blob/main/src/components/Table/SimpleTable.tsx"
        click PaginationTable "https://github.com/jotyy/mantine-admin/blob/main/src/components/Table/PaginationTable.tsx"
    end

    %% Landing Sections
    subgraph "Landing Page Sections"
        Hero["HeroSection"]:::ui
        Features["FeaturesSection"]:::ui
        CTA["CTASection"]:::ui
        Pricing["PricingSection"]:::ui
        FAQ["FAQSection"]:::ui
        SocialProof["SocialProofSection"]:::ui
        LandingContainer["LandingContainer"]:::ui

        click Hero "https://github.com/jotyy/mantine-admin/blob/main/src/components/Landing/HeroSection.tsx"
        click Features "https://github.com/jotyy/mantine-admin/blob/main/src/components/Landing/FeaturesSection.tsx"
        click CTA "https://github.com/jotyy/mantine-admin/blob/main/src/components/Landing/CTASection.tsx"
        click Pricing "https://github.com/jotyy/mantine-admin/blob/main/src/components/Landing/PricingSection.tsx"
        click FAQ "https://github.com/jotyy/mantine-admin/blob/main/src/components/Landing/FAQSection.tsx"
        click SocialProof "https://github.com/jotyy/mantine-admin/blob/main/src/components/Landing/SocialProofSection.tsx"
        click LandingContainer "https://github.com/jotyy/mantine-admin/blob/main/src/components/Landing/LandingContainer.tsx"
    end

    %% Config & Theming
    Config["Config & Theming"]:::config
    click Config "https://github.com/jotyy/mantine-admin/blob/main/src/config/index.ts"
    click Config "https://github.com/jotyy/mantine-admin/blob/main/src/styles/theme.ts"
    click Config "https://github.com/jotyy/mantine-admin/blob/main/src/styles/fonts.ts"

    %% Layout and data flows
    Browser --> NextRuntime
    NextRuntime --> Layout
    Layout --> HomePage
    Layout --> AuthLayout
    Layout --> DashboardLayout
    Layout --> LandingContainer
    NextRuntime --> CDN

    %% Component data interactions
    HomePage --> Hero
    Hero --> Features
    Hero --> CTA

    AuthLayout --> LoginPage
    AuthLayout --> RegisterPage
    LoginPage --> LoginForm
    RegisterPage --> RegisterForm

    DashboardLayout --> DashboardHome
    DashboardLayout --> ChartPage
    DashboardLayout --> TablePage
    DashboardLayout --> FormPage
    DashboardLayout --> SettingsPage

    %% UI composition
    DashboardHome --> DashboardContent
    DashboardContent --> BalanceCard
    DashboardContent --> OverviewCard
    DashboardContent --> ProfileCard
    DashboardContent --> TransactionCard
    DashboardContent --> WelcomeCard
    ChartPage --> BalanceChart
    TablePage --> SimpleTable
    TablePage --> PaginationTable

    %% Data fetching
    subgraph "Data Flow"
        Components["React Components"]:::ui
        Components --> UseTableHook
        Components -->|fetch data| ProductsService
        ProductsService -->|HTTP| MockAPI
        ProductsService -->|HTTP| ExternalAPI
        ProductsService --> ReactQueryCache
        ReactQueryCache --> Components
    end

    %% State management
    Components --> ZustandStore
    ZustandStore --> Components

    %% Styling and shared UI
    Components --> Navbar
    Components --> Footer
    Components --> PageContainer
    Components --> ThemeSwitcher
    Components --> DirectionSwitcher
    Components --> UserButton
    Components --> StatsGroup

    %% Config injection
    Components --> Config

    %% Class Definitions
    classDef ui fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef data fill:#E6FFDD,stroke:#2C662D,color:#2C662D;
    classDef state fill:#FFF4D6,stroke:#A16B00,color:#A16B00;
    classDef infra fill:#F0F0F0,stroke:#666666,color:#333333;
    classDef config fill:#FFE6F0,stroke:#B03A5B,color:#B03A5B;
```
