Skip to content

Commit 9864495

Browse files
authored
Merge branch 'master' into master
2 parents d317ca2 + bcad5b1 commit 9864495

File tree

45 files changed

+2426
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2426
-66
lines changed

.all-contributorsrc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,6 +3312,51 @@
33123312
"contributions": [
33133313
"translation"
33143314
]
3315+
},
3316+
{
3317+
"login": "HabibaMekay",
3318+
"name": "HabibaMekay",
3319+
"avatar_url": "https://avatars.githubusercontent.com/u/133516736?v=4",
3320+
"profile": "https://github.com/HabibaMekay",
3321+
"contributions": [
3322+
"code"
3323+
]
3324+
},
3325+
{
3326+
"login": "Ahmed-Taha-981",
3327+
"name": "Ahmed-Taha-981",
3328+
"avatar_url": "https://avatars.githubusercontent.com/u/122402269?v=4",
3329+
"profile": "https://github.com/Ahmed-Taha-981",
3330+
"contributions": [
3331+
"code"
3332+
]
3333+
},
3334+
{
3335+
"login": "malak-elbanna",
3336+
"name": "Malak Elbanna",
3337+
"avatar_url": "https://avatars.githubusercontent.com/u/67643605?v=4",
3338+
"profile": "https://malakelbanna.netlify.app/",
3339+
"contributions": [
3340+
"code"
3341+
]
3342+
},
3343+
{
3344+
"login": "depthlending",
3345+
"name": "BiKangNing",
3346+
"avatar_url": "https://avatars.githubusercontent.com/u/164312726?v=4",
3347+
"profile": "https://github.com/depthlending",
3348+
"contributions": [
3349+
"doc"
3350+
]
3351+
},
3352+
{
3353+
"login": "TarunVishwakarma1",
3354+
"name": "Tarun Vishwakarma",
3355+
"avatar_url": "https://avatars.githubusercontent.com/u/138651451?v=4",
3356+
"profile": "https://github.com/TarunVishwakarma1",
3357+
"contributions": [
3358+
"code"
3359+
]
33153360
}
33163361
],
33173362
"contributorsPerLine": 6,

.github/stale.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

