Backend service that integrates LangChain with OpenAI to process vector data. The API retrieves product information from Supabase, generates embeddings, and chains OpenAI prompts to provide intelligent responses about your e-commerce catalog.
Before running the API, you must sync your product data to Supabase:
cd api
npm run syncdataThis populates your Supabase database with product text data and generates vector embeddings.
Database Schema:
Create a table named products with the following columns:
id(UUID, primary key)name(text)description(text)embedding(vector, 1536 dimensions for OpenAI)
Vector Search Query:
SELECT * FROM products
WHERE embedding IS NOT NULL
ORDER BY embedding <-> $1
LIMIT 10;Note: This query follows the LangChain Supabase documentation pattern for vector similarity search.
SELECT * FROM products ORDER BY embedding <-> $1 LIMIT 10;
### 2. Angular Web App
Frontend chatbot interface for conversing about e-commerce products. Users can ask questions about inventory, product details, and recommendations through an intuitive chat interface.
## Prerequisites
- Node.js & npm
- Supabase account with API keys
- OpenAI API key
## Local Setup
### Environment Variables
Create `.env` files in both project directories:
SUPABASE_URL=your_supabase_url SUPABASE_KEY=your_supabase_key OPENAI_API_KEY=your_openai_key
### Express API
```bash
cd api
npm install
npm start
Server runs on http://localhost:3000
cd webapp
npm install
ng serveApp runs on http://localhost:4200
- Vector-based product search via Supabase
- LangChain + OpenAI integration for intelligent responses
- Real-time chatbot interface
- Context-aware product recommendations