Skip to main content

Chapter 1 : Overview

Tutorial For Cloud Native Development with use case of Building SaaS Multitenant using Enterprise Microservices and Tenant Specific Customizations.

Cloud Native Development Tutorial

Tutorial Contents

Tutorial will cover below microservices development:

  • Enterprise Microservices Development
    • Enterprise Microservices
    • Build Main Product Microservices V1
      • Synchronous Communications Based Microservices
        • Using REST WebClient and Helper Microservices
  • SaaS Multitenant
    • Extend Enterprise Microservices
      • Extend Main Product Microservices V2
        • with Tenant Manager Customization Services
    • Tenant Specific Customization Using Microservices
      • Synchronous Communications Based Customization Using Microservices
        • Using REST WebClient and Tenant-specific Microservices
      • Event-Based Customization Using Microservices
        • Using Kafka Events and Tenant-specific Microservices
  • BFF Backend For Frontend

Microservices Tech Stack

Tech Stack: Java 17 Spring Boot 3 Database: PostgreSQL Ver 8.2+ API Type: REST

Use Case - Ordering System - Enterprise SaaS Multitenant

Sample Tables

Enteprise microservices sample table SQLs.

Tables in SQL script

  • customer
  • tenant
  • product
  • inventory
  • orders
  • shipping

SaaS Multitenant

Building SaaS Multitenant using Enterprise Microservices and Tenant Specific Customizations

Software Requirements Specification

User Stories

  • Main Product V1 Features
FeatureServiceInputOutput
Create Orderorder-service-v1customerId, tenantId, productId, orderQuantityorderId, orderStatus
Call Check Inventory Quantity exists for Order fullfillmentinventory-quantity-check-serviceproductId, orderQuantityquantityAvailable (true/false)
- inventory-quantity-check-service
- If quantity available, deduct quantity from inventory and write LOG entry
- Inventory Consumption: productId: 2, orderQuantity: 10
  • Main Product V2 Features Plus
    • Tenant Specific Customization
FeatureServiceInputOutput
Create Order and Handle Tenant Customizations, if anyorder-service-v2customerId, tenantId, productId, orderQuantityorderId, orderStatus
Call Check Inventory Quantity exists for Order fullfillmentinventory-quantity-check-serviceproductId, orderQuantityquantityAvailable (true/false)
Call Check Tenant Specific Customizationstenant-manager-cust-servicecustomerId, tenantId, productId, orderId, orderQuantityorderId, orderStatus
If Tenant 2, call - Check orderQuantity is > 5tenant-2-validation-serviceorderQuantityvalidationPass (true/false)
If Tenant 3, send order event, which shipping service will consume and create shipping entrycustomerId, tenantId, productId, orderQuantityorder event sent
Shipping service will poll for and consume order event, then will create shipping entrytenant-3-shipping-serviceorder event ( customerId, tenantId, productId, orderQuantity)shippingId (shipping entry)
- tenant-3-shipping-service
- Upon creating shipping entry, write LOG entry
- Order Event Consumed : customerId: 1, tenantId: 2, productId: 2, orderId: 3
- Shipping Created : shippingId: 2

Enterprise Microservices Design

Microservices for BFF Backend For Frontend

ServicesBackend ProjectPort
BFFemapi-BFF-serviceemapi-BFF9060

Microservices for Main Product and Customizations

  • Architecture Model
ProductServiceService
Main Product[ Order Service ]
sync
[ inventory-quantity-check-service ]
sync
Tenant Customization[ Tenant Manager ]
[ + Customization Service ]

sync
[ tenant-2-validation-service ]
event
message queue
[ tenant-3-shipping-service ]
  • Microservices Details
ServicesBackend ProjectPort
Main Productorder-service-v1emapi-order-svc-v19070
inventory-quantity-check-serviceemapi-inv-check-svc9072
Tenant Customizationorder-service-v2emapi-order-svc-v29070
tenant-manager-cust-serviceemapi-tenant-mgr-cust-svc9074
tenant-2-validation-serviceemapi-tenant-2-svc9076
tenant-3-shipping-serviceemapi-tenant-3-svc9078

Microservices Communications

Microservices Communicate With Details

ServicesPortCommunication ModeWith ServicePort
Main Productorder-service-v19070synchronous-webclientinventory-quantity-check-service9072
Tenant Customizationorder-service-v29070synchronous-webclienttenant-manager-cust-service9074
tenant-manager-cust-service9074synchronous-webclienttenant-2-validation-service9076
tenant-manager-cust-service9074asynchronous-eventtenant-3-shipping-service9078

Considerations

  • Enterprise Microservices can be developed with low code customizations after using EasyManage Builder and generating code.
  • Security is skipped for tutorial purposes
  • Frontend Flutter app can be used for providing mobile app
  • BFF Backend For Frontend for mobile app is directly available after code generation.
  • The code generated from EasyManage can be cleaned, leaving what is required for the microservices, as by default generated code contains lot more features and GraphQL APIs also.