dragonxsx / microservices-ticketing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

microservices-ticketing


Logo

Ticketing

Table of Contents
  1. About The Project
  2. Getting Started
  3. Contact

About The Project

UI

This project is created from scratch to evaluate the possibility of microservices architecture.

Features:

  • Authentication
  • Product management (Create and Sell ticket)
  • View and purchase product
  • Stripe integration for payment

(back to top)

Techniques

  • Event-Driven Architecture using NATS Streaming Server as Event bus
  • Optimistic Concurrency Control (OCC) for handling concurrency issues
  • Implement worker service using Bull Queue
  • JWT Authentication
  • Server side rendering with Next.js

(back to top)

Built With

List of major frameworks/libraries used to bootstrap the project.

(back to top)

Project structure

Folder Detail
auth Service to handle authentication (signup/signin/signout)
client The client application (Next.js)
common The commmon service that used in every service and it's uploaded to npmjs.com
infra Kubernetes infrastucture for this application
nats-test Testing to NATS Streaming Server
orders Order service
tickets Ticket service
payments Service for handling payment processes
expiration Expiration worker for locking ticket during payment waiting
skaffold.yml Skaffold configuration for this project

(back to top)

Presentation

For more information, please refer

(back to top)

Getting Started

This is an instruction on setting up the project locally. To get a local copy up and running follow these simple example steps.

Prerequisites

  • Docker
  • Kubernetes
  • Skaffold

Installation

  1. Get a free Stripe API Key at https://stripe.com

  2. Clone the repo

    git clone https://github.com/dragonxsx/microservices-ticketing.git
  3. Install NGINX Ingress Controller

    kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.5.1/deploy/static/provider/cloud/deploy.yaml
  4. Generate ssl certificate and create tls secret

    openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ssl-key.key -out ssl-cert.cert -subj "/CN=ticketing.dev/O=ticketing.dev"
    kubectl create secret tls ticketing --key ssl-key.key --cert ssl-cert.cert
  5. Create secret environment variables

    kubectl create secret generic jwt-secret --from-literal=JWT_KEY=${YOUR_JWT_KEY}
    kubectl create secret generic stripe-secret --from-literal STRIPE_KEY=${YOUR_STRIPE_KEY}
  6. Change local environment hosts file

    Edit hosts file

    • For Windows: C:\Windows\System32\drivers\etc\hosts
    • For Mac/Linux: /etc/hosts

    Add new line

    127.0.0.1 ticketing.dev
    
  7. Bootstrap the application

    skaffold dev

Common issues

Error: mongo can't be pulled

Try pulling the image manually from outside of Skaffold:

docker pull mongo

If this is successful, it should cache it locally and the problem will no longer persist.

secret "jwt-secret" not found
kubectl create secret generic jwt-secret --from-literal=JWT_KEY=${YOUR_JWT_KEY}
503 service temporarily unavailable

Delete and re-install ingress controller

  1. Get the namespace which your ingress controller installed in
    kubectl get ns
    for example : ingress-nginx
  2. Remove all resources in this namespace
    kubectl delete all  --all -n ingress-nginx
    If your ingress controller is not installed in a dedicated namespace so you will have to remove resources one by one.
    kubectl delete ingress ingress-nginx
    kubectl delete deployment ingress-nginx
    kubectl delete service ingress-nginx
  3. Install ingress controller
    kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.5.1/deploy/static/provider/cloud/deploy.yaml

(back to top)

Contact

Nguyen Thanh Long - @dragonxsx

Project Links:

(back to top)

About


Languages

Language:TypeScript 87.2%Language:JavaScript 10.9%Language:Shell 1.3%Language:Dockerfile 0.6%