Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Front end "micro services" with Angular 2

I'm looking for a solution for a bit of an odd situation. Let's take a quick look at the angular2-seed project so I can better explain: https://github.com/mgechev/angular2-seed/tree/master/src/client/app.

In that project, we have 3 isolated modules - about, home, shared. What I am looking for is a way to isolate development of these, so we're ultimately able to release each piece independently. For example, say Team A is working on the about section, and Team B is working on home. Work is complete for each, and we're ready to release, however we realize the about section is missing a critical piece of functionality, however we still want to release the change to the home section. What we're looking for is a way to achieve this.

Here are some solutions already explored, but I'm not really happy with:

  • Have completely different applications for home/about (in my eyes, this eliminates many of the benefits of a SPA).
  • Have each module (about, home, shared) roll up into it's own NPM package. When we go to deploy, we would have some way to orchestrate pulling in all the published NPM packages for these modules.
like image 676
SpareWalrus Avatar asked Oct 06 '16 19:10

SpareWalrus


People also ask

Can Angular be used for microservices?

It's perfectly feasible to use microservices on the back end with a single Angular application on the front end. But if you want to divide it up and it makes sense to do so, you should first look at using multiple modules. You are already using modules (these are added to the imports of your app.

Can a Microservice have a frontend?

2: Frontend integration: The frontend is a component of each microservice. Each must be connected separately to provide users with a uniform UI/UX. Build-time integration is based on providing the frontends using packages, which a container app then loads as a dependency.

What is Micro front end in Angular?

Micro Frontend — is a client-side architecture design when individual components or pages are hosted in separate domains and integrated into the main shell app (host application). Each of the micro-app owned the whole business subdomain and has the following characteristics: Owned by one team.

What is front end microservices?

Micro frontends are a new pattern where web application UIs (front ends) are composed from semi-independent fragments that can be built by different teams using different technologies. Micro-frontend architectures resemble back-end architectures where back ends are composed from semi-independent microservices.


1 Answers

Orchestration:

Have each team build a component library (NPM) and pull those into a single Angular 2 application. That way, the teams can develop using microservices principles, but you can deploy a SPA monolith which reduces complexity.

Large component libraries should have multiple bundles and modules so you can be selective about what you pull in.

Communication between microservices:

If necessary, the component libraries can communicate over a back-end message bus.

If direct client-side integration is required between the component libraries, then you need a 3rd component library that about and home depends on, which contains a light-weight injectable message/event service. You can implement that service using RxJS Subjects.

like image 70
KTCO Avatar answered Oct 01 '22 03:10

KTCO