How newer1107/coe-main works
1. This repository is a single Next.js App Router application that combines the public website, authenticated portals, and a large /api backend in one codebase. The main architectural boundary is between UI routes under src/app/** and server route handlers under src/app/api/**.
2. The application serves three primary personas: students, faculty, and admins. Public pages handle browsing content and innovation pages; protected pages gate facility booking, faculty workflows, admin operations, and innovation-specific student actions. Route-level redirects and role checks enforce those boundaries.
3. The backend is API-driven. Most business logic lives in route handlers for auth, bookings, content publishing, innovation workflows, profile management, cron jobs, and utility endpoints. Client components mainly call these APIs and refresh local UI state.
4. Persistence is centered on MySQL via Prisma. The schema and a large migration history show this is the core system of record for users, OTPs, bookings, content, innovation problems, applications, claims, scoring, tickets, attendance, email jobs, and related metadata. The database is also used for workflow state transitions, not just CRUD.
5. Authentication is session-based with JWT access and refresh tokens stored in httpOnly cookies. The auth subsystem includes registration for students and faculty, OTP verification, login/logout, refresh, forgot/reset password, and role-aware access checks. This is the main security boundary for all protected APIs and pages.
6. Content management is a separate subsystem for news, events, grants, announcements, and hero slides. Faculty and admins can create or manage content, while public pages read it. This is the site’s public-facing information layer and is distinct from the innovation and booking domains.
7. Facility booking is its own workflow with a clear approval lifecycle: student creates a pending booking, admin confirms or rejects it, and confirmed bookings can trigger reminder emails. Admin moderation and student cancellation are separate endpoints, showing a two-sided operational process rather than direct self-service approval.
8. The innovation platform is the most complex subsystem and is split into two tracks: open problems and hackathons. Open problems use student profiles, custom problem questions, and applications with faculty review. Hackathons use event registration, team claims, staged screening/judging sync, scoring, leaderboard generation, and event-status transitions.
9. Hackathon operations are designed around staged control by faculty/admin. Teams submit a PPT-backed registration, screening results can shortlist or reject claims, shortlisted teams receive tickets, attendance is tracked per team member, and final judging persists rubric scores and ranks. Leaderboard visibility depends on the event reaching the closed state.
10. File and media storage is externalized to MinIO, accessed either directly or through a browser-safe proxy route under /api/storage/[...path]. This matters because uploads include resumes, PPTs, and content images, so object storage is a distinct infrastructure boundary from the MySQL database.
11. Notifications are split between synchronous email sending and durable queued delivery. Nodemailer talks to SMTP, while an email_jobs table and cron-driven queue worker provide retryable delivery for operational emails such as OTPs, booking reminders, application decisions, and hackathon stage notifications.
12. Scheduled automation is exposed as cron endpoints instead of an internal job runner. The cron routes handle booking reminders, innovation event reminders/transitions, and email queue draining. This means external schedulers or hosting jobs are expected to invoke HTTP endpoints, making automation part of the public server surface.
13. Analytics is integrated at the application edge with GA4. Event tracking is attached to key user actions such as login, signup, booking, content views, and innovation participation. The analytics layer is separate from the transactional data model and is used for engagement reporting, not business logic.
14. The repository is operationalized for containerized deployment. Docker Compose, a Dockerfile, and migration scripts indicate the app can run with its database, migrations, and environment variables in a production-oriented setup. The main runtime dependencies are the Next.js server, MySQL, SMTP, MinIO, and external cron triggers.
Main entry points: schema.prisma Prisma schema · layout.tsx App shell · prisma.ts Shared libs · page.tsx Student portal
Components 22
UI routes
Next.js App Router pages and client portals
- App shell · Global layout and shared UI chrome
src/app/layout.tsx - Public site · Home, about, privacy, laboratory, and landing content
src/app/page.tsx - Auth pages · Login and password recovery entry points
src/app/login/page.tsx - Student portal · Profile, innovation, and facility booking experiences
src/app/profile/page.tsx - Faculty portal · Faculty dashboard and innovation workflows
src/app/faculty/page.tsx - Admin portal · Administrative control surface and moderation views
src/app/admin/page.tsx - Innovation UI · Programs, problems, events, applications, and submissions
src/app/innovation/page.tsx - Booking UI · Student booking request entry point
src/app/facility-booking/page.tsx
Server APIs
Route handlers under src/app/api
- Content API · News, events, grants, announcements, and hero slides
src/app/api/news/route.ts - Auth API · Register, verify OTP, login, refresh, logout, and password reset
src/app/api/auth/login/route.ts - Booking API · Booking creation, my-bookings, and admin approval lifecycle
src/app/api/bookings/route.ts - Innovation API · Open problems, applications, claims, programs, and user lookup
src/app/api/innovation/problems/route.ts - Hackathon API · Event registration, leaderboard, analytics, attendance, and team management
src/app/api/innovation/events/[id]/route.ts - Faculty API · Faculty review, sync, submissions, and attendance actions
src/app/api/innovation/faculty/applications/route.ts - Admin API · Admin controls for users, faculty approvals, bookings, and stats
src/app/api/admin/users/route.ts - Cron API · Email queue draining, reminders, and innovation automation
src/app/api/cron/email-queue/route.ts - Storage proxy · Browser-safe MinIO access through a catch-all route
src/app/api/storage/[...path]/route.ts - Profile API · Profile read/update and completion checks
src/app/api/profile/route.ts
Data & infra
Persistence, storage, email, and shared runtime services
- Prisma schema · System of record for users, workflows, tickets, content, and jobs
prisma/schema.prisma - MinIO store · External file and media storage for uploads and public assets
- Email stack · Nodemailer delivery plus durable email job processing
src/lib/mailer.ts
Shared logic
Common libraries used across routes and pages
- Shared libs · JWT, Prisma, analytics, validators, scoring, tickets, and activity helpers
src/lib/prisma.ts
Connections 31
- App shell → Public site: renders · Shared layout frames the public-facing pages
- App shell → Auth pages: renders · Shared layout frames auth entry points
- App shell → Student portal: renders · Shared layout frames protected student flows
- App shell → Faculty portal: renders · Shared layout frames faculty flows
- App shell → Admin portal: renders · Shared layout frames admin flows
- Student portal → Innovation UI: navigates · Student area surfaces innovation workflows
- Student portal → Booking UI: navigates · Student area exposes facility booking
- Public site → Content API: reads · Public pages consume published content
- Auth pages → Auth API: calls · Login and recovery forms hit auth endpoints
- Student portal → Profile API: calls · Profile completeness and updates are API-driven
- Student portal → Booking API: calls · Students create and inspect bookings
- Innovation UI → Innovation API: calls · Problem and application screens use core innovation APIs
- Innovation UI → Hackathon API: calls · Event pages register teams and show results
- Faculty portal → Faculty API: calls · Faculty portal drives review and submission flows
- Admin portal → Admin API: calls · Admin portal manages users, bookings, and moderation
- Admin portal → Content API: calls · Admins can manage site content
- Cron API → Email stack: drives · Scheduled endpoints drain email jobs and send reminders
- Content API → Prisma schema: persists · Content records live in MySQL via Prisma
- Auth API → Prisma schema: persists · Users, OTPs, sessions, and password state are stored in MySQL
- Booking API → Prisma schema: persists · Booking requests and approval state are stored in MySQL
- Innovation API → Prisma schema: persists · Problems, applications, claims, and programs use the core database
- Hackathon API → Prisma schema: persists · Events, teams, tickets, attendance, and scoring are database-backed
- Faculty API → Prisma schema: persists · Faculty actions update review and submission state
- Admin API → Prisma schema: persists · Administrative operations read and update the system of record
- Profile API → Prisma schema: persists · Profile data and completion status are stored centrally
- Storage proxy → MinIO store: proxies · Uploads and downloads are brokered through the storage boundary
- Shared libs → Prisma schema: uses · Prisma access and workflow helpers depend on the data model
- Shared libs → Email stack: uses · Mailer and delivery helpers support queued notifications
- Shared libs → MinIO store: uses · Storage client helpers talk to object storage
- Shared libs → Content API: supports · Analytics and tracking are attached to content interactions
- Shared libs → Innovation API: supports · Scoring, tickets, and innovation analytics power workflows