How rajand2510/roomcraft works
Project Type and Purpose
• This is a full-stack e-commerce web application named “Roomcraft” that allows users to browse 3D home-decor models and preview them in AR before purchase.
• The frontend is built with React, Tailwind CSS, Three.js, React-xr, and Spline for 3D/AR experiences. The backend is a Node.js/Express REST API with MongoDB as the database and JWT for authentication. Razorpay handles payments.
File Structure Analysis
• Top-level directories:
• client/ – React app, with src/ (components, pages, contexts), public/ (static 3D models, images, draco decoder)
• server/ – Node/Express code (routes, models, config, auth, JWT, DB connection)
• Configuration: vite.config.js, tailwind.config.js, .env variables in server/config.js, vercel.json for deployment.
• Models: dozens of .gltf/.glb files under client/public/models served as static assets.
• API service in client/components/api/apiService.jsx calls server endpoints in server/routes.
README Insights
• Lists core features: 3D view, AR integration, secure checkout via Razorpay, JWT-based auth.
• Technology stack summary for frontend, backend, database, and payment gateway.
a. Main Components
• Client Browser / React App
– 3D Renderer (Three.js)
– AR Module (React-xr / WebXR)
– UI Components (Tailwind)
– Auth Context (JWT)
– Cart & Checkout Flows
• Static Asset Store
– 3D Models & Textures hosted under public/
– Draco decoder scripts for model compression
• Backend API (Node.js + Express)
– Authentication & Authorization (JWT)
– Product, Cart, Order REST endpoints
– Payment integration endpoint for Razorpay
• Database (MongoDB Atlas or local)
– Collections: Users, Products, CartOrders, UserOrders, OrderDone
• External Service
– Razorpay Payment Gateway
b. Relationships & Interactions
1. User opens browser → React App served via CDN or Node static files.
2. React App fetches product metadata from REST API.
3. 3D Models loaded directly from static asset store (/public/models).
4. AR module invokes device WebXR to render model in real environment.
5. On login/signup, credentials posted to Auth API → JWT returned → stored in client context.
6. Cart operations call CartOrderRoutes, updating CartOrders in MongoDB.
7. Checkout calls backend payment endpoint → backend communicates with Razorpay API → payment confirmation.
8. Order is persisted in OrderDone collection.
c. Architectural Patterns & Principles
• Layered architecture: UI layer (React) → API layer (Express) → Data layer (MongoDB).
• Separation of concerns: rendering logic, state management (contexts), and API service centralized.
• RESTful API design with resource-based routes.
• JWT stateless authentication for scalability.
• Static content delivery for heavy assets (3D models).
d. Key Technologies & Libraries
• React + Vite for fast dev and build.
• Tailwind CSS for utility-first styling.
• Three.js + React-XR for 3D and AR.
• Node.js + Express for backend.
• Mongoose models under server/models.
• JWT for tokens.
• Razorpay SDK for payments.