How adityayaduvanshi/meshgenx works
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