How prodip-shadow/learnx works
Purpose and Runtime
This is a Next.js App Router learning/exam platform with public marketing/auth pages and role-specific dashboards for students, teachers, and administrators. It runs as a Node/Next.js application and exposes backend functionality through App Router route handlers under src/app/api. The root application entry and shared providers are src/app/layout.jsx and src/providers/AuthProvider.jsx.
Route and Layout Boundaries
Two route groups separate public/common UI from authenticated dashboard UI:
• Common-site pages and shell: src/app/(withCommonLayout)/layout.jsx, src/app/(withCommonLayout)/page.jsx, and pages such as src/app/(withCommonLayout)/exams/page.jsx.
• Dashboard shell and role areas: src/app/(withDashboardLayout)/dashboard/layout.jsx, with student, teacher, and admin subtrees.
Shared navigation and dashboard presentation live in src/components/shared/Navbar.jsx and src/components/shared/DashboardSidebar.jsx.
Authentication and Authorization
Firebase is the authentication integration, initialized in src/lib/firebase.init.js, exposed through src/providers/AuthProvider.jsx, and consumed via src/hooks/useAuth.js. Client-side role gates partition dashboard access through src/components/StudentRoute.jsx, src/components/TeacherRoute.jsx, and src/components/AdminRoute.jsx. This makes identity/session state a frontend-provider boundary, while API handlers must enforce their own data access rules.
Role-Based Learning Workflows
Students discover/join exams, submit work, track progress, and access resources through src/app/(withDashboardLayout)/dashboard/student/my-exams/page.jsx, src/app/(withDashboardLayout)/dashboard/student/progress/page.jsx, and src/app/(withDashboardLayout)/dashboard/student/resources/page.jsx.
Teachers create exams, review their exams/results, manage students, and publish resources from src/app/(withDashboardLayout)/dashboard/teacher/create-exam/page.jsx, src/app/(withDashboardLayout)/dashboard/teacher/my-exams/page.jsx, and src/app/(withDashboardLayout)/dashboard/teacher/addResource/page.jsx.
Administrators oversee users, exams, and aggregate results in src/app/(withDashboardLayout)/dashboard/admin/users/page.jsx, src/app/(withDashboardLayout)/dashboard/admin/all-exams/page.jsx, and src/app/(withDashboardLayout)/dashboard/admin/all-exams-results/page.jsx.
Exams Pipeline
Public exam discovery and participation UI is centered on src/app/(withCommonLayout)/exams/page.jsx with interactive units in src/app/(withCommonLayout)/exams/_components/ExamHall.jsx and src/app/(withCommonLayout)/exams/_components/JoinModal.jsx. Teachers create exams through src/app/api/exams/create/route.js; student completion posts to src/app/api/exams/submit/route.js. Result and management screens then consume the persisted exam/submission domain in their role-specific dashboard views.
Resources and Persistence Services
MongoDB is the application data-store integration via src/lib/mongodb.js. Resource operations are a distinct API boundary: creation/deletion/listing at src/app/api/resources/create/route.js, src/app/api/resources/delete/route.js, and src/app/api/resources/get/route.js; file access is mediated by parameterized open/download handlers at src/app/api/resources/open/[resourceId]/route.js and src/app/api/resources/download/[resourceId]/route.js. UI counterparts are consolidated in src/components/ResourceComponents/.
Supporting Services
User administration is handled by src/app/api/users/route.js and src/app/api/users/update/route.js. Student application/request handling is isolated in src/app/api/become-student/route.js and src/app/api/become-student/manage/route.js. A chatbot service is independently exposed through src/app/api/chatbot/route.js, with a diagnostic endpoint at src/app/api/chatbot/diagnostic/route.js, and rendered by src/components/ChatBot/ChatBot.jsx.
Main entry points: route.js Exam create and submit · mongodb.js MongoDB · StudentRoute.jsx Role route gates · page.jsx Exam discovery
Components 19
Next.js application
- Root layout · Installs shared application providers.
src/app/layout.jsx - Public site shell · Hosts marketing and public exam pages.
src/app/(withCommonLayout)/layout.jsx - Exam discovery · Discovery and participation interface.
src/app/(withCommonLayout)/exams/page.jsx - Exam hall
src/app/(withCommonLayout)/exams/_components/ExamHall.jsx - Join modal
src/app/(withCommonLayout)/exams/_components/JoinModal.jsx - Resource components
Identity and access
- Role route gates · Student, teacher, and admin dashboard guards.
src/components/StudentRoute.jsx - Auth provider · Exposes client identity and session state.
src/providers/AuthProvider.jsx - Firebase Auth
src/lib/firebase.init.js
Role dashboards
- Dashboard shell · Shared authenticated dashboard boundary.
src/app/(withDashboardLayout)/dashboard/layout.jsx - Student learning · My exams, progress, and resources.
src/app/(withDashboardLayout)/dashboard/student/my-exams/page.jsx - Teacher exam management · Exam creation, review, students, and resources.
src/app/(withDashboardLayout)/dashboard/teacher/create-exam/page.jsx - Admin oversight · Users, all exams, and aggregate results.
src/app/(withDashboardLayout)/dashboard/admin/all-exams/page.jsx
Backend route handlers
- Exam create and submit · Persists teacher-created exams and student submissions.
src/app/api/exams/create/route.js - Resource API · Creates, lists, deletes, opens, and downloads resources.
src/app/api/resources/create/route.js - User administration API · Lists and updates user records.
src/app/api/users/route.js - Student request API · Handles student applications and management.
src/app/api/become-student/route.js - Chatbot service · Independent chatbot endpoint with client rendering.
src/app/api/chatbot/route.js
Persistence
- MongoDB · Stores exam, submission, user, request, and resource domains.
src/lib/mongodb.js
Connections 22
- Root layout → Auth provider: installs
- Auth provider → Firebase Auth: initializes session with
- Public site shell → Exam discovery: hosts
- Exam discovery → Exam hall: renders
- Exam hall → Join modal: opens
- Dashboard shell → Role route gates: applies
- Role route gates → Student learning: permits student role
- Role route gates → Teacher exam management: permits teacher role
- Role route gates → Admin oversight: permits admin role
- Exam discovery → Exam create and submit: joins and submits via
- Teacher exam management → Exam create and submit: creates and manages exams
- Student learning → Exam create and submit: reads results and progress
- Admin oversight → Exam create and submit: oversees exams and results
- Teacher exam management → Resource API: publishes resources
- Student learning → Resource components: accesses
- Resource components → Resource API: retrieves files through
- Admin oversight → User administration API: administers users
- Student request API → MongoDB: persists requests
- Exam create and submit → MongoDB: persists exams and submissions
- Resource API → MongoDB: persists resource records
- User administration API → MongoDB: updates users
- Chatbot service → MongoDB: uses application data