Lvls Above.

Mar 2024 - Jun 2024
Node.js
MongoDB
HTML
CSS
JavaScript
EJS

This project is a comprehensive e-commerce web application developed using Node.js, Express, and MongoDB. It provides a platform for users to browse, search, and purchase products, as well as for administrators to manage listings and user roles. The application includes user authentication, product listings with reviews, an integrated email notification system, and an admin dashboard.


Key Features

User Authentication and Authorization

  • Users can register and log in using local accounts or Google OAuth.
  • Session management is handled with express-session and connect-mongo.
  • Role-based access control allows administrators to manage content and user permissions.

Product Listings

  • Detailed product pages include images, descriptions, pricing, sizes, colours, and types.
  • Users can search and filter listings based on various criteria.
  • Admins have the ability to add, update, and delete product listings.

Reviews and Ratings

  • Authenticated users can leave reviews and ratings for products.
  • Aggregate ratings are calculated and displayed for each product.

Email Notifications

The application sends emails for various purposes, such as:

  • Purchase confirmations with order details.
  • One-Time Passwords (OTP) for account verification or password resets.
  • Subscription confirmations.
  • Custom emails to subscriber lists.
  • Email functionality is implemented using Nodemailer and integrates with SMTP services.

Admin Dashboard

  • Administrators can manage user roles and permissions.
  • Provides functionality to generate and download Google Merchant XML feeds for SEO.
  • Access to certain routes and actions is restricted to admin users.

Middleware and Validation

  • Custom middleware functions are used for authentication checks and validation of user inputs.
  • Data validation ensures that only properly formatted data is processed and stored.
  • Flash messages provide feedback to users on their actions.

Error Handling

  • The application includes comprehensive error handling mechanisms.
  • Custom error classes and middleware capture and process errors.
  • User-friendly error pages are displayed when issues occur.

Technologies Used

Backend:

  • Node.js: JavaScript runtime for server-side development.
  • Express.js: Web framework for building the application's backend.
  • MongoDB with Mongoose: NoSQL database for data storage and ORM.

Authentication and Authorization:

  • Passport.js: Handles user authentication strategies (local and Google OAuth).

Email Services:

  • Nodemailer: Sends emails for notifications and confirmations.

File Uploads and Processing:

  • Multer: Middleware for handling multipart/form-data for file uploads.
  • Cloudinary (via configuration): Stores and serves uploaded images.

Frontend:

  • EJS: Templating engine for rendering dynamic HTML pages.
  • Bootstrap: Frontend framework for responsive design and styling.
  • Custom CSS and JavaScript: Enhances user experience and interactivity.

Other Libraries and Tools:

  • Axios: Makes asynchronous HTTP requests.
  • XMLBuilder: Generates XML feeds for Google Merchant.
  • Dotenv: Loads environment variables from a .env file.
  • Middleware Modules: Custom middleware for various functionalities.

Project Structure

  • Controllers: Handles the logic for different routes and functionalities, such as listings, reviews, purchases, subscriptions, and user management.

  • Models: Defines the data schema for MongoDB collections, including users, listings, reviews, purchases, and subscriptions.

  • Routes: Sets up the endpoints for the application, connecting URLs to controller actions.

  • Views: Contains EJS templates for rendering the frontend pages, including layouts, partials, and individual page templates.

  • Public Directory: Hosts static files like CSS, images, JavaScript, and other assets accessible to users.

Utilities and Configurations:

  • Middleware: Custom middleware functions for authentication, validation, and error handling.
  • Cloud Configuration: Manages file storage settings for image uploads.
  • Email Service: Configures and manages email functionalities using Nodemailer.

Conclusion

This e-commerce web application showcases a full-stack implementation of an online store with advanced features. It highlights proficiency in backend development with Node.js and Express, frontend rendering with EJS and Bootstrap, database management with MongoDB, and essential functionalities like user authenticationfile uploadsemail notifications, and admin control panels. The application is designed with scalability and maintainability in mind, employing best practices in middleware usageerror handling, and code organisation.