How maorte/udemy-app works
Project Type and Purpose
• This is a full-stack MERN (MongoDB, Express.js, React, Node.js) application that simulates an online course platform (like Udemy).
• The frontend is a React/Redux single-page app; the backend is an Express.js REST API following the MVC pattern; data is persisted in MongoDB.
File Structure
• Top-level “client” directory: a React app using Redux Toolkit (slices in features/), React Router pages in pages/, styled-components, and an API abstraction in src/API/api.js.
• Top-level “server” directory: an Express.js project organized into routers/, controllers/, models/, and middleware (auth.js, adminAuth.js). Mongoose setup in db/mongoose.js.
• Config and utility files: .env in client, store/ for Redux middleware, utils/ for protected routes on client; on the server, Multer/Sharp handle avatar uploads.
README Insights
• Backend uses MVC.
• Authentication via bcrypt (password hashing) and JWT (token issuance + middleware).
• Multer + Sharp for image upload/processing.
• Two user roles: admin (can add videos/courses) and regular (view/comment).
Main Components
a. Frontend (React/Redux SPA)
• UI Components & Pages (AccountBox, CourseCard, VideoPage, etc.)
• Redux Store & Slices (auth, courses, videos, comments, users)
• API Client Layer (api.js)
• Route Guards (ProtectedRoute, ProtectedAdminRoute)
b. Backend (Node/Express)
• HTTP Server (Express app)
• Routers (user, course, video, comment)
• Controllers (business logic per resource)
• Models (Mongoose schemas for User, Course, Video, Comment)
• Middleware (auth, adminAuth, Multer for file uploads)
c. Database
• MongoDB (hosted or local) accessed via Mongoose
d. File Storage (for avatars)
• Local filesystem or cloud bucket, processed by Sharp
e. External Services
• JWT issuer/validator
• Bcrypt for hashing
Relationships and Data Flows
• User (browser) ↔ React SPA
• React SPA dispatches actions → Redux slices → uses api.js → HTTP requests to Express API
• Express middleware validates JWT → routers dispatch to controllers → controllers use Mongoose models → CRUD operations on MongoDB
• Avatar upload endpoint: client → Multer middleware → Sharp image processing → stored in filesystem/DB → controller returns URL
• Comments/videos/courses endpoints follow similar request → controller → model → response flow
Architectural Patterns & Design Principles
• Frontend: Component-based UI + Redux for state, separation of concerns (presentation vs. container components)
• Backend: MVC (routers→controllers→models)
• Layered architecture: UI layer → API layer → Business logic layer → Data access layer
• Auth patterns: JWT stateless authentication + role-based access (admin vs. user)