This is an e-commerce store application built using Node.js, Express.js, and EJS. The application follows the MVC (Model-View-Controller) architecture and integrates RESTful APIs for efficient data handling. The application features dynamic routing, robust database interactions through Sequelize ORM, role-based user authentication, admin-driven product management, and customer-focused shopping cart functionalities.
- Features
- Technologies Used
- Prerequisites
- Installation
- Usage
- Project Structure
- Database Configuration
- Running the Application
- Contributing
- License
- Role-based user authentication and authorization
- Admin-driven product management
- Customer-focused shopping cart functionality
- Order management system
- Dynamic routing and views rendered using EJS
- Integration with MySQL database using Sequelize ORM
- Logging with Morgan and request compression with compression
- MVC architecture for clean and maintainable codebase
- Node.js
- Express.js
- EJS (Embedded JavaScript templating)
- Sequelize ORM
- MySQL (AWS RDS)
- Morgan (HTTP request logger middleware)
- Compression (Gzip compression middleware)
- Node.js installed on your machine
- MySQL database (AWS RDS recommended)
- Git for version control
-
Clone the repository to your local machine:
git clone https://github.com/LahiruSen/book-store-nodejs.git
-
Navigate to the project directory:
cd book-store-nodejs -
Install the required dependencies:
npm install
-
Create a
.envfile in the root directory of your project and configure your environment variables:DB_NAME=your_db_name DB_USER=your_db_user DB_PASSWORD=your_db_password DB_HOST=your_db_host DB_DIALECT=mysql PORT=5000 -
Set up your MySQL database and update the configuration in the
util/database.jsfile accordingly. -
Run the application:
npm start
-
The application should now be running on
http://localhost:5000.
nodejs-ecommerce-app/
│
├── controllers/
│ ├── admin.js
│ ├── error.js
│ └── shop.js
│
├── models/
│ ├── cart-item.js
│ ├── cart.js
│ ├── order-item.js
│ ├── order.js
│ ├── product.js
│ └── user.js
│
├── public/
│ ├── css/
│ ├── js/
│ └── images/
│
├── routes/
│ ├── admin.js
│ └── shop.js
│
├── views/
│ ├── admin/
│ ├── shop/
│ ├── includes/
│ └── error/
│
├── util/
│ ├── database.js
│
├── app.js
├── package.json
├── .env
└── README.md
The application uses Sequelize ORM for database interactions. The database configuration is specified in the util/database.js file. Make sure to update this file with your MySQL database credentials.
const Sequelize = require('sequelize');
const sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASSWORD, {
dialect: process.env.DB_DIALECT,
host: process.env.DB_HOST
});
module.exports = sequelize;Contributions are welcome! Please fork the repository and submit a pull request for any improvements, bug fixes, or new features.
- Fork the repository
- Create a new branch (
git checkout -b feature-branch) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin feature-branch) - Create a new pull request
This project is licensed under the MIT License. See the LICENSE file for details.
This project was created by referring to the video guides provided by the Udemy course, NodeJS - The Complete Guide (MVC, REST APIs, GraphQL, Deno), instructed by Maximilian Schwarzmüller. It is a great course that offers in-depth knowledge and practical insights into Node.js and its related technologies. Special thanks to Maximilian Schwarzmüller for his excellent tutorials and guidance.
Feel free to reach out if you have any questions or suggestions. Happy coding!