Standalone React micro-frontend for the Students' Welfare Group, IIT Kharagpur mentorship workflow.
This project is built to be handed off and merged into a larger React codebase later. All application routes are isolated under /mentorship.
- React with Vite
react-router-dom- Tailwind CSS
lucide-react- Supabase Auth and Database via
@supabase/supabase-js
-
/mentorship
Entry route. Logged-out users see the email login screen. Signed-in and authorized users are redirected to/mentorship/dashboard. -
/mentorship/dashboard
Protected mentee dashboard for feedback submission. -
/mentorship/leaderboard
Leaderboard view reading frozen score snapshots from Supabase.
- The application uses Google OAuth via Supabase for authentication.
- After a successful Google sign-in, the application extracts the authenticated user's email.
- The sign-in flow checks the
public.userstable explicitly by email to verify if the user exists and has amenteeoradminrole. - If the email is not registered with the required roles, the user is immediately signed out from Supabase, redirected back to the login page, and shown an "Unauthorized" error banner.
- A valid user still needs a linked
public.menteesrow before the feedback dashboard can show assigned mentor/cycle data. - The Leaderboard item on the login sidebar links to
/mentorship/leaderboard.
The app uses a full-page internal dashboard layout, not a centered mockup frame.
- Desktop layout has a left SWG sidebar.
- Main content fills the remaining browser width.
- The signed-in navigation contains only Dashboard and Leaderboard.
- There is no Home item in the signed-in sidebar because
/mentorshipis the login/entry route. - The SWG logo in the signed-in shell links to
/mentorship/dashboard. - The visual style uses soft grey backgrounds, white panels, teal-blue accents, compact cards, and table/chip styling inspired by the SWG dashboard reference.
src/
components/
pages/
Login.jsx
Dashboard.jsx
Leaderboard.jsx
lib/
supabase.js
scoringUtils.js
App.jsx
main.jsx
styles.css
The app follows the finalized schema from SWG_Mentorship_Schema.pdf and uses these tables:
academic_sessionsusersmentorsmenteesfeedback_cyclesfeedbacksleaderboard_snapshots
Only users with role mentee or admin in the users table are allowed through OTP login. Mentors do not log in.
The required leaderboard scoring rule is:
Final Score = 0.65(F) + 0.35(E)
F = (Average 1-5 Rating / 5) * 100
E = (No. of Responses Received / Total Mentees Assigned) * 100
The frontend does not calculate leaderboard rankings. It reads stored values from leaderboard_snapshots:
reviewengagement_scorefinal_score
src/lib/scoringUtils.js includes the formula as a utility/reference for backend cron or admin calculation code, plus formatting helpers for the UI.
The dashboard intentionally does not include:
- Resume sections
- Last Mentor Meetup sections
- Meetup score calculation
- Meetup UI
The previous 50:30:20 scoring model was not implemented.
When a mentee opens /mentorship/dashboard, the app:
- Checks the authenticated user and role through Supabase Auth plus the
userstable. - Loads the mentee profile from
mentees. - Finds an active feedback cycle from
feedback_cycleswhere the current time is betweenopens_atandcloses_at. - Checks
feedbacksfor an existing row with the samementee_idandcycle_id. - Shows one of three states:
- Rating form if a cycle is active and unsubmitted.
- Thank-you state if feedback was already submitted.
- No active cycle banner if no cycle window is open.
Feedback submission writes to feedbacks using:
mentee_idmentor_idcycle_idq1_ratingq2_rating
The schema-level UNIQUE(mentee_id, cycle_id) constraint prevents double submission.
The leaderboard queries leaderboard_snapshots joined with mentors.
Views:
- Default View: latest closed feedback cycle for the current academic session.
- Overall Session View: rows where
cycle_id IS NULL.
The UI displays:
- Mentor rank
- Mentor name
- Mentor roll number
- Raw rating average
- Engagement percentage
- Final score out of 100
Copy .env.example to .env and fill in Supabase credentials:
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your-public-or-publishable-keyUse a Supabase publishable key or legacy anon public key. Never use the service_role or secret key in frontend .env.
Add your Supabase values in .env from .env.example, and ensure your Supabase RLS policies allow the intended users, mentees, feedback_cycles, feedbacks, academic_sessions, mentors, and leaderboard_snapshots reads/writes.
On Windows PowerShell, use npm.cmd if script execution policy blocks npm.
npm.cmd install
npm.cmd run devProduction build:
npm.cmd run buildPreview the built app:
npm.cmd run previewCompleted locally:
- Dependencies installed with
npm.cmd install. - Production build passed with
npm.cmd run build. /mentorshipredirects signed-in authorized users to/mentorship/dashboard.- Built preview responded successfully for:
/mentorship/mentorship/leaderboard
Note: npm audit reported 2 moderate findings from installed packages. No force fix was applied to avoid unintended dependency churn.
Before deploying, configure Row Level Security policies so the frontend can safely:
- Read allowed
usersrows for login eligibility (by email). - Read the authenticated mentee profile.
- Read active
feedback_cycles. - Read/write permitted
feedbacks. - Read current
academic_sessions. - Read
leaderboard_snapshotsand joinedmentors.
Leaderboard calculation should be handled outside the frontend, such as a Supabase scheduled function, cron job, or admin utility that writes immutable rows into leaderboard_snapshots.