Skip to content

Service Oriented Architecture

Suraj kc edited this page Jul 1, 2020 · 1 revision

3 layer architecture

  • Controllers receive incoming client requests, and they leverage services
  • Services contain all business logic and can also make call to data access layer
  • The data access layer interacts with data base by performing queries
  • The controller can respond to the client

Note: We can't place business logic inside controller because there is ton of extra stuffs added to req and res objects. By having business logic inside services, we are able to test it without have to mock express req, or res` objects.

Service layer

The service layer should:

  • Contain business logic
  • Leverage data access layer to interact with database

The service layer should not:

  • Be provided with req or res objects`
  • Handle responding to clients
  • Provide anything related to HTTP transport layer, status codes, headers etc/
  • Directly interact with database =

Ref: https://www.codementor.io/@evanbechtol/node-service-oriented-architecture-12vjt9zs9i

Clone this wiki locally