# newer1107/coe-main architecture

> Architecture diagram of the GitHub repository newer1107/coe-main, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/newer1107/coe-main
- Repository: https://github.com/newer1107/coe-main

## Overview

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: [`prisma/schema.prisma`](https://github.com/newer1107/coe-main/blob/main/prisma/schema.prisma) (Prisma schema), [`src/app/layout.tsx`](https://github.com/newer1107/coe-main/blob/main/src/app/layout.tsx) (App shell), [`src/lib/prisma.ts`](https://github.com/newer1107/coe-main/blob/main/src/lib/prisma.ts) (Shared libs), [`src/app/profile/page.tsx`](https://github.com/newer1107/coe-main/blob/main/src/app/profile/page.tsx) (Student portal)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["UI routes"]
  node_app_shell["App shell<br/>[layout.tsx]"]
  node_public_site["Public site<br/>public pages<br/>[page.tsx]"]
  node_auth_pages["Auth pages<br/>auth UI<br/>[page.tsx]"]
  node_student_portal["Student portal<br/>student UI<br/>[page.tsx]"]
  node_faculty_portal["Faculty portal<br/>faculty UI<br/>[page.tsx]"]
  node_admin_portal["Admin portal<br/>admin UI<br/>[page.tsx]"]
  node_innovation_ui["Innovation UI<br/>student workflows<br/>[page.tsx]"]
  node_booking_ui["Booking UI<br/>facility booking<br/>[page.tsx]"]
end

subgraph group_api["Server APIs"]
  node_content_api["Content API<br/>public content<br/>[route.ts]"]
  node_auth_api["Auth API<br/>session auth<br/>[route.ts]"]
  node_booking_api["Booking API<br/>workflow api<br/>[route.ts]"]
  node_innovation_api["Innovation API<br/>core workflows<br/>[route.ts]"]
  node_hackathon_api["Hackathon API<br/>event ops<br/>[route.ts]"]
  node_faculty_api["Faculty API<br/>review ops<br/>[route.ts]"]
  node_admin_api["Admin API<br/>moderation<br/>[route.ts]"]
  node_cron_api["Cron API<br/>scheduled jobs<br/>[route.ts]"]
  node_storage_api["Storage proxy<br/>object storage<br/>[route.ts]"]
  node_profile_api["Profile API<br/>user profile<br/>[route.ts]"]
end

subgraph group_infra["Data & infra"]
  node_db_schema[("Prisma schema<br/>mysql data model<br/>[schema.prisma]")]
  node_minio_store[("MinIO store<br/>object storage")]
  node_email_stack["Email stack<br/>smtp + queue<br/>[mailer.ts]"]
end

subgraph group_shared["Shared logic"]
  node_shared_libs["Shared libs<br/>runtime helpers<br/>[prisma.ts]"]
end

node_app_shell -->|"renders"| node_public_site
node_app_shell -->|"renders"| node_auth_pages
node_app_shell -->|"renders"| node_student_portal
node_app_shell -->|"renders"| node_faculty_portal
node_app_shell -->|"renders"| node_admin_portal
node_student_portal -->|"navigates"| node_innovation_ui
node_student_portal -->|"navigates"| node_booking_ui
node_public_site -->|"reads"| node_content_api
node_auth_pages -->|"calls"| node_auth_api
node_student_portal -->|"calls"| node_profile_api
node_student_portal -->|"calls"| node_booking_api
node_innovation_ui -->|"calls"| node_innovation_api
node_innovation_ui -->|"calls"| node_hackathon_api
node_faculty_portal -->|"calls"| node_faculty_api
node_admin_portal -->|"calls"| node_admin_api
node_admin_portal -->|"calls"| node_content_api
node_cron_api -->|"drives"| node_email_stack
node_content_api -->|"persists"| node_db_schema
node_auth_api -->|"persists"| node_db_schema
node_booking_api -->|"persists"| node_db_schema
node_innovation_api -->|"persists"| node_db_schema
node_hackathon_api -->|"persists"| node_db_schema
node_faculty_api -->|"persists"| node_db_schema
node_admin_api -->|"persists"| node_db_schema
node_profile_api -->|"persists"| node_db_schema
node_storage_api -->|"proxies"| node_minio_store
node_shared_libs -->|"uses"| node_db_schema
node_shared_libs -->|"uses"| node_email_stack
node_shared_libs -->|"uses"| node_minio_store
node_shared_libs -->|"supports"| node_content_api
node_shared_libs -->|"supports"| node_innovation_api

click node_app_shell "https://github.com/newer1107/coe-main/blob/main/src/app/layout.tsx"
click node_public_site "https://github.com/newer1107/coe-main/blob/main/src/app/page.tsx"
click node_auth_pages "https://github.com/newer1107/coe-main/blob/main/src/app/login/page.tsx"
click node_student_portal "https://github.com/newer1107/coe-main/blob/main/src/app/profile/page.tsx"
click node_faculty_portal "https://github.com/newer1107/coe-main/blob/main/src/app/faculty/page.tsx"
click node_admin_portal "https://github.com/newer1107/coe-main/blob/main/src/app/admin/page.tsx"
click node_innovation_ui "https://github.com/newer1107/coe-main/blob/main/src/app/innovation/page.tsx"
click node_booking_ui "https://github.com/newer1107/coe-main/blob/main/src/app/facility-booking/page.tsx"
click node_content_api "https://github.com/newer1107/coe-main/blob/main/src/app/api/news/route.ts"
click node_auth_api "https://github.com/newer1107/coe-main/blob/main/src/app/api/auth/login/route.ts"
click node_booking_api "https://github.com/newer1107/coe-main/blob/main/src/app/api/bookings/route.ts"
click node_innovation_api "https://github.com/newer1107/coe-main/blob/main/src/app/api/innovation/problems/route.ts"
click node_hackathon_api "https://github.com/newer1107/coe-main/blob/main/src/app/api/innovation/events/[id]/route.ts"
click node_faculty_api "https://github.com/newer1107/coe-main/blob/main/src/app/api/innovation/faculty/applications/route.ts"
click node_admin_api "https://github.com/newer1107/coe-main/blob/main/src/app/api/admin/users/route.ts"
click node_cron_api "https://github.com/newer1107/coe-main/blob/main/src/app/api/cron/email-queue/route.ts"
click node_storage_api "https://github.com/newer1107/coe-main/blob/main/src/app/api/storage/[...path]/route.ts"
click node_profile_api "https://github.com/newer1107/coe-main/blob/main/src/app/api/profile/route.ts"
click node_db_schema "https://github.com/newer1107/coe-main/blob/main/prisma/schema.prisma"
click node_email_stack "https://github.com/newer1107/coe-main/blob/main/src/lib/mailer.ts"
click node_shared_libs "https://github.com/newer1107/coe-main/blob/main/src/lib/prisma.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_shell,node_public_site,node_auth_pages,node_student_portal,node_faculty_portal,node_admin_portal,node_innovation_ui,node_booking_ui toneBlue
class node_content_api,node_auth_api,node_booking_api,node_innovation_api,node_hackathon_api,node_faculty_api,node_admin_api,node_cron_api,node_storage_api,node_profile_api toneAmber
class node_db_schema,node_minio_store,node_email_stack toneMint
class node_shared_libs toneRose
```

## Components

### UI routes

Next.js App Router pages and client portals

- [App shell](https://github.com/newer1107/coe-main/blob/main/src/app/layout.tsx): next app shell · Global layout and shared UI chrome · `src/app/layout.tsx`
- [Public site](https://github.com/newer1107/coe-main/blob/main/src/app/page.tsx): public pages · Home, about, privacy, laboratory, and landing content · `src/app/page.tsx`
- [Auth pages](https://github.com/newer1107/coe-main/blob/main/src/app/login/page.tsx): auth UI · Login and password recovery entry points · `src/app/login/page.tsx`
- [Student portal](https://github.com/newer1107/coe-main/blob/main/src/app/profile/page.tsx): student UI · Profile, innovation, and facility booking experiences · `src/app/profile/page.tsx`
- [Faculty portal](https://github.com/newer1107/coe-main/blob/main/src/app/faculty/page.tsx): faculty UI · Faculty dashboard and innovation workflows · `src/app/faculty/page.tsx`
- [Admin portal](https://github.com/newer1107/coe-main/blob/main/src/app/admin/page.tsx): admin UI · Administrative control surface and moderation views · `src/app/admin/page.tsx`
- [Innovation UI](https://github.com/newer1107/coe-main/blob/main/src/app/innovation/page.tsx): student workflows · Programs, problems, events, applications, and submissions · `src/app/innovation/page.tsx`
- [Booking UI](https://github.com/newer1107/coe-main/blob/main/src/app/facility-booking/page.tsx): facility booking · Student booking request entry point · `src/app/facility-booking/page.tsx`

### Server APIs

Route handlers under src/app/api

- [Content API](https://github.com/newer1107/coe-main/blob/main/src/app/api/news/route.ts): public content · News, events, grants, announcements, and hero slides · `src/app/api/news/route.ts`
- [Auth API](https://github.com/newer1107/coe-main/blob/main/src/app/api/auth/login/route.ts): session auth · Register, verify OTP, login, refresh, logout, and password reset · `src/app/api/auth/login/route.ts`
- [Booking API](https://github.com/newer1107/coe-main/blob/main/src/app/api/bookings/route.ts): workflow api · Booking creation, my-bookings, and admin approval lifecycle · `src/app/api/bookings/route.ts`
- [Innovation API](https://github.com/newer1107/coe-main/blob/main/src/app/api/innovation/problems/route.ts): core workflows · Open problems, applications, claims, programs, and user lookup · `src/app/api/innovation/problems/route.ts`
- [Hackathon API](https://github.com/newer1107/coe-main/blob/main/src/app/api/innovation/events/[id]/route.ts): event ops · Event registration, leaderboard, analytics, attendance, and team management · `src/app/api/innovation/events/[id]/route.ts`
- [Faculty API](https://github.com/newer1107/coe-main/blob/main/src/app/api/innovation/faculty/applications/route.ts): review ops · Faculty review, sync, submissions, and attendance actions · `src/app/api/innovation/faculty/applications/route.ts`
- [Admin API](https://github.com/newer1107/coe-main/blob/main/src/app/api/admin/users/route.ts): moderation · Admin controls for users, faculty approvals, bookings, and stats · `src/app/api/admin/users/route.ts`
- [Cron API](https://github.com/newer1107/coe-main/blob/main/src/app/api/cron/email-queue/route.ts): scheduled jobs · Email queue draining, reminders, and innovation automation · `src/app/api/cron/email-queue/route.ts`
- [Storage proxy](https://github.com/newer1107/coe-main/blob/main/src/app/api/storage/[...path]/route.ts): object storage · Browser-safe MinIO access through a catch-all route · `src/app/api/storage/[...path]/route.ts`
- [Profile API](https://github.com/newer1107/coe-main/blob/main/src/app/api/profile/route.ts): user profile · Profile read/update and completion checks · `src/app/api/profile/route.ts`

### Data & infra

Persistence, storage, email, and shared runtime services

- [Prisma schema](https://github.com/newer1107/coe-main/blob/main/prisma/schema.prisma): mysql data model · System of record for users, workflows, tickets, content, and jobs · `prisma/schema.prisma`
- **MinIO store**: object storage · External file and media storage for uploads and public assets
- [Email stack](https://github.com/newer1107/coe-main/blob/main/src/lib/mailer.ts): smtp + queue · Nodemailer delivery plus durable email job processing · `src/lib/mailer.ts`

### Shared logic

Common libraries used across routes and pages

- [Shared libs](https://github.com/newer1107/coe-main/blob/main/src/lib/prisma.ts): runtime helpers · JWT, Prisma, analytics, validators, scoring, tickets, and activity helpers · `src/lib/prisma.ts`

## Connections

- 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
