E-commerce Back-end Server

Overview

Ecommerce Backend Server

This project contains the intial setup needed for creating the MVC folder for our Ecommerce-backend application and setting up of database.

Table of contents

Technologies

Project is created with:

Application Setup

1. Install the Express Generator

> npm install -g express-generator

If you get permission error while installing it,then run the above command as an administrator or root user.

2. Install the Express Application

Go to the directory where you want to create your project and install the express application by running the following command:

> npx express --view=ejs ecommerce-backend

Now you should see a root directory with the name of ecommerce-backend in your current directory. And a logs of information indicating about the files and directories that are created:

create : ecommerce-backend/
   create : ecommerce-backend/public/
   create : ecommerce-backend/public/javascripts/
   create : ecommerce-backend/public/images/
   create : ecommerce-backend/public/stylesheets/
   create : ecommerce-backend/public/stylesheets/style.css
   create : ecommerce-backend/routes/
   create : ecommerce-backend/routes/index.js
   create : ecommerce-backend/routes/users.js
   create : ecommerce-backend/views/
   create : ecommerce-backend/views/error.ejs
   create : ecommerce-backend/views/index.ejs
   create : ecommerce-backend/app.js
   create : ecommerce-backend/package.json
   create : ecommerce-backend/bin/
   create : ecommerce-backend/bin/www
   change directory:
     $ cd ecommerce-backend
   install dependencies:
     $ npm install
   run the app:
     $ DEBUG=ecommerce-backend:* npm start

3. Install the Dependencies

Go inside the application and Install its depedencies by running the following command

> cd ecommerce-backend 
ecommerce-backend> npm install

4. Run the Express Application

You can start the server by running the following command:

ecommerce-backend> npm start

By default nodeJS uses port 3000, so you can to your browser and open

http://localhost:3000/

To change the port number, go inside bin/www and update 3000 to required port number.

This application will run on port 4000.

Application Structure

EJS tool have created the following folder structure by default

.
├── app.js
├── bin
│   └── www
├── package.json
├── package-lock.json
├── public
│   ├── images
│   ├── javascripts
│   └── stylesheets
│       └── style.css
├── routes
│   ├── index.js
│   └── users.js
└── views
    ├── error.ejs
    └── index.ejs

Since we are working on backend server for ecommerce application this structure is updated as follow:

.
├── app.js
├── bin
│   └── www
├── config
├── models
├── node_modules
├── package.json
├── package-lock.json
├── routes
│   ├── api
│   │   ├── index.js
│   │   └── v1
│   │       └── index.js
│   └── index.js
├── src
│   ├── constants
│   ├── controller
│   ├── middlewares
│   ├── models
│   └── services
├── tests
└── views
    ├── error.ejs
    └── index.ejs


Database Setup

1. MySQL Installation:

LINUX

sudo apt update
sudo apt install mysql-server

Windows

Follow this to download the mysql on windows.

MAC

brew install mysql

2. MySQL Configuration:

In Linux the root user of mysql is set to perform the authentication using the auth_socket by default. You can check it by running the following command:

 sudo mysql
 mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
user authentication_string auth_socket localhost
root auth_socket localhost
mysql.session *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE mysql_native_password localhost
mysql.sys *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE mysql_native_password localhost
debian-sys-maint *70FC20C6FDEF784AA4BEACA2F4BFF67F5B228C32 mysql_native_password localhost
4 rows in set (0.00 sec)

To allow our ecommerce application connect to this database we need to set the password for the root.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

Now we need to make run the following command to make the changes takes place

mysql> FLUSH PRIVILEGES;

and thats it. To test if the authentication using the password is working or not we will getout of the mysql and retry logging in using the user as root and password as password

mysql> exit;
> mysql -u root -p
> password

Create a Database ecommercedb for this application using the following command:

CREATE DATABASE ecommercedb;

Since we will be using the database, run the following command

USE ecommercedb;

Table Creation:

Use the following command to create the tables :

Categories

CREATE TABLE `Categories` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) NOT NULL,
  `CreatedAt` datetime DEFAULT CURRENT_TIMESTAMP,
  `UpdatedAt` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;

Data Insertion:

Following are the dummy data that can be used to populate the tables

Categories

INSERT INTO Categories (Name) VALUES ('Electronics');
INSERT INTO Categories (Name) VALUES ('Mobiles');
INSERT INTO Categories (Name) VALUES ('Books');
INSERT INTO Categories (Name) VALUES ('Applicances');
INSERT INTO Categories (Name) VALUES ('Fashion');

You might also like...

Uma aplicação back-end para consumo e envio de frases/mensagens semelhante ao twitter.

Tweteroo Uma aplicação back-end utilizando o nodemon para rodar o servidor e o express para consumo e envio de frases/mensagens. Rodar projeto Após cl

Feb 3, 2022

A back-end web app allows you to register and login to access a secrets page

A back-end web app allows you to register and login to access a secrets page

Oct 30, 2022

This shows NFT tracking in the certain wallet using express back-end.

nft-tracking-for-solana-wallet Express backend for NFT tracking in the certain wallet. Webhook for scraping secondary marketplace information for part

