Complete setup instructions for the Iowa State Textbook Marketplace.
- Node.js 18+ installed
- npm or yarn package manager
- Supabase account (free tier)
- OpenRouter API key (for AI features)
- Google Cloud Console account (for OAuth)
npm installCreate .env.local in the root directory:
# Supabase
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
# OpenRouter (for AI features)
OPENROUTER_API_KEY=your_openrouter_api_key
# Optional: Demo Mode
NEXT_PUBLIC_DEMO_MODE=falsenpm run devVisit http://localhost:3000
Run this SQL in your Supabase SQL Editor:
-- Create listings table
create table listings (
id uuid default gen_random_uuid() primary key,
created_at timestamp with time zone default timezone('utc'::text, now()) not null,
user_id uuid references auth.users(id) on delete cascade,
course_code text not null,
book_title text not null,
price numeric not null,
contact_info text not null,
condition text,
notes text,
status text default 'active' not null
);
-- Enable Row Level Security
alter table listings enable row level security;
-- Create policies
create policy "Anyone can view active listings"
on listings for select
using (status = 'active');
create policy "Users can insert their own listings"
on listings for insert
with check (auth.uid() = user_id);
create policy "Users can update their own listings"
on listings for update
using (auth.uid() = user_id);-
Go to Storage in Supabase Dashboard:
- Navigate to Storage → Create Bucket
- Bucket name:
profile-pictures - Public bucket: ✅ Yes (checked)
- Click "Create bucket"
-
Set up Storage Policies:
Run the SQL from
supabase-storage-setup.sqlor paste this:
-- Allow authenticated users to upload their own profile pictures
CREATE POLICY "Users can upload their own avatar"
ON storage.objects FOR INSERT TO authenticated
WITH CHECK (
bucket_id = 'profile-pictures' AND
(storage.foldername(name))[1] = 'avatars'
);
-- Allow anyone to view profile pictures (public read)
CREATE POLICY "Anyone can view profile pictures"
ON storage.objects FOR SELECT TO public
USING (bucket_id = 'profile-pictures');
-- Allow users to update their own profile pictures
CREATE POLICY "Users can update their own avatar"
ON storage.objects FOR UPDATE TO authenticated
USING (bucket_id = 'profile-pictures');
-- Allow users to delete their own profile pictures
CREATE POLICY "Users can delete their own avatar"
ON storage.objects FOR DELETE TO authenticated
USING (bucket_id = 'profile-pictures');Note: If you skip this step, users can still use URL input for profile pictures.
- Go to Google Cloud Console
- Create a new project or select existing
- Enable Google+ API
- Navigate to Credentials → Create Credentials → OAuth 2.0 Client ID
- User Type: External
- App name: Bookster
- User support email: Your email
- Scopes:
emailandprofile
- Application type: Web application
- Authorized JavaScript origins:
http://localhost:3000https://your-production-domain.com
- Authorized redirect URIs:
https://[YOUR-PROJECT-REF].supabase.co/auth/v1/callback
Copy your Client ID and Client Secret.
- Go to Supabase Dashboard → Authentication → Providers
- Enable Google provider
- Paste your Client ID and Client Secret
- Save configuration
In Supabase → Authentication → URL Configuration:
- Site URL:
http://localhost:3000(or your production URL) - Redirect URLs: Add your application URLs including:
http://localhost:3000/auth/callback(development)https://your-production-domain.com/auth/callback(production)
- Sign up at OpenRouter.ai
- Go to API Keys → Create new key
- Add to
.env.localasOPENROUTER_API_KEY
- Description Enhancement - Improves listing descriptions with Google Gemini
- Search Suggestions - Smart search assistance for finding items
- Install Netlify CLI:
npm install -g netlify-cli- Login and deploy:
netlify login
netlify init
netlify deploy --prod- Set environment variables in Netlify dashboard
Make sure to set these in your hosting platform:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYOPENROUTER_API_KEY
- Dependencies installed
- Environment variables set
- Supabase tables created
- RLS policies configured
- Google OAuth configured
- OpenRouter API key added
- Development server runs
- Can create account
- Can log in
- Can post listing
- Can browse listings
- AI features work
- Check
.env.localfile exists - Verify environment variables are correct
- Restart development server
- Verify Google OAuth redirect URIs match exactly
- Check Supabase site URL is configured
- Clear browser cookies and try again
- Verify Supabase tables are created
- Check RLS policies are enabled
- Ensure user is authenticated
- Verify OpenRouter API key is valid
- Check API key has sufficient credits
- Review API endpoint logs
If you encounter issues:
- Check the troubleshooting section above
- Review Supabase logs (Dashboard → Logs)
- Check browser console for errors
- Verify all environment variables are set
Your Bookster marketplace is now set up and ready to use!