How shadmansshuvo/edu-verse works
1. Overall shape
- This is a Next.js App Router monolith with clear route-group boundaries: app/(auth) for sign-in/sign-up, and app/(main) for the product experience.
- Most business logic is split between server-rendered pages, co-located server actions (actions.ts), and API route handlers under app/api.
2. Primary product areas
- The main application is organized around the platform’s core domains: courses, modules, exams, dashboard, my-courses, profile, settings, contact, and admin/instructor views.
- Each domain has its own page entrypoints and often domain-specific components, which keeps feature boundaries visible in the file structure.
3. Role-based access control boundary
- The app is explicitly role-driven: Student, Instructor, and Administrator each have separate pages and dashboards.
- middleware.ts is the main gatekeeper for route protection and likely enforces session presence and role access before the request reaches pages or APIs.
4. Authentication and session model
- Authentication is custom rather than outsourced: lib/auth.ts, lib/session.ts, and lib/password.ts indicate HTTP-only cookie sessions with local password handling.
- Auth flows are handled in app/(auth)/signin and app/(auth)/signup, with server actions performing the actual credential/session mutations.
5. Database architecture
- Data access is organized as a raw SQL layer, not an ORM: the db/ directory is split by entity (courses.ts, modules.ts, exam.ts, orders.ts, users.ts, etc.).
- db/schema.psql defines the relational schema, while db/schemas.ts and lib/validators/* provide validation boundaries for request and form data.
- The persistent model spans users/roles/permissions, course content, enrollments/orders/payments, exams/attempts/responses, reviews/comments, chat history, notifications, and settings.
6. Course/content delivery flow
- The learning experience centers on course → module → material relationships.
- Course pages and module pages render content and learning tools, while mutations such as adding materials, managing modules, and enrolling students are handled by page-local actions or API routes.
- Shared components like lesson player, material item, add-material form, and review form sit outside the route tree and are reused across content views.
7. Exams and assessment subsystem
- Exams are modeled as a separate domain with student and instructor experiences.
- Students interact through exam dashboards, exam forms, and result pages; instructors use list and view components to manage exams and inspect attempts.
- The presence of attempt, question, and response database modules shows the assessment flow is persisted end-to-end, not computed client-side.
8. Payments and enrollment lifecycle
- Paid enrollment is a first-class workflow: the payment subtree includes initiate, success, fail, and cancel routes, plus an IPN webhook.
- lib/sslcommerz.ts is the payment integration layer, so the payment provider is external, but state reconciliation is local through API callbacks and database writes.
- Enrollment and order records are therefore coupled to payment status and course access control.
9. Media and video subsystem
- Video delivery is backed by Mux, with dedicated routes for upload URL generation, sync, and Mux webhooks.
- lib/mux.ts and lib/storage.ts suggest a hybrid media pipeline: upload/asset management is externalized, while course materials and metadata are tracked in PostgreSQL and/or Supabase Storage.
10. AI features
- There are two AI-facing capabilities: an AI chat assistant and an AI quiz generator.
- These are isolated behind API routes (app/api/ai/...) and surfaced in reusable client components like ai-chat-widget and auto-quiz-generator.
- Chat history and cleanup are explicit backend concerns, implying persistence rather than ephemeral prompt handling.
11. Dashboard, analytics, and admin operations
- The dashboard area aggregates platform activity into stats, progress lists, recent attempts, and course/exam summaries.
- app/(main)/admin and app/(main)/instructor separate governance from teaching operations, with backend support in db/admin.ts, db/dashboard.ts, db/instructor.ts, and related entity modules.
- This suggests analytics are precomputed or query-driven from PostgreSQL rather than from a separate analytics service.
12. Shared UI and presentation layer
- components/ contains cross-cutting UI: navigation, footer, search, theme support, loaders, skeletons, modals, and animated primitives.
- The app uses modern front-end presentation tooling, but these components are still secondary to the server/data architecture; they mainly shape how route-level data is displayed.
13. Infrastructure and integration boundaries
- The repo’s external dependencies that materially affect architecture are PostgreSQL, Mux, SSLCommerz, and Supabase Storage.
- The app also exposes operational routes such as setup-admin, search suggestions, and sitemap generation, which show the project is designed for both runtime functionality and platform bootstrapping.
14. Data flow summary
- Typical request path is: browser page/component → server action or API route → db layer / external service → PostgreSQL response or webhook-backed update → UI re-render.
- The architecture is optimized for server-side authority: access control, business rules, payment state, media sync, and AI persistence all converge on backend routes and the SQL layer.
Main entry points: [id]/page.tsx Course detail · dashboard/page.tsx Dashboard · app/layout.tsx Root layout · (auth)/layout.tsx Auth layout
Components 33
Auth routes
Sign-in and sign-up flows.
- Auth layout · Shared shell for sign-in and sign-up.
app/(auth)/layout.tsx - Sign in · Credential entrypoint for existing users.
app/(auth)/signin/page.tsx - Sign up · Account creation entrypoint.
app/(auth)/signup/page.tsx
Main app
Primary product routes and role-based experiences.
- Root layout · Global application shell.
app/layout.tsx - Home · Primary entry route for the product.
app/(main)/page.tsx - Dashboard · Progress, attempts, and course activity overview.
app/(main)/dashboard/page.tsx - Courses · Course discovery and filtering.
app/(main)/courses/page.tsx - Course detail · Single course page with curriculum and enrollment.
app/(main)/courses/[id]/page.tsx - Modules · Module browsing entrypoint.
app/(main)/modules/page.tsx - Module detail · Single module page for lessons and materials.
app/(main)/modules/[id]/page.tsx - Exams · Student and instructor exam dashboards.
app/(main)/exams/page.tsx - Exam detail · Single exam page with role-specific controls.
app/(main)/exams/[id]/page.tsx - Exam result · Attempt result and scoring view.
app/(main)/exams/[id]/result/[attemptId]/page.tsx - Admin · Administrative control and analytics entrypoint.
app/(main)/admin/page.tsx - Instructor · Instructor workspace for course and exam management.
app/(main)/instructor/page.tsx - Profile · User profile and avatar management.
app/(main)/profile/page.tsx - Settings · Preferences, security, and role-specific settings.
app/(main)/settings/page.tsx - Payments · Success, failure, cancel, initiate, and IPN routes.
app/(main)/payment/success/page.tsx
API routes
Mutation and integration handlers.
- AI APIs · Chat and quiz generation endpoints.
app/api/ai/chat/route.ts - Payment APIs · Provider callbacks and checkout reconciliation.
app/api/payment/initiate/route.ts - Video APIs · Mux upload, sync, and webhook handlers.
app/api/video/upload-url/route.ts - Ops APIs · Search, modules, my-courses, and admin bootstrap endpoints.
app/api/search/suggestions/route.ts
Core services
Authentication, middleware, validation, and external adapters.
- Middleware · Route protection and role enforcement.
middleware.ts - Auth core · Local session and password handling.
lib/auth.ts - Integrations · Mux, SSLCommerz, and storage helpers.
lib/mux.ts - Validators · Request and settings validation boundary.
lib/validators/settings.ts
Data layer
Raw SQL persistence by domain.
- Users · Users, roles, permissions, sessions, and settings.
db/users.ts - Courses · Courses, subjects, enrollments, materials, and reviews.
db/courses.ts - Learning · Modules, progress, comments, and dashboard data.
db/modules.ts - Assessment · Exams, attempts, questions, and responses.
db/exam.ts - Commerce · Orders and payment state.
db/orders.ts - Communication · Chat, notifications, and contact records.
db/chat.ts
Shared UI
Reusable app-wide components.
- Shared UI · Reusable navigation, chat, media, forms, and settings UI.
components/navbar.tsx
Connections 40
- Root layout → Auth layout: wraps · Root shell contains the auth route tree.
- Root layout → Home: wraps · Root shell contains the main application routes.
- Auth layout → Sign in: hosts · Auth layout renders sign-in.
- Auth layout → Sign up: hosts · Auth layout renders sign-up.
- Home → Dashboard: navigates · Landing route leads into the dashboard.
- Home → Courses: navigates · Landing route leads into course discovery.
- Courses → Course detail: drills into · Catalog opens an individual course.
- Course detail → Modules: links learning · Course experience connects to module-based learning.
- Modules → Module detail: drills into · Module list opens a single module.
- Exams → Exam detail: drills into · Exam dashboard opens a specific exam.
- Exam detail → Exam result: shows result · Completed attempts surface in result pages.
- Dashboard → Exams: tracks · Dashboard aggregates exam activity and attempts.
- Course detail → Payments: checkout · Enrollment flows through payment pages.
- Admin → Dashboard: analyzes · Admin views build on dashboard-style aggregates.
- Instructor → Courses: manages · Instructor workspace relates to course administration.
- Profile → Settings: configures · Profile and preferences are adjacent.
- Sign in → Auth core: uses · Sign-in actions depend on session and password helpers.
- Sign up → Auth core: uses · Sign-up actions depend on local auth helpers.
- Middleware → Auth core: checks · Route protection depends on session state and roles.
- Root layout → Middleware: protected by · Application routes are gated before page execution.
- AI APIs → Communication: persists · Chat history and cleanup are stored server-side.
- AI APIs → Validators: validates · AI requests are validated before execution.
- Payment APIs → Integrations: calls · Payment handlers delegate to SSLCommerz integration.
- Payment APIs → Commerce: updates · Callbacks reconcile orders and payment state.
- Video APIs → Integrations: calls · Video handlers interact with Mux and storage.
- Video APIs → Courses: updates · Video sync updates course material metadata.
- Ops APIs → Courses: reads · Search and learning helpers query course data.
- Ops APIs → Users: reads · Bootstrap and account helpers touch user data.
- Settings → Validators: uses · Settings mutations are validated before persistence.
- Settings → Users: writes · Account and preference changes update user records.
- Course detail → Courses: reads · Course detail pages load catalog and enrollment data.
- Course detail → Commerce: writes · Enroll and pay actions affect commerce records.
- Module detail → Learning: reads · Module views pull lesson and material data.
- Exam detail → Assessment: reads · Exam pages load questions, attempts, and responses.
- Admin → Users: reads · Administrative views rely on user and role data.
- Instructor → Assessment: reads · Instructor views inspect exams and attempts.
- Dashboard → Learning: reads · Progress and summary cards aggregate learning data.
- Dashboard → Assessment: reads · Recent attempts and unattempted exams come from assessment data.
- Shared UI → Course detail: supports · Shared UI components are reused across course pages.
- Shared UI → Dashboard: supports · Shared UI components are reused across dashboard views.