.github/workflows/stale.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Comment on stale issues and PRs'
2+
on:
3+
schedule:
4+
- cron: '30 1 * * *'
5+
6+
jobs:
7+
stale:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/stale@v9
11+
with:
12+
stale-issue-message: 'This issue is stale because it has been open 60 days with no activity.'
13+
stale-pr-message: 'This PR is stale because it has been open 60 days with no activity.'
14+
close-issue-message: 'This issue was closed because it has been stalled for too long with no activity.'
15+
close-pr-message: 'This PR was closed because it has been stalled for too long with no activity.'
16+
days-before-issue-stale: 60
17+
days-before-pr-stale: 60
18+
days-before-issue-close: -1
19+
days-before-pr-close: -1

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=coverage)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
77
[![Join the chat at https://gitter.im/iluwatar/java-design-patterns](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
88
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
9-
[![All Contributors](https://img.shields.io/badge/all_contributors-362-orange.svg?style=flat-square)](#contributors-)
9+
[![All Contributors](https://img.shields.io/badge/all_contributors-368-orange.svg?style=flat-square)](#contributors-)
1010
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1111

1212
<br/>
@@ -544,6 +544,13 @@ This project is licensed under the terms of the MIT license.
544544
<td align="center" valign="top" width="16.66%"><a href="https://github.com/SalmaAzeem"><img src="https://avatars.githubusercontent.com/u/121863224?v=4?s=100" width="100px;" alt="Salma"/><br /><sub><b>Salma</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=SalmaAzeem" title="Code">💻</a></td>
545545
<td align="center" valign="top" width="16.66%"><a href="https://codemaverick-143.github.io/My-Portfolio/"><img src="https://avatars.githubusercontent.com/u/182847716?v=4?s=100" width="100px;" alt="Arpit Sarang"/><br /><sub><b>Arpit Sarang</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=CodeMaverick-143" title="Code">💻</a></td>
546546
<td align="center" valign="top" width="16.66%"><a href="https://github.com/mayatarek"><img src="https://avatars.githubusercontent.com/u/111644421?v=4?s=100" width="100px;" alt="Maya"/><br /><sub><b>Maya</b></sub></a><br /><a href="#translation-mayatarek" title="Translation">🌍</a></td>
547+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/HabibaMekay"><img src="https://avatars.githubusercontent.com/u/133516736?v=4?s=100" width="100px;" alt="HabibaMekay"/><br /><sub><b>HabibaMekay</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=HabibaMekay" title="Code">💻</a></td>
548+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/Ahmed-Taha-981"><img src="https://avatars.githubusercontent.com/u/122402269?v=4?s=100" width="100px;" alt="Ahmed-Taha-981"/><br /><sub><b>Ahmed-Taha-981</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Ahmed-Taha-981" title="Code">💻</a></td>
549+
<td align="center" valign="top" width="16.66%"><a href="https://malakelbanna.netlify.app/"><img src="https://avatars.githubusercontent.com/u/67643605?v=4?s=100" width="100px;" alt="Malak Elbanna"/><br /><sub><b>Malak Elbanna</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=malak-elbanna" title="Code">💻</a></td>
550+
</tr>
551+
<tr>
552+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/depthlending"><img src="https://avatars.githubusercontent.com/u/164312726?v=4?s=100" width="100px;" alt="BiKangNing"/><br /><sub><b>BiKangNing</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=depthlending" title="Documentation">📖</a></td>
553+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/TarunVishwakarma1"><img src="https://avatars.githubusercontent.com/u/138651451?v=4?s=100" width="100px;" alt="Tarun Vishwakarma"/><br /><sub><b>Tarun Vishwakarma</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=TarunVishwakarma1" title="Code">💻</a></td>
547554
</tr>
548555
</tbody>
549556
</table>

hexagonal-architecture/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Hexagonal Architecture is particularly beneficial in scenarios:
180180
* There is a requirement for high testability and maintainability.
181181
* The application should remain unaffected by changes in external interfaces.
182182

183-
## Real-World Applications of Hexagonal Architecure Pattern in Java
183+
## Real-World Applications of Hexagonal Architecture Pattern in Java
184184

185185
* Implemented extensively within enterprise applications that leverage frameworks like Spring.
186186
* Used in microservices architectures to maintain clear boundaries and protocols between services.

hexagonal-architecture/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<dependency>
4747
<groupId>de.flapdoodle.embed</groupId>
4848
<artifactId>de.flapdoodle.embed.mongo</artifactId>
49-
<version>4.18.0</version>
49+
<version>4.18.1</version>
5050
<scope>test</scope>
5151
</dependency>
5252
<dependency>
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
title: "Client-Side UI Composition Pattern: Assembling Modular UIs in Microservices Architecture"
3+
shortTitle: Client-Side UI Composition Pattern
4+
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: User Interface
6+
language: en
7+
tag:
8+
- Micro Frontends
9+
- API Gateway
10+
- Asynchronous Data Fetching
11+
- UI Integration
12+
- Microservices Architecture
13+
- Scalability
14+
---
15+
16+
## **Intent of Client-Side UI Composition Design Pattern**
17+
18+
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.
19+
20+
---
21+
22+
## **Also Known As**
23+
24+
- Micro Frontends
25+
- Modular UI Assembly
26+
- Client-Side Integration
27+
28+
---
29+
30+
## **Detailed Explanation of Client-Side UI Composition Pattern with Real-World Examples**
31+
32+
### **Real-world Example**
33+
> 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.
34+
35+
### **In Plain Words**
36+
> 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.
37+
38+
### **Wikipedia says**
39+
>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.
40+
---
41+
42+
## **Programmatic Example of Client-Side UI Composition in JavaScript**
43+
44+
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.
45+
46+
`ApiGateway` Implementation
47+
48+
```java
49+
public class ApiGateway {
50+
51+
private final Map<String, FrontendComponent> routes = new HashMap<>();
52+
53+
public void registerRoute(String path, FrontendComponent component) {
54+
routes.put(path, component);
55+
}
56+
57+
public String handleRequest(String path, Map<String, String> params) {
58+
if (routes.containsKey(path)) {
59+
return routes.get(path).fetchData(params);
60+
} else {
61+
return "404 Not Found";
62+
}
63+
}
64+
}
65+
66+
```
67+
68+
`FrontendComponent` Implementation
69+
```java
70+
public interface FrontendComponent {
71+
String fetchData(Map<String, String> params);
72+
}
73+
```
74+
## Example components
75+
```java
76+
public class ProductComponent implements FrontendComponent {
77+
@Override
78+
public String fetchData(Map<String, String> params) {
79+
return "Displaying Products: " + params.getOrDefault("category", "all");
80+
}
81+
}
82+
83+
public class CartComponent implements FrontendComponent {
84+
@Override
85+
public String fetchData(Map<String, String> params) {
86+
return "Displaying Cart for User: " + params.getOrDefault("userId", "unknown");
87+
}
88+
}
89+
```
90+
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.
91+
92+
---
93+
94+
## **When to Use the Client-Side UI Composition Pattern**
95+
96+
- When you have a microservices architecture where multiple teams develop different parts of the frontend.
97+
- When you need to scale and deploy different UI modules independently.
98+
- When you want to integrate multiple data sources or services into a cohesive frontend.
99+
100+
---
101+
102+
## **Client-Side UI Composition Pattern JavaScript Tutorials**
103+
104+
- [Micro Frontends in Action (O'Reilly)](https://www.oreilly.com/library/view/micro-frontends-in/9781617296873/)
105+
- [Micro Frontends with React (ThoughtWorks)](https://www.thoughtworks.com/insights/articles/building-micro-frontends-using-react)
106+
- [API Gateway in Microservices (Spring Cloud)](https://spring.io/guides/gs/gateway/)
107+
108+
---
109+
110+
## **Benefits and Trade-offs of Client-Side UI Composition Pattern**
111+
112+
### **Benefits**:
113+
- **Modularity**: Each UI component is independent and can be developed by separate teams.
114+
- **Scalability**: Micro Frontends allow for independent deployment and scaling of each component.
115+
- **Flexibility**: Teams can choose different technologies to build components, offering flexibility in development.
116+
- **Asynchronous Data Fetching**: Components can load data individually, improving performance.
117+
118+
### **Trade-offs**:
119+
- **Increased Complexity**: Managing multiple micro frontends can increase overall system complexity.
120+
- **Client-Side Performance**: Depending on the number of micro frontends, it may introduce a performance overhead due to multiple asynchronous requests.
121+
- **Integration Overhead**: Client-side integration logic can become complex as the number of components grows.
122+
123+
---
124+
125+
## **Related Design Patterns**
126+
127+
- [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.
128+
- [Backend for Frontend (BFF)](https://microservices.io/patterns/apigateway.html) – BFF pattern helps build custom backends for different UI experiences.
129+
130+
---
131+
132+
## **References and Credits**
133+
134+
- [Micro Frontends Architecture (Microfrontends.org)](https://micro-frontends.org/)
135+
- [Building Microservices with Micro Frontends](https://martinfowler.com/articles/micro-frontends.html)
136+
- [Client-Side UI Composition (Microservices.io)](https://microservices.io/patterns/client-side-ui-composition.html)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@startuml client_side_ui_composition_updated
2+
skinparam classAttributeIconSize 0
3+
4+
class ApiGateway {
5+
+registerRoute(path: String, component: FrontendComponent)
6+
+handleRequest(path: String, params: Map<String, String>): String
7+
}
8+
9+
class FrontendComponent {
10+
+fetchData(params: Map<String, String>): String
11+
#getData(params: Map<String, String>): String
12+
}
13+
14+
class ProductFrontend {
15+
+getData(params: Map<String, String>): String
16+
}
17+
18+
class CartFrontend {
19+
+getData(params: Map<String, String>): String
20+
}
21+
22+
class ClientSideIntegrator {
23+
+composeUI(path: String, params: Map<String, String>)
24+
}
25+
26+
ApiGateway --> FrontendComponent
27+
FrontendComponent <|-- ProductFrontend
28+
FrontendComponent <|-- CartFrontend
29+
ClientSideIntegrator --> ApiGateway
30+
31+
@enduml
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
5+
6+
The MIT License
7+
Copyright © 2014-2022 Ilkka Seppälä
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in
17+
all copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
THE SOFTWARE.
26+
27+
-->
28+
29+
<project xmlns="http://maven.apache.org/POM/4.0.0"
30+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
31+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
32+
<modelVersion>4.0.0</modelVersion>
33+
<parent>
34+
<groupId>com.iluwatar</groupId>
35+
<artifactId>java-design-patterns</artifactId>
36+
<version>1.26.0-SNAPSHOT</version>
37+
</parent>
38+
39+
<artifactId>microservices-client-side-ui-composition</artifactId>
40+
41+
<dependencies>
42+
<dependency>
43+
<groupId>org.junit.jupiter</groupId>
44+
<artifactId>junit-jupiter-engine</artifactId>
45+
<scope>test</scope>
46+
</dependency>
47+
48+
</dependencies>
49+
50+
</project>

0 commit comments

Comments
 (0)