An innovative platform that combines 3D visualization technology with AI-generated designs to revolutionize apparel customization. This application enables users to create unique, personalized clothing items in a real-time 3D environment with intuitive tools for color selection, logo placement, and AI-assisted design generation.
The e-commerce market has seen a significant shift toward personalization, with studies showing that 36% of consumers expect personalized products. However, traditional 2D preview systems fail to provide accurate representations of the final product, leading to customer dissatisfaction and high return rates.
Creating an intuitive 3D customization interface that:
- Maintains high performance on various devices
- Provides realistic visualization without requiring specialized hardware
- Integrates seamlessly with AI design generation
- Delivers a low learning curve for non-technical users
Our solution bridges these gaps by implementing:
- WebGL-based 3D rendering optimized for modern browsers
- Reactive state management for real-time customization
- Integration with advanced AI image generation
- A component-based architecture that simplifies future enhancements
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Client Layer โ โ Application โ โ Server Layer โ
โ (React/Vite) โโโโโโโบโ (Three.js/UI) โโโโโโโบโ (Express/API) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ UI Components โ โ 3D Rendering โ โ AI Integration โ
โ (Framer/Tailwind)โ โ (Drei/Fiber) โ โ (OpenAI/DALL-E) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
- Component-Based Architecture: Modular components that encapsulate specific functionality
- State Management: Centralized state using Valtio for predictable data flow
- 3D Pipeline: Three.js with React integration via R3F and Drei for advanced 3D capabilities
- AI Integration: Error-resilient OpenAI API implementation with retry logic and graceful fallbacks
- Optimized 3D models with reduced polygon counts
- Progressive loading and rendering
- Memoization of expensive operations
- Client-side caching for improved responsiveness
- React 19: Core UI library using the latest features for improved performance
- Vite: Modern build tool for fast development and optimized production builds
- Three.js: JavaScript 3D library for WebGL rendering
- React Three Fiber/Drei: React components for Three.js integration
- Tailwind CSS: Utility-first CSS framework for rapid UI development
- Framer Motion: Animation library for smooth, physics-based transitions
- Valtio: Proxy-based state management for reactive updates
- Node.js: JavaScript runtime for server-side execution
- Express.js: Web framework for RESTful API development
- OpenAI API: Integration with DALL-E for AI-generated designs
- CORS: Cross-Origin Resource Sharing support for secure API access
- ESLint/Prettier: Code quality and formatting tools
- Vite Hot Module Replacement: For rapid development iterations
- Responsive Design Components: Adaptable UI for various device sizes
- Interactive 3D Model Viewing: 360ยฐ rotation and zoom capabilities
- Real-time Color Customization: Dynamic color application with immediate feedback
- Logo Upload & Placement: Precise positioning of custom logos and designs
- AI-Generated Designs: Text-to-image design generation powered by DALL-E
- Texture Application: Apply complex patterns and textures to the entire garment
- Dynamic Theme Adaptation: UI theme adjusts based on selected product colors
- Download Capabilities: Export customized designs as high-resolution images
- Responsive Interface: Optimized for desktop and mobile devices
- Realistic Lighting & Shadows: Advanced lighting model for accurate visualization
- Physically-Based Rendering: Materials that accurately represent real-world fabrics
- Error-Resilient AI Integration: Robust error handling with user-friendly fallbacks
- Optimized Asset Loading: Efficient loading of 3D models and textures
- Node.js (v16.0.0 or higher)
- npm (v8.0.0 or higher)
- Modern web browser with WebGL support
- OpenAI API key for AI design generation
-
Clone the repository
git clone https://github.com/your-username/3D-Ecommerce-AI-Assist.git cd 3D-Ecommerce-AI-Assist -
Install frontend dependencies
cd client npm install -
Install backend dependencies
cd ../server npm install -
Configure environment variables Create a
.envfile in the server directory with your OpenAI API key:OPENAI_API_KEY=your_openai_api_key_here -
Start the development servers
In one terminal, start the backend server:
cd server npm startIn another terminal, start the frontend development server:
cd client npm run dev -
Access the application Open your browser and navigate to
http://localhost:5173to access the application.
-
Build the frontend
cd client npm run build -
Deploy the backend
cd ../server npm start -
Serve the static files Configure your production server to serve the static files from the
client/distdirectory and proxy API requests to the backend server.
-
Home Screen
- Start at the landing page showcasing the 3D model
- Click "Customize It" to enter the customization mode
-
Customization Interface
- Left Panel: Access editing tools (color picker, file upload, AI generator)
- Center Stage: Interact with the 3D model (rotate, zoom)
- Bottom Bar: Toggle between logo and full-texture modes
- Top Right: Download your design or return to the home screen
- Click the color picker icon in the left toolbar
- Select your desired color from the color palette
- Watch as the 3D model updates in real-time with your selection
- The application theme also adapts to complement your color choice
- Click the file upload icon in the left toolbar
- Upload an image file (PNG with transparency recommended)
- Select "Logo" to apply it to the shirt
- Toggle the logo visibility using the t-shirt icon in the bottom bar
- Click the AI icon in the left toolbar
- Enter a descriptive prompt (e.g., "abstract geometric pattern with blue and gold")
- Click "Logo" for a small design or "Full" for an all-over texture
- Wait for the AI to generate your custom design
- The design will automatically apply to your 3D model
- Click the download icon in the top-right corner
- A high-resolution image of your current view will be saved to your device
- This image captures the exact perspective, lighting, and customizations
- User profile management
- Design history and saved designs
- Design sharing and social features
- Analytics dashboard for usage metrics
- MongoDB/Firebase integration for user data storage
- Design persistence across sessions
- User authentication and profile management
- Usage analytics and behavioral tracking
- JWT-based authentication system
- Role-based access control
- Secure API endpoints with rate limiting
- GDPR-compliant data handling
- Multiple product types (hoodies, hats, shoes)
- Material simulation (cotton, polyester, denim)
- Advanced customization (sleeves, collars, pockets)
- AR try-on capabilities
- Collaborative design sessions
- Marketplace integration for purchasing designs
App
โโโ Home (Landing Page)
โโโ Canvas (3D Rendering Container)
โ โโโ CameraRig (Handles camera positioning/movement)
โ โโโ Backdrop (Environment and lighting)
โ โโโ Shirt (3D model with material setup)
โโโ Customizer (Main editing interface)
โโโ EditorTabs (Tool selection)
โ โโโ ColorPicker (Color selection tool)
โ โโโ FilePicker (Image upload tool)
โ โโโ AIPicker (AI generation tool)
โโโ FilterTabs (Toggle between logo/full texture)
The application uses Valtio for proxy-based state management:
intro: Controls whether to show the landing page or customizercolor: Current selected color in hex formatisLogoTexture: Toggle for logo visibilityisFullTexture: Toggle for full texture visibilitylogoDecal: Source for the logo texturefullDecal: Source for the full-body texture
The backend server provides an API endpoint for AI image generation:
- Endpoint:
/api/v1/dalle - Method: POST
- Payload:
{ prompt: "description of desired image" } - Response:
{ photo: "base64_encoded_image" } - Error Handling: Includes retry logic and specific error messages
// Applying textures to the 3D model
const Shirt = () => {
const snap = useSnapshot(state);
const logoTexture = useTexture(snap.logoDecal);
const fullTexture = useTexture(snap.fullDecal);
return (
<mesh castShadow>
<group>
<mesh castShadow receiveShadow geometry={nodes.T_Shirt_male.geometry}>
<meshStandardMaterial
map={snap.isFullTexture && fullTexture}
color={snap.color}
roughness={0.9}
metalness={0.05}
/>
{snap.isLogoTexture && (
<Decal
position={[0, 0.04, 0.15]}
rotation={[0, 0, 0]}
scale={0.15}
map={logoTexture}
depthTest={false}
depthWrite={true}
/>
)}
</mesh>
</group>
</mesh>
);
};// AI image generation with robust error handling
router.route('/').post(async (req, res) => {
try {
const { prompt } = req.body;
let attempts = 0;
const maxAttempts = 2;
while (attempts < maxAttempts) {
try {
const response = await openai.images.generate({
model: 'gpt-image-1',
prompt,
n: 1,
background: 'transparent',
size: '1024x1024',
output_format: 'png',
});
const image = response.data[0].b64_json;
return res.status(200).json({ photo: image });
} catch (apiError) {
attempts++;
if (attempts >= maxAttempts) throw apiError;
await new Promise(resolve => setTimeout(resolve, 1000 * attempts));
}
}
} catch (error) {
console.error('DALL-E API Error:', error);
let errorMessage = "Something went wrong generating the image";
let statusCode = 500;
// Provide useful error messages based on error type
if (error.status === 403) {
statusCode = 403;
errorMessage = "Access denied: API key permission issue";
} else if (error.status === 400) {
statusCode = 400;
errorMessage = "Invalid prompt or parameters";
}
res.status(statusCode).json({
message: errorMessage,
error: {
type: error.type || 'unknown_error',
code: error.code || null
}
});
}
})This project is licensed under the MIT License - see the LICENSE file for details.
- Jimmy Burns - Project Lead & Developer
