# adityayaduvanshi/meshgenx architecture

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

- Interactive diagram: https://gitdiagram.com/adityayaduvanshi/meshgenx
- Repository: https://github.com/adityayaduvanshi/meshgenx

## Overview

Step 1: Identify the project type and purpose
- MeshGenX is a single-page, full-client Next.js application (no custom backend services) that converts uploaded SVG files into interactive 3D models, lets users tweak geometry/materials/environments, previews the result in-browser using Three.js, and exports models (STL/GLB/GLTF) or high-res PNG renders.

Step 2: Analyze the file structure
- Top-level config: next.config.mjs, tsconfig.json, eslint/prettier configs.
- “app/” folder: Next.js app routes and layouts (page.tsx, layout.tsx, edit/page.tsx).
- “components/”: UI controls (geometry, material, environment), model-preview component, file-upload, export buttons, theme provider, mobile warning, etc.
- “components/ui/”: design system primitives (buttons, sliders, dialogs, toggles).
- “lib/”: core libraries – Three.js imports, exporters logic, animation values, constants, state store (Zustand), types, utilities.
- “hooks/”: reuse (debounce, mobile detection).
- “public/”: static assets (presets, environment maps).
- “styles/”: global CSS.

Step 3: Examine the README for additional insights
- Confirms in-browser SVG→3D conversion, geometry/material/environment controls, export options (3D formats + PNG), no mention of server-side transform.
- Live demo hosted on Vercel → static host/CDN.

a. Main components
1. Browser Client (Next.js/React)
2. Presentation Layer (UI Components)
3. State Management (Zustand store in lib/store.ts)
4. 3D Engine (Three.js via lib/three-imports.ts)
5. Exporters Module (lib/exporters.ts)
6. File I/O (components/file-upload.tsx)
7. Static Assets (public/ environment presets, CSS)
8. Hosting/CDN (Vercel/Next.js static build)

b. Relationships and data flow
- User uploads an SVG → FileUpload component reads file → pushes to State Store
- Control panels (geometry-controls, material-controls, environment-controls) read/write state → triggers re-render in ModelPreview
- ModelPreview queries state → builds/updates Three.js scene → renders canvas
- ExportButtons pull current scene data → call Exporters module → produce download blobs (STL/GLB/GLTF/PNG) → browser download API
- ThemeProvider/ UI controls wrap around all components for styling.

c. Architectural patterns/design principles
- Component-based UI (React)
- Unidirectional data flow (Zustand store)
- Separation of concerns: UI vs. 3D engine vs. export logic
- Static site generation + client-side hydration (Next.js app router)
- Utility/hooks for cross-cutting concerns (debounce, mobile detection)

d. Key technologies/frameworks
- Next.js App Router, React, TypeScript
- Zustand (state management)
- Three.js (3D rendering)
- three-examples GLTFExporter / STLExporter
- Vercel (hosting)
- PostCSS/Tailwind or CSS modules (styles/globals.css)

- Client-side separation: UI layer vs. rendering engine vs. exporter module.
- Static asset delivery (public folder/CDN).
- That no backend microservices are involved—everything is in‐browser.

