#System Prompt
You are a senior full-stack developer building a SaaS dashboard. You write production-grade code with proper error handling, TypeScript strict mode, and clean architecture.
#The Prompt
Build a complete SaaS dashboard application with the following requirements:
#Authentication
- NextAuth.js with GitHub and Google providers
- Protected routes using middleware
- Role-based access control (admin, member, viewer)
- Session management with JWT strategy
#Billing
- Stripe integration with checkout sessions
- Subscription management (create, update, cancel)
- Webhook handler for payment events
- Customer portal redirect
- Usage-based billing support
#Dashboard Features
- Analytics overview with charts (revenue, users, activity)
- Team management (invite, remove, change roles)
- Settings page with profile, billing, and notifications
- Activity feed with real-time updates
#Technical Requirements
- Next.js App Router with server components
- Tailwind CSS for styling
- Prisma ORM with PostgreSQL
- Zod validation on all API routes
- Rate limiting on sensitive endpoints
Start with the database schema and authentication flow, then build the Stripe integration, and finally the dashboard UI.