How ruhul-amin33/edu-web works
1. Overall shape
- This is a single Node.js/Express monolith for an education platform, with server-side rendered pages rather than a separate SPA.
- The main entrypoint is server.js, which wires HTTP routing, middleware, static assets, uploads, and database access.
2. Presentation layer
- The UI is built with EJS templates under views/.
- Shared page chrome lives in views/partials/ (layout, footer, sidebar, social icons), while feature pages are split by domain: auth, student, exam, materials, courses, admin, teacher, admission.
- Static frontend assets are in public/css/style.css and public/js/main.js, which support the bilingual UI, dark mode, animations, and responsive navigation.
3. Route boundaries / application modules
- The app is organized by domain routes in routes/: auth, student, exam, materials, courses, teacher, admin, and admission.
- Each route file corresponds to a functional subsystem and its pages, making the app closer to a modular MVC style than a thin REST API.
4. Authentication and access control
- middleware/auth.js is the shared boundary for login/session enforcement and role-based authorization.
- Roles matter structurally: students, teachers, and admins see different dashboards, navigation, and capabilities, and the middleware gates those paths.
5. Data persistence
- Primary persistence is MySQL, configured through config/db.js.
- database.sql is the base schema plus seed data, while the migration_*.sql files indicate incremental schema evolution for admissions, folder hierarchy, and year/board handling.
- The data model supports users, questions, exams, materials, courses, purchases, reviews, reports, team members, and admin moderation state.
6. File and content storage
- Uploaded content is stored under uploads/, split into uploads/pdfs for study materials and uploads/avatars for team/user images.
- The README also describes optional Cloudinary storage for durable file hosting; when configured, it becomes the external asset store and avoids losing uploads on ephemeral disks.
7. Student workflow
- Students authenticate, set up their stream/level, and then move through dashboard → materials browsing → course purchase → exam setup → exam taking → result/history.
- Exam pages include timed question delivery, navigation, submission, results, and wrong-question reporting, all backed by server-side state and database records.
8. Teacher workflow
- Teachers can create MCQ questions, bulk upload them, edit rejected items, and view question approval status.
- Their submissions flow into an admin moderation queue, so teacher content is not directly published without review.
9. Admin as the control plane
- The admin area is the operational center of the system: dashboard analytics, user/role management, course and material management, team/content management, review moderation, purchase verification, and question approval/rejection.
- This subsystem also manages nested content organization, reflected by the folder-system migration and the materials/admin pages.
10. External integrations
- Password reset relies on email delivery via Gmail credentials from .env.
- Course payments are handled operationally through local business workflows for bKash/Nagad/Rocket rather than a visible payment API integration in this repo.
- The app is designed to run locally or behind a process manager/reverse proxy in production, but the architecture remains a classic server-rendered web app with MySQL and file storage.
11. Key data flows to diagram
- Browser request → Express route → auth middleware (if protected) → MySQL query / file access → EJS render → browser response.
- Upload flows go from admin/teacher forms to filesystem or Cloudinary, then metadata is stored in MySQL.
- Email reset flows go from auth routes to the mail provider.
- Content moderation flows go from teacher/student submissions into admin review, then back into published content or rejection comments.
Main entry points: server.js server.js · db.js MySQL Config · admin.js Admin · teacher.js Teacher
Components 20
Presentation
Server-rendered pages and static assets
- Views · Server-side rendered pages and shared layout partials
views - Home & Pages · Landing pages, auth screens, student and domain views
views/home.ejs - Admin Views · Admin dashboards, moderation, users, courses, materials, and reports
views/admin - Domain Views · Student, teacher, exam, courses, materials, and admission pages
views/student - UI Assets · Shared stylesheet and client-side behavior for navigation, theme, and responsiveness
public
App Modules
Express routes and shared middleware
- server.js · Wires middleware, routes, static assets, uploads, and rendering
server.js - Auth · Login, registration, password reset, and session flows
routes/auth.js - Student · Student dashboard, profile, and setup pages
routes/student.js - Teacher · Question creation, bulk upload, editing, and exam setup
routes/teacher.js - Admin · Operational control plane for users, content, moderation, and analytics
routes/admin.js - Exam · Exam browsing, setup, taking, results, and history
routes/exam.js - Materials · Material browsing, search, and access pages
routes/materials.js - Courses · Course catalog and detail pages
routes/courses.js - Admission · Admission landing and related flow
routes/admission.js - Auth Guard · Shared login, session, and role-based access control
middleware/auth.js
Data Layer
Database schema and persistence config
- MySQL Config · Database connection and query setup
config/db.js - Schema · Base schema, seed data, and incremental migrations
database.sql
Storage & Integrations
Uploaded content and external services
- Uploads · Local storage for PDFs and avatars
uploads - Cloudinary · Optional hosted file storage for durable uploads
- Email Reset · Password reset delivery through Gmail credentials
Connections 25
- server.js → Auth Guard: protects · Applies access control to protected routes
- server.js → Auth: mounts · Registers auth endpoints
- server.js → Student: mounts · Registers student endpoints
- server.js → Teacher: mounts · Registers teacher endpoints
- server.js → Admin: mounts · Registers admin endpoints
- server.js → Exam: mounts · Registers exam endpoints
- server.js → Materials: mounts · Registers materials endpoints
- server.js → Courses: mounts · Registers course endpoints
- server.js → Admission: mounts · Registers admission endpoints
- server.js → Views: renders · Serves EJS pages for responses
- server.js → UI Assets: serves · Exposes static CSS, JS, and images
- server.js → MySQL Config: queries · Reads and writes application data
- MySQL Config → Schema: uses · Connects the app to schema and migrations
- Auth → Email Reset: sends · Triggers password reset email delivery
- Teacher → Uploads: uploads · Stores teacher-uploaded question assets where needed
- Admin → Uploads: manages · Admin content operations may create or organize stored files
- Admin → Cloudinary: optional · Can publish uploads to hosted storage when configured
- Student → Admin: submits to · Student activity and admin-managed state flow to moderation or review
- Teacher → Admin: submits to · Teacher questions enter the admin approval queue
- Exam → MySQL Config: records · Persists exam setup, attempts, results, and history
- Materials → MySQL Config: reads · Loads materials and purchase-related records
- Courses → MySQL Config: reads · Loads course catalog and detail data
- Admin Views → MySQL Config: administers · Moderation and management pages operate on database records
- Domain Views → Views: included in · Domain pages are rendered through the shared view system
- Home & Pages → UI Assets: styled by · Landing and public pages depend on shared UI assets