A comprehensive Next.js 15 exam preparation and management platform with Arabic (RTL) support, role-based access control, and subscription management.
- better-auth integration with email OTP and Google OAuth
- Role-based access control (ADMIN, STUDENT, EDITOR)
- Custom session management with subscription sync
- Secure API endpoints with Arcjet protection
- Create and manage exams with time limits
- Multiple question types: MULTIPLE_CHOICE, TRUE_FALSE, CHART_AND_MULTIPLE_CHOICE, TABLE_AND_MULTIPLE_CHOICE
- CSV question import functionality
- Question randomization system
- Real-time progress tracking with automatic submission
- Comprehensive user profiles with exam history
- Data privacy controls and export capabilities
- Subscription management (FREE/PRO plans)
- Usage tracking and limits
- Analytics and metrics dashboard
- User management interface
- Content creation and management
- Polar.sh integration for payments
- Webhook handling with signature verification
- Usage-based billing and limits
- Customer portal integration
- Publicly accessible exam catalog
- Pricing and subscription pages
- SEO-optimized with sitemap generation
- Next.js 15 - React framework with App Router
- React 19 - UI library
- TypeScript - Type safety
- Tailwind CSS - Utility-first styling
- shadcn/ui - Reusable component library
- Framer Motion - Animations
- Recharts - Data visualization
- Next.js Server Actions - Server-side logic
- Prisma ORM - Database management
- PostgreSQL - Primary database
- better-auth - Authentication system
- Zod - Schema validation
- Arcjet - Rate limiting and security
- Polar.sh - Subscription management
- Nodemailer - Email delivery
- Pino - Structured logging
- CSV Parser - Bulk data import
- Bun - Fast JavaScript runtime and package manager
- Biome - Fast linter and formatter
- Husky - Git hooks
- tsx - TypeScript execution
- Prisma Studio - Database GUI
- Bun 1.0+ (or Node.js 18+)
- PostgreSQL database
-
Clone the repository
git clone https://github.com/tinyfroggy/exam-app cd exam-app -
Install dependencies
bun install
-
Setup environment variables
cp .env.example .env
Fill in your environment variables (see Environment Variables section)
-
Setup database
bun run prisma
-
Start development server
bun dev
Visit http://localhost:3000 to see the application.
bun dev # Start development server
bun run build # Build for production
bun run start # Start production serverbun run prisma # Generate Prisma client and push schema
bun run seed # Seed database with test data
bun run db:reset # Reset database and seed (β οΈ deletes all data)
bun run studio # Open Prisma Studiobun run check # Run Biome linter and formatter
bun run showE # TypeScript type checkingCopy .env.example to .env and configure the following sections:
DATABASE_URL=postgresql://user:password@localhost:5432/exam_dbBETTER_AUTH_SECRET=your-secret-key
BETTER_AUTH_URL=http://localhost:3000
NEXT_PUBLIC_BETTER_AUTH_URL=http://localhost:3000GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secretAPP_EMAIL_ADDRESS=your-email@gmail.com
APP_EMAIL_PASSWORD=your-app-passwordARCJET_KEY=your-arcjet-keyPOLAR_ACCESS_TOKEN=your-polar-access-token
POLAR_PRODUCT_ID_PRO=your-product-id
POLAR_SUCCESS_URL=http://localhost:3000/success
POLAR_WEBHOOK_SECRET=your-webhook-secretFREE_PLAN_MONTHLY_LIMIT=10
PRO_PLAN_MONTHLY_LIMIT=1000app/
βββ (admin)/ # Admin-only routes
βββ (auth)/ # Authentication pages
βββ (private)/ # Protected user routes
βββ (public)/ # Public pages
βββ api/ # API endpoints (minimal)
- Users - Authentication and profile data
- Exams - Exam definitions and metadata
- Questions - Question bank with multiple types
- UserExamAttempts - Exam sessions and results
- BaseService - Common database operations
- AdminActions - Admin-specific operations
- AuthActions - Authentication services
- UserActions - User profile management
- SubscriptionActions - Payment and billing
- Rate limiting with Arcjet
- Email validation and protection
- Webhook signature verification
- SQL injection prevention with Prisma
- XSS protection with sanitization
- RBAC (Role-Based Access Control)
- Full Arabic (RTL) support
- Arabic UI text and messages
- RTL-optimized layouts
- Arabic date and time formatting
- Structured logging with Pino
- Error tracking and handling
- Performance monitoring
- Usage analytics for subscriptions
Deploy to Railway with one click or via CLI:
- Create a new project on Railway
- Connect your GitHub repository
- Add a PostgreSQL database from the Railway dashboard
- Set your environment variables from
.env.example - Railway will auto-deploy on every push to main
Ensure your PostgreSQL database is accessible and run:
npx prisma migrate deploy- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License.
- API Reference: Available in development mode
- Support: Create an Issue
Built with β€οΈ using Next.js 15 and modern web technologies