Live Deployment Frontend Repository
π― Production-ready AI-powered visual search engine with 42,700+ fashion products. Find visually similar items using CLIP embeddings and FAISS similarity search.
Created by Nilesh Kumar | [email protected]
- π¨ 42,700+ Product Database - Fully indexed fashion products with embeddings
- π Production Ready - Deployed with Docker (1.62GB optimized image)
- β‘ Lightning Fast - <100ms search across entire catalog using FAISS
- π€ AI-Powered - OpenAI CLIP (ViT-B/32) for semantic understanding
- π Cloud-Ready - Cloudinary CDN integration for scalable storage
- π Enterprise Security - Rate limiting, validation, auto-cleanup
- π Real-Time Search - Upload image or URL, get instant similar products
- π Live Demo - Check the live deployment at https://visualmatch.knileshh.com
π¦ Products: 42,700 fashion items
π Embeddings: 21.8 million dimensions (42,700 Γ 512)
πΎ Database: 187 MB optimized SQLite
π³ Docker Image: 1.62 GB (87% optimized from 12.4GB)
β‘ Search Index: FAISS IndexFlat for maximum accuracy
π Image Storage: Cloudinary CDN (globally distributed)
π― Search Speed: <100ms for entire catalog
π Memory Usage: ~1.5GB runtime
- Visual Search: Upload an image or provide a URL to find visually similar products
- AI-Powered: Uses OpenAI's CLIP model for semantic image understanding
- Fast Search: FAISS indexing enables efficient similarity search across 42K+ products
- Try it Live: Visit the live demo: https://visualmatch.knileshh.com
- Adjustable Threshold: Fine-tune similarity matching with adjustable threshold slider
- Responsive UI: Mobile-friendly interface that works on all devices
- RESTful API: Well-documented API endpoints for integration
- Auto-Cleanup: Automatic removal of old uploaded files to prevent storage bloat
- Cloud Storage: Integrated with Cloudinary for scalable image hosting
visual-product-matcher/
βββ app.py # Main Flask application
βββ config.yaml # Application configuration
βββ requirements.txt # Python dependencies
βββ Dockerfile # Docker configuration
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules
β
βββ src/ # Source code
β βββ models/ # Database models
β βββ services/ # Business logic services
β βββ routes/ # API and UI routes
β βββ middleware/ # Security and rate limiting
β
βββ templates/ # HTML templates
βββ static/ # CSS, JS, images
β βββ css/
β βββ js/
β βββ images/
β
βββ data/ # Data directory (gitignored)
β βββ products.db # SQLite database
β βββ embeddings/ # Cached embeddings
β βββ index/ # FAISS index
β βββ uploads/ # User uploads (auto-cleaned)
β βββ temp/ # Temporary files
β
βββ scripts/ # Utility scripts
β βββ init_data.py # Initialize database and index
β βββ upload_to_cloudinary.py # Cloudinary migration
β βββ quick_api_test.py # API testing
β βββ README.md # Scripts documentation
β
βββ deployment/ # Deployment files
β βββ Dockerfile # Docker container
β βββ gunicorn_config_cloud.py # Production config
β βββ README.md # Deployment guide
β
βββ docs/ # Documentation
β βββ API_DOCUMENTATION.md # API reference
β βββ DEPLOYMENT_CHECKLIST.md # Deployment guide
β βββ README.md # Docs index
β
βββ logs/ # Application logs (gitignored)
git clone <repository-url>
cd visual-product-matcherpython -m venv venv
# On Windows
venv\Scripts\activate
# On Linux/Mac
source venv/bin/activatepip install -r requirements.txt# Copy example env file
cp .env.example .env
# Edit .env with your credentials
# Add CLOUDINARY_URL if using CloudinaryBuild the product database and FAISS index:
python scripts/init_data.pyThis will:
- Scan all images in
fashion-images/directory - Extract metadata and store in SQLite database
- Generate CLIP embeddings for all products
- Build FAISS search index
Note: Initial setup may take 30-60 minutes for 42K images depending on your hardware.
python app.pyThe application will be available at http://localhost:5000
# Build image
docker build -t visual-matcher .
# Run container
docker run -d -p 8080:8080 --env-file .env visual-matcher
# Check health
curl http://localhost:8080/api/healthgunicorn --config gunicorn_config_cloud.py "app:create_app()"- API Documentation - Complete API reference for integration
- Deployment Guide - Step-by-step deployment to Railway & Vercel
- Scripts Documentation - Utility scripts usage
- Deployment Files - Docker and production configuration
Upload and Search:
curl -X POST http://localhost:5000/api/upload \
-F "[email protected]" \
-F "k=10" \
-F "threshold=0.3"Search by URL:
curl -X POST http://localhost:5000/api/search-url \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/image.jpg", "k": 10}'Health Check:
curl http://localhost:5000/api/healthRun API tests:
# Quick test (while server is running)
python scripts/quick_api_test.py
# Comprehensive test suite
python scripts/test_api_endpoints.pyEdit config.yaml to customize:
- Upload settings: File size limits, allowed formats, auto-cleanup intervals
- ML settings: CLIP model, device (CPU/GPU), batch size
- Search settings: Default results count, similarity thresholds
- Performance: Caching, indexing options
Uploaded files are automatically deleted after 60 minutes (configurable):
upload:
cleanup:
enabled: true
interval_minutes: 30 # Check every 30 minutes
max_age_minutes: 60 # Delete files older than 60 minutesThe Docker image has been optimized from 12.4GB to 1.62GB (87% reduction):
# Build optimized image
docker build -t visual-product-matcher:latest .
# Run locally
docker run -d -p 8080:8080 --env-file .env visual-product-matcher:latest
# Test
curl http://localhost:8080/api/health# Login
docker login
# Tag image
docker tag visual-product-matcher:latest YOUR_USERNAME/visual-product-matcher:latest
docker tag visual-product-matcher:latest YOUR_USERNAME/visual-product-matcher:v1.2.0
# Push
docker push YOUR_USERNAME/visual-product-matcher:latest
docker push YOUR_USERNAME/visual-product-matcher:v1.2.0See docs/DOCKER_HUB_PUSH.md for detailed instructions.
-
From Docker Hub:
- Deploy:
YOUR_USERNAME/visual-product-matcher:latest - Add environment variables
- Set
PORT=8080
- Deploy:
-
From GitHub:
- Connect your repository
- Railway auto-detects Dockerfile
- Configure environment variables
- Deploy!
See docs/DEPLOYMENT_CHECKLIST.md for complete guide.
// See docs/API_DOCUMENTATION.md for integration examples
const results = await fetch('https://your-api.railway.app/api/search-url', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ url: imageUrl, k: 20, threshold: 0.3 })
});- Rate Limiting: Upload (10/min), Search (30/min), General (100/hour)
- File Validation: Type, size, and integrity checks
- SSRF Protection: URL validation and sanitization
- Auto-Cleanup: Prevents storage exhaustion
- CORS: Configured for cross-origin requests
See SECURITY.md for security policy and reporting.
- Docker Image: 1.62GB (optimized, 87% smaller than original 12.4GB)
- Search Speed: <100ms for 42K products (with FAISS)
- Embedding Generation: ~50ms per image (GPU) / ~200ms (CPU)
- Memory Usage: ~1.5GB runtime (with model loaded)
- Database: 187MB (SQLite with products + metadata)
- Startup Time: ~30 seconds (includes model loading)
- Backend: Python 3.10, Flask 3.0, Gunicorn
- ML/AI: PyTorch (CPU-optimized), OpenAI CLIP (ViT-B/32), FAISS
- Database: SQLite with SQLAlchemy
- Cloud Storage: Cloudinary CDN
- Frontend: HTML5, CSS3, Vanilla JavaScript
- Container: Docker (multi-stage, optimized build)
- Deployment: Railway-ready, Cloud Run compatible
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2025 Nilesh Kumar
- OpenAI CLIP - Vision and language model
- Meta FAISS - Similarity search library
- Flask - Web framework
- Cloudinary - Image hosting and CDN
Nilesh Kumar
- Website: knileshh.com
- Email: [email protected]
- GitHub: @knileshh
Built with β€οΈ by Nilesh Kumar β’ Production Ready π
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI CLIP - Vision and language model
- FAISS - Similarity search library
- Flask - Web framework
- Cloudinary - Image hosting platform
Built with β€οΈ by Nilesh Kumar β’ Production Ready π