How salmaimassenda2023/students-management works
Project type and purpose
• This is a full-stack web application built on Next.js (App Router), using Prisma for database access and Firebase for authentication & role management.
• Purpose: Provide user signup/signin, profile setup (admin vs. student), CRUD operations on student records, and an admin dashboard.
File structure
• “app/” directory: Next.js pages & server-side routes (App Router).
– app/page.js, app/layout.js, app/globals.css: top-level layout and styling.
– app/signin, app/signup, app/students_list, app/dashboard: UI routes (React Server Components or Client Components).
– app/api: serverless API routes under Next.js.
· admin-profile-setup, user-profile-setup, auth/[...nextauth], students/[id] & students: REST endpoints.
• “firebase/”: Firebase integration
– firebase-client.js: client SDK initialization
– firebase-admin.js: admin SDK for verifying tokens & setting custom claims
– setAdminRole.js: serverless function to grant admin roles
• “prisma/”: database schema & migrations
• “utils/”: shared helpers
– authOptions.js: NextAuth configuration
– middleware.js: route protection
– prisma.js: Prisma client instance
• Config files: next.config.mjs, jsconfig.json, postcss.config.mjs, firebase.json
README
• Confirms it’s a Next.js App Router project, bootstrapped with create-next-app.
a. Main components
1. Client Browser (React UI)
2. Next.js App (Server & Routing Layer)
3. Next.js API Routes (serverless functions)
4. Firebase Auth
5. Firebase Admin SDK (role management)
6. Prisma Client + Database (e.g. PostgreSQL/MySQL)
7. Hosting Platforms (Vercel for Next.js, Firebase for serverless functions)
b. Relationships & interactions
• The Client Browser loads React pages (signin, signup, dashboard, students_list) served by the Next.js App.
• UI calls Next.js API Routes (e.g., /api/auth → NextAuth on Firebase, /api/students → Prisma queries)
• API Routes use utils/middleware.js to enforce auth and authOptions.js to configure NextAuth with Firebase credentials.
• When a user signs up or signs in, NextAuth uses the Firebase Client SDK to register/authenticate.
• On protected endpoints, the Next.js layer calls Firebase Admin SDK to verify tokens and check custom claims for admin privileges.
• All database reads/writes for students and profiles go through Prisma Client to the underlying SQL database.
• setAdminRole.js can be triggered to assign “admin” claims in Firebase.
c. Architectural patterns & design principles
• Separation of concerns:
– UI (React Server/Client Components)
– Authentication (NextAuth + Firebase)
– Business logic & data access (API Routes + Prisma)
• Serverless Functions pattern via Next.js App Router’s route.js files.
• Middleware layer for authentication and authorization.
• Infrastructure as code: Prisma migrations, firebase.json.
d. Relevant technologies/frameworks
• Next.js App Router, React Server Components
• NextAuth.js (authOptions.js)
• Firebase JS SDK & Admin SDK
• Prisma ORM & SQL database
• Vercel (Next.js hosting) & Firebase Functions