A production-ready Next.js MERN monorepo application for managing sports equipment and attendance in college sports programs. Features Microsoft Azure AD authentication with role-based access control for Students, Coaches, and Admins.
- Frontend: Next.js 15 with TypeScript, Tailwind CSS, App Router
- Backend: Next.js API Routes (serverless functions)
- Database: MongoDB with Mongoose ODM
- Authentication: Microsoft Azure AD (Entra ID) + JWT
- File Generation: PDFKit for certificates, ExcelJS for reports
- Development: Turbopack for fast development builds
sports/
├── src/
│ ├── app/ # Next.js App Router pages
│ │ ├── api/ # Backend API routes
│ │ ├── login/ # Login page
│ │ └── dashboard/ # Dashboard pages
│ ├── components/ # React components
│ │ ├── ui/ # Reusable UI components
│ │ └── auth/ # Authentication components
│ ├── context/ # React contexts
│ ├── lib/ # Utility libraries
│ ├── middleware/ # API middleware
│ ├── models/ # Mongoose models
│ └── types/ # TypeScript type definitions
├── public/ # Static assets
└── package.json # Dependencies and scripts
- Microsoft Login: Azure AD integration for college accounts
- Role-based Access: Student, Coach, Admin roles
- Auto-registration: Students auto-register via email pattern
- Additional Security: Coach/Admin require additional password verification
- Equipment Requests: Request sports equipment with quantity and return date
- Status Tracking: Track equipment through lifecycle (Requested → Taken → Returned → Approved)
- Return Process: Mark equipment as returned, triggers admin approval
- No Dues Certificate: Auto-generated PDF certificate after all items returned
- Transaction History: View all equipment transactions with filtering
- Dashboard: Overview of active borrowings, pending returns, overdue items
- Logbook Management: Searchable/filterable equipment transaction history
- Return Approval: Approve or reject equipment returns
- Attendance Management: View and manage attendance across all sports
- Coach Management: Create, update, delete coach accounts
- Export Functionality: Excel export for logbook and attendance data
- Password Management: Change admin password
- Sport-specific Access: Only see students from assigned sport
- Attendance Marking: Mark students present/absent
- Student Roster: View and search assigned students
- Attendance Reports: View attendance history with statistics
Before running this application, ensure you have:
- Node.js (v18 or later)
- MongoDB (local installation or MongoDB Atlas)
- Azure AD Application registered in Microsoft Entra
- Git for version control
git clone <repository-url>
cd sports
npm install
Create a .env.local
file in the root directory:
# Database
MONGODB_URI=mongodb://localhost:27017/sports-equipment-db
# Authentication
JWT_SECRET=your-super-secret-jwt-key-change-in-production-min-32-chars
# Microsoft Azure AD
MICROSOFT_CLIENT_ID=your-azure-app-client-id
MICROSOFT_CLIENT_SECRET=your-azure-app-client-secret
MICROSOFT_AUTHORITY=https://login.microsoftonline.com/your-tenant-id
# Public environment variables (accessible in browser)
NEXT_PUBLIC_MICROSOFT_CLIENT_ID=your-azure-app-client-id
NEXT_PUBLIC_MICROSOFT_AUTHORITY=https://login.microsoftonline.com/your-tenant-id
# Default Admin (create on first run)
DEFAULT_ADMIN_EMAIL=admin@college.edu
DEFAULT_ADMIN_PASSWORD=ChangeThisPassword123!
- Go to Azure Portal
- Navigate to "Azure Active Directory" → "App registrations"
- Create a new registration with redirect URI:
http://localhost:3000/
- Configure API permissions: Microsoft Graph → User.Read (delegated)
- Create client secret and copy values to
.env.local
npm run dev
The application will be available at http://localhost:3000
- JWT token authentication
- Role-based API protection
- Password hashing with bcrypt
- Input validation
- Environment variable protection
- Auth:
/api/auth/*
- Login and role verification - Student:
/api/student/*
- Equipment requests and transactions - Admin:
/api/admin/*
- Dashboard, approvals, exports - Coach:
/api/coach/*
- Students and attendance
Professional, minimal design with:
- Clean cards with soft shadows
- Blue/green/gray color palette
- Responsive mobile-first layout
- Accessible components with proper contrast
- Connect GitHub repository
- Add environment variables
- Deploy automatically
npm run build
npm start
Common issues and solutions:
- Microsoft Login: Check Azure AD configuration
- Database: Verify MongoDB connection
- Build Errors: Clear cache and reinstall dependencies
For detailed setup instructions, API documentation, and troubleshooting, see the sections above.
Ready to manage your college sports equipment efficiently! 🏆