# megh-bari/pattern-craft architecture

> Architecture diagram of the GitHub repository megh-bari/pattern-craft, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/megh-bari/pattern-craft
- Repository: https://github.com/megh-bari/pattern-craft

## Overview

##### Project Type and Purpose
- This is a full-stack web application built with Next.js 14 (App Router), TypeScript, and Tailwind CSS.
- Its purpose is to present a curated library of CSS background patterns and gradients, allow live preview in the browser, and enable copy-and-paste of CSS/Tailwind code snippets.
- It’s deployed as a monolithic application on Vercel, serving both static assets and dynamic server-rendered pages.

##### File Structure
- Top-level:
- next.config.ts, postcss.config.mjs, eslint.config.mjs, tsconfig.json → build & lint config
- public/ → static assets (pattern preview images, favicon, etc.)
- components.json → metadata for UI components (shadcn/ui)
- src/app/ → Next.js App directory (routes, layout, global styles, React Server Components)
- components/ → page-level UI components (Navbar, Hero, PatternShowcase, Footer, ThemeProvider)
- utils/patterns.ts → pattern definition objects (id, name, CSS style, code)
- types/pattern.ts → TypeScript interfaces for patterns
- globals.css → global Tailwind and custom CSS
- layout.tsx → root layout, includes ThemeProvider and common UI
- page.tsx → home page that orchestrates Hero and PatternShowcase
- src/components/ui/ → shared, low-level UI primitives (Badge, Button) provided by shadcn/ui.
- src/lib/utils.ts → general utilities (e.g., formatting, helpers).
- package.json & lock → dependencies (next, react, tailwindcss, etc.)

##### Extract Insights from README
- Architecture is monolithic but layered: presentation layer (React pages & components), data layer (patterns stored in code), utility layer (helpers).
- No external databases or APIs; patterns are loaded from an in-repo JSON/TS file.
- Deployed on Vercel with CDN for static assets and SSR endpoints.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    Browser["Client Browser"]:::frontend
    Browser -->|"HTTP Request /"| CDN

    %% CDN Layer
    CDN["Vercel Edge CDN"]:::infra
    CDN -->|"Forward Request"| NextServer

    %% Server Layer
    subgraph "Next.js Server (SSR/SSG)" 
        direction TB
        NextServer["Next.js Server"]:::backend
        NextServer -->|"Read Patterns"| PatternData
        NextServer -->|"Serve Static"| StaticAssets
        NextServer -->|"Render React RSC"| ReactServerComponents
        ReactServerComponents["React Server Components"]:::backend
        ReactServerComponents -->|"Includes Layout and Pages"| Layout
        ReactServerComponents --> Page
        ReactServerComponents --> ThemeProvider
        ReactServerComponents --> Navbar
        ReactServerComponents --> Hero
        ReactServerComponents --> PatternShowcase
        ReactServerComponents --> Footer
        ReactServerComponents --> UIPrimitives
        ReactServerComponents --> Utils
        Layout["Page Layout"]:::backend
        Page["Home Page Content"]:::backend
        ThemeProvider["ThemeProvider"]:::backend
        Navbar["Navbar Component"]:::backend
        Hero["Hero Component"]:::backend
        PatternShowcase["PatternShowcase Component"]:::backend
        Footer["Footer Component"]:::backend
        subgraph "UI Primitives"
            direction TB
            Badge["Badge (UI Primitive)"]:::ui
            Button["Button (UI Primitive)"]:::ui
        end
        UIPrimitives --> Badge
        UIPrimitives --> Button
        Utils["General Utility Functions"]:::util
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        PatternData["Pattern Data Source"]:::data
        PatternTypes["Pattern Type Definitions"]:::data
    end
    PatternData --> PatternTypes

    %% Static Assets
    StaticAssets["Static Assets (public/images)"]:::static

    %% Build & Config
    subgraph "Build & Config"
        direction TB
        NextConfig["next.config.ts"]:::config
        PostCSSConfig["postcss.config.mjs"]:::config
        ESLintConfig["eslint.config.mjs"]:::config
        TSConfig["tsconfig.json"]:::config
        ComponentsMeta["components.json"]:::config
        NextConfig --> PostCSSConfig
        PostCSSConfig --> TSConfig
        ComponentsMeta --> TSConfig
    end

    %% Response Flow
    NextServer -->|"HTML + JS Bundle"| Browser
    Browser -->|"Hydration"| PatternShowcase

    %% Click Events
    click Layout "https://github.com/megh-bari/pattern-craft/blob/main/src/app/layout.tsx"
    click Page "https://github.com/megh-bari/pattern-craft/blob/main/src/app/page.tsx"
    click Navbar "https://github.com/megh-bari/pattern-craft/blob/main/src/app/components/navbar.tsx"
    click Hero "https://github.com/megh-bari/pattern-craft/blob/main/src/app/components/hero.tsx"
    click PatternShowcase "https://github.com/megh-bari/pattern-craft/blob/main/src/app/components/pattern-showcase.tsx"
    click Footer "https://github.com/megh-bari/pattern-craft/blob/main/src/app/components/footer.tsx"
    click ThemeProvider "https://github.com/megh-bari/pattern-craft/blob/main/src/app/components/theme-provider.tsx"
    click PatternData "https://github.com/megh-bari/pattern-craft/blob/main/src/app/utils/patterns.ts"
    click PatternTypes "https://github.com/megh-bari/pattern-craft/blob/main/src/app/types/pattern.ts"
    click Badge "https://github.com/megh-bari/pattern-craft/blob/main/src/components/ui/badge.tsx"
    click Button "https://github.com/megh-bari/pattern-craft/blob/main/src/components/ui/button.tsx"
    click Utils "https://github.com/megh-bari/pattern-craft/blob/main/src/lib/utils.ts"
    click StaticAssets "https://github.com/megh-bari/pattern-craft/tree/main/public/images"
    click NextConfig "https://github.com/megh-bari/pattern-craft/blob/main/next.config.ts"
    click PostCSSConfig "https://github.com/megh-bari/pattern-craft/blob/main/postcss.config.mjs"
    click ESLintConfig "https://github.com/megh-bari/pattern-craft/blob/main/eslint.config.mjs"
    click TSConfig "https://github.com/megh-bari/pattern-craft/blob/main/tsconfig.json"
    click ComponentsMeta "https://github.com/megh-bari/pattern-craft/blob/main/components.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0091EA,stroke-width:2px
    classDef infra fill:#ECEFF1,stroke:#607D8B,stroke-width:2px
    classDef backend fill:#E8F5E9,stroke:#2E7D32,stroke-width:2px
    classDef data fill:#FFF3E0,stroke:#FB8C00,stroke-width:2px
    classDef static fill:#FCE4EC,stroke:#C2185B,stroke-width:2px
    classDef ui fill:#F3E5F5,stroke:#6A1B9A,stroke-width:2px
    classDef util fill:#E1F5FE,stroke:#0288D1,stroke-width:2px
    classDef config fill:#EDE7F6,stroke:#5E35B1,stroke-width:2px
```
