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:
- 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
- Computer Win 10+, 16GB RAM, 50GB Free
Prerequisites on Local Computer
Please see Self-Host : Prerequisites for Hardware, Software and Tools required on your local computer.
Prerequisites For Microservices
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.
- Prerequisite - Setup Kafka Servers
- Pease refer to section Backend Templates
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.
- Sample Enteprise Microservices Tables SQL - For MySQL
- Sample Enteprise Microservices Tables SQL - For PostgreSQL
Refer to earlier tutorial for detailed steps Section 1-1 : Import Tables, Select Build
Import Sample Tables Screenshots
- Import Tables - Search Tables
- Import Tables - Import
- Import Tables - View Imported Tables
Section 1-2 : Build Backend Spring Java (Multiple Projects)
Please follow Tutorial 1 : Build Your First App
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- B] With Kafka Events, Kafka Streams
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 Service | Tables | Proj Settings Include Kafka Events, Kafka Streams | Port | emapi Project Rename To | |
---|---|---|---|---|---|
BFF | BFF-service | customer, tenant, product, inventory, orders, shipping | No | 9060 | emapi-BFF |
Main Product | order-service-v1 | customer, tenant, product, orders | No | 9070 | emapi-order-svc-v1 |
inventory-quantity-check-service | inventory | No | 9072 | emapi-inv-check-svc | |
Tenant Customization | order-service-v2 | customer, tenant, product, orders | No | 9070 | emapi-order-svc-v2 |
tenant-manager-cust-service | customer, tenant, orders | Yes | 9074 | emapi-tenant-mgr-cust-svc | |
tenant-2-validation-service | tenant | No | 9076 | emapi-tenant-2-svc | |
tenant-3-shipping-service | shipping | Yes | 9078 | emapi-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
Project Settings - Backend Spring Java Configuration
- A] Without Kafka Events, Kafka Streams
Code Generated
- List Builds
- Downloaded and extracted code
- Optional Clean-up Step
- 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>
- del dir
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
- dest full path
Build BFF Backend For Frontend
Backend Stage Project : emapi-BFF
Refer to Stage Wise Configuration
Build Backend Spring Java using Common Steps For Build Backend In Stages
Make sure to
- Select applicable tables
- Applicable Project Settings
- Common Steps For Build Backend In Stages gives examples for "Build BFF Backend For Frontend" only, so you can follow them, as is.
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.
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 asemapi-order-svc-v1
- dest full path
C:\work\saas-multi\main-prod\emapi-order-svc-v1
- dest full path
• For inventory-quantity-check-service
After Common Steps,
- COPY / Rename this
emapi
folder asemapi-inv-check-svc
- dest full path
C:\work\saas-multi\main-prod\emapi-inv-check-svc
- dest full path
• 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 asemapi-tenant-mgr-cust-svc
- dest full path
C:\work\saas-multi\tenant-cust\emapi-tenant-mgr-cust-svc
- dest full path
• For tenant-2-validation-service
After Common Steps,
- COPY / Rename this
emapi
folder asemapi-tenant-2-svc
- dest full path
C:\work\saas-multi\tenant-cust\emapi-tenant-2-svc
- dest full path
• For tenant-3-shipping-service
After Common Steps,
- COPY / Rename this
emapi
folder asemapi-tenant-3-svc
- dest full path
C:\work\saas-multi\tenant-cust\emapi-tenant-3-svc
- dest full path
You have completed building backend multiple emapi*
projects to use in building microservices in further steps.