Designing around major data entities
The fourth step in router-first architecture is achieving a stateless, data-driven design. To achieve this, it helps a lot to organize your APIs around major data components. This will roughly match how you consume data in various components in your Angular application. We will start off by defining our major data components by creating a rough data Entity Relationship Diagram (ERD). In Chapter 5, Designing Authentication and Authorization, we will review the design and implementation of an API for the user data entity using Swagger.io and Express.js for REST and Apollo for GraphQL.
Defining entities
Let’s start by looking at what kind of entities you would like to store and how these entities might relate to one another.
Here’s a sample design for LemonMart, created using draw.io:
Figure 4.17: ERD for LemonMart
Currently, whether your entities are stored in a SQL or NoSQL database is inconsequential...