View Demo
·
Report Bug
·
Request Feature
Table of Contents
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
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.
-
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
- Create Network Bridge
docker network create --driver bridge starbucks
- 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
- 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
- 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
- Install HTTPIE on your local machine:
brew install httpie
- 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
- 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'@'%';
- 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
- Reload Kong Config
docker exec -it kong kong reload
- Continue testing httpie:
- http localhost/api/ping
- http GET localhost/api/ping key:2H3fONTa8ugl1IcVS7CjLPnPIS2Hp9dJ
- 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
- Cloud SQL command
gcloud sql connect mysql8 --user=root --quiet
- Login to MySQL
mysql -u private-ip -p -h <INSTANCE_CONNECTION_NAME>:db-name
- Create cashier instance
docker run --platform=linux/amd64 --network starbucks -e "MYSQL_HOST=mysql" --name starbucks-cashier -td -p 9090:9090 starbucks-cashier
- Install HTTPIE (everytime to test apikey)
apt-get update && apt-get install -y httpie
- Test apikey
- http GET localhost:8080/api/ping apikey:2H3fONTa8ugl1IcVS7CjLPnPIS2Hp9dJ
- curl http://localhost:8080/api/ping
- Login: login
- Scan: touch (3,3)
- Pay: touch (2,2), => touch (3,3)
- Pay again: => touch (3,3), touch (2,2), => touch (3,3)
- Run
starbucks-api
sub-project before runningstarbucks-cashier
- Send card request from
starbucks-client
tostarbucks-cashier
-
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
Distributed under the MIT License. See LICENSE.txt
for more information.
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!