Chapter 1 : Overview
Tutorial For Cloud Native Development with use case of Building SaaS Multitenant using Enterprise Microservices and Tenant Specific Customizations.
Getting Started
Its recommended to undertake below tutorial first , if you are fresher or Learning to Code :
Also familiarize with and get done on its:
- Tutorial Prerequisites
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
- Synchronous Communications Based Microservices
- SaaS Multitenant
- Extend Enterprise Microservices
- Extend Main Product Microservices V2
- with Tenant Manager Customization Services
- Extend Main Product Microservices V2
- 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
- Synchronous Communications Based Customization Using Microservices
- Extend Enterprise 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.
- Sample Enteprise Microservices Tables SQL - For MySQL
- Sample Enteprise Microservices Tables SQL - For PostgreSQL
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
Feature | Service | Input | Output |
---|---|---|---|
Create Order | order-service-v1 | customerId, tenantId, productId, orderQuantity | orderId, orderStatus |
↓ → Call Check Inventory Quantity exists for Order fullfillment | inventory-quantity-check-service | productId, orderQuantity | quantityAvailable (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
Feature | Service | Input | Output |
---|---|---|---|
Create Order and Handle Tenant Customizations, if any | order-service-v2 | customerId, tenantId, productId, orderQuantity | orderId, orderStatus |
↓ → Call Check Inventory Quantity exists for Order fullfillment | inventory-quantity-check-service | productId, orderQuantity | quantityAvailable (true/false) |
↓ → Call Check Tenant Specific Customizations | tenant-manager-cust-service | customerId, tenantId, productId, orderId, orderQuantity | orderId, orderStatus |
↓ → If Tenant 2, call - Check orderQuantity is > 5 | tenant-2-validation-service | orderQuantity | validationPass (true/false) |
↓ → If Tenant 3, send order event, which shipping service will consume and create shipping entry | customerId, tenantId, productId, orderQuantity | order event sent | |
Shipping service will poll for and consume order event, then will create shipping entry | tenant-3-shipping-service | order 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
Services | Backend Project | Port | |
---|---|---|---|
BFF | emapi-BFF-service | emapi-BFF | 9060 |
Microservices for Main Product and Customizations
- Architecture Model
Product | Service | Service | |||||
---|---|---|---|---|---|---|---|
Main Product | [ Order Service ] | → ← | sync | → ← | [ inventory-quantity-check-service ] | ||
↑ ↓ sync | |||||||
Tenant Customization | [ Tenant Manager ] [ + Customization Service ] | → ← | sync | → ← | [ tenant-2-validation-service ] | ||
↓ → async | → | event message queue | → | [ tenant-3-shipping-service ] |
- Microservices Details
Services | Backend Project | Port | |
---|---|---|---|
Main Product | order-service-v1 | emapi-order-svc-v1 | 9070 |
inventory-quantity-check-service | emapi-inv-check-svc | 9072 | |
Tenant Customization | order-service-v2 | emapi-order-svc-v2 | 9070 |
tenant-manager-cust-service | emapi-tenant-mgr-cust-svc | 9074 | |
tenant-2-validation-service | emapi-tenant-2-svc | 9076 | |
tenant-3-shipping-service | emapi-tenant-3-svc | 9078 |
Microservices Communications
Microservices Communicate With Details
Services | Port | Communication Mode | With Service | Port | |
---|---|---|---|---|---|
Main Product | order-service-v1 | 9070 | synchronous-webclient | inventory-quantity-check-service | 9072 |
Tenant Customization | order-service-v2 | 9070 | synchronous-webclient | tenant-manager-cust-service | 9074 |
tenant-manager-cust-service | 9074 | synchronous-webclient | tenant-2-validation-service | 9076 | |
tenant-manager-cust-service | 9074 | asynchronous-event | tenant-3-shipping-service | 9078 |
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.