IGlass is a cutting-edge AI-powered eyewear e-commerce platform that revolutionizes the way customers discover and purchase glasses online. Originally built as a monolithic application, IGlass has been strategically transformed into a robust microservices architecture to enhance scalability, maintainability, and performance.
IGlass combines advanced artificial intelligence with seamless e-commerce functionality to deliver a personalized shopping experience. The platform leverages computer vision and deep learning to analyze customers' facial features and provide tailored eyewear recommendations that perfectly complement their unique face shapes and personal style preferences.
At the heart of IGlass lies a sophisticated AI engine powered by YOLOv8 (You Only Look Once) object detection model and OpenCV image processing libraries. This technological foundation enables real-time face shape classification and intelligent product matching, ensuring customers find their perfect eyewear match with unprecedented accuracy.
Beyond AI recommendations, IGlass offers a full-featured online shopping platform with secure payment processing via Stripe, comprehensive order management, user account systems, and administrative tools. The integration with Snapchat's AR technology provides an immersive virtual try-on experience, bridging the gap between online and in-store shopping.
The transition to microservices architecture allows IGlass to:
- Scale independently based on service demand
- Deploy updates without affecting the entire system
- Maintain high availability with fault isolation
- Support diverse technology stacks optimized for specific functions
- Enable rapid development with autonomous service teams
The platform is now divided into independent, scalable microservices:
- π Authentication Service - User authentication and authorization
- π€ User Management Service - User profiles and account management
- ποΈ Product Service - Product catalog and inventory
- π Cart Service - Shopping cart operations
- β€οΈ Favorites Service - User wishlist management
- π¦ Order Service - Order processing and payment
- π Virtual Try-On Service - AI-powered face detection and recommendations
- π Admin Service - Administrative operations
- π Home Service - Homepage content and featured products
- Face Shape Detection - YOLOv8 and OpenCV-based classification (Heart, Oblong, Oval, Square, Round)
- Personalized Recommendations - AI-driven eyewear suggestions based on face analysis
- Virtual Try-On - Real-time AR experience using Snapchat technology
- Product Catalog - Browse eyewear categories (men's, women's, kids', prescription, sunglasses)
- Shopping Cart - Add, update, and manage cart items
- Favorites System - Save preferred products
- Secure Payments - Stripe integration with webhook support
- Order Management - Complete order lifecycle tracking
- JWT-based Authentication - Secure token management
- Role-based Authorization - Admin and user access controls
- Session Management - Persistent user sessions
- Input Validation - Comprehensive request validation
| Method | Endpoint | Description | Access |
|---|---|---|---|
| POST | /auth/signup |
User registration | Public |
| POST | /auth/login |
User authentication | Public |
| POST | /auth/logout |
User logout | Protected |
| POST | /auth/refresh-token |
Token refresh | Public |
| GET | /auth/check |
Verify authentication | Protected |
| POST | /auth/forgotPassword |
Password reset request | Public |
| POST | /auth/verifyResetCode |
Verify reset code | Public |
| POST | /auth/resetPassword |
Password reset | Public |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| GET | /users/getMe |
Get current user profile | User |
| PUT | /users/changeMyPassword |
Change password | User |
| PUT | /users/updateMe |
Update profile | User |
| DELETE | /users/deleteMe |
Delete account | User |
| GET | /users/ |
Get all users | Admin |
| POST | /users/ |
Create user | Admin |
| GET | /users/:id |
Get user by ID | Admin |
| PUT | /users/:id |
Update user | Admin |
| DELETE | /users/:id |
Delete user | Admin |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| GET | /products/ |
Get all products | Public |
| GET | /products/:id |
Get single product | Public |
| POST | /products/ |
Create product | Admin |
| PATCH | /products/:id |
Update product | Admin |
| DELETE | /products/:id |
Delete product | Admin |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| GET | /cart/cart |
Get user cart | User |
| POST | /cart/cart |
Add item to cart | User |
| PATCH | /cart/cart/save |
Update cart item | User |
| DELETE | /cart/cart/delete |
Remove cart item | User |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| GET | /favorites/favorites |
Get user favorites | User |
| POST | /favorites/favorites |
Add to favorites | User |
| DELETE | /favorites/favorites/:productId |
Remove from favorites | User |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| GET | /orders/orders |
Get user orders | User |
| GET | /orders/deliveryDetails |
Get delivery info | User |
| GET | /orders/succes |
Order success page | User |
| POST | /orders/checkout |
Process payment | User |
| DELETE | /orders/orders/cancel |
Cancel order | User |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| POST | /virtual/bestStyle |
AI face detection & recommendations | User |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| POST | /admin/addproduct |
Add new product with image | Admin |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| GET | /home/ |
Get homepage content | Public |
- Node.js - JavaScript runtime
- Express.js - Web framework
- MongoDB - NoSQL database
- Mongoose - MongoDB ODM
- JWT - Token-based authentication
- bcryptjs - Password hashing
- express-session - Session management
- express-validator - Input validation
- express-rate-limit - Rate limiting
- hpp - HTTP Parameter Pollution protection
- YOLOv8 - Face detection model
- OpenCV - Image processing
- Python - AI model execution
- Stripe - Payment processing
- Stripe Webhooks - Order status updates
- Snapchat AR - Virtual try-on technology
- Multer - File upload handling
- Cloudinary - Cloud image storage
- Sharp - Image processing
- Axios - Inter-service communication
- Nodemailer - Email notifications
- Angular - SPA framework
- HTML/CSS/Bootstrap - UI components
- Node.js >= 16.x
- Python >= 3.12.0 (64-bit)
- MongoDB >= 4.4
- Docker (optional for containerized deployment)
-
Clone the repository
git clone https://github.com/HadyHashiam/IGlass-Microservices.git cd IGlass-Microservices -
Setup each microservice
# Authentication Service cd auth-service npm install # User Service cd ../user-service npm install # Product Service cd ../product-service npm install # Cart Service cd ../cart-service npm install # Continue for all services...
-
Configure environment variables
Create
.envfiles for each service with appropriate configurations:# Common variables for all services NODE_ENV=development MONGO_URI=mongodb://localhost:27017/iglass JWT_SECRET=your_jwt_secret_key # Authentication Service specific JWT_EXPIRE=15m JWT_REFRESH_EXPIRE=7d EMAIL_HOST=smtp.gmail.com EMAIL_PORT=587 EMAIL_USER=[email protected] EMAIL_PASSWORD=your_app_password # Payment Service specific STRIPE_SECRET_KEY=sk_test_your_stripe_secret STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_public STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret # File Upload Service specific CLOUDINARY_CLOUD_NAME=your_cloud_name CLOUDINARY_API_KEY=your_api_key CLOUDINARY_API_SECRET=your_api_secret # Virtual Try-On Service specific SNAPCHAT_API_KEY=your_snapchat_api_key PYTHON_SCRIPT_PATH=./ai/face_detection.py
-
Start all services
# Start each service on different ports # Auth Service (Port 3001) cd auth-service && npm start # User Service (Port 3002) cd user-service && npm start # Product Service (Port 3003) cd product-service && npm start # Continue for all services...
-
Frontend Setup
cd frontend npm install ng serve
# Build and run all services
docker-compose up --build
# Scale specific services
docker-compose up --scale product-service=3Services communicate through:
- HTTP REST APIs - Inter-service communication
- JWT Token Validation - Authentication verification
- Database Queries - Shared data access patterns
- Event-driven Architecture - Async operations
- User authenticates with Auth Service
- JWT token issued and stored
- Other services validate tokens via Auth Service
- User data propagated across services
- Image Upload - User uploads photo via frontend
- Processing - Virtual Try-On Service processes image
- AI Analysis - YOLOv8 model detects face shape
- Recommendations - Algorithm suggests suitable eyewear
- Results - Personalized recommendations returned
- Heart - Wider forehead, narrow chin
- Oblong - Longer than wide
- Oval - Balanced proportions
- Square - Strong jawline, wide forehead
- Round - Soft curves, similar width and length
- JWT tokens with expiration
- Refresh token rotation
- Password hashing with bcrypt
- Rate limiting on sensitive endpoints
- CORS configuration
- Input validation on all endpoints
- HTTP Parameter Pollution protection
- Secure headers middleware
- Environment variables for secrets
- Database connection security
- File upload validation
- Image processing sanitization
// Upload image for AI analysis
POST /virtual/bestStyle
Content-Type: multipart/form-data
FormData: {
image: [uploaded_file],
userId: "user_id"
}
Response: {
faceShape: "oval",
recommendations: [
{ productId: "123", confidence: 0.95 },
{ productId: "456", confidence: 0.87 }
]
}POST /cart/cart
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer <jwt_token>
{
productId: "product_123",
quantity: 2,
selectedOptions: {
color: "black",
prescription: true
}
}POST /orders/checkout
Authorization: Bearer <jwt_token>
{
cartItems: [...],
shippingAddress: {...},
paymentMethod: "stripe"
}- Independent scaling of services
- Technology diversity per service needs
- Fault isolation - service failures don't crash system
- Development team autonomy
- Service health checks
- Request/response logging
- Performance metrics
- Error tracking
# Unit tests for each service
npm test
# Integration tests
npm run test:integration
# Load testing
npm run test:load- Responsive design for all devices
- Progressive Web App capabilities
- Mobile-first approach
- Cross-platform compatibility
- Fork the repository
- Create feature branches (
git checkout -b feature/new-service) - Follow microservices patterns
- Add comprehensive tests
- Update documentation
- Submit pull requests
- Container orchestration (Kubernetes/Docker Swarm)
- Load balancing for high availability
- Database clustering for scalability
- CDN integration for static assets
- SSL certificates for security
- Automated testing for all services
- Docker image building
- Service deployment automation
- Database migrations
- Environment promotion
This project is licensed under the ISC License.
Hady Hashiam - Lead Developer & AI Engineer
π Powered by microservices architecture for ultimate scalability and AI-driven personalization
