Skip to content

Communication between all parts

cyoq edited this page Jun 28, 2020 · 3 revisions

Interaction between backend, frontend, device and websocket-server.

For the sake of simplicity our actor or user is called Oleg(one of this repository authors).

In the schema it is possible to see how all parts interact together. These are the steps how everything works:

  • #1 - Frontend part sends login request with username and password to API Server.
  • #2 - API Server checks whether the credentials are right and sends back a response with JWT token, which lasts 10 minutes.
  • #3 - Frontend part uses Vuex and dispatches USER_REQUEST action, in order to get information about user profile.
  • #4 - API Server sends back the user profile.
  • #5 - Frontend part sends the request for connection to the Websocket Server if the user is in /dash or /charts routes.
  • #6 - Smart Power Socket, which is already verified by API Server, sends data to API Server as soon as it is possible.
  • #7 - When API Server gets socket's power measurement, it tries as soon as possible to send it and user id, to which socket belongs to, to Redis server. Redis Server has only one channel for communication.
  • #8 - Websocket Server as soon as it is turned on subscribes to the Redis Server's channel.
  • #9 - Redis Server sends all data from API Server to Websocket Server, where the Websocket Server sends this data to the Frontend, in order to show information to the user.

ws_conversation_schema