Blazor – Application Separation of Concerns in Blazor

Architecturecseparation-of-concerns

I am building a cross-platform application and have planned to use Blazor. I have made similar applications in the past but using ASP.Net Core for the back-end and Angular for the front-end. I always had a strong separation between the front and back-end in those applications, which is always good. The back-end was written as a ASP.Net Core Web API, and the front-end communicated with it through a REST API.

Now I have read a lot about Blazor from the Microsoft docs, and as far as I understood, it could be a potential alternative to Angular. However, I am not so sure how I could separate the front-end and back-end in this scenario.

Does it make sense also to create a back-end as I used to and create the front-end in Blazor, which would communicate with the back-end through the REST API, or is this not ideal?

Best Answer

I'm going to focus on Blazor WebAssembly here, not Blazor Server-Side, because you're trying to compare it to an Angular frontend.

However, I am not so sure how I could separate the front-end and back-end in this scenario.

I'm not quite sure why you're assuming the separation that you'd otherwise have would be any different when you introduce Blazor.
In the end, you're still going to end up with some kind of webpage loaded into the user's browser, a backend server which serves that webpage, and communication happening between the two.

The only thing Blazor changes is what language you use for the development of your frontend app. It does not change the fact that your frontend site needs to contact your REST api in order to receive the information to display. Just because your frontend app is written with C# does not mean that it will also e.g. connect directly to your database the same way your backend C# code would.

The short answer here is that you could freely substitute any Angular app with a Blazor app without needing to worry about your architecture being any different.

Related Topic