Skip to main content

Chapter 3 : Enterprise Microservices

Tutorial For Building SaaS Multitenant using Enterprise Microservices and Tenant Specific Customizations.

Enterprise Microservices Development

This page gives overview and details, while screenshots are given in indivdual section pages.

Section 1-1 : Prerequisites and Setup Required

Important Checklist

Make sure you have access to computer and software as below, for the given tutorial track before starting:

caution
  • Beginner Track: For Main Product Microservices
    • Computer Win 10+, 8GB RAM, 50GB Free
  • Intermediate Track: For Tenant Customization Microservices
    • Computer Win 10+, 16GB RAM, 50GB Free
      • For Docker Desktop, Kafka Setup - Run in Docker

Prerequisites on Local Computer

Please see Self-Host : Prerequisites for Hardware, Software and Tools required on your local computer.

Prerequisites For Microservices

tip

Please defer Kafka Setup to be done after 1-2-1 Build BFF Backend For Frontend, so that you will have access to templates in downloaded code.

Setup Kafka, Run Kafka in Docker

  • Please refer to EasyManage Template for integrating kafka. Templates are included in downloaded code, e.g. EmGenDir_MYTEMP02_WS_51069\WS_51069\resources\templates.

  • README file gives more detail: EmGenDir_MYTEMP02_WS_51069\WS_51069\resources\templates\backend\spring-java\integrating\kafka\README-kafka.md

Section 1-1 : Import Sample Tables

Start building with these enteprise microservices sample table SQLs.

tip

Refer to earlier tutorial for detailed steps Section 1-1 : Import Tables, Select Build

Import Sample Tables Screenshots

  • Import Tables - Search Tables

Import Tables - Search

  • Import Tables - Import

Import Tables - Import

  • Import Tables - View Imported Tables

Import Tables - View Imported

Section 1-2 : Build Backend Spring Java (Multiple Projects)

Project Configuration Settings

Use as below:

  • Security : None

  • Project Settings - Backend Spring Java Configuration

    - One of below, to be used as per stage

    - A] Without Kafka Events, Kafka Streams

    Project Settings

    - B] With Kafka Events, Kafka Streams

    Project Settings

Build Backend In Stages

And build Backend Spring Java with tables provided in enteprise microservices sample table SQLs, as per given stages below.

Stage Wise Configuration

List Stages For BFF, Main Product and Customizations

For ServiceTablesProj Settings Include
Kafka Events,
Kafka Streams
Portemapi Project Rename To
BFFBFF-servicecustomer, tenant, product, inventory, orders, shippingNo9060emapi-BFF
Main Productorder-service-v1customer, tenant, product, ordersNo9070emapi-order-svc-v1
inventory-quantity-check-serviceinventoryNo9072emapi-inv-check-svc
Tenant Customizationorder-service-v2customer, tenant, product, ordersNo9070emapi-order-svc-v2
tenant-manager-cust-servicecustomer, tenant, ordersYes9074emapi-tenant-mgr-cust-svc
tenant-2-validation-servicetenantNo9076emapi-tenant-2-svc
tenant-3-shipping-serviceshippingYes9078emapi-tenant-3-svc

Repeat steps for each stage / service: And build Backend Spring Java with tables provided in enteprise microservices sample table SQLs, as per above stages. Use particular set of tables mentioned as per microservice to be built.

Destination Folders For Backend Projects

Create a directory structure to hold our microservices development folders. Please note emapi-* folders are copy/rename of our backend build emapi folder as per stage.

C:\work\saas-multi\BFF-backend-for-frontend\emapi-BFF
C:\work\saas-multi\main-prod\emapi-order-svc-v1
C:\work\saas-multi\main-prod\emapi-inv-check-svc
C:\work\saas-multi\main-prod\emapi-order-svc-v2
C:\work\saas-multi\tenant-cust\emapi-tenant-mgr-cust-svc
C:\work\saas-multi\tenant-cust\emapi-tenant-2-svc
C:\work\saas-multi\tenant-cust\emapi-tenant-3-svc

Common Steps

