Skip to content

A static E-Commerce website selling high quality audio products

Notifications You must be signed in to change notification settings

Adastros/audiophile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Logo

audiophile

A static E-Commerce website selling high quality audio products.
View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Contact

About The Project

Product Name Screen Shot

Audiophile is a multi-page e-commerce website designed to sell high quality audio products. This website is hosted on Fly.io and was built using Figma design files, images, and pre-written text content provided by Frontend Mentor.

Functionally, users on the website are able to:

  • View the optimal layout for the website depending on their device's screen size
  • Add/Remove products from the cart
  • Edit product quantities in the cart
  • Keep track of what's in the cart, even after refreshing the browser
  • Fill in all fields in the checkout
  • Receive notifications if fields are missed or incorrect during checkout
  • See correct checkout totals depending on the products in the cart
    • Shipping always adds $50 to the order
    • VAT is calculated as 20% of the product total, excluding shipping
  • See an order confirmation modal after checking out with an order summary
  • Receive an order confirmation email

(back to top)

Built with

Frontend

Create React App React Chakra-UI Cypress React Router Redux React-hook-form

Backend

MongoDB Node Express Mongoose Babel Express-validator React Email Resend Dotenv

(back to top)

System Diagrams

Below are flow and sequence diagrams of the website system. The diagrams were generated using Mermaid and can also be found in the diagrams folder.

Flow Diagram

General System Flow Diagram
flowchart LR
    A[User Client] <-->|Webpage data| B["Fly.io Server (Backend)"]
    A <--> |Images and icons| E["Cloundinary (Image Hosting)"]
    B <--> |Purchase order and cart data|C[("MongoDB (Database)")]
    B --> |Purchase order email header and body data| D["Resend (Email Platform)"]
    D --> |Purchase order email| A
Loading

Sequence Diagrams

On Page Load Sequence Diagram
sequenceDiagram
participant c as User Client
participant b as Fly.io Server (Backend)
participant cl as Cloudinary (Image Hosting)
participant d as MongoDB (Database)

c->>b: GET https://audiophile.fan
b-->>c: Send HTML, CSS, Javascript files
c->>b: GET webpage data (JSON data)
b-->>c: Send webpage data (JSON data)
c->>cl: GET images and icons
cl-->>c: Send images and icons
c->>b: POST send cart ID
alt cart ID falsey
    b->>d: Create new cart document
    d-->>b: Send newly created cart document's ID 
    b-->>c: Send new cart ID
else cart ID truthy
    b->>d: GET cart info
    d-->>b: Send cart info
    b-->>c: Send cart info
end
Loading
Email Sequence Diagram
sequenceDiagram
participant c as User Client
participant b as Fly.io Server (Backend)
participant d as MongoDB (Database)
participant r as Resend (Email Platform)

c->>b: POST valid, completed checkout form data
b->>b: Validate and sanitize form data
par
    b->>d: POST - Mark purchaseComplete field in cart document as true 
    d->>d: Update purchaseComplete field in cart document as true
and
    c->>b: GET - new cart ID
    b->>d: Create new cart document
    d-->>b: Send newly created cart document's ID 
    b-->>c: Send new cart ID
and
    b->>d: POST - Send checkout form data
    d->>d: Create new purchaseOrder document with received data
    d-->>b: Fufill promise and send new purchaseOrder document
    b->>r: Render and send purchase order email template
    par 
        b-->>c: Send response 200 status
    and
        r-->>c: Send purchase order email
    end
end
Loading
Adding Items to Cart Sequence Diagram
sequenceDiagram
participant c as User Client
participant b as Fly.io Server (Backend)
participant d as MongoDB (Database)

c->>b: POST - item, quantity, and cart ID
c->>c: Update redux store with new item and/or quantity
b->>d: Send item, quantity, and cart ID
d->>d: Update cart document with received information
b-->>c: Send response 200 status
Loading

(back to top)

Getting Started

To get a local copy of the website up and running follow the steps below.

Prerequisites

Check to see if you have Node.js and npm installed.

node -v
npm -v

If Node.js and/or npm isn't installed, run the following commands in your terminal. The first command will install NVM (Node Version Manager), which is used to manage multiple active Node.js versions. The second command installs the latest version of Node.js and npm.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
nvm install --lts

Run the following commands to verify that Node.js and npm were installed.

node -v
npm -v

If curl isn't on your system, run the following commands to install it.

sudo apt update
sudo apt upgrade
sudo apt install curl

You'll need the following services to run your own version of the website.
Note: The service providers listed below were used to create this website and are not required to run your own version of the website.

Installation

  1. Set up and acquire API keys from your chosen service providers.

  2. Clone the repo.

    git clone https://github.com/Adastros/audiophile.git
  3. Move to either the "backend" or "frontend" directory.

  4. Install NPM packages for the directory you are in by typing the following command.

    npm install
  5. Move to the other directory in your terminal and repeat step 4 to install the required dependencies.

  6. Create a .env file in the "backend" directory.

  7. Create the variables listed below and add your API key/ secrets to the .env file. If you are using different service providers than what I used for this project, rename, add, or replace the .env variables as needed. Make sure to update the code base to use your .env variables.

    LOCAL_PORT = '3003'
    CLOUDINARY_URL = 'YOUR CLOUDINARY URL'
    REACT_APP_CLOUDINARY_BASE_URL = 'YOUR CLOUDINARY IMAGE BASE URL'
    MONGODB_URI = 'YOUR MONGODB API URI'
    REACT_APP_RESEND_API = "YOUR RESEND API KEY"
    REACT_APP_FROM_EMAIL = "'FROM' FIELD EMAIL ADDRESS (ex: [email protected])"
  8. Transpile the react email template code from the "emails" directory into the "htmlEmail" directory by running one of the following commands. In the first command, babel:build-email is a custom, shortened version of the second command. The script can be found in the package.json and renamed if desired.

    npm run babel:build-email
    babel ./emails -d ./htmlEmail
  9. Create a production build of the website by running the following command in the "frontend" directory.

    npm run build
  10. Copy and paste the "build" folder from the "frontend" directory to the "backend" directory.

  11. Run the following command while in the "backend" directory on your terminal to start the server and run the website.

     npm start
  12. Visit http://localhost:3003/ in your browser to see the website.

(back to top)

What I learned

The following are the major takeaways from working on this project:

Website Deployment and System Design

  • How to architect, design, and deploy a website to the internet using a custom domain

Figma Interpretation and Design

  • How to interpret Figma wire frame designs
  • How to create custom wire frame designs in Figma

Email Handling

  • How to create email templates and send emails using a third party email vendor

Testing

  • How to perform integration tests with Cypress and backend/ server side tests with Postman

Backend Setup and Server Configuration

  • How to configure and set up a backend server
  • How to use and configure a noSQL/ document database (MongoDB)

Website Routing

  • How website routing is handled on the client and server side

(back to top)

Contact

Linkedin Gmail

(back to top)

About

A static E-Commerce website selling high quality audio products

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published