I'm fairly new to microservices and web development, but built myself a small microservice architecture in ASP.NET where I have a few services with simple CRUD operations exposed by a REST api. Currently I can consume them in a single MVC client and render the views with the data from the microservices via model binding.
What I'm trying to achieve now is to make the frontend of each service independent as well, but I struggle to figure out how. By my understanding each service must have it's own views and somehow make these available to the client. But how do I handle model binding in the .cshtml like I currently do in the client in that case?
I've tried to read up on the topic but fail to find an entry point.
Is there example of a microfrontend implementation in ASP.NET (not core) anywhere?
Services are just services, and you use them expose data to one or many applications. Which have access to the services typically by using authentication of some sort. You do not want to have views tied into the micro service. Because then you're just making an MVC type app and calling it a micro service, which is ok but not a micro service.
Think of services as having one main purpose to send and receive data, like a User service. Your front-end will call that service to get data about a user, update a user, create a user, etc. Each service is different, and one view can access many services.
See links for more details:
So you'll want to make your front-end with the framework/stach of choice, like Blazor/MVC 5/Vue/Angular/React/etc and have that front-end code call the services you're making via HTTP requests.
edit based on comments:
In the same vein you'll also want to make sure that your front-end application(s) follow a similar approach. You want to avoid a massive monolithic front-end by building an array of smaller and to-the-point applications.
For example, you could have a giant application that handles: meetings, calendars, appointments, trip planning, users, and customers. OR, you could take the micro service approach and build each feature out into its own independently deploy-able application. So you will have meetings app, a calendar app, a users app, etc. Each application is it's own entity but uses the services you have, so you get separation for loose coupling allowing for scalability, and the other pros that come along with micro service architecture, in your front-end.
see here for more details on a micro front-end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With