A modern platform for managing school enrollments and tracking lunch debt
Features β’ Installation β’ Configuration β’ Usage β’ API Documentation β’ Admin Panel β’ Testing
- Overview
- Features
- Tech Stack
- Installation
- Configuration
- Usage
- API Documentation
- Admin Panel
- Project Structure
- Security
- Troubleshooting
Lunch Money is a comprehensive web application designed to help schools manage enrollments and track lunch debt. The platform features a user-friendly enrollment form for schools to register and a secure admin panel for managing all enrollments.
- β¨ Modern UI/UX - Beautiful, responsive design built with Tailwind CSS
- π Secure Admin Panel - Environment-based authentication
- π Real-time Management - View, edit, and delete enrollments
- ποΈ MongoDB Integration - Robust database storage
- π Next.js 15 - Latest features and performance optimizations
- School Enrollment Form
- Easy-to-use form for school registration
- Real-time validation
- Success/error notifications
- Responsive design
-
Secure Authentication
- Environment variable-based login
- Session management
- Protected routes
-
Enrollment Management
- View all enrollments in a table
- Inline editing capabilities
- Delete enrollments with confirmation
- Sort by creation date (newest first)
| Technology | Version | Purpose |
|---|---|---|
| Next.js | 15.1.0 | React framework with App Router |
| React | 19.2.0 | UI library |
| MongoDB | Latest | Database |
| Mongoose | 9.0.1 | MongoDB ODM |
| Tailwind CSS | 3.4.17 | Styling |
| Node.js | Latest | Runtime environment |
- Node.js 18+ installed
- MongoDB instance (local or MongoDB Atlas)
- npm or yarn package manager
git clone <repository-url>
cd Lunch-Moneynpm installCreate a .env file in the root directory:
cp .env.example .envEdit the .env file with your configuration:
MONGODB_URI=mongodb://localhost:27017/lunch-money
ADMIN_USERNAME=admin
ADMIN_PASSWORD=your_secure_password
ADMIN_SESSION_SECRET=your_random_secret_key_here
NODE_ENV=developmentLocal MongoDB:
# macOS (using Homebrew)
brew services start mongodb-community
# Linux
sudo systemctl start mongod
# Windows
# Start MongoDB service from Services panelMongoDB Atlas:
- Create a free cluster at MongoDB Atlas
- Get your connection string
- Update
MONGODB_URIin.env
npm run devOpen http://localhost:3000 in your browser.
| Variable | Description | Required | Example |
|---|---|---|---|
MONGODB_URI |
MongoDB connection string | β Yes | mongodb://localhost:27017/lunch-money |
ADMIN_USERNAME |
Admin panel username | β Yes | admin |
ADMIN_PASSWORD |
Admin panel password | β Yes | secure_password_123 |
ADMIN_SESSION_SECRET |
Session encryption key | β Yes | random_string_here |
NODE_ENV |
Environment mode | β No | development or production |
Local MongoDB:
MONGODB_URI=mongodb://localhost:27017/lunch-moneyMongoDB Atlas:
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/lunch-money?retryWrites=true&w=majority- Navigate to the homepage
- Scroll to the "School Enrollment Form" section
- Fill in all required fields:
- School Name
- District Name
- Administrator Name
- Email Address
- Total Students
- Current Lunch Debt
- Click "Enroll School"
- You'll see a success message upon submission
- Navigate to
/admin/login - Enter your admin credentials (from
.env) - Click "Login"
- You'll be redirected to the dashboard
View Enrollments:
- All enrollments are displayed in a table
- Sorted by creation date (newest first)
Edit Enrollment:
- Click "Edit" on any enrollment row
- Modify the fields inline
- Click "Save" to update
- Click "Cancel" to discard changes
Delete Enrollment:
- Click "Delete" on any enrollment row
- Confirm the deletion
- The enrollment will be permanently removed
Logout:
- Click the "Logout" button in the top-right corner
Submit a new school enrollment.
Request Body:
{
"schoolName": "Lincoln High School",
"districtName": "Springfield District",
"administratorName": "John Doe",
"email": "admin@lincoln.edu",
"totalStudents": 500,
"currentLunchDebt": "5%"
}Response (201):
{
"message": "Enrollment submitted successfully",
"enrollment": {
"_id": "...",
"schoolName": "Lincoln High School",
...
}
}Get all enrollments (Admin only).
Headers:
- Requires admin session cookie
Response (200):
{
"enrollments": [
{
"_id": "...",
"schoolName": "...",
"districtName": "...",
"administratorName": "...",
"email": "...",
"totalStudents": 500,
"currentLunchDebt": "5%",
"createdAt": "2024-01-01T00:00:00.000Z"
}
]
}Update an enrollment (Admin only).
Request Body:
{
"schoolName": "Updated School Name",
"districtName": "...",
"administratorName": "...",
"email": "...",
"totalStudents": 600,
"currentLunchDebt": "4%"
}Response (200):
{
"message": "Enrollment updated successfully",
"enrollment": { ... }
}Delete an enrollment (Admin only).
Response (200):
{
"message": "Enrollment deleted successfully"
}Admin login.
Request Body:
{
"username": "admin",
"password": "your_password"
}Response (200):
{
"message": "Login successful"
}Check authentication status.
Response (200):
{
"authenticated": true
}Admin logout.
Response (200):
{
"message": "Logout successful"
}- URL:
http://localhost:3000/admin/login - Credentials: Set in
.envfile
- β Secure authentication
- π Enrollment dashboard
- βοΈ Inline editing
- ποΈ Delete functionality
- π Session management
- π± Responsive design
- Credentials stored only in environment variables
- HTTP-only cookies for session management
- Protected API routes
- No hardcoded credentials
Lunch-Money/
βββ src/
β βββ app/
β β βββ admin/
β β β βββ dashboard/
β β β β βββ page.jsx # Admin dashboard
β β β βββ login/
β β β βββ page.jsx # Admin login page
β β βββ api/
β β β βββ admin/
β β β β βββ login/
β β β β β βββ route.js # Admin login/logout API
β β β β βββ logout/
β β β β βββ route.js # Admin logout API
β β β βββ enrollments/
β β β βββ [id]/
β β β β βββ route.js # Update/Delete enrollment
β β β βββ route.js # Create/Get enrollments
β β βββ layout.jsx # Root layout
β β βββ page.jsx # Homepage
β βββ components/
β β βββ EnrollmentForm.jsx # Enrollment form component
β β βββ Navbar.jsx # Navigation bar
β β βββ Footer.jsx # Footer component
β β βββ ... # Other components
β βββ lib/
β β βββ mongodb.js # MongoDB connection utility
β βββ models/
β βββ Enrollment.js # Enrollment Mongoose model
βββ public/
β βββ assets/ # Static assets
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules
βββ jsconfig.json # JavaScript configuration
βββ next.config.js # Next.js configuration
βββ package.json # Dependencies
βββ README.md # This file
-
Environment Variables
- All sensitive data stored in
.env .envexcluded from version control
- All sensitive data stored in
-
Authentication
- Session-based authentication
- HTTP-only cookies
- Secure session secrets
-
API Protection
- Admin routes require authentication
- Input validation on all endpoints
- Error handling without exposing internals
-
Data Validation
- Email format validation
- Required field checks
- Type validation
- Use strong
ADMIN_PASSWORD - Generate random
ADMIN_SESSION_SECRET - Enable HTTPS
- Use MongoDB Atlas with IP whitelisting
- Set
NODE_ENV=production - Implement rate limiting
- Add CORS configuration if needed
Error: MongooseServerSelectionError
Solutions:
- Verify MongoDB is running:
mongoshor check service status - Check
MONGODB_URIin.env - For Atlas: Verify network access and credentials
- Check firewall settings
Solutions:
- Verify
ADMIN_USERNAMEandADMIN_PASSWORDin.env - Check browser console for errors
- Clear cookies and try again
- Verify
ADMIN_SESSION_SECRETis set
Solutions:
- Check browser console for errors
- Verify MongoDB connection
- Check all required fields are filled
- Verify email format is correct
Solutions:
- Delete
.nextfolder:rm -rf .next - Clear node_modules:
rm -rf node_modules && npm install - Check Node.js version:
node --version(should be 18+)
# Development
npm run dev # Start development server
# Production
npm run build # Build for production
npm start # Start production server
# Code Quality
npm run lint # Run ESLint- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is private and proprietary.
- Create components in
src/components/ - Add API routes in
src/app/api/ - Update models in
src/models/if needed - Test thoroughly before deployment
Enrollment Model:
{
schoolName: String (required)
districtName: String (required)
administratorName: String (required)
email: String (required)
totalStudents: Number (required)
currentLunchDebt: String (required)
createdAt: Date (auto-generated)
}Comprehensive testing guide is available in TESTING.md.
-
Test Enrollment Form:
- Fill out and submit the enrollment form on the homepage
- Verify success message appears
- Check MongoDB for saved data
-
Test Admin Panel:
- Navigate to
/admin/login - Login with credentials from
.env - View, edit, and delete enrollments
- Navigate to
-
Test API Endpoints:
# Test enrollment submission curl -X POST http://localhost:3000/api/enrollments \ -H "Content-Type: application/json" \ -d '{"schoolName":"Test","districtName":"Test","administratorName":"Test","email":"test@test.com","totalStudents":100,"currentLunchDebt":"5%"}'
For detailed testing procedures, see TESTING.md.
For issues and questions:
- Check the Troubleshooting section
- Review TESTING.md for testing procedures
- Review API documentation
- Check browser console for errors
- Verify environment configuration
Built with β€οΈ using Next.js and MongoDB
β Star this repo if you find it helpful!