Adastros / audiophile

A static E-Commerce website selling high quality audio products
https://audiophile.fan
1 stars 0 forks source link


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:

(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 ```mermaid 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 ```

Sequence Diagrams

On Page Load Sequence Diagram ```mermaid 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 ```
Email Sequence Diagram ```mermaid 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 ```
Adding Items to Cart Sequence Diagram ```mermaid 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 ```

(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@example.com)"
  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

Figma Interpretation and Design

Email Handling

Testing

Backend Setup and Server Configuration

Website Routing

(back to top)

Contact

Linkedin Gmail

(back to top)