This document covers local development setup, architecture details, and deployment instructions for Reddit Multi Poster.
- Prerequisites
- Local Development Setup
- Database Setup (Supabase)
- Environment Variables
- Database Migrations
- Useful Commands
- Tech Stack
- Architecture Overview
- Deployment
- Node.js 18+ and npm
- Docker (for local Supabase)
- Reddit API credentials (Get them here)
# Clone the repository
git clone https://github.com/amaldinesh7/reddit-multi-poster.git
cd reddit-multi-poster
# Install dependencies
npm install
# Copy environment template
cp .env.example .env.local
# Start local Supabase (requires Docker)
npx supabase start
# Apply database migrations
npx supabase db reset
# Start the development server
npm run devOpen http://localhost:3000 to view the app.
This project uses Supabase for data persistence. You can run Supabase locally for development.
npx supabase startThis will start all Supabase services (PostgreSQL, Auth, Storage, etc.) in Docker containers.
After starting, you'll see output like:
Studio URL: http://127.0.0.1:54323
API URL: http://127.0.0.1:54321
DB URL: postgresql://postgres:postgres@127.0.0.1:54322/postgres
npx supabase stopCreate a .env.local file in the project root:
# Local Supabase
NEXT_PUBLIC_SUPABASE_URL=http://127.0.0.1:54321
SUPABASE_SERVICE_ROLE_KEY=<your-service-role-key-from-supabase-start-output>
# Reddit OAuth (required)
REDDIT_CLIENT_ID=your_client_id
REDDIT_CLIENT_SECRET=your_client_secret
REDDIT_REDIRECT_URI=http://localhost:3000/api/auth/callback
REDDIT_USER_AGENT=reddit-multi-poster/1.0For production environment variables, see VERCEL_SETUP.md.
Migrations are stored in supabase/migrations/ and are applied automatically when you run:
# Apply all migrations to local database (resets data)
npx supabase db reset
# Or just push new migrations without resetting
npx supabase db push| Migration | Description |
|---|---|
001_initial_schema.sql |
Core tables (users, categories, user_subreddits, subreddit_cache) |
002_add_post_requirements.sql |
Adds post_requirements column for Reddit posting rules |
005_add_entitlements.sql |
User entitlements for free/paid tiers |
006_add_storage_bucket.sql |
Storage bucket for media uploads |
007_fix_queue_jobs_updated_at.sql |
Queue jobs timestamp fix |
npx supabase migration new <migration_name># Development
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
# Database
npx supabase status # Check local Supabase status
npx supabase stop # Stop local Supabase
npx supabase db reset # Reset database with migrations
npx supabase db push # Push migrations without reset
npx supabase migration list # View migration history
# Type Generation
npx supabase gen types typescript --local > types/database.ts
# Database Access
PGPASSWORD=postgres psql -h 127.0.0.1 -p 54322 -U postgres -d postgres
# Open Supabase Studio (GUI)
# Visit http://127.0.0.1:54323| Layer | Technology |
|---|---|
| Frontend | Next.js 14, React 18, TypeScript |
| Styling | Tailwind CSS, shadcn/ui components |
| Backend | Next.js API Routes |
| Database | Supabase (PostgreSQL) |
| Auth | Reddit OAuth 2.0 |
| Hosting | Vercel |
| Queue | Custom queue system with Supabase |
┌─────────────────────────────────────────────────────────────────┐
│ Frontend (Next.js) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ Pages │ │ Components │ │ Hooks & Contexts │ │
│ │ - index │ │ - PostQueue │ │ - useAuth │ │
│ │ - login │ │ - MediaUp │ │ - useQueueJob │ │
│ │ - settings │ │ - SubPicker │ │ - useFailedPosts │ │
│ └─────────────┘ └─────────────┘ └─────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ API Routes (/api/*) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ Auth │ │ Queue │ │ Settings │ │
│ │ - callback │ │ - submit │ │ - subreddits │ │
│ │ - logout │ │ - status │ │ - categories │ │
│ └─────────────┘ └─────────────┘ └─────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Supabase (PostgreSQL) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ Users │ │ Queue Jobs │ │ Subreddit Cache │ │
│ │ │ │ │ │ │ │
│ └─────────────┘ └─────────────┘ └─────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Reddit API │
│ OAuth 2.0 • Post Submission • Flair Fetching │
└─────────────────────────────────────────────────────────────────┘
Posting Flow:
- User uploads content and selects subreddits
- Frontend validates and submits to
/api/queue/submit - Queue job is created in Supabase
- Posts are submitted to Reddit with 15-min delays
- Real-time progress updates via polling
Auth Flow:
- User clicks "Continue with Reddit"
- Redirected to Reddit OAuth consent
- Callback saves tokens securely in Supabase
- Session managed via HTTP-only cookies
Migrations auto-deploy via GitHub Actions on push to main. See .github/workflows/deploy-supabase.yml.
For complete Vercel setup, see VERCEL_SETUP.md.
# Link to your Supabase project (one-time setup)
npx supabase link --project-ref YOUR_PROJECT_ID
# Push migrations to production
npx supabase db pushSupabase free tier projects pause after 7 days of inactivity. This project includes an automatic keep-alive solution using Vercel Cron Jobs.
The /api/keep-alive endpoint runs every 6 hours via Vercel Cron to perform a lightweight database query, keeping your Supabase instance active.
See VERCEL_SETUP.md for setup instructions.
- VERCEL_SETUP.md - Vercel deployment & cron setup
- QUEUE_SETUP.md - Queue system details
- DODO_PAYMENTS_SETUP.md - Payment integration