BookStore Application

This is small project about book store has been implemented microservice architecture with Nodejs 16.2 and React & NextJS.

Features

  • Create CRUD book store web app with React, Next.js and Nodejs.
  • Implement Microservice with Nodejs.
  • Deployment with Docker, Kubernetes and Skaffold dev.

This is prototype for app alt text

Tech

Bookstore app uses a number of open source projects to work properly:

  • [React] - A JavaScript library for building user interfaces!
  • [NextJS] - A flexible React framework that gives you building blocks to create fast web applications.
  • [NodeJS] - As an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications.
  • [Express] - Fast node.js network app framework.
  • [MongoDB] - A document database with the scalability and flexibility that you want with the querying and indexing that you need.
  • [Typescript] - Strongly typed programming language that builds on JavaScript.
  • Kubernetes - Open-source system for automating deployment, scaling, and management of containerized applications.
  • [Skaffold] - Command line tool that facilitates continuous development for Kubernetes-native applications.
  • [NATS] - NATS is a connective technology that powers modern distributed systems.
  • [GitHub-Action] - Implementing CI/CD with GitHub Actions

Introduce System

Architecture

alt text

1. Client app:

This app is written by Next.js, a framework that provides a common structure for the front-end development of React apps with zero configuration and a single command toolchain. It provides functionalities to create React-based applications with transparent handling of server-side rendering.

Next.js is an open-source development framework built over Node.js that simplifies the process for SSR and offers many other useful features.

alt text

This is overview architecture when intergrating client in the system

alt text

2. Microservices

Describe services:

alt text

service-auth

This service will receive request from client to handle authentication and authorization for user Readme-Auth.

alt text

Refer to this link to get more information about authentication and authorization of auth-service.

3. Database

Type of resource

alt text

4. Infrastructure

Kubernetes

alt text

alt text

Ingress-nginx

What is Ingress? Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster. Traffic routing is controlled by rules defined on the Ingress resource.

Here is a simple example where an Ingress sends all its traffic to one Service: Ingress-ngix

An Ingress may be configured to give Services externally-reachable URLs, load balance traffic, terminate SSL / TLS, and offer name-based virtual hosting. An Ingress controller is responsible for fulfilling the Ingress, usually with a load balancer, though it may also configure your edge router or additional frontends to help handle the traffic.


Installation In Local

1. Client

- Set up

Run npm install

- Running client

Run npm run dev


Development

Want to contribute? Great!

Bookstore app uses Docker + Kubernetes + Skaffold for fast developing. Make a change in your file and instantaneously see your updates! This is all step to set up and deploy this project on Kubernetes.

First step:

Windown and Mac
Install Docker desktop on machine

Second step (Kubernetes setup):

1. Enable Kubenertes on Docker desktop
2. Setup ingress-nginx (https://kubernetes.github.io/ingress-nginx/deploy/)

Third step (Update host var)

Add this line to host var file:
127.0.0.1   bookstore

Last step (Start deploy and runing webapp)

 1. Install Skaffold dev https://skaffold.dev/
 2. Run command to start project:
    cd book-store-app
    Skaffold dev

Verify the deployment by navigating to your server address in your preferred browser.

bookstore.com