Prerequisites
Before setting up the platform, ensure you have:- Node.js 18+ installed
- MongoDB database (local or cloud)
- Google Cloud Platform account
- Mercado Pago account (for payments)
- GitHub/Google OAuth applications configured
Environment Variables
The platform requires multiple environment variables for proper operation.Authentication Variables
NextAuth.js secret key for session encryption. Generate using:
Google OAuth Client ID from Google Cloud Console
Google OAuth Client Secret from Google Cloud Console
Email address of the platform administrator. Only this email will have admin access.
OAuth redirect URI (e.g.,
http://localhost:3000/api/auth/callback/google)src/auth.ts:15-26
Database Configuration
MongoDB connection string. Format:
prisma/schema.prisma:11-14
Google Calendar Integration
Google Calendar ID where classes will be scheduled (usually your email address)
Google Calendar API key from Google Cloud Console
Service account credentials as JSON string (optional, for service account authentication)
src/app/api/calendar/route.ts:10-11
Payment Integration (Mercado Pago)
Mercado Pago private access token from your account dashboard
Mercado Pago public key (client-side accessible)
src/app/api/mercado-pago/create-preference/route.ts:24
Application URLs
Full base URL of your application including protocol:
- Development:
http://localhost:3000/ - Production:
https://yourdomain.com/
AI Integration (Optional)
OpenAI API key for AI-powered activity generation (if using)
src/env.ts:6
Example .env File
Database Setup
1. Initialize Prisma
Generate Prisma client:2. Push Schema to Database
For MongoDB, push the schema:MongoDB with Prisma doesn’t use traditional migrations. Use
db push to synchronize your schema.3. Seed Initial Data (Optional)
Create a seed script if needed:OAuth Configuration
Google Cloud Console Setup
-
Create a Project
- Go to Google Cloud Console
- Create a new project or select existing
-
Enable APIs
- Enable Google Calendar API
- Enable Google+ API (for OAuth)
-
Create OAuth Credentials
- Navigate to “APIs & Services” > “Credentials”
- Create OAuth 2.0 Client ID
- Application type: Web application
- Authorized redirect URIs:
-
Configure Consent Screen
- Add required scopes:
openidemailprofilehttps://www.googleapis.com/auth/calendar.events
- Add required scopes:
-
Copy Credentials
- Copy Client ID to
AUTH_GOOGLE_ID - Copy Client Secret to
AUTH_GOOGLE_SECRET
- Copy Client ID to
GitHub OAuth Setup (Optional)
- Go to GitHub Settings > Developer settings > OAuth Apps
- Create new OAuth App
- Set Authorization callback URL:
- Copy Client ID and Client Secret to environment variables
Payment Integration Setup
See the dedicated Payment Integration guide for detailed Mercado Pago configuration.Calendar Integration Setup
See the dedicated Calendar Setup guide for detailed Google Calendar configuration.Application Deployment
Development
http://localhost:3000
Production Build
Deployment Platforms
The application can be deployed to:-
Vercel (recommended for Next.js)
- Automatic deployments from Git
- Environment variables in dashboard
- Serverless functions support
-
Railway
- Full Node.js environment
- MongoDB hosting available
- Environment variable management
-
DigitalOcean App Platform
- Container-based deployment
- Database hosting
- SSL certificates included
Environment Variables in Production
Post-Deployment Checklist
After deployment, verify:- OAuth providers work (test login)
- Admin email grants proper access
- Database connections are stable
- Google Calendar events create successfully
- Mercado Pago webhooks receive notifications
- SSL certificate is active (production)
- Error logging is configured
- Backup strategy is in place
Security Best Practices
Session Security
- Sessions expire after 30 days
- JWT tokens are signed with
AUTH_SECRET - HTTPS required in production
API Security
- All admin routes verify email match
- Server actions validate user sessions
- Database queries use parameterized inputs
Data Protection
- User passwords managed by OAuth providers
- Sensitive tokens stored server-side only
- Environment variables never exposed to client
Monitoring and Logging
Recommended Tools
- Error Tracking: Sentry
- Performance: Vercel Analytics
- Database: MongoDB Atlas monitoring
- Uptime: UptimeRobot
Log Locations
Current logging is console-based. Consider implementing:Troubleshooting
Common Issues
“No admin access”- Verify
ADMIN_EMAILmatches your OAuth email exactly - Check environment variables are loaded
- Clear browser cookies and re-login
- Verify admin user has granted calendar permissions
- Check
googleRefreshTokenis stored in database - Verify Calendar API is enabled in Google Cloud
- Ensure
BASE_URLends with/ - Verify Mercado Pago webhook URL is correct
- Check webhook URL is publicly accessible
- Verify
DATABASE_URLformat - Check MongoDB Atlas IP whitelist
- Ensure database user has proper permissions
Related Resources
Payment Integration
Configure Mercado Pago payment processing
Calendar Setup
Set up Google Calendar integration