Repository note, April 21, 2026: this is the original
peether-protocolworkspace. Current public release work has moved to:
- Backend API: https://github.com/pinkpeether/ptdt-settlement-api
- Frontend UI: https://github.com/pinkpeether/ptdt-settlement-frontend
Use the split repositories for current setup work. The content below is retained as legacy/reference documentation unless updated by a later commit.
Recommended Database Solution for Quick Start
✅ Fastest Setup - 2 minutes to production database ✅ Free Tier Available - Start at $0, scale as you grow ✅ PostgreSQL Native - Full compatibility with our API ✅ Built-in Auth - JWT tokens included ✅ Real-time Subscriptions - For live dashboards ✅ Automatic Backups - Daily snapshots ✅ Global CDN - Low-latency everywhere
- Go to supabase.com
- Click "New Project"
- Fill in:
- Project Name:
ptdt-settlement - Database Password: Generate strong password
- Region: Pick closest to you
- Project Name:
- Click "Create new project"
⏱️ Wait 2-3 minutes for project creation
- Go to Settings → Database
- Find the Connection String section
- Copy the Full Connection String (PostgreSQL)
- Replace
[YOUR-PASSWORD]with your password
Example:
postgresql://postgres:YOUR_PASSWORD@db.your-project.supabase.co:5432/postgres
# Copy your Supabase connection string
DATABASE_URL=postgresql://postgres:YOUR_PASSWORD@db.your-project.supabase.co:5432/postgresnpm install
npm run devDone! Your API is connected to Supabase. ✅
If you want to use Supabase's real-time features or auth:
- Go to Settings → API
- Copy these values:
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key- Go to Supabase → SQL Editor
- Create a new query
- Copy and paste this schema:
-- Create quotes table
CREATE TABLE quotes (
id TEXT PRIMARY KEY,
ride_fare DECIMAL NOT NULL,
currency VARCHAR(3) NOT NULL,
ptdt_price DECIMAL NOT NULL,
ptdt_amount DECIMAL NOT NULL,
discount DECIMAL DEFAULT 0,
operator_id TEXT NOT NULL,
status VARCHAR(20) DEFAULT 'active',
expires_at TIMESTAMP NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Create payments table
CREATE TABLE payments (
id TEXT PRIMARY KEY,
quote_id TEXT NOT NULL,
rider_wallet TEXT NOT NULL,
driver_wallet TEXT NOT NULL,
amount_ptdt DECIMAL NOT NULL,
tx_hash TEXT,
status VARCHAR(20) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (quote_id) REFERENCES quotes(id)
);
-- Create withdrawals table
CREATE TABLE withdrawals (
id TEXT PRIMARY KEY,
driver_wallet TEXT NOT NULL,
amount_ptdt DECIMAL NOT NULL,
method VARCHAR(10) NOT NULL,
status VARCHAR(20) NOT NULL,
tx_hash TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Create driver_earnings table
CREATE TABLE driver_earnings (
driver_wallet TEXT PRIMARY KEY,
total_earnings DECIMAL DEFAULT 0,
ptdt_balance DECIMAL DEFAULT 0,
rides_completed INT DEFAULT 0,
last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Create indexes for performance
CREATE INDEX idx_quotes_operator ON quotes(operator_id);
CREATE INDEX idx_quotes_status ON quotes(status);
CREATE INDEX idx_payments_status ON payments(status);
CREATE INDEX idx_withdrawals_driver ON withdrawals(driver_wallet);
CREATE INDEX idx_earnings_wallet ON driver_earnings(driver_wallet);- Click "Run"
✅ Your database schema is now ready!
If you're using Prisma ORM:
npm install @prisma/client
prisma init
prisma db push| Tier | Cost | Connections | Storage | Use Case |
|---|---|---|---|---|
| Free | $0 | 3 | 500 MB | Development |
| Pro | $25/mo | 100 | 8 GB | Production (small) |
| Team | $599/mo | Unlimited | 200+ GB | Enterprise |
Start free, upgrade only when needed.
Problem: connect ECONNREFUSED
Solution:
- Check DATABASE_URL is correct
- Verify password doesn't have special chars (or URL encode them)
- Ensure project is not paused
Problem: FATAL: password authentication failed
Solution:
- Reset database password in Supabase settings
- Update DATABASE_URL with new password
- Test connection again
Problem: permission denied for schema public
Solution:
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON ALL TABLES IN SCHEMA public TO postgres;
GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO postgres;✅ Do:
- Use strong passwords (20+ chars)
- Enable Row Level Security (RLS) for production
- Backup regularly (Supabase does this automatically)
- Use connection pooling for high traffic
- Monitor database usage in Supabase dashboard
❌ Don't:
- Commit DATABASE_URL to git
- Use the same password across projects
- Give everyone full admin access
- Run production on free tier
- Go to Logs → Postgres Logs
- Filter by:
- Error - Find problems
- Slow Queries - Optimize performance
- Connections - Monitor usage
- Go to Settings → Database
- See:
- Storage used
- Connections count
- Query performance
When you hit 1,000 daily active users:
- Upgrade to Pro tier
- Enable connection pooling
- Create indexes for common queries
- Monitor slow queries
When you hit 10,000 daily active users:
- Use read replicas
- Consider read-only instances
- Implement caching layer (Redis)
- Optimize database queries
- ✅ Create Supabase project
- ✅ Get connection string
- ✅ Update
.envfile - ✅ Create database schema
- ✅ Start API with
npm run dev - ✅ Test endpoints
- Supabase Docs: https://supabase.com/docs
- Supabase Slack: Join community
- Our Email: pinkpeether@gmail.com
You now have a production-grade PostgreSQL database in 2 minutes. 🚀