r/webdev • u/Accurate-Screen8774 • 1d ago
Showoff Saturday Decentralized Microfrontend Architecture
IMPORTANT DISCLAIMER: This is my own project. I am using AI. Its important to get that out of the way... because its the key reason for why YOU SHOULD NOT USE IT. Im not trying to promote "yet another secure messaging app", this is an example to see what is possible with a related UI framework im working on ( https://github.com/positive-intentions/dim ). Its unreviewed, unaudited and far from finished. This framework is intended for myself on my own projects. It is provided open-source for transparency, testing and demo purposes only. There will be breaking changes.
- Messaging app repo: https://github.com/positive-intentions/dimim
- Live demo: https://dim.glitr.io/
- Framework guide: https://glitr.io/docs/technical/research-and-development/dim/getting-started
I was investigating an idea i had about JSX-like syntax for webcomponents after some experience with Lit. It is nice lightweight webcomponent UI frameworks, but i didnt like that it was using class-based components. It can support React with a wrapper, but React is fundamentally an abstraction away from the DOM. i was aiming for something like human readable code like you have with React but without the need to minify/transpile the code.
The key details that set this approach apart:
- No minification or transpilation
- No React, NPM or bundler
- Works from local index.html
The architecture is also a bit unique. Module federation has been around for a while but still fairly under-used. Im aiming for something that could be described as like a vanilla JS "decentralized microfrontend architecture", where in this approach, i can abstract complexity into seperate repositories to manage reusble functionality like in the boilerplate example:
- Code: https://github.com/positive-intentions/dim-boilerplate
- Demo: https://positive-intentions.github.io/dim-boilerplate
- Docs: https://glitr.io/docs/technical/research-and-development/dim/dim-boilerplate
To avoid vibecoded cryptography, the aim here is to avoid handling encryption where appropriate. Browsers that support webrtc, will have their own mechanisms for managing encryption (as required by the spec). The keys will not be accessible from app-level JS code. For security best-practice, users should use an OS, browser and network they trust.
To make something this complicated at scale, i would need to have an approach for testing out changes in a way thats more isolated/focused. The npm ecosystem is useful because you can have things like storybook, unit-testing and browser automation tools. So i wanted to see what is possible with the pure javascript approach and created runTests.html. Like the main app, the code is just plain javascript and so it can be imported and tested with production statics. The testing functionality here is especially far from finished. This is an important feature to do it properly because it would be doing a lot of heavy lifting as the project improves.
P.S. The disclaimer above is always worth repeating. Im aiming for a post like this to be like "building in public". If interesting to anyone, i hope its inviting to take a look. It's hard to determine if/when its a good time to share, so best to get it out there sooner for any outstanding issues i may have overlooked.
6
u/Least-Swing-4152 23h ago
Le meme dit que React/npm/Vite c'est un traumatisme crânien, mais une archi microfrontend "décentralisée" sans npm ça veut dire quoi, cinq équipes qui copient le même fichier jQuery à la main dans cinq repos?
2
u/minmidmax 23h ago
Web components with modern HTML and CSS can do pretty much everything you do with a bloated, convoluted, framework.
They also work with any framework.
0
u/Raja_kumar9627 22h ago
the no-build approach is what caught my attention