/ecommerce-PERN

Ecommerce built with PERN stack.

Primary LanguageJavaScript

Lottus

Ecommerce built with PERN stack

Introduction

Desktop
desktop_view
Phone Tablet
phone tablet

Lottus is an ecommerce built with the PERN stack and other technologies such as Docker and Nginx as a reverse proxy.

It can be developed and deployed with Docker, Docker compose and Nginx for a better performance.

The user may log in, sign up, make purchases, add products to the wishlist, see the purchases and other stuff like edit the profile.

Built with

  • postgres
  • express
  • react
  • node
  • mui
  • jwt

Getting started

Prerequisites

  • Install node.js.
  • Install Docker and Docker Compose to deploy the project locally.

Installation

  1. Clone the repo:
git clone https://github.com/ClouddCoder/ecommerce-PERN.git
  1. In the api and client directories install npm packages:
npm install
  1. Create an .env file in the project root for the docker compose config:
# Service ports
NGINX_PORT = <HOST_PORT_FOR_MAPPING>
CLIENT_PORT = <HOST_PORT_FOR_MAPPING>
API_PORT = <HOST_PORT_FOR_MAPPING>
POSTGRES_PORT = <HOST_PORT_FOR_MAPPING>
PGADMIN_PORT = <HOST_PORT_FOR_MAPPING>

# Database credentials
POSTGRES_USER = <YOUR_DB_USER>
POSTGRES_PASSWORD = <YOUR_DB_PASSWORD>
POSTGRES_DB = <YOUR_DB_NAME>

# PgAdmin credentials
PGADMIN_DEFAULT_EMAIL = <YOUR_PGADMIN_EMAIL>
PGADMIN_DEFAULT_PASSWORD = <YOUR_PGADMIN_PASSWORD>
  1. Create an .env file for the api and client directories with the following environment variables:

api directory

PORT = <SERVER_PORT>
JWT_PASSWORD = <JWT_PASSWORD> # The backend uses JWT to authenticate the user.

# Database setup for deployment.
DB_USER = <YOUR_DB_USERNAME>
DB_PASSWORD = <YOUR_DB_PASSWORD>
DB_HOST = <YOUR_DB_HOST>
DB_NAME = <YOUR_DB_NAME>
DB_PORT = <YOUR_DB_PORT>
DB_SSL = <1_OR_0> # If your database is hosted in a server, probably you need to set SSL.

# Database setup for development using docker-compose.
DB_USER_DEV = <YOUR_DB_USER_FOR_DEVELOPMENT>
DB_PASSWORD_DEV = <YOUR_DB_PASSWORD_FOR_DEVELOPMENT>
DB_HOST_DEV = <YOUR_DB_HOST_FOR_DEVELOPMENT>
DB_NAME_DEV = <YOUR_DB_NAME_FOR_DEVELOPMENT>
DB_PORT_DEV = <YOUR_DB_PORT_FOR_DEVELOPMENT>
DB_SSL_DEV = <1_OR_0>

# Database setup for testing using a docker container.
DB_USER_TEST = <YOUR_DB_USER_FOR_TESTING>
DB_PASSWORD_TEST = <YOUR_DB_PASSWORD_FOR_TESTING>
DB_HOST_TEST = <YOUR_DB_HOST_FOR_TESTING>
DB_NAME_TEST = <YOUR_DB_NAME_FOR_TESTING>
DB_PORT_TEST = <YOUR_DB_PORT_FOR_TESTING>
DB_SSL_TEST = <1_OR_0>

client directory

# These variables are used to connect the backend.

# For deployment.
REACT_APP_BASE_URL = <ENTER_YOUR_BACKEND_SERVER_URL>

# For development using Docker compose.
REACT_APP_BASE_URL_DEV = <ENTER_YOUR_LOCALHOST_URL>

Usage

This project can be deployed locally with Docker compose. In the project root, run the application:

docker compose up

Then open a new tab in the browser and type localhost:3050.

Demo

Currently the ecommerce is deployed using Render.com for the front-end and the database and Cloud Run from GCP for the API.

https://lottus.onrender.com

Contributors

License

Lottus is MIT licensed.