A complete e-commerce platform with 3D product customization featuring a modern frontend and robust Node.js backend.
StyleForge3D is a full-stack application that allows users to customize products in real-time 3D, select colors, add stickers, and place orders.
Frontend:
- HTML5, CSS3, JavaScript (Vanilla)
- Three.js for 3D rendering
- OrbitControls for 3D interaction
- LocalStorage for cart persistence
Backend:
- Node.js & Express.js
- MongoDB with Mongoose
- JWT Authentication
- RESTful API architecture
- CORS enabled for frontend communication
styleforge3d-fullstack/
β
βββ frontend/ # Client-side application
β βββ index.html # Landing page
β βββ shop.html # Product catalog
β βββ studio.html # 3D customizer
β βββ cart.html # Shopping cart
β βββ css/
β β βββ style.css # All styles
β βββ js/
β β βββ app.js # Main utilities
β β βββ cart.js # Cart functionality
β β βββ api.js # API integration (NEW)
β βββ models/
β βββ cap.glb # 3D models
β
βββ backend/ # Server-side application
β βββ server.js # Main server file
β βββ package.json # Dependencies
β βββ .env # Environment variables
β βββ models/ # Database schemas
β β βββ Product.js
β β βββ Order.js
β β βββ User.js
β βββ routes/ # API endpoints
β β βββ products.js
β β βββ cart.js
β β βββ orders.js
β β βββ users.js
β βββ scripts/
β βββ initDatabase.js # Database seeder
β
βββ README.md # This file
-
Node.js (v14 or higher)
- Download: https://nodejs.org/
-
MongoDB (v4.4 or higher)
- Download: https://www.mongodb.com/try/download/community
- OR use MongoDB Atlas (cloud): https://www.mongodb.com/cloud/atlas
-
VS Code with Live Server extension
- Download VS Code: https://code.visualstudio.com/
- Install Live Server extension
# Extract the zip file
unzip styleforge3d-fullstack.zip
cd styleforge3d-fullstack# Navigate to backend folder
cd backend
# Install dependencies
npm install
# Configure environment variables
# Edit .env file with your settings
# (MongoDB URI, JWT secret, etc.)
# Initialize database with sample products
npm run init-db
# Start the backend server
npm start
# OR for development with auto-reload:
npm run devThe backend will start on: http://localhost:3000
# Navigate to frontend folder
cd ../frontend
# Open in VS Code
code .
# Right-click index.html and select "Open with Live Server"The frontend will open on: http://localhost:5500
-
Download a free .glb model from:
- Sketchfab: https://sketchfab.com/3d-models/
- Search for "baseball cap glb"
- Download in GLB format
-
Rename to
cap.glb -
Place in
frontend/models/cap.glb
Note: The app includes fallback 3D geometry, so it works without a model file!
cd backend
npm startServer runs on http://localhost:3000
Open frontend/index.html with Live Server in VS Code
- Landing Page β Click "Start Customizing"
- Shop Page β Browse products, click "Customize Now"
- 3D Studio β
- Rotate model with mouse
- Select colors
- Add stickers
- Click "Add to Cart"
- Cart Page β View items, proceed to checkout
GET /api/products # Get all products
GET /api/products/:id # Get single product
POST /api/products # Create product (Admin)
PUT /api/products/:id # Update product (Admin)
DELETE /api/products/:id # Delete product (Admin)
GET /api/cart/:sessionId # Get cart items
POST /api/cart/:sessionId # Add to cart
DELETE /api/cart/:sessionId/:itemId # Remove from cart
DELETE /api/cart/:sessionId # Clear cart
POST /api/orders # Create order
GET /api/orders/:orderNumber # Get order by number
GET /api/orders/email/:email # Get orders by email
PUT /api/orders/:orderNumber/status # Update order status
POST /api/users/register # Register new user
POST /api/users/login # Login user
GET /api/users/profile/:userId # Get user profile
# Get all products
curl http://localhost:3000/api/products
# Get single product
curl http://localhost:3000/api/products/PRODUCT_ID
# Create order
curl -X POST http://localhost:3000/api/orders \
-H "Content-Type: application/json" \
-d '{
"customerEmail": "test@example.com",
"customerName": "John Doe",
"items": [...]
}'- Import the API endpoints
- Set base URL:
http://localhost:3000/api - Test each endpoint
PORT=3000
NODE_ENV=development
FRONTEND_URL=http://localhost:5500
MONGODB_URI=mongodb://localhost:27017/styleforge3d
JWT_SECRET=your-super-secret-jwt-key
JWT_EXPIRE=7dLocal MongoDB:
MONGODB_URI=mongodb://localhost:27017/styleforge3d
MongoDB Atlas (Cloud):
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/styleforge3d
{
name: String,
description: String,
basePrice: Number,
category: String,
availableColors: [{ name, hex }],
availableStickers: [{ name, icon, price }],
stock: Number,
featured: Boolean
}{
orderNumber: String,
customerEmail: String,
customerName: String,
items: [OrderItem],
subtotal: Number,
total: Number,
status: String,
paymentStatus: String
}Problem: MongoDB connection failed
# Solution: Make sure MongoDB is running
# Windows:
net start MongoDB
# Mac/Linux:
sudo systemctl start mongodProblem: Port 3000 already in use
# Solution: Change PORT in .env file
PORT=5000Problem: CORS errors
# Solution: Check FRONTEND_URL in backend .env matches your Live Server URL
FRONTEND_URL=http://localhost:5500Problem: API not responding
# Solution: Make sure backend server is running
cd backend
npm start- Push code to GitHub
- Connect repository to hosting platform
- Set environment variables
- Deploy
- Build frontend (no build step needed - static files)
- Upload to hosting platform
- Update API URL in frontend to production backend URL
# Edit backend/scripts/initDatabase.js
# Add new product object to sampleProducts array
# Run:
cd backend
npm run init-db- Create route in
backend/routes/ - Import in
backend/server.js - Add route:
app.use('/api/endpoint', routeName)
- Colors: Edit
frontend/studio.htmlcolor picker - Stickers: Edit
frontend/studio.htmlsticker grid - Products: Edit
frontend/shop.htmlproduct cards - Styles: Edit
frontend/css/style.css
β
Real-time 3D product visualization
β
Dynamic color selection
β
Sticker customization
β
Live price calculation
β
Shopping cart with localStorage
β
RESTful API backend
β
MongoDB database integration
β
User authentication (JWT)
β
Order management
β
Responsive design
- JWT authentication for protected routes
- Password hashing with bcrypt
- Helmet.js for security headers
- Input validation with express-validator
- CORS configuration
- Environment variables for secrets
- Compression middleware
- MongoDB indexing
- Efficient 3D model loading
- LocalStorage for cart caching
- Minimal dependencies
- Fork the repository
- Create feature branch
- Commit changes
- Push to branch
- Open pull request
This project is open source and available under the MIT License.
Build amazing 3D customization experiences with StyleForge3D!
Need Help?
- Check the troubleshooting section
- Review API documentation
- Inspect browser console for errors
- Check backend logs
Created with β€οΈ for learning and innovation