- From FileUpload → State Store
- From Controls → State Store → ModelPreview
- From ModelPreview → Exporters → Download

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Browser Client (Next.js App Router)"
        direction TB
        Page["page.tsx"]:::frontend
        Layout["layout.tsx"]:::frontend
        EditPage["edit/page.tsx"]:::frontend
    end

    subgraph "UI Components"
        direction TB
        FileUpload["FileUpload"]:::frontend
        GeometryControls["GeometryControls"]:::frontend
        MaterialControls["MaterialControls"]:::frontend
        EnvironmentControls["EnvironmentControls"]:::frontend
        BackgroundControls["BackgroundControls"]:::frontend
        EnvironmentPresets["EnvironmentPresets"]:::frontend
        SVGModel["SVGModel"]:::frontend
        ModelPreview["ModelPreview"]:::frontend
        ExportButtons["ExportButtons"]:::frontend
        ThemeProvider["ThemeProvider"]:::frontend
        MobileWarning["MobileWarning"]:::frontend
    end

    subgraph "Design System Primitives (UI)"
        direction TB
        Button["Button"]:::frontend
        Slider["Slider"]:::frontend
        AlertDialog["AlertDialog"]:::frontend
        DropdownMenu["DropdownMenu"]:::frontend
        ThemeToggle["ThemeToggle"]:::frontend
    end

    subgraph "Core Logic"
        direction TB
        Store["Zustand Store"]:::core
        Exporters["Exporters Module"]:::core
        AnimationValues["AnimationValues"]:::core
        Constants["Constants"]:::core
        Types["Types"]:::core
        Utils["Utils"]:::core
    end

    subgraph "3D Engine"
        direction TB
        ThreeImports["Three.js Imports"]:::engine
    end

    subgraph "Hooks"
        direction TB
        Debounce["use-debounce"]:::core
        MobileDetect["use-mobile-detection"]:::core
    end

    subgraph "Static Assets & Styling"
        direction TB
        Public["Public Assets"]:::asset
        Globals["globals.css"]:::asset
    end

    Vercel["Vercel / CDN"]:::external

    FileUpload -->|upload SVG| Store
    GeometryControls -->|update| Store
    MaterialControls -->|update| Store
    EnvironmentControls -->|update| Store
    BackgroundControls -->|update| Store
    Store -->|state| ModelPreview
    ModelPreview -->|renders with| ThreeImports
    EnvironmentPresets -->|load maps| ThreeImports
    ThreeImports -->|provides scene| ModelPreview
    ExportButtons -->|request export| Exporters
    Exporters -->|return blobs| ExportButtons
    Public -->|serves assets to| Page
    Vercel -->|hosts static build| Page

    click Page "https://github.com/adityayaduvanshi/meshgenx/blob/master/app/page.tsx"
    click Layout "https://github.com/adityayaduvanshi/meshgenx/blob/master/app/layout.tsx"
    click EditPage "https://github.com/adityayaduvanshi/meshgenx/blob/master/app/edit/page.tsx"
    click FileUpload "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/file-upload.tsx"
    click GeometryControls "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/controls/geometry-controls.tsx"
    click MaterialControls "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/controls/material-controls.tsx"
    click EnvironmentControls "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/controls/environment-controls.tsx"
    click BackgroundControls "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/controls/background-controls.tsx"
    click EnvironmentPresets "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/environment-presets.tsx"
    click SVGModel "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/svg-model.tsx"
    click ModelPreview "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/model-preview.tsx"
    click ExportButtons "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/export-buttons.tsx"
    click ThemeProvider "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/theme-provider.tsx"
    click MobileWarning "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/mobile-warning.tsx"
    click Button "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/ui/button.tsx"
    click Slider "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/ui/slider.tsx"
    click AlertDialog "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/ui/alert-dialog.tsx"
    click DropdownMenu "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/ui/dropdown-menu.tsx"
    click ThemeToggle "https://github.com/adityayaduvanshi/meshgenx/blob/master/components/ui/theme-toggle.tsx"
    click Store "https://github.com/adityayaduvanshi/meshgenx/blob/master/lib/store.ts"
    click ThreeImports "https://github.com/adityayaduvanshi/meshgenx/blob/master/lib/three-imports.ts"
    click Exporters "https://github.com/adityayaduvanshi/meshgenx/blob/master/lib/exporters.ts"
    click AnimationValues "https://github.com/adityayaduvanshi/meshgenx/blob/master/lib/animation-values.ts"
    click Constants "https://github.com/adityayaduvanshi/meshgenx/blob/master/lib/constants.ts"
    click Types "https://github.com/adityayaduvanshi/meshgenx/blob/master/lib/types.ts"
    click Utils "https://github.com/adityayaduvanshi/meshgenx/blob/master/lib/utils.ts"
    click Debounce "https://github.com/adityayaduvanshi/meshgenx/blob/master/hooks/use-debounce.ts"
    click MobileDetect "https://github.com/adityayaduvanshi/meshgenx/blob/master/hooks/use-mobile-detection.ts"
    click Public "https://github.com/adityayaduvanshi/meshgenx/tree/master/public/"
    click Globals "https://github.com/adityayaduvanshi/meshgenx/blob/master/styles/globals.css"

    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef core fill:#90EE90,stroke:#333,stroke-width:1px
    classDef engine fill:#FFA500,stroke:#333,stroke-width:1px
    classDef asset fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef external fill:#E6E6FA,stroke:#333,stroke-width:1px
```
