Giter Site home page Giter Site logo

alxc / ilc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from namecheap/ilc

0.0 0.0 0.0 15.47 MB

Enterprise-ready framework for Micro Frontends composition into SPA with SSR & i18n support

Home Page: http://ilc.namecheap.technology

License: Other

Shell 0.07% JavaScript 59.09% TypeScript 38.94% HTML 1.80% Smarty 0.01% Dockerfile 0.09%

ilc's Introduction

Isomorphic Layout Composer logo


Latest version Demo website Actions Status Docker Pulls Docker Pulls

Isomorphic Layout Composer (ILC) - a layout service that composes a web page from fragment services. It supports client/server-based page composition.

Its competitive advantage over other solutions is an isomorphic page composition. It means that ILC assembles a page on the server-side using apps that support Server-side rendering (SSR), and after that, the page is passed on the client-side, so the client-side rendering handles all further navigation.

This approach allows to combine advantages of the Micro Frontends, SPA, and Server-side rendering approaches.

This repository also contains an example of how you can create a frontend that is composed from multiple applications that work in concert and deliver a unified experience.

Why do I need ILC?

Microservices get a lot of traction these days. They allow multiple teams to work independently, choose their technology stacks, and establish release cycles. Unfortunately, frontend development doesn't take full advantage of the microservices' benefits. The common practice for building websites is still "a monolith" - a single frontend codebase that consumes multiple APIs.

What if we introduce microservices on the frontend? It would allow frontend developers to work together with their backend counterparts on the same feature and independently deploy parts of the website ("fragments"), such as header, product, and footer. To bring microservices to the frontend, you need a layout service that can "stitch" a website out of fragments. This is where ILC comes into play.

Key features

🚀 Quick start

!!! tip "Demo website" For a quick preview, check out our demo website

To quickstart with ILC locally, follow the steps below:

  1. Clone the namecheap/ilc repository.

  2. Run npm install

    1. OPTIONAL Switch database to PostgreSQL by changing environment variable DB_CLIENT to pg in services registry_worker and registry
  3. Run docker compose up -d. Wait for the process to complete:

    [+] Running 6/6
     ⠿ Network ilc_default                  Created     0.1s
     ⠿ Container ilc-ilc-1                  Started     0.8s
     ⠿ Container ilc-mysql-1                Started     0.8s
     ⠿ Container ilc-registry-1             Started     20.0s
     ⠿ Container ilc-demo-apps-1            Started     1.4s
     ⠿ Container ilc-registry_worker-1      Started     19.8s
    
  4. Run docker compose run registry npm run seed. Wait for the process to complete:

    [+] Running 1/1
     ⠿ Container ilc-mysql-1                Recreated   3.8s
    [+] Running 1/1
     ⠿ Container ilc-mysql-1                Started     0.4s
    
    > [email protected] seed /codebase
    > knex --knexfile config/knexfile.ts seed:run
    
    Requiring external module ts-node/register
    Working directory changed to /codebase/config
    WARNING: NODE_ENV value of 'production' did not match any deployment config file names.
    WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
    Ran 8 seed files
  5. Open your browser and navigate to ILC or Registry UI:

!!! tip "Additional commands" * View logs: docker compose logs -f --tail=10 * Shutdown local ILC: docker compose down

!!! note "" You can find more information about demo applications for this quick start in the namecheap/ilc-demo-apps repository.

Architecture overview

ILC Architecture overview

Repository structure

The namecheap/ilc repository consists of the following parts:

  • ilc: code of the Isomorphic Layout Composer
  • registry: app that contains configuration that ILC uses: a list of micro-fragments, routes, etc.

Further reading

🔌 Adapters

ILC relies on the adapters provided within the single-spa ecosystem to connect various frameworks. However, to ensure better integration with ILC, some of the original adapters were extended:

Notes

@portal/ prefix

ILC uses webpack (a static module bundler) to build each application for our micro-frontend approach. Webpack requires access to everything it needs to include in the bundle at build time. It means when an app imports a service (for example, planets import the fetchWithCache service), webpack tries to bundle the service into the planets bundle.

The built-in way to prevent this behavior is webpack externals. This approach works well but to avoid adding a regex to each service ILC uses the @portal prefix to instruct both webpack and developers that the import is another micro-app/service/frontend.

Code splitting

Code splitting is a complicated topic. In ILC, code splitting is even more complicated. The reason is that the webpack module format expects the loading of extra modules from the website root, which will always fail until a place from where to load extra modules is configured. In ILC, you can see an example of this approach in the demo people application.

Sockets timeout to fragments

If you experience socket timeouts during requests to fragments, plese checkout this workaround namecheap#444

ilc's People

Contributors

asamolion avatar b1ff avatar bandantonio avatar blackrabbit99 avatar dammned avatar dependabot[bot] avatar ifree92 avatar nightnei avatar oleh-momot avatar pokhodenko avatar stas-nc avatar stylet avatar tgarlanger avatar themcmurder avatar valikdev avatar yehor-manzhula avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.