# jiaweing/dropdrawer architecture

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

- Interactive diagram: https://gitdiagram.com/jiaweing/dropdrawer
- Repository: https://github.com/jiaweing/dropdrawer

## Overview

##### Project type and purpose
- This is a Next.js-based React component library and demo/documentation site for a single responsive UI component called “DropDrawer.”
- It ships as a drop-in replacement for shadcn/ui’s `DropdownMenu`, automatically swapping to a drawer on mobile. The repo contains:
- A Next.js app (under `app/`) for docs and live demo
- A folder of React UI components (`components/`) including the DropDrawer implementation
- Utility code (`hooks/`, `lib/`) and static assets (`public/`, `docs/`)
- Examples of usage (`examples/`) and a registry JSON for shadcn CLI (`public/r/registry.json`)

##### File structure
- Top-level directories:
- `app/` – Next.js App Router: global styles, layout, home page, structured-data metadata
- `components/` – UI building blocks:
○ `ui/` – shadcn/Radix-based primitives (`button.tsx`, `drawer.tsx`, `dropdown-menu.tsx`, etc.)
○ `mode-toggle.tsx`, `post-actions-dropdown.tsx`, `structured-data.tsx`, `theme-provider.tsx`
○ The DropDrawer component lives under `components/ui/dropdrawer.tsx` (as “dropdrawer”)
- `hooks/` – `use-mobile.ts`: breakpoint detection hook
- `lib/` – miscellaneous utilities (e.g. `utils.ts`)
- `public/` – static assets, images, docs screenshots, registry JSON (`r/dropdrawer.json`)
- `examples/` – usage snippets (TSX files)
- Config/build files: `next.config.ts`, `tsconfig.json`, `postcss.config.mjs`, `eslint.config.mjs`, lockfiles

##### README for additional insights
- DropDrawer is purely a UI component library, no backend or database.
- Exposes a parallel API to `DropdownMenu`, plus mobile drawer modes.
- Demo site shows light/dark and mobile/desktop screenshots.

##### Elements
- Clear, rectangular nodes for each module (Next.js App, Layout, DropDrawer, Hook, Primitives, Public Assets)
- Framework & Routing (Next.js) – green
- Reusable Components (DropDrawer, UI primitives) – blue
- Hooks & Utils – orange
- Static Assets & External – purple/red

##### Detail
- That `useIsMobile` toggles the rendering branch inside DropDrawer

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Next.js Framework Layer
    subgraph "Next.js Framework & Routing"
        direction TB
        Browser["Browser"]:::external
        NextApp["Next.js App Router"]:::framework
        Layout["Root Layout (app/layout.tsx)"]:::framework
        Page["Home Page (app/page.tsx)"]:::framework
        Styles["Global Stylesheet (app/globals.css)"]:::framework
    end

    %% Components Layer
    subgraph "Reusable Components"
        direction TB
        ThemeProv["ThemeProvider (components/theme-provider.tsx)"]:::components
        StrucData["Structured-Data Provider (components/structured-data.tsx)"]:::components
        DropDrawer["DropDrawer (components/ui/dropdrawer.tsx)"]:::components
        Drawer["Drawer Primitive (components/ui/drawer.tsx)"]:::components
        Dropdown["DropdownMenu Primitive (components/ui/dropdown-menu.tsx)"]:::components
    end

    %% Hooks & Utils Layer
    subgraph "Hooks & Utilities"
        direction TB
        Hook["useIsMobile Hook (hooks/use-mobile.ts)"]:::hooks
        Utils["Utility Functions (lib/utils.ts)"]:::hooks
    end

    %% Static Assets Layer
    subgraph "Static Assets & Registry"
        direction TB
        DropReg["dropdrawer.json"]:::static
        RegJSON["registry.json"]:::static
    end

    %% Examples Layer
    subgraph "Examples"
        direction TB
        Example["post-example.tsx"]:::external
    end

    %% External Services
    ExternalReg["shadcn Registry Endpoint"]:::external

    %% Connections
    Browser -->|"HTTP GET"| NextApp
    NextApp -->|"file-based routing"| Layout
    NextApp --> Styles
    Layout -->|"wraps with"| ThemeProv
    Layout -->|"wraps with"| StrucData
    Layout --> Page
    Page -->|"imports & renders"| DropDrawer
    DropDrawer -->|"hook call"| Hook
    DropDrawer -->|"imports"| Drawer
    DropDrawer -->|"imports"| Dropdown
    Hook -->|"returns boolean"| DropDrawer
    Drawer -->|"user interaction"| DropDrawer
    Dropdown -->|"user interaction"| DropDrawer
    Example -->|"imports"| DropDrawer
    DropReg -->|"served statically"| Browser
    RegJSON -->|"served statically"| ExternalReg
    ExternalReg -->|"HTTP GET"| RegJSON
    Utils -->|"util functions used by"| DropDrawer

    %% Click Events
    click NextApp "https://github.com/jiaweing/dropdrawer/tree/main/app/"
    click Styles "https://github.com/jiaweing/dropdrawer/blob/main/app/globals.css"
    click Layout "https://github.com/jiaweing/dropdrawer/blob/main/app/layout.tsx"
    click Page "https://github.com/jiaweing/dropdrawer/blob/main/app/page.tsx"
    click ThemeProv "https://github.com/jiaweing/dropdrawer/blob/main/components/theme-provider.tsx"
    click StrucData "https://github.com/jiaweing/dropdrawer/blob/main/components/structured-data.tsx"
    click DropDrawer "https://github.com/jiaweing/dropdrawer/blob/main/components/ui/dropdrawer.tsx"
    click Drawer "https://github.com/jiaweing/dropdrawer/blob/main/components/ui/drawer.tsx"
    click Dropdown "https://github.com/jiaweing/dropdrawer/blob/main/components/ui/dropdown-menu.tsx"
    click Hook "https://github.com/jiaweing/dropdrawer/blob/main/hooks/use-mobile.ts"
    click Utils "https://github.com/jiaweing/dropdrawer/blob/main/lib/utils.ts"
    click DropReg "https://github.com/jiaweing/dropdrawer/blob/main/public/r/dropdrawer.json"
    click RegJSON "https://github.com/jiaweing/dropdrawer/blob/main/public/r/registry.json"
    click Example "https://github.com/jiaweing/dropdrawer/blob/main/examples/post-example.tsx"

    %% Styles
    classDef framework fill:#d5f5e3,stroke:#2e7d32,color:#1b4332
    classDef components fill:#aed6f1,stroke:#1b4f72,color:#1b2631
    classDef hooks fill:#f9e79f,stroke:#b9770e,color:#784212
    classDef static fill:#f5b7b1,stroke:#c0392b,color:#641e16
    classDef external fill:#d7bde2,stroke:#7d3c98,color:#4a235a
```
