Skip to content

ItsOmkara/Smart-Ecommerce-with-Visual-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ VISOAI β€” Smart E-Commerce with Visual AI Search

AI-powered e-commerce platform where you can upload any image and instantly find visually similar products using CLIP + FAISS technology.

Next.js Spring Boot Python MySQL TailwindCSS


✨ Features

  • πŸ“Έ Visual Search β€” Upload any image and find similar products using OpenAI's CLIP model + FAISS vector search
  • πŸ›οΈ Product Catalog β€” Browse, search, and filter products across multiple categories
  • πŸ” JWT Authentication β€” Secure user registration, login, and session management
  • πŸ›’ Shopping Cart β€” Add to cart, update quantities, and remove items (synced with backend)
  • πŸ“¦ Checkout & Orders β€” Address form, order placement, and order history stored in database
  • 🎨 Premium UI β€” Dark glassmorphism design with liquid animations, smooth transitions, and Framer Motion
  • πŸ“± Responsive β€” Fully responsive across desktop, tablet, and mobile

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Next.js Frontend │────▢│  Spring Boot API   │────▢│     MySQL DB       β”‚
β”‚     (Port 3000)    β”‚     β”‚    (Port 8080)      β”‚     β”‚                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”‚  Visual Search
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Python AI Service β”‚
β”‚  CLIP + FAISS      β”‚
β”‚    (Port 8001)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Layer Technology Description
Frontend Next.js 14, TypeScript, Tailwind CSS, Framer Motion UI with visual search, product browsing, cart, checkout
Backend Spring Boot 3.4, Java 17, Spring Security, JPA REST APIs for products, auth, cart, orders
AI Service Python, FastAPI, OpenAI CLIP (ViT-B/32), FAISS Image embedding & similarity search
Database MySQL 8.0 Products, users, cart, orders, order items

πŸ“ Project Structure

Smart-Ecommerce-with-Visual-AI/
β”œβ”€β”€ src/                        # Next.js Frontend
β”‚   β”œβ”€β”€ app/                    # App router pages
β”‚   β”‚   β”œβ”€β”€ page.tsx            # Landing page
β”‚   β”‚   β”œβ”€β”€ products/           # Product listing & detail
β”‚   β”‚   β”œβ”€β”€ search/             # Visual search page
β”‚   β”‚   β”œβ”€β”€ cart/               # Shopping cart & checkout
β”‚   β”‚   β”œβ”€β”€ login/              # Login page
β”‚   β”‚   └── signup/             # Registration page
β”‚   β”œβ”€β”€ components/             # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ ui/                 # Button, Input, Badge, etc.
β”‚   β”‚   β”œβ”€β”€ layout/             # Navbar, Footer
β”‚   β”‚   β”œβ”€β”€ product/            # Product card
β”‚   β”‚   └── cart/               # Cart sheet
β”‚   └── lib/                    # Utilities & contexts
β”‚       β”œβ”€β”€ api.ts              # API service layer
β”‚       β”œβ”€β”€ auth-context.tsx    # Auth state management
β”‚       β”œβ”€β”€ cart-context.tsx    # Cart state management
β”‚       └── types.ts            # TypeScript interfaces
β”‚
β”œβ”€β”€ backend/                    # Spring Boot Backend
β”‚   └── src/main/java/com/visualai/backend/
β”‚       β”œβ”€β”€ controller/         # REST controllers
β”‚       β”œβ”€β”€ entity/             # JPA entities
β”‚       β”œβ”€β”€ repository/         # Spring Data repositories
β”‚       β”œβ”€β”€ service/            # Business logic
β”‚       └── config/             # Security & CORS config
β”‚
β”œβ”€β”€ ai-service/                 # Python AI Service
β”‚   β”œβ”€β”€ main.py                 # FastAPI app entry
β”‚   β”œβ”€β”€ config.py               # Configuration
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ clip_model.py       # CLIP model wrapper
β”‚   β”‚   └── faiss_index.py      # FAISS index management
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ search.py           # Visual search endpoint
β”‚   β”‚   └── index.py            # Index rebuild endpoint
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   └── image_utils.py      # Image loading utilities
β”‚   └── requirements.txt        # Python dependencies
β”‚
β”œβ”€β”€ package.json                # Frontend dependencies
β”œβ”€β”€ tailwind.config.ts          # Tailwind configuration
β”œβ”€β”€ next.config.mjs             # Next.js configuration
└── README.md

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ and npm
  • Java 17+ (JDK)
  • Python 3.9+
  • MySQL 8.0+
  • Maven (or use the included mvnw wrapper)

1. Clone the Repository

git clone https://github.com/ItsOmkara/Smart-Ecommerce-with-Visual-AI.git
cd Smart-Ecommerce-with-Visual-AI

2. Database Setup

Create a MySQL database:

CREATE DATABASE visual_ecommerce_db;

The tables are auto-created by Hibernate when the backend starts (spring.jpa.hibernate.ddl-auto=update).

3. Backend (Spring Boot)

cd backend
./mvnw spring-boot:run

Or open the backend/ folder in IntelliJ IDEA and run the application.

The backend will start on http://localhost:8080.

4. AI Service (Python)

cd ai-service
python -m venv venv

# Windows
.\venv\Scripts\activate
# macOS/Linux
source venv/bin/activate

pip install -r requirements.txt
python main.py

The AI service will start on http://localhost:8001.

⚠️ First startup downloads the CLIP model (~350MB). FAISS index is built automatically from database products.

5. Frontend (Next.js)

# From the project root
npm install
npm run dev

The frontend will start on http://localhost:3000.


πŸ”‘ API Endpoints

Auth

Method Endpoint Description
POST /api/auth/register Register a new user
POST /api/auth/login Login (returns JWT)
GET /api/auth/me Get current user info

Products

Method Endpoint Description
GET /api/products List all products
GET /api/products?category= Filter by category
GET /api/products/:id Get product by ID
GET /api/products/search?q= Text search
GET /api/products/:id/related Related products

Cart (requires auth)

Method Endpoint Description
GET /api/cart Get cart items
POST /api/cart Add to cart
PUT /api/cart/:productId Update quantity
DELETE /api/cart/:productId Remove item
DELETE /api/cart Clear cart

Orders (requires auth)

Method Endpoint Description
POST /api/orders Place order (with shipping address)
GET /api/orders Order history

Visual Search (AI Service)

Method Endpoint Description
POST /api/search/visual Upload image for visual search
POST /api/index/rebuild Rebuild FAISS index

🧠 How Visual Search Works

  1. User uploads an image on the search page
  2. CLIP (ViT-B/32) encodes the image into a 512-dimensional embedding
  3. FAISS index performs approximate nearest neighbor search against pre-computed product embeddings
  4. Top-K similar products are returned with similarity scores
  5. Full product details are fetched from the Spring Boot API

πŸ› οΈ Tech Stack

Category Technologies
Frontend Next.js 14, React 18, TypeScript, Tailwind CSS 3, Framer Motion, Radix UI
Backend Java 17, Spring Boot 3.4, Spring Security, Spring Data JPA, Lombok
AI/ML Python, FastAPI, OpenAI CLIP, FAISS, PyTorch, NumPy
Database MySQL 8.0, Hibernate ORM
Auth JWT (jjwt 0.12.6), Spring Security

πŸ‘€ Author

Omkar Birajdar β€” @ItsOmkara

About

πŸ›’ AI-powered e-commerce platform with visual search β€” upload any image to find similar products using CLIP + FAISS. Built with Next.js, Spring Boot & FastAPI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors