项目作者: denise-schaefer

项目描述 :
example repo for micro frontends with react and dependency inversion as integration pattern
高级语言: JavaScript
项目地址: git://github.com/denise-schaefer/micro-frontends.git
创建时间: 2019-03-29T19:51:41Z
项目社区:https://github.com/denise-schaefer/micro-frontends

开源协议:MIT License

下载


micro-frontends

example repo for micro frontends with react and dependency inversion as integration pattern

playground to learn how to integrate micro frontends, usages product and content search as example

Assume you have two ore more different search providers as e.g. product and content search. Both are
developed in different teams which want to develop and release their features independently. But you
have to integrate them in frontend like the following:

alt search-example

Why?

To scale with multiple teams in a micro services environment

  • Keep coupling low
  • One-way dependency graph
  • Specialized assets know general assets, but not vice versa

Set up

  1. yarn build
  2. cd app/composer
  3. yarn serve
  4. cd app/search
  5. yarn serve
  6. cd app/product
  7. yarn serve
  8. cd app/content
  9. yarn serve

Open http://localhost:8080 in web browser

Architecture

Components

Dependency graph without cycles

alt components dependency

Sequence

Load HTML and JS

alt load html and js

Execute search with one product search provider

alt execute search with one product search provider

… and add additional content search provider

alt execute search with product and content search provider

… and if no results from any search provider, provide fallback with suggestions

alt fallback with suggestions

Project structure

  1. .
  2. ├── composer
  3. └── server
  4. ├── content
  5. ├── client
  6. └── server
  7. ├── product
  8. ├── client
  9. └── server
  10. ├── search
  11. ├── client
  12. └── server
  13. └── search-api
  14. ├── lib
  15. └── src

search-api

interface to register different search providers with

  • ID
  • order
  • execute_search
  • execute_count
  • getSearchTab
  • getResultComponent
  • client

    • provides container stuff, like rendering search tabs or search results
    • calls search callback on active search provider
    • handles search errors, search fallback and merges suggestions from all search providers
  • server

    • delivers client js, could be a CDN as well

product

  • client

    • provides components to render search results and search tabs
    • could implement filter and use fetchData callback to re-execute search
  • server

    • delivers client js, could be a CDN as well
    • could provide REST-API in real world use case

content

same as product

composer

  • server
    • central unit that receives browser request and return html document
    • includes all scripts
    • may or may not fetch initial data and could be used for server side rendering

Slides

Uses demoit and Go

  1. Install Go
  2. Start with ./demoit slides/demo

or use PDF.

ToDos

Suspense/Loading optimization

error handling

add example and test it

layout

optimization, evt. remove react-bootstrap