Skip to content

Commit 5241a4a

Browse files
committed
docs: update client-side ui composition
1 parent 4b06dc2 commit 5241a4a

File tree

4 files changed

+70
-54
lines changed

4 files changed

+70
-54
lines changed

microservices-api-gateway/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Microservices API Gateway Pattern in Java: Simplifying Service Access with a Unified Endpoint"
3-
shortTitle: Microservice API Gateway
3+
shortTitle: Microservices API Gateway
44
description: "Learn how the API Gateway pattern simplifies client-side development, enhances security, and optimizes communication in microservices architecture. Explore examples, benefits, and best practices."
55
category: Integration
66
language: en

microservices-api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/ImageClientImpl.java

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class ImageClientImpl implements ImageClient {
4545
*/
4646
@Override
4747
public String getImagePath() {
48+
4849
var httpClient = HttpClient.newHttpClient();
4950
var httpGet =
5051
HttpRequest.newBuilder().GET().uri(URI.create("http://localhost:50005/image-path")).build();
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,53 @@
11
---
2-
title: "Client-Side UI Composition Pattern: Assembling Modular UIs in Microservices Architecture"
3-
shortTitle: Client-Side UI Composition Pattern
2+
title: "Microservices Client-Side UI Composition Pattern In Java: Assembling Modular UIs in Microservices Architecture"
3+
shortTitle: Microservices Client-Side UI Composition
44
description: "Learn how the Client-Side UI Composition pattern allows the assembly of modular UIs on the client side, enabling independent teams to develop, deploy, and scale UI components in a microservices architecture. Discover the benefits, implementation examples, and best practices."
5-
category: Structural
5+
category: Architectural
66
language: en
77
tag:
8-
- Asynchronous
8+
- Client-server
9+
- Cloud distributed
10+
- Composition
11+
- Decoupling
12+
- Integration
13+
- Microservices
14+
- Modularity
15+
- Scalability
16+
- Web development
917
---
1018

11-
## **Intent of Client-Side UI Composition Design Pattern**
19+
## Intent of Client-Side UI Composition Design Pattern
1220

13-
The Client-Side UI Composition Pattern allows the assembly of UIs on the client side by composing independent UI components (Micro Frontends). Each component is developed, tested, and deployed independently by separate teams, ensuring flexibility and scalability in microservices architecture.
21+
Compose user interface from independently deployable microservices on the client side for greater flexibility and decoupling.
1422

15-
---
16-
17-
## **Also Known As**
23+
## Also Known As
1824

19-
- Micro Frontends
20-
- Modular UI Assembly
21-
- Client-Side Integration
25+
* UI Aggregator
26+
* Frontend-Driven Composition
2227

23-
---
28+
## Detailed Explanation of Client-Side UI Composition Pattern with Real-World Examples
2429

25-
## **Detailed Explanation of Client-Side UI Composition Pattern with Real-World Examples**
30+
Real-world Example
2631

27-
### **Real-world Example**
2832
> In a SaaS dashboard, a client-side composition pattern enables various independent modules like “Billing,” “Reports,” and “Account Settings” to be developed and deployed by separate teams. These modules are composed into a unified interface for the user, with each module independently fetching data from its respective microservice.
2933
30-
### **In Plain Words**
34+
In Plain Words
35+
3136
> The Client-Side UI Composition pattern breaks down the user interface into smaller, independent parts that can be developed, maintained, and scaled separately by different teams.
3237
33-
### **Wikipedia says**
34-
>UI composition refers to the practice of building a user interface from modular components, each responsible for fetching its own data and rendering its own content. This approach enables faster development cycles, easier maintenance, and better scalability in large systems.
35-
---
38+
Wikipedia says
3639

37-
## **Programmatic Example of Client-Side UI Composition in JavaScript**
40+
> UI composition refers to the practice of building a user interface from modular components, each responsible for fetching its own data and rendering its own content. This approach enables faster development cycles, easier maintenance, and better scalability in large systems.
3841
39-
In this example, an e-commerce platform composes its frontend by integrating three independent modules: **CartService**, **ProductService**, and **OrderService**. Each module is served by a microservice and fetched on the client side through an API Gateway.
42+
Sequence diagram
4043

41-
`ApiGateway` Implementation
44+
![Client-Side UI Composition sequence diagram](./etc/microservices-client-side-ui-composition-sequence-diagram.png)
45+
46+
## Programmatic Example of Client-Side UI Composition in Java
47+
48+
This example composes an e-commerce frontend by integrating three independent modules. Each module is served by a microservice and fetched on the client side through an API Gateway.
49+
50+
### `ApiGateway` Implementation
4251

4352
```java
4453
public class ApiGateway {
@@ -60,13 +69,16 @@ public class ApiGateway {
6069

6170
```
6271

63-
`FrontendComponent` Implementation
72+
### `FrontendComponent` Interface
73+
6474
```java
6575
public interface FrontendComponent {
6676
String fetchData(Map<String, String> params);
6777
}
6878
```
69-
## Example components
79+
80+
### Example Components
81+
7082
```java
7183
public class ProductComponent implements FrontendComponent {
7284
@Override
@@ -82,50 +94,53 @@ public class CartComponent implements FrontendComponent {
8294
}
8395
}
8496
```
85-
This approach dynamically assembles different UI components based on the route provided in the client-side request. Each component fetches its data asynchronously and renders it within the main interface.
8697

87-
---
98+
This approach dynamically assembles UI components based on the route in the client-side request. Each component fetches its data asynchronously and renders it within the main interface.
8899

89-
## **When to Use the Client-Side UI Composition Pattern**
100+
## When to Use the Client-Side UI Composition Pattern
90101

91-
- When you have a microservices architecture where multiple teams develop different parts of the frontend.
92-
- When you need to scale and deploy different UI modules independently.
93-
- When you want to integrate multiple data sources or services into a cohesive frontend.
94-
95-
---
102+
* When each microservice must present its own UI components
103+
* When frequent independent deployments of UI features are required
104+
* When teams own end-to-end functionality, including front-end modules
105+
* When Java-based backends provide separate APIs for direct UI consumption
96106

97-
## **Client-Side UI Composition Pattern JavaScript Tutorials**
107+
## Client-Side UI Composition Pattern Tutorials
98108

99109
- [Micro Frontends in Action (O'Reilly)](https://www.oreilly.com/library/view/micro-frontends-in/9781617296873/)
100110
- [Micro Frontends with React (ThoughtWorks)](https://www.thoughtworks.com/insights/articles/building-micro-frontends-using-react)
101111
- [API Gateway in Microservices (Spring Cloud)](https://spring.io/guides/gs/gateway/)
102112

103-
---
113+
## Real-World Applications of Client-Side UI Composition Pattern in Java
104114

105-
## **Benefits and Trade-offs of Client-Side UI Composition Pattern**
115+
* Large-scale e-commerce portals with microservices powering modular pages
116+
* SaaS platforms requiring rapid iteration of front-end features
117+
* Java-based microservice architectures using frameworks like Spring Boot for modular UI components
106118

107-
### **Benefits**:
108-
- **Modularity**: Each UI component is independent and can be developed by separate teams.
109-
- **Scalability**: Micro Frontends allow for independent deployment and scaling of each component.
110-
- **Flexibility**: Teams can choose different technologies to build components, offering flexibility in development.
111-
- **Asynchronous Data Fetching**: Components can load data individually, improving performance.
119+
## Benefits and Trade-offs of Client-Side UI Composition Pattern
112120

113-
### **Trade-offs**:
114-
- **Increased Complexity**: Managing multiple micro frontends can increase overall system complexity.
115-
- **Client-Side Performance**: Depending on the number of micro frontends, it may introduce a performance overhead due to multiple asynchronous requests.
116-
- **Integration Overhead**: Client-side integration logic can become complex as the number of components grows.
121+
Benefits:
117122

118-
---
123+
* Facilitates independent deployment cycles for UI features
124+
* Reduces overall coupling and fosters autonomy among teams
125+
* Enables polyglot front-end development
119126

120-
## **Related Design Patterns**
127+
Trade-offs:
121128

122-
- [Microservices API Gateway Pattern](https://java-design-patterns.com/patterns/microservices-api-gateway/) – API Gateway serves as a routing mechanism for client-side UI requests.
123-
- [Backend for Frontend (BFF)](https://microservices.io/patterns/apigateway.html) – BFF pattern helps build custom backends for different UI experiences.
129+
* Increases client complexity for rendering and data aggregation
130+
* Can cause performance challenges with multiple service calls
131+
* Demands consistent UX guidelines across diverse microservices
124132

125-
---
133+
## Related Design Patterns
134+
135+
* Backend for Frontend (BFF): Provides custom endpoints for specific UIs
136+
* Micro Frontends: Splits the front-end into smaller, individually deployable fragments
137+
* [Microservices API Gateway Pattern](https://java-design-patterns.com/patterns/microservices-api-gateway/): API Gateway serves as a routing mechanism for client-side UI requests.
126138

127-
## **References and Credits**
139+
## References and Credits
128140

129-
- [Micro Frontends Architecture (Microfrontends.org)](https://micro-frontends.org/)
130-
- [Building Microservices with Micro Frontends](https://martinfowler.com/articles/micro-frontends.html)
131-
- [Client-Side UI Composition (Microservices.io)](https://microservices.io/patterns/client-side-ui-composition.html)
141+
* [Building Microservices](https://amzn.to/3UACtrU)
142+
* [Building Microservices with Micro Frontends (Martin Fowler)](https://martinfowler.com/articles/micro-frontends.html)
143+
* [Client-Side UI Composition (Microservices.io)](https://microservices.io/patterns/client-side-ui-composition.html)
144+
* [Cloud Native Java: Designing Resilient Systems with Spring Boot, Spring Cloud, and Cloud Foundry](https://amzn.to/44vDTat)
145+
* [Micro Frontends Architecture (Microfrontends.org)](https://micro-frontends.org/)
146+
* [Microservices Patterns: With examples in Java](https://amzn.to/3UyWD5O)

0 commit comments

Comments
 (0)