How shai-mohan/tutortots works
Project Type and Purpose
• This is a full-stack, multi-role web application (“TutorTots”) built with Next.js (App Router) that connects Sunway University students and tutors.
• Frontend: React pages/components with Tailwind CSS and shadcn/ui.
• Backend services: Supabase for authentication, PostgreSQL database, and serverless functions accessed via the Supabase client library.
File-Structure Analysis
• app/ – Next.js “App Router” directory with role-based subpaths (admin, student, tutor, about, tutors, test-connection).
• components/ – Shared React components (auth-provider, forms, UI primitives under ui/).
• hooks/ – Custom React hooks (use-toast, use-mobile).
• lib/ – Utility modules and Supabase client initialization (supabase.ts), recommendation logic, sentiment analysis.
• public/ – Static assets (images, videos, Lottie animations).
• scripts/ – SQL scripts for DB schema, RLS, seeding, functions (points system, availability, feedback).
• config files – next.config.mjs, tailwind.config.ts, tsconfig.json.
README Insights
• Tech stack confirms Next.js + TypeScript, Tailwind, Supabase (DB & Auth), React Hook Form + Zod, Framer Motion, Recharts.
• Deployed to Vercel.
a. Main Components
• Next.js Frontend (UI Layer)
– App Router pages (Role-based routes: /student, /tutor, /admin)
– Shared components & UI library (shadcn/ui, Radix)
– State management (React Hook Form, Zod, custom hooks)
• Business Logic Layer (lib/)
– Recommendation engine (lib/recommendation.ts)
– Sentiment analysis (lib/local-sentiment.ts)
– Utility functions (lib/utils.ts)
• Backend Services
– Supabase Auth (email/password, magic link)
– Supabase PostgreSQL database (tables for users, tutors, students, rewards, availability, feedback, points)
– Supabase Functions (via SQL scripts or Supabase Edge functions if used)
• External Services
– Vercel (hosting & Serverless Functions)
– Lottie (animation JSON assets)
– Recharts for chart rendering
b. Relationships & Data Flow
1. User interacts with Next.js UI → React Hook Form triggers validation (Zod) → on submit calls lib/supabase client.
2. Supabase client → Auth API or Database RPCs → reads/writes Postgres via RLS policies.
3. lib/ modules perform computations (recommendation, sentiment) either client-side or server-side.
4. UI renders charts (Recharts) and animations (Framer Motion, Lottie) based on fetched data.
5. Deployment → Vercel serves SSR/ISR pages and static assets; environment variables connect to Supabase.
c. Architectural Patterns & Principles
• Component-based UI (atomic UI primitives under components/ui).
• Role-based routing using Next.js App Router conventions.
• Separation of concerns: UI (components), state/validation (hooks/forms), business logic (lib), data persistence (Supabase).
• Secure data access with Supabase Row Level Security and SQL migration scripts.
• Serverless deployment model (Vercel + Supabase).
d. Key Technologies
• Next.js (React 19, App Router)
• TypeScript
• Tailwind CSS
• shadcn/ui & Radix UI for primitives
• React Hook Form + Zod
• Supabase (Auth + Database + Functions)
• Framer Motion, Lottie, Recharts