shohinsan / starbucks-enterprise-n-tier

Multi-Tier End-To-End Starbucks Enterprise Project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Contributors Forks Stargazers Issues MIT License LinkedIn

Journal

Journal Link

Installation Guide


Multi-Tier End-To-End Starbucks Enterprise Solutions

My Image




View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. License
  6. Acknowledgments

About The Project

day 0 - cashier ui

This is the comprehensive project for CMPE 172 (Enterprise Software Development) at San Jose State University, for the Spring 2023 semester. This project is a multi-tiered, end-to-end system composed of several elements:

  • A web-based application enabling cashiers to oversee their customers' orders (referred to as the Cashier's app)
  • A mobile application facilitating payment for customer orders (termed as the Starbucks app)
  • A Starbucks API responsible for processing requests coming from both the Cashier's and Starbucks apps
  • A database designed to maintain records of orders and cards

Architecture

day 0 - architecture

(back to top)

Built With

Spring Java MySQL Redis HTML5 CSS3 JavaScript Bootstrap Postman Docker Google Cloud RabbitMQ

(back to top)

Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Prerequisites

  • Maven Dependencies

    mvn package
  • Postman Import

    • spring-starbucks-kong-collection.json
    • starbucks-kong-environment.json
  • Docker Desktop

    • MySQL
    • Kong API
    • Starbucks API
    • Starbucks Cashier
  • Mobile CLI

    • cd project_folder
    java -cp starbucks-app.jar -Dapiurl="http://localhost:8080" -Dapikey="2H3fONTa8ugl1IcVS7CjLPnPIS2Hp9dJ" -Dregister="5012349" starbucks.Main 2>debug.log
    

Installation

starbucks-api

  1. Create Network Bridge docker network create --driver bridge starbucks
  2. Create Kong API Docker Instance
docker run --platform=linux/amd64 -d --name kong \
     --network=starbucks \
     -e "KONG_DATABASE=off" \
     -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
     -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
     -e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
     -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
     -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
     -p 80:8000 \
     -p 443:8443 \
     -p 127.0.0.1:8001:8001 \
     -p 127.0.0.1:8444:8444 \
     kong:2.4.0
  1. Create Kong Config File
	docker exec -it kong kong config init /home/kong/kong.yml
	docker exec -it kong cat /home/kong/kong.yml >> kong-initial.yml
  1. Cmd + A , and replace kong.yaml with the following:
_format_version: "1.1"

services:
- name: starbucks
  protocol: http
  host: starbucks-api
  port: 8080
  path: /
  plugins:
  - name: key-auth  
  routes:
  - name: api
    paths:
    - /api
consumers:
- username: apiclient
  keyauth_credentials:
  - key: 2H3fONTa8ugl1IcVS7CjLPnPIS2Hp9dJ
  1. Install HTTPIE on your local machine:
brew install httpie
  1. Create MySQL instance in Docker
docker run --platform=linux/amd64 -d --network starbucks --name mysql -td -p 3306:3306 -e MYSQL_ROOT_PASSWORD=cmpe172 mysql:8.0
  1. Create MySQL user
login:
- mysql -u root -p
- cmpe172
create:
- create database starbucks;
- create user 'admin'@'%' identified by 'cmpe172'; 
- grant all on starbucks.* to 'admin'@'%';
  1. Test httpie (Kong supports GET request only)
- http GET :8001/status
- http GET :8001/config config=@kong.yaml
- http --ignore-stdin :8001/config config=@kong.yaml
  1. Reload Kong Config
docker exec -it kong kong reload
  1. Continue testing httpie:
- http localhost/api/ping
- http GET localhost/api/ping key:2H3fONTa8ugl1IcVS7CjLPnPIS2Hp9dJ
  1. Create starbucks-api Instance
docker run --platform=linux/amd64 -d --name starbucks-api \
    --network kong-network -td -e env=dev \
    spring-starbucks-api \
    java -jar -Dspring.profiles.active=dev /srv/spring-starbucks-api-3.1.jar

Once you're done with docker, modify MySQL used in localhost to Google's Cloud SQL

  1. Cloud SQL command
gcloud sql connect mysql8 --user=root --quiet
  1. Login to MySQL
mysql -u private-ip -p -h <INSTANCE_CONNECTION_NAME>:db-name

starbucks-cashier

  1. Create cashier instance
docker run --platform=linux/amd64 --network starbucks -e "MYSQL_HOST=mysql" --name starbucks-cashier -td -p 9090:9090 starbucks-cashier

Docker Desktop

  1. Install HTTPIE (everytime to test apikey)
apt-get update && apt-get install -y httpie
  1. Test apikey
- http GET localhost:8080/api/ping apikey:2H3fONTa8ugl1IcVS7CjLPnPIS2Hp9dJ
- curl http://localhost:8080/api/ping

(back to top)

starbucks-app

  • Login: login
  • Scan: touch (3,3)
  • Pay: touch (2,2), => touch (3,3)
  • Pay again: => touch (3,3), touch (2,2), => touch (3,3)

Usage

  • Run starbucks-api sub-project before running starbucks-cashier
  • Send card request from starbucks-client to starbucks-cashier

(back to top)

Roadmap

  • Docker Demo

    • Show the Starbucks API "Kong API Gateway" endpoint and API being used. Demo this via a CURL ping test to API.
    • Show the launch manifest / configuration for Starbucks Cash Register confirming connection to API via Kong with API Key
    • Start up and Log into your Starbucks Cash Register App (your ported Spring MVC version)
    • Show the launch command to run Starbucks "Mobile" App with connection to the same Kong API Gateway and API Key
    • Start up the "Starbucks Mobile App" pointing out the "Store/Register" ID being used
    • Connect to Backend MySQL Database and query the "New Starbucks Card" created by Starbucks Mobile App
    • Query to show the Card Number, Card Code and starting Balance in "Activated Status"
  • Google Cloud Demo

    • Support Admin Logins for Starbucks Employees
    • Cashiers App Deployed and running on GKE PODS
    • Supports Order Selection - Dring Type, Size, Milk Option
    • Rendering must use MVC by processing REST API calls from Starbucks API via Kong Gateway on GCP
    • Order Created via REST API call to Kong Endpoint with API key running on GCP
    • Order Payment Reflected on UI with Updated Balance Paid by Mobile App
    • External IP of Load Balancer used for Demo/Screnshots of Cashier's App
    • Evidence of Load Balancer with Heahtly Backends on GCP / GKE
    • Evidence of Healthy Running Starbucks API Pods in GKE
    • Evidence of Reachability Tests via Ping API call with Kong API key to Service Endpoint
    • Evidence of Running MySQL Instance on Cloud SQL
    • Evidence that MySQL IP is used by Cashier's App to Persist Order Data
    • Evidence that Data Stored in MySQL DB cooresponds to Data visible on Web UI
    • Evidence that RabbitMQ is Deployed in GKE or GCP and used in Project via changes to Spring Source Code
    • Evidence via Demo/Screenshots that the Functionality Works
    • Moible App should be connected to Starbucks API via Kong using API key
    • Cashier's App and other Apps in Demo must connect to Starbucks API via Kong using API Key
    • Source code for Apps shows evidence that REST API requests are using API Key Auth

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Acknowledgments

Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!

(back to top)

About

Multi-Tier End-To-End Starbucks Enterprise Project

License:MIT License


Languages

Language:Java 77.3%Language:Shell 8.3%Language:HTML 4.1%Language:Makefile 3.9%Language:JavaScript 3.3%Language:CSS 1.9%Language:Handlebars 1.0%Language:Dockerfile 0.3%