Git Product home page Git Product logo

ovieh / ticketing Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 4.82 MB

ReactJS + NodeJS full stack web app backed by Microservices and Event-Driven architecture with NATS Streaming. Containerized & Orchestrated with Docker + Kubernetes.

Dockerfile 3.50% TypeScript 95.25% JavaScript 1.03% CSS 0.14% Shell 0.09%
ssr nodejs typescript microservices event-driven-architecture nats-streaming-server kubernetes nextjs mongodb ingress-nginx

ticketing's Introduction

Ticketing App - Microservices & Event Driven Architecture

Local Dev

Set up ingress-nginx controller

  • This is required for both local dev K8s cluster and DigitalOcean K8s cluster

Check ingress-nginx documentation: https://kubernetes.github.io/ingress-nginx/


Create secret tokens in k8s cluster

  • This is required for both local dev k8s and DigitalOcean k8s
e.g. To create a secret token in k8s cluster that is used for stripe payment service:

kubectl create secret generic stripe-secret --from-literal STRIPE_KEY=[YOUR_STRIPE_SECRET_KEY]

And inside payment service k8s deployment config file (payments-depl.yaml):

- name: STRIPE_KEY
  valueFrom:
    secretKeyRef:
      name: stripe-secret
      key: STRIPE_KEY
      
And for the confirmation service: 
kubectl create secret generic sendgrid-secret --from-literal SENDGRID_API_KEY=[YOUR_SENDGRID_API_KEY]

And inside confirmation service k8s deployment config file (confirmation-depl.yaml):

- name: SENDGRID_API_KEY
  valueFrom:
    secretKeyRef:
      name: sendgrid-secret
      key: SENDGRID_API_KEY
      

Set up mock host name (local dev)

  • To redirect requests coming to: ticketing.dev => localhost

  • only for local development purposes

  • MacOS/Linux:
    modify /etc/hosts file to include 127.0.0.1 ticketing.dev

  • Windows:
    modify C:\Windows\System32\Drivers\etc\hosts file to include 127.0.0.1 ticketing.dev

  • To skip the unskippable HTTPS warning in Chrome:
    try type thisisunsafe


Skaffold (local dev)

Install Skaffold Dev Tool: brew install skaffold

From root project directory: run skaffold dev


Authentication Strategies

  • Want no backend session storage when using Microservices architecture - so stick with JWT.

  • Want to use Server-Side Rendering and access user's auth information when HTML first gets rendered - so store and transmit JWT within Cookies, i.e. use cookies as a transport mechanism.

  • Want to be able to revoke a user - so use short-lived JWT (e.g. expired in 15 minutes) with refresh mechanism.

CI/CD: Github Actions

Frontend Client

Built with NextJS

Minimalistic ReactJS framework for rendering React app on the server. https://nextjs.org/

Routes

  • /
    Show list of all tickets

  • /auth/signin
    Show sign in form

  • /auth/signup
    Show sign up form

  • /auth/signout
    Sign out

  • /tickets/new
    Form to create a new ticket

  • /tickets/:ticketId
    Details about a specific ticket

  • /tickets/:orderId
    Show info about an order and payment button

Common NPM Module

All the commonly used classes, interfaces and middlewares, etc. are extracted into a published NPM Module.

Backend API

Microservices + Event-Driven Architecture

  • NATS Streaming Server

Optimistic Concurrency Control

  • Leverage mongoose-update-if-current npm module to update mongodb documents' version.

auth service

  • GET /api/users/currentUser
    Get current user's information
  • POST /api/users/signup
    { "email": "[email protected]", "password": "123456" }
    User Sign up
  • POST /api/users/signin
    { "email": "[email protected]", "password": "123456" }
    User sign in
  • POST /api/users/signout
    {}
    User sign out

tickets service

  • GET /api/tickets
    Retrieve all tickets
  • GET /api/tickets/:id
    Retrieve ticket with specific ID
  • POST /api/tickets
    { title: string, price: string }
    Create a ticket
  • PUT /api/tickets/:id
    { title: string, price: string }
    Update a ticket

orders service

  • GET /api/orders
    Retrieve all active orders for the given user making the request
  • GET /api/orders/:id
    Get details about a specific order
  • POST /api/orders
    { ticketId: string }
    Create an order to purchase the specified ticket
  • DELETE /api/orders/:id
    Cancel the order

expiration service

  • BullJS
    Use Bull.js to manage job queues, with job delay option

  • Redis
    Use Redis to store list of jobs

payments service

  • StripeJS
    For handling payments

  • POST /api/payments
    { token: string, orderId: string}
    Create new charge/payment

confirmation service

  • BULLJS Use Bull.js to manage job queues

  • Redis
    Use Redis to store list of jobs

  • SENDGRID Email delivery service, used to send emails confirming purchase

ticketing's People

Contributors

ovieh avatar

Stargazers

 avatar

Watchers

 avatar  avatar

ticketing's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.