codedamn

Node service-oriented architecture

Node service-oriented architecture

Hey readers! In this article, we will be talking about Node js service-oriented architecture. If you are not aware of these terms, I would highly recommend you to read Node js architecture blog on codedamn.

Service-Oriented Architecture 

What is service-oriented architecture in Node js?
It is a style or pattern of software where it is designed in such a way that services are provided through application components over a communication network protocol.

The main aim of service-oriented architecture is to allow users to mix large chunks of functionalities into one in order to build an application and services by combining services. Below depicts the functions or components of service-oriented architecture.

service-oriented architecture
service-oriented architecture

In Node js, the service-oriented architecture has three layers to it. Below are the steps in which the service-oriented architecture works in Node js

  • The incoming requests are received by a controller which leverages services
  • This service layer contains main logic and can make calls to the data layer as it has access to it
  • After the service layer, the data layer then accesses the database by performing queries and operations on data
  • Output or response is then sent back to the service layer
  • The service layer then sends all the responses back to the controller 
  • Controller or router returns the response received to the client

The main aim of layered architecture in Node js is to separate components according to their function and task and to organize layers to perform dedicated tasks.

It consists of three layers:

  1. Router layer
  2. Service layer
  3. Data access layer

    Router layer– It contains routes of API in an application. The main task of this layer is to return responses from the service layer to the server.

    Service layer– The service layer handles the main logic of an app. Data transformation takes place in this layer before sending a response to the server.

    Data access layer– This layer has access to database functionalities like creating, updating or deleting the data. It is the layer where requests and responses are handled. This layer contains protocols like HTTP and HTTPS in order to request a server if no database is connected to the app directly.

    The key concept is to understand the data flow among different layers in this architecture.

    Additionally, the backend service in Service-oriented architecture is divided into three parts. These play a major role within architecture and those are:

    • Service provider– maintains and make services accessible to developers
    • Service repository– makes web service or information available upon request and make it accessible from every location
    • Service consumer– provides data that binds to the use of services, interaction with different services, etc.

    Working of the service-oriented architecture

    As soon as an event triggers on the button click, the function sends the API data to the router. The router then calls the service layer and waits for it to respond. Finally, the router returns the data to the service layer.

    After data has been received by the service layer, it gets passed onto the data layer. The data layer makes requests to the database for certain operations. This response is then sent to the service layer which then returns it to the router and is then presented to the user. That’s how layered architecture works in general. Here each layer is assigned a specific task therefore everything is clear and easy.

    Advantages 

    • Reliable– Even though service-oriented architecture has small and independent services, it becomes easier to debug code as it checks small chunks instead of checking a large codebase
    • Independent of location– services can be accessed through URL therefore change in location doesn’t affect customer experience
    • Scalable– service-oriented architecture can run on multiple platforms and can operate various servers within the given environment
    • Reusability– The SOA uses its services in multiple applications independently without disturbing other services
    • Easy maintenance– SOA is an independent unit therefore updating becomes easy as it is a single entity
    • Agile– Due to reusable components and services, it helps developers integrate and build applications quickly according to requirements consequently increasing the agility of service-oriented architecture.

    Disadvantages 

    • High cost– It requires human intervention, technology development, etc.
    • High server bandwidth– Requires internet services and large bandwidth in order to run servers and services of an application
    • Overload– If you combine multiple small services in one or one service is used by multiple applications due to the concept of reusable services, it can create a load on server which fluctuates performance.

    Conclusion

    This was all about Node js service architecture. Check out the latest tech courses on codedamn. You can also use their playground which has a built-in environment for all development programming languages specially made for practicing without having to build an environment. Also if you have any queries, do let us know in the comment box and join codedamn’s developer community.

    Learn programming on codedamn

    Codedamn is an interactive coding platform with tons of sweet programming courses that can help you land your first coding job. Here's how:

    Programming is one of the most in-demand jobs today. Learning to program can change your future. All the best!

    Sharing is caring

    Did you like what Vishnupriya wrote? Thank them for their work by sharing it on social media.