How abhishek9525-max/design3d works
Project Type & Purpose
• This is a full-stack web application that serves interactive 3D product models with secure user authentication.
• Frontend: React + Tailwind + @react-three/fiber for 3D viewing.
• Backend: Node/Express REST API + MongoDB + JWT.
File Structure & Key Components
• Frontend (frontend/):
– Public static assets: 3D models under public/ABeautifulGame, AnimatedCube, AntiqueCamera, Lantern.
– React SPA: src/ (App.jsx, pages, context/AuthContext.jsx, ThreeDViewer.jsx)
– Routing: React Router in pages/*.jsx.
– Styling & build: tailwind.config.js, postcss.config.js, vite.config.js.
– Deployment: vercel.json.
• Backend (backend/):
– server.js: Express app entry.
– Routes: routes/authRoutes.js, productRoutes.js
– Controllers: controller/authUser.js, product.js
– Middleware: authMiddleware.js (JWT guard)
– Models: User.js, Product.js (Mongoose schemas)
– Config: db.js (Mongo connection)
– Deployment: vercel.json
README Insights
• REST API endpoints for products & auth.
• JWT for stateless authentication.
• MongoDB via Mongoose.
• 3D viewer uses model URLs returned by backend or served via static public folder.
Main System Components
A. Client Layer
1. Browser / SPA (React)
• UI pages (Home, Login, Register, ThreeDViewer)
• AuthContext: holds JWT, user state, injects Authorization header
• Three.js Viewer: @react-three/fiber, @react-three/drei fetches and renders .gltf/.glb assets
B. API Layer
2. API Gateway (Express server)
• Authentication Routes (/api/auth/*): login, register
• Product Routes (/api/products/*): CRUD operations
• Middleware: authMiddleware verifies JWT
C. Data Layer
3. Database (MongoDB)
• Collections: users, products
• Mongoose models handle schema & queries
D. Static Asset Store
4. Static Hosting (Vercel static for 3D models in frontend/public)
Interactions & Data Flows
1. User → Browser → React Router →
a. If unauthenticated: Login/Register pages → POST /api/auth → Express → MongoDB → JWT → back to client.
b. If authenticated: Home page → GET /api/products → Express → MongoDB → product list (incl. asset URLs).
c. 3D Viewer: fetch glTF from static URLs on Vercel → WebGL render.
2. ProtectedRoute wrapper in React checks AuthContext before allowing access to ThreeDViewer or product management.
Architectural Patterns & Design Principles
• Layered architecture: Presentation (React), Application (Express), Data (MongoDB).
• RESTful design for APIs.
• Stateless JWT auth for horizontal scalability.
• Controller-Service-Model separation in backend.
• Component-based UI with context for cross-cutting concerns (auth).
• Static asset hosting separate from dynamic API.