Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MatthewSabia1/SubPirate-Pro/llms.txt
Use this file to discover all available pages before exploring further.
Overview
SubPirate does not provide a dedicated REST endpoint for listing Reddit accounts. Instead, the frontend queries thereddit_accounts Supabase table directly using the Supabase client with RLS (Row-Level Security) enforcing user ownership.
Direct Supabase Query
The frontend uses the Supabase JavaScript client to queryreddit_accounts table:
Authentication
Row-level security policies enforce that users can only read their own accounts. The Supabase client automatically includes the user’s JWT token in all requests.Table Schema
Thereddit_accounts table contains:
Primary key
Foreign key to auth.users (indexed)
Reddit’s internal user ID (e.g. “t2_abc123”)
Reddit username without “u/” prefix
Reddit profile avatar URL (nullable)
Total karma (link + comment karma)
Post karma
Comment karma
Last successful OAuth connection
Account creation timestamp
Last update timestamp
Row-Level Security (RLS)
Thereddit_accounts table has RLS enabled with policies:
SELECT Policy
INSERT Policy
UPDATE Policy
DELETE Policy
Example Usage
List All Accounts
Check If User Has Accounts
Get Account by ID
Related Tables
reddit_account_tokens
Encrypted OAuth tokens are stored separately inreddit_account_tokens:
reddit_account_id(FK to reddit_accounts.id, unique)user_id(FK to auth.users.id)access_token_enc(encrypted)refresh_token_enc(encrypted)scope(text array)token_expires_at(timestamptz)
campaign_reddit_accounts
Links Reddit accounts to campaigns:campaign_id(FK to campaigns.id)reddit_account_id(FK to reddit_accounts.id)is_active(boolean)health_status(enum: ‘healthy’, ‘warning’, ‘error’, ‘disabled’)consecutive_failures(integer)disabled_until(timestamptz, nullable)
Subscription Limits
The number of Reddit accounts a user can connect is determined by their subscription tier:| Tier | Max Accounts |
|---|---|
| Free | 0 |
| Basic | 1 |
| Pro | 3 |
| Enterprise | 10 |
upsert_reddit_account_with_limit stored procedure when connecting new accounts via /api/reddit/oauth/exchange.
Implementation Reference
SeeRedditAccountContext.tsx:48-52 for the production implementation: