A leaderboard application built with Next.js for tracking Google Cloud Study Jam participants.
- Admin dashboard for uploading CSV data
- Google Sheets integration
- Responsive design for mobile and desktop
- Dark/light theme toggle
- Search and sorting functionality
- Participant statistics
- Data persistence for 2 days
- Node.js 18+
- npm or yarn
- MongoDB (local or Atlas)
-
Clone the repository:
git clone <your-repo-url> cd leaderboard-app
-
Install dependencies:
npm install
-
Create a
.env.localfile with:NEXT_PUBLIC_ADMIN_USERNAME=admin NEXT_PUBLIC_ADMIN_PASSWORD=your_secure_password MONGODB_URI=your_mongodb_connection_string -
Set up TTL indexes for automatic data cleanup (data will be automatically deleted after 2 days):
npm run setup-ttl-indexes
-
Run the development server:
npm run dev
-
Open http://localhost:3000 in your browser
The application now includes automatic data retention for 2 days:
- Data is automatically deleted after 2 days using MongoDB TTL indexes
- Manual cleanup scripts are available for maintenance
To ensure data is automatically deleted after 2 days, run:
npm run setup-ttl-indexesThis script creates TTL (Time To Live) indexes on the MongoDB collections that will automatically expire documents after 2 days.
To manually clean up old data (older than 2 days):
npm run cleanup-old-data- When data is inserted into the database, a
createdAttimestamp is added to each document - TTL indexes are configured to automatically delete documents older than 2 days
- This ensures that leaderboard data is retained for exactly 2 days as requested
- Push your code to GitHub
- Sign up at Vercel
- Create a new project and import your GitHub repository
- Add environment variables in the Vercel dashboard:
NEXT_PUBLIC_ADMIN_USERNAME- Your admin usernameNEXT_PUBLIC_ADMIN_PASSWORD- Your admin passwordMONGODB_URI- Your MongoDB connection string (for MongoDB Atlas or other cloud MongoDB services)
- Configure build settings:
- Build Command:
npm run build - Output Directory:
.next - Install Command:
npm install
- Build Command:
- After deployment, run the TTL index setup script to ensure data retention works:
npm run setup-ttl-indexes
- Deploy!
For production deployment, you should set these environment variables in your Vercel dashboard:
NEXT_PUBLIC_ADMIN_USERNAME=your_admin_username
NEXT_PUBLIC_ADMIN_PASSWORD=your_secure_admin_password
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/leaderboard
Note: Environment variables prefixed with NEXT_PUBLIC_ will be embedded into the browser bundle and are visible to the client. For sensitive data, use environment variables without this prefix.
For production, it's recommended to use a cloud MongoDB service like MongoDB Atlas rather than a local database.
To use MongoDB Atlas:
- Log in to your MongoDB Atlas account
- Select your cluster
- Click "Connect"
- Choose "Connect your application"
- Copy the connection string and replace
<password>with your actual password - Replace
<dbname>with your database name (e.g.,leaderboard) - Update the
MONGODB_URIenvironment variable with your MongoDB Atlas connection string - Make sure your IP address is whitelisted in MongoDB Atlas
- Ensure your database user has read/write permissions
Example connection string:
MONGODB_URI=mongodb+srv://anadisharma44_db_user:your_password@your-cluster-name.mongodb.net/leaderboard?retryWrites=true&w=majority&appName=Cluster0
If you encounter SSL/TLS connection errors:
- Ensure your system has the latest certificates
- Update your Node.js to the latest LTS version
- Try connecting with relaxed SSL settings for testing (NOT recommended for production)
- Check your firewall settings
- Verify your system's OpenSSL configuration
- Click "Admin Login" button
- Enter credentials (default: admin / your_secure_password)
- Upload CSV data or connect to Google Sheets
Your CSV should include at minimum:
- "User Name"
- "User Email"
Optional columns:
- "rank"
- "# of Skill Badges Completed"
- "# of Arcade Games Completed"
- "All Skill Badges & Games Completed"
- "Google Cloud Skills Boost Profile URL"
Update the environment variables:
NEXT_PUBLIC_ADMIN_USERNAMENEXT_PUBLIC_ADMIN_PASSWORD
To learn more about the technologies used:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.