Skip to content

SilvinPradhan/eCommWeb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

eCommWeb πŸ§‘β€πŸ’»

SilvinPradhan's GitHub stats

[FullStack] E-Commerce Shopping Platform developed using the modern technology stacks, MERN (MongoDB, Express, React, Node), MailChimp, Google Analytics, Braintree(PayPal) πŸ›οΈ

Build Status Status GitHub Pull Requests

Become a Patron by supporting my work

If you guys like my work, please do support my work by becoming a patron here:
https://www.patreon.com/ghostDragoon95

Contents

  • Cloning
  • Installation
  • File Structure
  • Language & Tools
  • Integration
  • Deployment

Cloning

In your terminal of the destination folder, run the following command:

$ git clone https://github.com/SilvinPradhan/eCommWeb.git <eCommWeb>


Installation

  1. After cloning the project, navigate inside the project
    > cd eCommerceWeb
    > npm install [//]: # (Install Dependencies and Packages.)
    > cd .. <!--- navigate out of the backend folder --->
    > cd eComm-client <!--- navigate inside client project folder --->
    > npm install <!--- install package dependencies --->
  1. To setup the server, navigate inside the backend project folder, i.e, eCommerceWeb. Run the following commands:
    • sudo touch .env // Create an environment variable file
  2. Add the following environment variables in .env file: [Image file here!]
  3. Now, in the terminal of the backend project folder, run the following command:
    $ npm run server
  4. For the DATABASE environment variable, you need to set up the Free Tier Cluster for MongoDB Atlas. Follow this site which is a walkthrough for the setup:
    https://studio3t.com/knowledge-base/articles/mongodb-atlas-tutorial/
  5. Add a new terminal on the same Parent Directory (eCommWeb)
 > cd eComm-client
 > sudo touch .env

[Image file here!]

  1. Add the following lines to the .env file:
SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_URL='http://localhost:8000/api'
  1. Now test if the React App is working: $ npm run start

File Structure

  1. Backend Directory Tree
eCommerceWeb/
β”œβ”€β”€ controllers
β”‚Β Β  β”œβ”€β”€ auth.js
β”‚Β Β  β”œβ”€β”€ braintree.js
β”‚Β Β  β”œβ”€β”€ category.js
β”‚Β Β  β”œβ”€β”€ order.js
β”‚Β Β  β”œβ”€β”€ product.js
β”‚Β Β  └── user.js
β”œβ”€β”€ helpers
β”‚Β Β  └── dbErrorHandler.js
β”œβ”€β”€ loading.js
β”œβ”€β”€ models
β”‚Β Β  β”œβ”€β”€ category.js
β”‚Β Β  β”œβ”€β”€ order.js
β”‚Β Β  β”œβ”€β”€ product.js
β”‚Β Β  └── user.js
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ package.json
β”œβ”€β”€ routes
β”‚Β Β  β”œβ”€β”€ auth.js
β”‚Β Β  β”œβ”€β”€ braintree.js
β”‚Β Β  β”œβ”€β”€ category.js
β”‚Β Β  β”œβ”€β”€ order.js
β”‚Β Β  β”œβ”€β”€ product.js
β”‚Β Β  └── user.js
└── validator
    └── loading.js
  1. Frontend Directory Tree
ecomm-client/
β”œβ”€β”€ README.md
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ package.json
β”œβ”€β”€ public
β”‚Β Β  β”œβ”€β”€ favicon.ico
β”‚Β Β  β”œβ”€β”€ index.html
β”‚Β Β  β”œβ”€β”€ logo192.png
β”‚Β Β  β”œβ”€β”€ logo512.png
β”‚Β Β  β”œβ”€β”€ manifest.json
β”‚Β Β  └── robots.txt
β”œβ”€β”€ server.js
└── src
    β”œβ”€β”€ 404
    β”‚Β Β  β”œβ”€β”€ PageNotFound.js
    β”‚Β Β  └── PageNotFound.scss
    β”œβ”€β”€ App.js
    β”œβ”€β”€ admin
    β”‚Β Β  β”œβ”€β”€ AddCategory.js
    β”‚Β Β  β”œβ”€β”€ AddProduct.js
    β”‚Β Β  β”œβ”€β”€ ManageProducts.js
    β”‚Β Β  β”œβ”€β”€ Orders.js
    β”‚Β Β  β”œβ”€β”€ UpdateProduct.js
    β”‚Β Β  └── apiAdmin.js
    β”œβ”€β”€ auth
    β”‚Β Β  β”œβ”€β”€ AdminRoute.js
    β”‚Β Β  β”œβ”€β”€ PrivateRoute.js
    β”‚Β Β  └── user.js
    β”œβ”€β”€ config.js
    β”œβ”€β”€ core
    β”‚Β Β  β”œβ”€β”€ Header.js
    β”‚Β Β  β”œβ”€β”€ Home.js
    β”‚Β Β  β”œβ”€β”€ Layout.js
    β”‚Β Β  β”œβ”€β”€ apiCore.js
    β”‚Β Β  β”œβ”€β”€ cards
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Card.js
    β”‚Β Β  β”‚Β Β  └── ShowImage.js
    β”‚Β Β  β”œβ”€β”€ cart
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Cart.js
    β”‚Β Β  β”‚Β Β  └── cartHandler.js
    β”‚Β Β  β”œβ”€β”€ checkbox
    β”‚Β Β  β”‚Β Β  └── CheckBox.js
    β”‚Β Β  β”œβ”€β”€ checkout
    β”‚Β Β  β”‚Β Β  └── Checkout.js
    β”‚Β Β  β”œβ”€β”€ loading
    β”‚Β Β  β”‚Β Β  └── loading.js
    β”‚Β Β  β”œβ”€β”€ newsletter
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ NewsletterForm.js
    β”‚Β Β  β”‚Β Β  └── NewsletterSubscribe.js
    β”‚Β Β  β”œβ”€β”€ price
    β”‚Β Β  β”‚Β Β  └── FixedPrice.js
    β”‚Β Β  β”œβ”€β”€ product
    β”‚Β Β  β”‚Β Β  └── Product.js
    β”‚Β Β  β”œβ”€β”€ radiobox
    β”‚Β Β  β”‚Β Β  └── RadioBox.js
    β”‚Β Β  β”œβ”€β”€ search
    β”‚Β Β  β”‚Β Β  └── Search.js
    β”‚Β Β  └── shop
    β”‚Β Β      └── Shop.js
    β”œβ”€β”€ loading.js
    β”œβ”€β”€ reportWebVitals.js
    β”œβ”€β”€ routes
    β”‚Β Β  └── routes.js
    β”œβ”€β”€ setupTests.js
    β”œβ”€β”€ static
    β”‚Β Β  └── images
    β”‚Β Β      β”œβ”€β”€ cards
    β”‚Β Β      β”‚Β Β  └── homepage.png
    β”‚Β Β      └── categoryBG
    β”‚Β Β          └── bg.jpg
    β”œβ”€β”€ style.css
    β”œβ”€β”€ user
    β”‚Β Β  β”œβ”€β”€ AdminDashboard.js
    β”‚Β Β  β”œβ”€β”€ Profile.js
    β”‚Β Β  β”œβ”€β”€ UserDashboard.js
    β”‚Β Β  β”œβ”€β”€ apiUser.js
    β”‚Β Β  β”œβ”€β”€ signin.js
    β”‚Β Β  └── signup.js
    └── utils
        └── miscellaneous.js
        

Language & Tools

  • Node
  • Express
  • Mongoose
  • React
  • Webpack
  • Google Analytics

Integration

Send newsletter to connect with your audience? Maybe your application has user signup functionality and you have a great database of emails. In this case, there are ways to take advantage of that database and use this column to create your contact list directly. And maybe your web application does not require sign up and you're not capturing those that come to your website. It is vital to have an easy and quick access to form a contact list and stay connected with your audience/customers. This is all possible with integrating Mailchimp which does all of the heavy lifting for you.

Steps to integrate Mailchimp

[Optional]

  1. Get to Mailchimp's site and sign up for a free account here.
  2. Go the terminal of the frontend directory of your project, and run the following command: $ npm i react-mailchimp-form
  3. In your Mailchimp navigate to your dashboard, and to your β€˜Audience’ tab. You’ll need to make sure that you have your contact list initiated.
  4. Copy the HTML and extract the action from β€œSignup Forms > Embedded forms”.

    Note: This β€˜Signup Form’ can be navigated to from the Audience Tab, as well. While in β€˜Embedded forms’ you’ll see the section in the right column β€˜Copy/paste onto your site’.
  5. Do not copy the whole block of code, but the following string in <form action="COPY_MAILCHIMP_URL" />
  6. In the client side directory, navigate to .env file and paste the copied string (COPY_MAILCHIMP_URL) into a new environment variable, i.e, REACT_APP_MAILCHIMP_URL='COPY_MAILCHIMP_URL'.
  7. Now, navigate to your NewsletterSubscriptionForm jsx file and build a form. You need to test making sure that all of your signups are hitting your Audience Contact list in MailChimp.
  8. To COPY a custom Newsletter Subscription Form that I built, navigate to -> src/core/newsletter/NewsletterSubscribe
  9. Before pushing the code to the github repo, make sure TO MOVE YOUR β€˜action=’ value to a .env file to hide your personal, secret mailchimp key.

Steps to integrate Google Analytics

What can we do with Google Analytics?

  • You will be able to track your revenue,
  • Track user flow/traffic to your site,
  • Track your new user acquisition rate,
  • Even track which age-group are more interested in your business,
  • Also, you can gain insight into the region they live in.

Steps

  1. Create an account in Google Accounts: google.analytics.com
    If you have already setup an Google Account, you just have to set up a new account and give it a name.
  2. Create a property
    Property is a way for Google to track your website. We need to create a new property for our website.
    • Go to your dashboard and find Admin -> Create New Property
    • Fill up the required name and other details and provide the URL of your website.
      [ Important ]
      Be sure to click on the Advanced Settings and turn on the Create Universal
    * Then Select a property and get the tracking id and save it somewhere.
  3. Now you are done setting up your project in Google Analytics. If you have a live website you will start getting some insights about the visitors already.
  4. [React] Install Dependencies:
    • First, install react-ga package from npm. It’s the official npm package for React integration with Google analytics.
      yarn add react-ga or npm i react-ga -S
  5. Setup Google Analytics inside your React Project
    • Inside App.js or index.js, add the following code:
      import ReactGA from 'react-ga'; const TRACKING_ID = "UA-12341234-1"; // YOUR_OWN_TRACKING_ID ReactGA.initialize(TRACKING_ID);
  6. Integration with React Router
    We can create a RouteChangeTracker component to listen to the changes in route and send data back to Google Analytics
    import { withRouter } from 'react-router-dom';
    import ReactGA from 'react-ga';
    const RouteChangeTracker = ({ history }) => {
    
    history.listen((location, action) => {
    ReactGA.set({ page: location.pathname });
    ReactGA.pageview(location.pathname);
    });
    
    return <div></div>;
    };
    export default withRouter(RouteChangeTracker);
    
  7. Do not forget to add the RouteChangeTracker component inside your App.js file.

Server Documentation

You can find the server documentation with the steps to setup and deploy the WebApp: Server Documentation

About

[FullStack] E-Commerce Shopping Platform developed using the modern technology stacks, MERN (MongoDB, Express, React, Node) and deployed with Digital Ocean

Topics

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published