A full-stack AI-powered product discovery platform with semantic search, personalized recommendations, and intelligent user interactions. Built with FastAPI, Next.js, PostgreSQL (Supabase), and CLIP embeddings.
- AI-Powered Search: Semantic product search using CLIP embeddings and FAISS similarity search
- Personalized Recommendations: Context-aware recommendations based on user behavior and preferences
- User Interactions: Track views, clicks, likes, and purchases to improve personalization
- Modern Frontend: Beautiful, responsive UI built with Next.js 16 and Tailwind CSS
- Real-time Updates: React Query for efficient data fetching and caching
- Production Ready: Full authentication, error handling, and monitoring
- Python 3.12+
- Node.js 18+
- Supabase CLI (for local development)
- PostgreSQL 15+ with pgvector extension
- Redis 7+ (optional, for caching)
# Download Supabase CLI binary
curl -L https://github.com/supabase/cli/releases/download/v2.54.11/supabase_darwin_amd64.tar.gz -o /tmp/supabase.tar.gz
mkdir -p ~/bin
tar -xzf /tmp/supabase.tar.gz -C ~/bin
export PATH="$HOME/bin:$PATH"# Start local Supabase stack (PostgreSQL, Auth, Storage, Studio)
supabase start
# Access Supabase Studio at: http://localhost:54323
# PostgreSQL: postgresql://postgres:postgres@127.0.0.1:54322/postgres# Create Python virtual environment
python3.12 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
pip install -r requirements-dev.txt # For development tools
# Set up pre-commit hooks (catches formatting issues before commit)
pre-commit install
# Copy environment file
cp .env .env.local # Edit if needed
# Create database schema
python create_db.py
# Start backend API
python -m uvicorn backend.api.main:app --host 0.0.0.0 --port 8001 --reload
# API will be available at: http://localhost:8001
# API Docs: http://localhost:8001/docscd frontend
# Install dependencies
npm install
# Copy environment file
cp .env.local.example .env.local
# Start frontend
npm run dev
# Frontend will be available at: http://localhost:3000knytt/
โโโ backend/ # Python FastAPI backend
โ โโโ api/ # API routes and endpoints
โ โ โโโ main.py # FastAPI app entry point
โ โ โโโ routers/ # API route handlers
โ โ โ โโโ auth.py # Authentication (login, register)
โ โ โ โโโ search.py # Product search
โ โ โ โโโ recommend.py # Recommendations
โ โ โ โโโ feedback.py # User interactions
โ โ โ โโโ users.py # User management
โ โ โโโ schemas/ # Pydantic request/response models
โ โ โโโ dependencies.py # Dependency injection
โ โ โโโ security.py # JWT auth, password hashing
โ โ โโโ middleware.py # Request logging, timing
โ โโโ db/ # Database layer
โ โ โโโ models.py # SQLAlchemy ORM models
โ โ โโโ session.py # Database connection
โ โโโ ml/ # Machine learning components
โ โ โโโ retrieval.py # FAISS index management
โ โ โโโ search.py # Search service
โ โ โโโ caching.py # Embedding cache
โ โโโ celery/ # Background tasks (Celery)
โโโ frontend/ # Next.js 16 frontend
โ โโโ src/
โ โ โโโ app/ # Next.js App Router pages
โ โ โ โโโ page.tsx # Home page
โ โ โ โโโ search/ # Search page
โ โ โ โโโ login/ # Login page
โ โ โ โโโ register/ # Register page
โ โ โ โโโ favorites/ # User favorites
โ โ โ โโโ history/ # Interaction history
โ โ โ โโโ products/[id]/ # Product details
โ โ โโโ components/ # React components
โ โ โ โโโ layout/ # Header, Footer
โ โ โ โโโ home/ # Hero, CategoryPills, MasonryGrid
โ โ โ โโโ search/ # SearchFilters, SearchResults
โ โ โ โโโ recommendations/ # RecommendationCarousel
โ โ โ โโโ products/ # ProductCard, ProductGrid
โ โ โ โโโ ui/ # Reusable UI components
โ โ โ โโโ providers/ # Context providers
โ โ โโโ lib/ # Core utilities
โ โ โ โโโ query-client.ts # React Query config
โ โ โ โโโ queries/ # Data fetching hooks
โ โ โ โ โโโ auth.ts # Auth queries (login, register, useAuth)
โ โ โ โ โโโ search.ts # Search queries
โ โ โ โ โโโ recommendations.ts # Recommendation queries
โ โ โ โ โโโ feedback.ts # Interaction tracking
โ โ โ โ โโโ user.ts # User data queries
โ โ โ โโโ stores/ # Zustand state stores
โ โ โ โโโ cartStore.ts # Shopping cart
โ โ โโโ types/ # TypeScript types
โ โ โ โโโ api.ts # API request/response types
โ โ โ โโโ product.ts # Product types
โ โ โ โโโ enums.ts # Enums and constants
โ โ โโโ styles/ # Global styles
โ โโโ public/ # Static assets
โโโ supabase/ # Supabase configuration
โ โโโ migrations/ # Database migrations (legacy)
โโโ create_db.py # Database schema creation script
โโโ .env # Environment variables
โโโ README.md # This file
The application uses 6 main tables:
- users: User accounts and authentication
- user_embeddings: ML-powered user preference embeddings
- user_interactions: Tracking user behavior (views, clicks, likes)
- products: Product catalog
- product_embeddings: Vector embeddings for products (512-dim CLIP)
- task_executions: Background job tracking
# Activate virtual environment
source venv/bin/activate
# Run backend with auto-reload
python -m uvicorn backend.api.main:app --host 0.0.0.0 --port 8001 --reload
# Create database schema
python create_db.py
# Access API docs
open http://localhost:8001/docscd frontend
# Start dev server
npm run dev
# Build for production
npm run build
# Start production server
npm run start
# Run linting
npm run lint
# Type check
npm run type-check# Access Supabase Studio
open http://localhost:54323
# Connect to PostgreSQL directly
PGPASSWORD=postgres psql -h 127.0.0.1 -p 54322 -U postgres -d postgres
# Reset database (recreate schema)
python create_db.pyPOST /auth/register- Register new userPOST /auth/login- Login and receive JWT tokensPOST /auth/logout- Logout (clear cookies)GET /auth/me- Get current authenticated userPOST /auth/refresh- Refresh access token
POST /api/v1/search- Semantic product searchPOST /api/v1/recommend- Personalized recommendations
POST /api/v1/feedback- Track user interactions (view, click, like, etc.)GET /api/v1/users/{user_id}/stats- User statisticsGET /api/v1/users/{user_id}/history- Interaction historyGET /api/v1/users/{user_id}/favorites- User favorites
GET /health- Health checkGET /status- Detailed system statusGET /metrics- Performance metrics
# Supabase (Local)
SUPABASE_URL=http://127.0.0.1:54321
SUPABASE_ANON_KEY=sb_publishable_ACJWlzQHlZjBrEguHvfOxg_3BJgxAaH
SUPABASE_SERVICE_KEY=sb_secret_N7UND0UgjKTVK-Uodkm0Hg_xSvEMPvz
# Database
DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:54322/postgres
# API
API_HOST=0.0.0.0
API_PORT=8001
# Redis (Optional)
REDIS_HOST=localhost
REDIS_PORT=6379
# ML Configuration
CLIP_MODEL=ViT-B/32
EMBEDDING_DIMENSION=512NEXT_PUBLIC_SUPABASE_URL=http://127.0.0.1:54321
NEXT_PUBLIC_SUPABASE_ANON_KEY=sb_publishable_ACJWlzQHlZjBrEguHvfOxg_3BJgxAaH
NEXT_PUBLIC_API_URL=http://localhost:8001# Backend tests
pytest tests/ -v
# Frontend tests
cd frontend
npm run testSee docs/deployment/README.md for deployment guides:
- Supabase Cloud + GCP Cloud Run (Recommended)
- Docker Compose (Development)
- Kubernetes (Production)
- FastAPI backend with authentication
- SQLAlchemy database models
- Supabase integration (PostgreSQL, Auth)
- Next.js 16 frontend with App Router
- React Query for data fetching
- Zustand for state management
- User authentication (JWT)
- Product search and recommendations
- User interaction tracking
- Responsive UI with Tailwind CSS
- CLIP embeddings generation
- FAISS similarity search
- ML model integration
- Image upload and processing
- Real-time notifications
- Social features (sharing, following)
- Analytics dashboard
- A/B testing framework
- Multi-language support
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Install development dependencies and pre-commit hooks:
pip install -r requirements-dev.txt pre-commit install
- Make your changes (pre-commit hooks will auto-format on commit)
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Note: Pre-commit hooks will automatically run Black, isort, flake8, and other checks before each commit. This ensures code quality and prevents CI failures.
MIT License - see LICENSE file for details
For questions and support, please open an issue in the repository.
Built with โค๏ธ using FastAPI, Next.js, and Supabase