Chat backend via node.js: How to create 2 entities - users and messages?

I have this task I can’t understand how to handle it step-by-step. You may know the situation I have now: you listened to a theory lecture, but when it comes to practise, you don’t know how to handle it until a tutor shows you the process of it. I didn’t get an example of how to perform it, so I have to ask here.

The task details are:###

  • Each entity implements the CRUD (create, read, update, delete) through REST (post, get, put, delete).
  • The user entity contains the basic fields (name, etc.)
  • Messages entity contains senderId and receiverId (id users), as well as the body of the message.
  • Create a router that returns all users that the user with this id has talked to.
  • The data can be stored in memory (as in the example) or in MongoDB.
  • Split the responsibility of backend modules similar to example given- routes, services, an optional repositories.
  • Describe all the routes in the repository.