This guide will help you set up the Supabase database for the Wardrobe AI application.
- A Supabase account (free tier available at supabase.com)
- Node.js and npm installed on your system
- Go to supabase.com and sign up/sign in
- Click "New Project"
- Choose your organization
- Enter project details:
- Name:
wardrobe-ai(or your preferred name) - Database Password: Choose a strong password
- Region: Select the region closest to you
- Name:
- Click "Create new project"
- Wait for the project to be created (usually takes 1-2 minutes)
- In your Supabase dashboard, go to Settings → API
- Copy the following values:
- Project URL (looks like:
https://your-project-id.supabase.co) - anon public key (starts with
eyJ...)
- Project URL (looks like:
-
In your project root, create a
.env.localfile:touch .env.local
-
Add your Supabase credentials to
.env.local:NEXT_PUBLIC_SUPABASE_URL=https://your-project-id.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key-here
Replace the values with your actual credentials from Step 2.
- In your Supabase dashboard, go to SQL Editor
- Click "New Query"
- Copy the entire contents of
database/schema.sqland paste it into the editor - Click "Run" to execute the SQL and create all tables
-
Start your development server:
npm run dev
-
Open your browser to
http://localhost:3000 -
Try adding a new clothing item - it should now be saved to the database!
You can view your data in the Supabase dashboard:
- Go to Table Editor in your Supabase dashboard
- You should see the following tables:
clothing_itemstagsitem_tagsoutfitsoutfit_itemsoutfit_tags
-
"Invalid API key" error
- Double-check your
.env.localfile - Make sure there are no extra spaces or quotes around the values
- Restart your development server after making changes
- Double-check your
-
"Table doesn't exist" error
- Make sure you ran the SQL schema in Step 4
- Check that all tables were created successfully
-
"Row Level Security" errors
- The schema includes RLS policies for a mock user
- In production, you'll need to implement proper authentication
- Check the Supabase Documentation
- Review the console logs in your browser's developer tools
- Check the Supabase dashboard logs under Logs → API
Once your database is set up:
- Add Authentication: Implement user login/signup
- Image Storage: Set up Supabase Storage for clothing photos
- Real-time Updates: Enable real-time subscriptions for live updates
- Deploy: Deploy your app to Vercel or another platform
- Never commit your
.env.localfile to version control - The
anonkey is safe to use in client-side code - For production, consider implementing proper user authentication
- The current setup uses a mock user ID - replace this with real authentication
The database includes the following main entities:
- clothing_items: Stores individual clothing items
- tags: Stores reusable tags for categorization
- item_tags: Links clothing items to tags (many-to-many)
- outfits: Stores outfit combinations
- outfit_items: Links outfits to clothing items
- outfit_tags: Links outfits to tags
All tables include proper relationships, indexes for performance, and Row Level Security policies.