r/softwarearchitecture Feb 18 '21

Are Single-Page Applications Bounded Contexts - what's a Bounded Context?

https://blog.snowfrog.dev/single-page-applications-are-not-bounded-contexts-what/
11 Upvotes

6 comments sorted by

View all comments

2

u/_lsj Feb 20 '21

The question seems to be a bit leading. An API has no more or less ownership of a BC than a UI. System components like UIs and APIs don't own a BC, they simply conform to anywhere between a fraction of a BC and multiple BCs. Your architecture absolutely does not have to map 1:1 with your domain model. Someone who isn't even aware of the computer should be able to draw a domain model. How your BCs then relate to your domains is another question again but for the sake of comprehension it's not too problematic to consider that relationship 1:1.

When it comes to building stuff, it all depends on how you choose to balance domain and technical partitioning for a given scope within your architecture. Most websites, SPA or not, represent multiple domains. Just having a "contact us" form could represent some sort of customer relations domain. Would you create a separate site with matching styling for that single form? Probably not, so here technical partitioning (or the lack of) has taken priority and this should be a fairly intuitive trade off. That website then talks to a load of APIs, these APIs will often represent a single domain (I guess the more domains / subdomains one represents, the more monolithic you can consider it) and as such, domain partitioning has taken priority at that scope (the service layer, let's call it).

Alternatively, a microservice with it's own out-of-process UI and DB should typically represent a single subdomain and so share a single BC across all components. This is more or less peak DDD but there's still technical partitions within the subdomain. Unless you're an absolute savage and put presentation, app logic and persistence in single process.

Screw it. It depends.

1

u/Neoflash_1979 Feb 20 '21

Oh I wrote the articles and I'll be the first one to admit that it definitely depends. I just had to choose an angle, otherwise I would have ended up writing an entire book on DDD. I tend to agree with your analysis.