Skip to content

USC 2021 Spring EE547 Applied and Cloud Computing Final Project Score: A

Notifications You must be signed in to change notification settings

ja841014/Moving_Sale_E-Shop

Repository files navigation

Moving_Sale_E-Shop

Cooperated with teammate to develop and deployed web application on AWS EC2 by using Node.js Express, Vue.js, MongoDB Atlas, AWS RDS, Cloudinary and GraphQL API.

To see the app in action

The Database Schema

MySQL

CREATE TABLE user(
  user_id VARCHAR(40) NOT NULL CHECK (user_id <> ''),
  userName VARCHAR(40) NOT NULL CHECK (userName <> ''),
  account VARCHAR(40) NOT NULL CHECK (account <> ''),
  email VARCHAR(50) NOT NULL CHECK (email <> ''),
  pass VARCHAR(50) NOT NULL CHECK (pass <> ''),
  PRIMARY KEY (user_id)
);

CREATE TABLE product(
  product_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  productName VARCHAR(40) NOT NULL CHECK (productName <> ''),
  seller VARCHAR(40) NOT NULL DEFAULT 'Alison',
  price INT UNSIGNED NOT NULL CHECK (price >= 0),
  category VARCHAR(40) NOT NULL,
  boughtDate VARCHAR(40) NOT NULL,
  product_photo VARCHAR(150) NOT NULL CHECK (product_photo <> ''),
  look_like VARCHAR(150) NOT NULL CHECK (look_like <> ''),
  numberOfProduct INT NOT NULL CHECK (numberOfProduct >= 0),
  descript VARCHAR(200) NOT NULL,
  PRIMARY KEY (product_id)
);

CREATE TABLE history(
  history_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  price INT UNSIGNED NOT NULL,
  buyer VARCHAR(40) NOT NULL CHECK (buyer <> ''),
  seller VARCHAR(40) NOT NULL CHECK (seller <> ''),
  buy_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  product_name VARCHAR(40) NOT NULL CHECK (product_name <> ''),
  num INT UNSIGNED NOT NULL,
  PRIMARY KEY (history_id)
);

GraphQL

type Product {
  productId:    ID!
  productName:  String!
  price:        Int!
  seller:       User!
  category:     String!
  boughtDate:   String!
  product_photo:String!
  look_like:    String!
  numberOfProduct: Int!
  descript:     String!
}

type User {
  userId:       ID!
  userName:     String
  account:      String!
  pass:         String!
  email:        String!
  products:     [Product]
  buyProducts:  [History]
}

type History {
  buyer:        String
  buy_at:       String
  num:          Int
  product_name: String
  price:        Int
}

Architecuture

Flow Chart

Features

  • Used node.js express as backend, Vue.js as frontend and integrated with MongoDB Atlas and AWS RDS.
  • Used GraphQL to fetch and update data in database.
  • Used local strategy of Passport.js for authentication and authorization.
  • Implemented shopping cart by using LocalStorage and MySQL.

Prerequisites

1. MySQL server start

Please start your MySQL server. And then create database and tables which is mentioned above.

CREATE DATABASE project

2. Edit database.js

Change the host ip.

3. Key of Cloudinary and MongoDB Atlas

Create an .env file copy and paste the following lines inside

CLOUDINARY_CLOUD_NAME=xxxx
CLOUDINARY_KEY=xxxx
CLOUDINARY_SECRET=xxxx
DB_URL=xxxxx

Run the program

Please run:

cd Moving_Sale_E-Shop
node index.js

Major files

index.js: All GET and POST
database.js: Connect with MySQL server
login.ejs: Page to login
register.ejs: Page to register as a member
profile.ejs: Users' personal information
home.ejs: Home Page
about.ejs: Page of our self-introduction
product.ejs: Page of listing all selling goods
productDetail.ejs: Detail of a specific product
add.ejs: Page to upload a new product
controllers/users.js: Logic part of login, logout and register
routes/users.js: Route part of login, logout and register
resolvers.js: Logic part of GraphQL

About

USC 2021 Spring EE547 Applied and Cloud Computing Final Project Score: A

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published