mirror of
https://github.com/zooai/computer.git
synced 2026-10-30 14:50:20 +00:00
Forked from hanzo.computer, fully rebranded for Zoo Labs Foundation. Vite + React + Tailwind. Deploys to GitHub Pages.
Supabase Setup for Zoo.Computer
This directory contains the database schema and setup instructions for the Zoo.Computer leasing platform.
Database Information
Project ID: fefkbezinxawrutwjdkq
Region: us-east-1
Database URL: postgresql://postgres:[PASSWORD]@db.fefkbezinxawrutwjdkq.supabase.co:5432/postgres
Supabase URL: https://fefkbezinxawrutwjdkq.supabase.co
Setup Instructions
1. Initialize Database
- Go to Supabase SQL Editor: https://supabase.com/dashboard/project/fefkbezinxawrutwjdkq/sql
- Run the
schema.sqlfile to create all tables and policies - Verify tables are created in Table Editor
2. Configure Environment Variables
Copy .env.example to .env.local:
cp .env.example .env.local
Get your Supabase API keys:
- Go to Project Settings → API
- Copy the Project URL (already in .env.example)
- Copy the
anonpublic key toVITE_SUPABASE_ANON_KEY
3. Test Database Connection
npm run dev
Try submitting an RFQ or cluster request to verify the connection.
Database Schema
Core Tables
- users: User profiles (extends Supabase auth)
- rfqs: Request for Quote submissions
- cluster_requests: GPU cluster inquiries
- quotes: Admin-generated quotes
- orders: Accepted quotes or direct purchases
- subscriptions: Recurring GPU leasing subscriptions
- invoices: Generated invoices
- gpu_reservations: Provisioned GPU instances
- usage_records: GPU usage tracking
- admin_actions: Audit log for admin operations
Row Level Security (RLS)
All tables have RLS policies:
- Customers can create RFQs/cluster requests and view their own data
- Admins can view and manage all data
- Anonymous users can submit RFQs (unauthenticated)
Admin Setup
To create an admin user:
- Sign up via the app (creates a customer user)
- In Supabase SQL Editor, run:
UPDATE public.users
SET role = 'admin'
WHERE email = '[email protected]';
API Functions
Helper functions in src/lib/supabase.ts:
Customer Functions:
submitRFQ()- Submit request for quotesubmitClusterRequest()- Submit cluster inquirygetUserRFQs()- Get user's RFQsgetUserQuotes()- Get user's quotesgetUserOrders()- Get user's ordersgetUserSubscriptions()- Get user's subscriptions
Admin Functions:
getAllRFQs()- Get all RFQs (with optional status filter)getAllClusterRequests()- Get all cluster requestsupdateRFQStatus()- Update RFQ statusupdateClusterRequestStatus()- Update cluster request status
Integration with Forms
Both RFQ and Clusters pages use Supabase for data persistence:
Request Quote (/request-quote):
- Submits to
rfqstable viasubmitRFQ()
Clusters (/clusters):
- Submits to
cluster_requeststable viasubmitClusterRequest()
Next Steps
- ✅ Database schema created
- ✅ RLS policies configured
- ⏳ Create admin dashboard to view RFQs/cluster requests
- ⏳ Build quote generation workflow
- ⏳ Integrate Zoo Commerce for payments
- ⏳ Build customer dashboard
Troubleshooting
Connection errors:
- Verify Supabase URL and anon key in
.env.local - Check project is not paused in Supabase dashboard
RLS errors:
- Verify policies are enabled:
SELECT * FROM pg_policies WHERE tablename = 'rfqs'; - Test with authenticated vs. unauthenticated requests
Missing tables:
- Re-run
schema.sqlin SQL Editor - Check for SQL errors in execution logs