The admin frontend is a reactjs websocket app. To build run:
cd frontend/
REACT_APP_BASIC_AUTH_USER="" REACT_APP_BASIC_AUTH_PASS="" npm run build
Sms notifications are sent via the twilio api: https://www.twilio.com
The following environment variables need to be set:
BASIC_AUTH_PASS=
BASIC_AUTH_USER=
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_PHONE_NUMBER=
DATABASE_URL=
We use Postgres as our backend for storing user and order data.
The following command set up a local docker postgres instance for development:
DB_PASSWORD="somePassword"
docker run --name yumyums-postgres-local -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=${DB_PASSWORD} -p 5432:5432 -d postgres
docker exec -ti yumyums-postgres-local psql -U postgres -c 'create database "customer_orders";'
To run locally:
docker run -p 8080:8080 -e BASIC_AUTH_PASS=$BASIC_AUTH_PASS -e BASIC_AUTH_USER=$BASIC_AUTH_USER -e DATABASE_URL="host=postgres user=postgres password=mysecretpass dbname=customer_orders port=5432 sslmode=disable" -e TWILIO_ACCOUNT_SID=$TWILIO_ACCOUNT_SID -e TWILIO_AUTH_TOKEN=$TWILIO_AUTH_TOKEN -e TWILIO_PHONE_NUMBER=$TWILIO_PHONE_NUMBER --link yumyums-postgres-local:postgres yumyums/order-messenger
A websocket mock server can easily be spun up for client side UI development.
Run:
cd mock/
npm i
npm run start
All custom business logic lives in mock/src/api/services
.
The following commands generates the mock server from scratch:
npm install -g @asyncapi/generator
ag docs/order-events.yaml @asyncapi/nodejs-ws-template -o mock -p server=dev
Before deploying to Heroku, we must dockerize our app:
docker build -t yumyums/order-messenger .
We use heroku to deploy our app. A new version of our app is deployed by pushing to a remote heroku git branch:
git push heroku main
Set up a heroku database instance:
heroku addons:create -a yumyums-order-messenger heroku-postgresql:mini
REACT_APP_BASIC_AUTH_USER=
REACT_APP_BASIC_AUTH_PASS=
All environment variable were set as fly secrets, using example command:
flyctl secrets set BASIC_AUTH_PASS=mysecret
The following environment variables will need to be set:
BASIC_AUTH_PASS=
BASIC_AUTH_USER=
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_PHONE_NUMBER=