🥱 Microservices

A live streaming application

Services

  1. Client: Next.js
  2. WebRTC
  3. Auth
  4. Chat
  5. Alter
  6. Payments
  7. Donation
  8. Orders
  9. Expiration
  10. Common: share code by npmjs.com

Devops

  • Docker
  • Kubernetes
    • Ingress-Nginx
  • CI/CD
  • Skaffold
  • WireGuard

Init a Microservice workflow

A Typescirpt Service

node init -y 
npm install typescript ts-node-dev express @types/express
tsc –init

package.json “start”: “ts-node-dev src/index.ts"
npm start
A Typescirpt Service…

docker

client/Dockfile
client/.dockerignore
docker build -t zane5/auth .
docker…

k8s

infra/k8s/client-depl.yaml
infra/k8s/ingress-srv.yaml
k8sinfra/k8s/client-depl.yaml…

skaffold

skaffold.yaml
run skaffold dev
skaffold…

sql/nosql

auth-mongo-depl.yaml
sql/nosqlauth-mongo-depl.yaml
Viewer does not support full SVG 1.1

A Auth Service

Page 1
Page 1
https://steaming.dev
React APP
client browers
React APP…
MongoDB Instance
MongoDB Instance

Auth Service

Auth Service
Express APP
Express APP
Mongooes
Mongooes

Request to Purchase Item auth 1


{ticketId: ‘xxx’}
JWT, Cookie 30min old
Request to Purchase Item auth 1…

Auth Service

Auth Service
Token refresh logic
Token refresh logic

Oroder Service

Oroder Service
Ticket Purchase Logic
Ticket Purchase Logic
logged in ?
logged in ?
purchase this ticket
purchase this ticket

Request to Purchase Item auth2


{ticketId: ‘xxx’}
JWT, Cookie 30min old
Request to Purchase Item auth2…

Auth Service

Auth Service
Token refresh logic
Token refresh logic
JWT Cookie over 30 min
JWT Cookie over 30 min

Oroder Service

Oroder Service
Ticket Purchase Logic
Ticket Purchase Logic
logged in ?
logged in ?
purchase this ticket
purchase this ticket
JWT Cookie older than 30 min
JWT Cookie older than 30 min
refresh JWT Cookie
refresh JWT Cookie
Admin User
Admin User

Auth DB

Auth DB

Auth Service

Auth Service

User Management Logic

User Management Logic
Update DB
Update DB
Emit  a user banned event
Emit  a user banned event

Event Bus

Event Bus
UserBanner Event
UserBanner Event

Orders Service

Orders Service
banned user in memory cache in 30min
{id: ‘xxx’}
30min
banned user in memory cache in 3…
Page 1
Page 1
https://steaming.devContainer

Client

Client

Next.JS

Next.JS

Order Service

Order Service

Auth Service

Auth Service

request
get

request…

Response
Full rendered HTML

Response…
Viewer does not support full SVG 1.1

Model

User+ email: string+ password: stringOrder+ userId: ref+ state: create | cancel | Awaiting Payment | Complete+ ticketId: ref+ expiresAt: Dateitem (gift)+ title: string+ price: number+ userId: ref+ orderId: ref+ type: stringCharge+ orderId: ref+ stateus: create | failed | completed+ amount: number+ stripeId: string+ stripeRefundId: string

Zane Zheng
Zane Zheng
Full Stack (Ruby on Rails) / Devops

An Full Stack / Devops with JS, Ruby, Linux, JAMStack, MicroServices.