JetStream includes an intelligent AI-driven matching service that helps users find compatible flights and travel companions based on their preferences, travel history, and professional background.
-
Set up Cohere API
-
Create an account at Cohere
-
Generate an API key
-
Add your API key to
.env.local:COHERE_API_KEY=your_api_key_here
-
-
Set up Pinecone Vector Database
-
Create an account at Pinecone
-
Create a new project and note your API key
-
Add your Pinecone configuration to
.env.local:PINECONE_API_KEY=your_api_key_here PINECONE_CLOUD=aws PINECONE_REGION=us-east-1 PINECONE_INDEX=jetstream
Note: Free tier Pinecone is only available in
aws/us-east-1region. -
-
Configure Vercel Environment Variables for Production
-
In your Vercel project settings, navigate to the "Environment Variables" section
-
Add the following environment variables:
PINECONE_API_KEY=your_pinecone_api_key PINECONE_CLOUD=aws PINECONE_REGION=us-east-1 PINECONE_INDEX=jetstream COHERE_API_KEY=your_cohere_api_key -
Save your changes and redeploy your project
-
-
Initialize Pinecone Index
-
Run the initialization script:
node scripts/initialize-pinecone.js
-
Follow the prompts to create or reset your index
-
-
Add Data to the Vector Database
- User profiles and flights need to be added to the vector database to enable matching
- Use the sync API endpoints:
PUT /api/matching- Sync a user profilePUT /api/matching/flights- Sync a flightPOST /api/matching/flights- Sync multiple flights
-
Fetch Matching Results
-
Make a POST request to
/api/matchingwith the following parameters:{ "userId": "user_id_here", "includeFlights": true, "includeCompanions": true, "destinationPreference": "optional_destination", "dateRange": { "start": "2023-01-01", "end": "2023-12-31" }, "tripPurpose": "business", "maxResults": 10 }
-
-
Integrate the AIMatchingSection Component
-
Import and use the
AIMatchingSectioncomponent in your pages:import AIMatchingSection from '@/app/flights/components/AIMatchingSection'; // In your component: <AIMatchingSection userId={currentUser.id} destinationPreference="NYC" dateRange={{ start: "2023-01-01", end: "2023-12-31" }} tripPurpose="business" onFlightSelect={(flight) => handleFlightSelection(flight)} />
-
The matching service uses Cohere's embeddings to create vector representations of user profiles and flights. These vectors are stored in a Pinecone vector database, which enables fast similarity searches to find the best matches based on a variety of factors:
- For flights: Destination preferences, travel dates, amenity preferences, and more
- For companions: Professional background, interests, travel history, and preferences
Each match includes a compatibility score and specific reasons why the match was recommended, providing transparency to users.
We've added comprehensive scripts to set up and restore the JetStream database, fully integrated with JetShare functionality. To initialize the database:
-
Make sure your
.env.localfile contains the Supabase credentials:NEXT_PUBLIC_SUPABASE_URL=your-supabase-url SUPABASE_SERVICE_ROLE_KEY=your-service-role-key -
Run the master setup script:
node db/setup-all.js
This script will:
- Test the connection to Supabase
- Check existing tables
- Populate JetShare settings
- Populate ratings and JetShare transactions
- Verify the final state of the database
For more details about the database structure and available scripts, see the Database README.
If you're facing issues with missing tables or columns, you need to run the migration scripts against your Supabase database:
- Go to your Supabase dashboard and open the SQL Editor
- Copy the contents of the migration files:
migrations/profiles.sql- Enhances the profiles table with missing columnsmigrations/travel_preferences.sql- Creates the travel preferences table
- Run each script in the SQL Editor
- Refresh your browser to see the changes take effect
After running these migrations, the following features will work correctly:
- Profile updates (company, position, etc.)
- Travel preferences (interests, social preferences, etc.)
- User settings and privacy controls