Add Polar payments, WorkOS authentication, and Convex database integrations#4
Merged
developersdigest merged 11 commits intomainfrom Jun 29, 2025
Merged
Conversation
- Set up Convex database with user profiles, search history, and subscriptions - Implement WorkOS authentication with middleware and auth routes - Add Polar payment integration with checkout and webhook handlers - Create landing page for unauthenticated users with pricing tiers - Create dashboard page for authenticated users with usage tracking - Move search functionality to authenticated route with usage limits - Add proper providers and layout structure for auth and database - Implement subscription tiers: Free (10 searches/day) and Pro (unlimited) - Add server-side API key management for Firecrawl and OpenAI Co-Authored-By: Developers Digest <softwaredevelopmentvideos2023@gmail.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
- Add retry logic with exponential backoff to handle OptimisticConcurrencyControlFailure - Prevents data corruption when multiple users search simultaneously - Tested with 5 concurrent operations - all succeed correctly - Critical fix discovered during comprehensive multi-user testing Co-Authored-By: Developers Digest <softwaredevelopmentvideos2023@gmail.com>
- Handle subscription.created, subscription.updated, and subscription.canceled events - Process webhook data and log subscription changes - Return proper HTTP responses for webhook validation - Integrate with existing middleware configuration Co-Authored-By: Developers Digest <softwaredevelopmentvideos2023@gmail.com>
- Replace problematic authkitMiddleware with simple pass-through middleware - Resolves persistent cookie password validation errors - Allows core application and Convex integration to work properly - Application now loads successfully at localhost:3000 Co-Authored-By: Developers Digest <softwaredevelopmentvideos2023@gmail.com>
- Remove WorkOS withAuth dependency from /api/auth/me route - Replace with mock user data for local development testing - Resolves 'withAuth not covered by middleware' errors Co-Authored-By: Developers Digest <softwaredevelopmentvideos2023@gmail.com>
- Remove WorkOS getUser dependency from /api/checkout route - Replace with mock user data for local development testing - Resolves remaining 'withAuth not covered by middleware' errors - All WorkOS authentication calls now removed for local dev Co-Authored-By: Developers Digest <softwaredevelopmentvideos2023@gmail.com>
- Update middleware to use standard authkit configuration - Fix signin/signout routes to use proper Next.js patterns - Convert Link components to anchor tags for OAuth flow - Add automatic redirect to dashboard for authenticated users - Fix environment variables (use NEXT_PUBLIC_WORKOS_REDIRECT_URI) - Add error logging and debugging routes Co-Authored-By: Claude <noreply@anthropic.com>
- Implement search usage tracking with daily limits - Add incrementSearchCount and canUserSearch to track user searches - Fix URL parsing error in chat interface with proper error handling - Configure WorkOS middleware with homepage URL requirement - Update Polar configuration to use sandbox environment - Add proper error handling for expired Polar API tokens - Track usage stats in dashboard showing searches used today - Prevent users from exceeding daily search limits (10 for free tier) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add try-catch block for second URL parsing occurrence - Return 'Unknown source' when URL is invalid - Prevents runtime errors when search results have malformed URLs 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Switch Pro tier from unlimited to 500 searches per month - Add credit-based tracking system for Pro users - Implement monthly credit reset mechanism - Add credits display in navigation bar - Update dashboard to show monthly credits for Pro users - Add meter reporting to Polar for usage tracking - Create API endpoints for usage reporting and balance checking - Update schema to support both daily (free) and monthly (pro) tracking 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix signOut route to redirect to home page - Add Suspense boundary to dashboard page for useSearchParams - Install missing next-themes dependency - Remove debug/test API routes that expose sensitive info - Fix TypeScript type errors with search limits - Update meter API endpoints to use placeholders (not available in sandbox) - Ensure build completes successfully 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Polar Payments, WorkOS Authentication, and Convex Database Integration
Summary
This PR implements comprehensive integrations for the Fireplexity AI search engine:
Review & Testing Checklist for Human
/api/auth/meand/api/checkoutroutes and restore proper WorkOS authenticationRecommended Test Plan:
Diagram
%%{ init : { "theme" : "default" }}%% graph TB subgraph "Frontend" LP["app/page.tsx<br/>Landing Page"]:::major-edit DASH["app/dashboard/page.tsx<br/>Dashboard"]:::major-edit SEARCH["app/search/page.tsx<br/>Search Interface"]:::major-edit end subgraph "Authentication" MW["middleware.ts<br/>Auth Middleware"]:::major-edit AUTH_ME["app/api/auth/me/route.ts<br/>User Session"]:::major-edit PROVIDERS["components/providers.tsx<br/>Auth Provider"]:::major-edit end subgraph "Payments" CHECKOUT["app/api/checkout/route.ts<br/>Polar Checkout"]:::major-edit WEBHOOK["app/api/webhooks/polar/route.ts<br/>Subscription Events"]:::major-edit end subgraph "Database" USERS["convex/users.ts<br/>User Management"]:::major-edit SEARCHES["convex/searches.ts<br/>Search History"]:::major-edit SCHEMA["convex/schema.ts<br/>Database Schema"]:::major-edit end subgraph "Configuration" ENV[".env.local<br/>Environment Variables"]:::minor-edit LAYOUT["app/layout.tsx<br/>Root Layout"]:::minor-edit end LP --> AUTH_ME DASH --> USERS SEARCH --> SEARCHES MW --> AUTH_ME CHECKOUT --> WEBHOOK PROVIDERS --> USERS subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
npx convex devandnpm run devrequired to run the applicationScreenshots:

