A modern, elegant payment tracking application for learning programs. Built with Next.js, TypeScript, Tailwind CSS, MongoDB, and Paystack integration.
- Modern Authentication: Google OAuth integration with NextAuth.js
- Flexible Payment Schedules: Support for daily, weekly, monthly, and one-time payments
- Beautiful UI: Dark theme with blue accents, modern and minimal design
- Payment Processing: Integrated with Paystack for secure payments
- Progress Tracking: Visual progress bars and payment history
- Email Notifications: Automated payment reminders via Gmail
- Admin Dashboard: Comprehensive admin interface for tracking all users and payments
- Responsive Design: Mobile-first design with Tailwind CSS
- Frontend: Next.js 14, TypeScript, Tailwind CSS
- Backend: Next.js API routes, MongoDB with Mongoose
- Authentication: NextAuth.js with Google Provider
- Payments: Paystack integration
- Email: Nodemailer with Gmail SMTP
- Database: MongoDB Atlas
git clone <repository-url>
cd paytracknpm installCopy the example environment file:
cp .env.example .env.localFill in your environment variables in .env.local:
# Authentication
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-nextauth-secret-key-here
# Google OAuth (Get from Google Cloud Console)
GOOGLE_CLIENT_ID=your-google-client-id-here
GOOGLE_CLIENT_SECRET=your-google-client-secret-here
# MongoDB Atlas
MONGODB_URI=your-mongodb-atlas-connection-string-here
# Paystack (Get from Paystack Dashboard)
PAYSTACK_SECRET_KEY=your-paystack-secret-key-here
PAYSTACK_PUBLIC_KEY=your-paystack-public-key-here
# Gmail SMTP (Use Gmail App Password)
GMAIL_USER=your-gmail-address@gmail.com
GMAIL_APP_PASSWORD=your-gmail-app-password-here
# Admin Access
ADMIN_EMAIL=your-admin-email@gmail.com- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Google+ API
- Create credentials (OAuth 2.0 Client ID)
- Add authorized redirect URI:
http://localhost:3000/api/auth/callback/google - Copy Client ID and Client Secret to
.env.local
- Create account at MongoDB Atlas
- Create a new cluster
- Create a database user
- Get connection string and add to
.env.local - Whitelist your IP address
- Create account at Paystack
- Get your secret and public keys from the dashboard
- Add keys to
.env.local
- Enable 2-factor authentication on your Gmail account
- Generate an App Password:
- Go to Google Account settings
- Security → 2-Step Verification → App passwords
- Generate password for "Mail"
- Use your Gmail and app password in
.env.local
npm run devVisit http://localhost:3000 to see the application.
- Sign in with your Google account
- Add a program with details like name, cost, duration, and payment schedule
- Make payments through Paystack integration
- Track progress with visual progress bars and payment history
- Receive email reminders for upcoming payments
- Set your email as
ADMIN_EMAILin environment variables - Access admin dashboard at
/admin - View all users, programs, and payments
- Send manual payment reminders
- Monitor revenue and statistics
GET/POST /api/auth/*- NextAuth.js endpoints
GET /api/programs- Get user's programsPOST /api/programs- Create new program
POST /api/payments/initialize- Initialize Paystack paymentGET /api/payments/verify- Verify payment callback
GET /api/admin/stats- Get admin statisticsPOST /api/admin/send-reminder- Send payment reminder
GET /api/cron/send-reminders- Send automated reminders
Ensure all production environment variables are set:
NEXTAUTH_URLshould be your production domain- All API keys should be production keys
ADMIN_EMAILshould be your admin email
- Ensure MongoDB Atlas is properly configured
- Database will auto-create collections on first use
Set up the following cron jobs for automated system management:
- Payment Reminders:
/api/cron/send-reminders- Daily at 9 AM - Program Management:
/api/cron/manage-programs- Every hour
The program management cron handles:
- Freezing programs that miss payment deadlines (only after first payment)
- Admin notifications for all automated actions
Payment Flow:
- Programs start with no payment deadline after approval
- Payment schedule begins only after the first payment is made
- Subsequent payments follow the chosen schedule (daily/weekly/monthly)
Example cron setup:
# Payment reminders (daily at 9 AM)
0 9 * * * curl -H "Authorization: Bearer YOUR_CRON_SECRET" https://yourapp.com/api/cron/send-reminders
# Program management (hourly)
0 * * * * curl -H "Authorization: Bearer YOUR_CRON_SECRET" https://yourapp.com/api/cron/manage-programsAdd CRON_SECRET=your-secure-secret to your environment variables for cron job authentication.
Set up a cron job to call /api/cron/send-reminders daily to send automatic payment reminders.
src/
├── app/ # App router pages
│ ├── api/ # API routes
│ ├── auth/ # Authentication pages
│ ├── admin/ # Admin dashboard
│ └── dashboard/ # User dashboard
├── components/ # React components
│ ├── admin/ # Admin components
│ └── dashboard/ # Dashboard components
├── lib/ # Utility libraries
│ ├── auth.ts # NextAuth configuration
│ ├── mongodb.ts # Database connection
│ ├── email.ts # Email utilities
│ └── utils.ts # Helper functions
├── models/ # MongoDB models
│ ├── Program.ts # Program schema
│ └── Payment.ts # Payment schema
└── types/ # TypeScript type definitions
- Daily: Users pay a daily amount based on monthly cost ÷ 30
- Weekly: Users pay weekly based on monthly cost ÷ 4
- Monthly: Users pay the full monthly amount
- Once: Users pay the entire program cost upfront
- Payment confirmation emails after successful payments
- Payment reminder emails for overdue payments
- Beautiful HTML email templates with branding
- View all users and their programs
- Monitor payment schedules and overdue accounts
- Send manual payment reminders
- Track total revenue and statistics
- Environment variables for sensitive data
- NextAuth.js for secure authentication
- Paystack handles payment security
- Input validation on all forms
- Admin-only routes protection
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is built for educational and business purposes.
PayTrack by Tini - Making learning payment tracking elegant and simple.