Common steps are shown with screenshots for 1st stage, i.e. BFF project

  • Tables Selected for BFF

Tables Selected for BFF

  • Project Settings - Backend Spring Java Configuration

    - A] Without Kafka Events, Kafka Streams

    Project Settings

  • Code Generated

Code Generated

  • List Builds

 List Builds

  • Downloaded and extracted code

Locate Backend Spring Java emapi folder

  • Optional Clean-up Step
info
  • Common Step After Build Backend In Stages

As we will use REST APIs

  • Optionally Delete GraphQL project folders after code download

  • Locate your code Downloaded and extracted folder for stage built, e.g. C:\Users\JohnDoe\Downloads\EmGenDir_MYTEMP02_WS_51067\WS_51067\backend\spring-java

  • Make changes as below in that folder's emapi:

    • del dir emapi\app\dbgraphql
    • edit emapi\app\pom.xml: Remove line <module>dbgraphql</module>
    • del dir emapi\testApi\dbgraphqlTest
    • edit emapi\testApi\pom.xml: Remove line <module>dbgraphqlTest</module>
  • Below Steps modify as per Stage wise Configuration

  • Edit server port as per stage project in file

    • emapi\app\dbrest\src\main\resources\application.properties
    • e.g. For BFF change to server.port = 9060
  • COPY / Rename this emapi folder as Backend Stage Project, e.g. emapi-BFF

    • dest full path C:\work\saas-multi\BFF-backend-for-frontend\emapi-BFF

Build BFF Backend For Frontend

Backend Stage Project : emapi-BFF

tip

Make sure to

  • Select applicable tables
  • Applicable Project Settings
tip
info

Also Build Frontend Mobile App after BFF Backend For Frontend, using same generated code. Locate mobile app in frontend folder. This part is covered in next section Build Frontend Mobile App

  • After Common Steps

This tutorial is covered in Chapter : Chapter 4 : BFF Backend For Frontend

  • Please complete above Tutorial and come back here to resume.

Build Frontend Mobile App

Flutter Mobile App Project : emapi-BFF

After building "BFF Backend For Frontend", use same generated code for mobile app. We will use same backend for this mobile app, with REST APIs.

This tutorial is covered in Chapter : Chapter 5 : Frontend Mobile App

  • Please complete above Tutorial and come back here to resume.

Build Backends For Main Product And Customizations

You will use the emapi projects to build microservices in further steps.

Note: Repetitive Screenshots for Table selected, Code generated, list build are ommitted in further build backend stages.

tip

For Building Backends, Please keep referring to below 2 sections

Refer to Stage Wise Configuration

Build Backend Spring Java using Common Steps For Build Backend In Stages

For order-service-v1

After Common Steps,

  • COPY / Rename this emapi folder as emapi-order-svc-v1
    • dest full path C:\work\saas-multi\main-prod\emapi-order-svc-v1

For inventory-quantity-check-service

After Common Steps,

  • COPY / Rename this emapi folder as emapi-inv-check-svc
    • dest full path C:\work\saas-multi\main-prod\emapi-inv-check-svc

For order-service-v2

Note: This backend is extending of emapi-order-svc-v1, so this will be created from its copy lateron.

For tenant-manager-cust-service

After Common Steps,

  • COPY / Rename this emapi folder as emapi-tenant-mgr-cust-svc
    • dest full path C:\work\saas-multi\tenant-cust\emapi-tenant-mgr-cust-svc

For tenant-2-validation-service

After Common Steps,

  • COPY / Rename this emapi folder as emapi-tenant-2-svc
    • dest full path C:\work\saas-multi\tenant-cust\emapi-tenant-2-svc

For tenant-3-shipping-service

After Common Steps,

  • COPY / Rename this emapi folder as emapi-tenant-3-svc
    • dest full path C:\work\saas-multi\tenant-cust\emapi-tenant-3-svc
info

You have completed building backend multiple emapi* projects to use in building microservices in further steps.

Enterprise Microservices For Building SaaS Multitenant

Build Enterprise Microservices

Section 1-3 : Main Product Microservices

Section 1-4 : Tenant Specific Customization Using Microservices