This repository is a movie recommendation system demonstrating the integration between CloudFlare Workers, CloudFlare AI Gateway, CloudFlare Pages, Supabase/PostgreSQL with PGVector extension, and OpenAI API for semantic search capabilities.
The application consists of three main components:
- A frontend web application built with vanilla JavaScript
- An OpenAI embedding worker for generating vector embeddings
- A Supabase/PostgreSQL worker for performing vector similarity search
- Vector embeddings generation using OpenAI's text-embedding-ada-002 model
- Vector similarity search using PostgreSQL with PGVector extension
- Scheduled ingestion of movie data using CloudFlare Workers
- CORS-enabled API endpoints for cross-origin requests
node.js
>= 16npm
>= 8- A CloudFlare account with Workers and Pages enabled
- A Supabase account with PGVector extension enabled
- An OpenAI API key
-
Clone the repository:
git clone https://github.com/your-username/pop-choice.git cd pop-choice
-
Install dependencies and start the frontend:
cd web && npm install && npm run dev
-
Deploy the OpenAI embedding worker:
cd workers/openai-pop-choice-embedding-worker npm install npm run deploy
-
Deploy the Supabase worker:
cd workers/supabase-pop-choice-worker npm install npm run deploy
The following environment variables need to be set in your CloudFlare Workers:
OPENAI_API_KEY
: Your OpenAI API keyAUTH_OPENAI_POP_CHOICE_WORKER
: CloudFlare AI Gateway authorization tokenSUPABASE_URL
: Your Supabase project URLSUPABASE_API_KEY
: Your Supabase service role key
SUPABASE_URL
: Your Supabase project URLSUPABASE_API_KEY
: Your Supabase service role key