Skip to content

IGlass is an innovative AI-driven platform that offers personalized eyewear recommendations based on users' face shapes and styles. By utilizing deep learning models and virtual try-on technology via Snapchat, users can upload their photos, get suggestions, and even try on glasses virtually for a seamless and interactive shopping experience.

Notifications You must be signed in to change notification settings

HadyHashiam/Microservices_IGlass_Node.js_RabbitMQ

Repository files navigation

IGlass β€” AI-Eyewear Store (Microservices Architecture)

IGlass Banner

πŸ“‹ Overview

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.

🎯 What Makes IGlass Special?

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.

πŸš€ Core Innovation

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.

πŸ›οΈ Complete E-commerce Experience

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.

πŸ—οΈ Modern Architecture

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

πŸ—οΈ Microservices Architecture

The platform is now divided into independent, scalable microservices:

Core Services

  • πŸ” 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

✨ Key Features

πŸ€– AI-Powered Features

  • 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

πŸ›’ E-commerce Features

  • 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

πŸ”’ Security & Authentication

  • JWT-based Authentication - Secure token management
  • Role-based Authorization - Admin and user access controls
  • Session Management - Persistent user sessions
  • Input Validation - Comprehensive request validation

πŸš€ API Endpoints

Authentication Service (Port: 3001)

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

User Management Service

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

Product Service

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

Cart Service

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

Favorites Service

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

Order Service

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

Virtual Try-On Service

Method Endpoint Description Access
POST /virtual/bestStyle AI face detection & recommendations User

Admin Service

Method Endpoint Description Access
POST /admin/addproduct Add new product with image Admin

Home Service

Method Endpoint Description Access
GET /home/ Get homepage content Public

πŸ› οΈ Technology Stack

Backend Microservices

  • Node.js - JavaScript runtime
  • Express.js - Web framework
  • MongoDB - NoSQL database
  • Mongoose - MongoDB ODM

Authentication & Security

  • 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

AI & Computer Vision

  • YOLOv8 - Face detection model
  • OpenCV - Image processing
  • Python - AI model execution

Payment & Integration

  • Stripe - Payment processing
  • Stripe Webhooks - Order status updates
  • Snapchat AR - Virtual try-on technology

File Management

  • Multer - File upload handling
  • Cloudinary - Cloud image storage
  • Sharp - Image processing

Communication

  • Axios - Inter-service communication
  • Nodemailer - Email notifications

Frontend

  • Angular - SPA framework
  • HTML/CSS/Bootstrap - UI components

πŸ“¦ Installation & Setup

Prerequisites

  • Node.js >= 16.x
  • Python >= 3.12.0 (64-bit)
  • MongoDB >= 4.4
  • Docker (optional for containerized deployment)

Local Development Setup

  1. Clone the repository

    git clone https://github.com/HadyHashiam/IGlass-Microservices.git
    cd IGlass-Microservices
  2. 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...
  3. Configure environment variables

    Create .env files 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
  4. 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...
  5. Frontend Setup

    cd frontend
    npm install
    ng serve

Docker Deployment (Optional)

# Build and run all services
docker-compose up --build

# Scale specific services
docker-compose up --scale product-service=3

πŸ”„ Service Communication

Services communicate through:

  • HTTP REST APIs - Inter-service communication
  • JWT Token Validation - Authentication verification
  • Database Queries - Shared data access patterns
  • Event-driven Architecture - Async operations

Authentication Flow

  1. User authenticates with Auth Service
  2. JWT token issued and stored
  3. Other services validate tokens via Auth Service
  4. User data propagated across services

πŸ“Š AI Model Integration

Face Shape Detection Pipeline

  1. Image Upload - User uploads photo via frontend
  2. Processing - Virtual Try-On Service processes image
  3. AI Analysis - YOLOv8 model detects face shape
  4. Recommendations - Algorithm suggests suitable eyewear
  5. Results - Personalized recommendations returned

Supported Face Shapes

  • Heart - Wider forehead, narrow chin
  • Oblong - Longer than wide
  • Oval - Balanced proportions
  • Square - Strong jawline, wide forehead
  • Round - Soft curves, similar width and length

πŸ”’ Security Features

Authentication Security

  • JWT tokens with expiration
  • Refresh token rotation
  • Password hashing with bcrypt
  • Rate limiting on sensitive endpoints

API Security

  • CORS configuration
  • Input validation on all endpoints
  • HTTP Parameter Pollution protection
  • Secure headers middleware

Data Protection

  • Environment variables for secrets
  • Database connection security
  • File upload validation
  • Image processing sanitization

🎯 Usage Examples

Face Shape Detection

// 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 }
  ]
}

Add to Cart

POST /cart/cart
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer <jwt_token>

{
  productId: "product_123",
  quantity: 2,
  selectedOptions: {
    color: "black",
    prescription: true
  }
}

Process Order

POST /orders/checkout
Authorization: Bearer <jwt_token>

{
  cartItems: [...],
  shippingAddress: {...},
  paymentMethod: "stripe"
}

πŸ“ˆ Performance & Scalability

Microservices Benefits

  • Independent scaling of services
  • Technology diversity per service needs
  • Fault isolation - service failures don't crash system
  • Development team autonomy

Monitoring & Logging

  • Service health checks
  • Request/response logging
  • Performance metrics
  • Error tracking

πŸ§ͺ Testing

# Unit tests for each service
npm test

# Integration tests
npm run test:integration

# Load testing
npm run test:load

πŸ“± Mobile & Desktop

  • Responsive design for all devices
  • Progressive Web App capabilities
  • Mobile-first approach
  • Cross-platform compatibility

🀝 Contributing

  1. Fork the repository
  2. Create feature branches (git checkout -b feature/new-service)
  3. Follow microservices patterns
  4. Add comprehensive tests
  5. Update documentation
  6. Submit pull requests

πŸš€ Deployment

Production Environment

  • Container orchestration (Kubernetes/Docker Swarm)
  • Load balancing for high availability
  • Database clustering for scalability
  • CDN integration for static assets
  • SSL certificates for security

CI/CD Pipeline

  • Automated testing for all services
  • Docker image building
  • Service deployment automation
  • Database migrations
  • Environment promotion

πŸ“„ License

This project is licensed under the ISC License.

πŸ‘¨β€πŸ’» Author

Hady Hashiam - Lead Developer & AI Engineer


πŸš€ Powered by microservices architecture for ultimate scalability and AI-driven personalization

About

IGlass is an innovative AI-driven platform that offers personalized eyewear recommendations based on users' face shapes and styles. By utilizing deep learning models and virtual try-on technology via Snapchat, users can upload their photos, get suggestions, and even try on glasses virtually for a seamless and interactive shopping experience.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published