Nov 16, 2022

stackoverflow back end clone with node.js

stackoverflow back end clone with node.js

Stackoverflow clone with Node.js Run To run this project, download it to your computer and open it with a code editor. Open the .env file in the env f

Nov 20, 2022

📜 TypeScript Project Template for Back End Development

TypeScript Project Template Back End Development Project Template Browse TypeScript code» Built With Table of Contents Installation and Usage Error Ha

Dec 31, 2022

Back-end desenvolvido com NodeJS, TypeScript, Prisma e Express para prover dados para as aplicações em desenvolvimento.plicações do evento NLW eSports.

Back-end desenvolvido com NodeJS, TypeScript, Prisma e Express para prover dados para as aplicações em desenvolvimento.plicações do evento NLW eSports.

NLW eSports Back-End Aplicação back-end para surprir as necessidades de dados das demais plataformas desenvolvidas que são citadas mais abaixo. Este s

Sep 17, 2022

Back-End da aplicação EnfUroped V2

Uroped API O EnfUroped API é uma "REST API" que alimenta a aplicação EnfUroped-client, confira vários documentos úteis sobre o projeto na pasta docs.

Oct 9, 2022

Site informativo de times, partidas e classificações de futebol (Criado apenas back-end)

Bem vindo ao Trybe Futebol Clube! Esse projeto é uma API RESTfull na qual utiliza arquitetura MSC(model, Service, Controller) para ler,filtrar e criar

Oct 29, 2022

A POC of a Discord.js bot that sends 3D rendering instructions to a Go server through gRPC which responds with the image bytes which are then sent back on Discord.

A POC of a Discord.js bot that sends 3D rendering instructions to a Go server through gRPC which responds with the image bytes which are then sent back on Discord.

Jan 8, 2022
Owner
Atul Singh
Full stack engineer, interested in deep learning, computer vision, autonomous robots (especially self driving cars).
Atul Singh
Personal Blog - a project developed with Angular for the front-end interface and Wordpress for the back-end API served with Docker containers

PersonalBlog This project was generated with Angular CLI version 13.0.1. Front-end Interface Development server Run ng serve or ng serve --configurati

null 9 Oct 5, 2022
Pass trust from a front-end Algorand WalletConnect session, to a back-end web service

AlgoAuth Authenticate to a website using only your Algorand wallet Pass trust from a front-end Algorand WalletConnect session, to a back-end web servi

Nullable Labs 16 Dec 15, 2022
It consists of a recreation of Twitter, to put into practice both Front-end and Back-end knowledge by implementing the MERN Stack together with other technologies to add more value to the project.

Twitter-Clone_Back-end ✨ Demo. ?? About the project. ?? Descriptions. It consists of a recreation of Twitter, to put into practice knowledge of both F

Mario Quirós Luna 5 Apr 12, 2022
It consists of a recreation of Twitter, to put into practice knowledge of both Front-end and Back-end implementing the MERN Stack along with other technologies to add more value to the project.

Twitter-Clone_Front-end ✨ Demo. Login Home Profile Message Notifications Deployed in: https://twitter-clone-front-end.vercel.app/ ?? About the project

Mario Quirós Luna 5 Jun 26, 2022
Web-Technology with Aj Zero Coding. In this tutorial we learn front-end and back-end development.

Installation through NPM: The jQWidgets framework is available as NPM package: jQuery, Javascript, Angular, Vue, React, Web Components: https://www

Ajay Dhangar 3 Nov 19, 2022
A dashboard for managing orders and inventory for a wordpress e-commerce site which has woo commerce plugin installed

WordPressWooCommerceDashboard - A dashboard for managing orders and inventory for a wordpress e-commerce site which has woo commerce plugin installed. This program provides shipping tracking for Delhivery.

Vikrama Reddy 1 Jan 3, 2022
RESTful API using Hapi NodeJs Framework. This app is project from Dicoding Couses, Belajar Membuat Aplikasi Back-end untuk Pemula

RESTful API using Hapi NodeJs Framework. This app is project from Dicoding Couses, Belajar Membuat Aplikasi Back-end untuk Pemula

Muhammad Ferdian Iqbal 1 Jan 3, 2022
A NPM package powered by Yeoman that generates a scaffolding boilerplate for back-end workflow with Node.js.

generator-noderplate Generate Node.js starter files with just one command! We have deployed a npm package that will generate a boilerplate for nodejs

Samarjeet 3 Jan 24, 2022
School App / Back-End with MongoDB / mongoose / Express / TS

TEST Api Dependencies El mati se la come es por eso que en 1998 la guerra fria se llevo a mas de la mitad del activo del pais "dependencies": { "axios

Santiago Bancalari 3 Jun 10, 2022
Uma aplicação back-end para listar e verificar se o dia é um feriado de acordo com os feriados registrados no sistema

Holydayzer Sobre Uma aplicação back-end para listar e verificar se o dia é um feriado de acordo com os feriados registrados no sistema. Como rodar Exe

Vinícius 2 Mar 9, 2022