External voting service aka like-dislike feature

    Good afternoon, Habrasociety!

    In the process of implementing one of my projects (with blackjack and all other social charms), I had to implement the voting functionality (like, like / dislike, rating, etc) of users for some entities of the project domain.

    Disclaimer: to my great regret, there will be only discussions about the functions of some abstract external voting service and not a line of code or useful links, but I need to get feedback from knowledgeable people.

    After searching Google for ready-made solutions, we could not find anything suitable. Basically, solutions (plugins for various web frameworks) come down to adding additional fields to existing tables (or collection objects in the case of MongoDB), which write the number of likes / dislikes, and also which of the users have already voted. Such solutions have significant drawbacks, since on the one hand they do not have sufficient flexibility to easily modify voting algorithms (which is very important for a new project in the search for the right model), and on the other hand they require modification of the existing code and, even worse, the level data storage to add voting functionality.

    At the same time, there are a significant number of services that provide the ability to add comments to your site, such as cackle.me , disqus.com , etc. Services are external to the project being developed and allow you to add the ability to comment on anything on your site with minimal effort. website (or in the application).

    A logical question arose, why there are no similar services for adding votes to your site?

    Functions required by the voting service

    • external API
    • data storage on the side of an external service
    • Possibility of delayed data upload by voice
    • solving classic like / dislike use cases on the side of an external service
      • user vote (like) for some object
      • all votes (likes) for a given object
      • all user votes (when, for what objects, how)
      • when building a list of objects, get information for which of the objects the current user voted and with what result
      • when building a list of objects, get information about the number of likes / dislikes or the number of stars rated at 1,2,3,4,5 for each of the objects


    Thus, the main logic of the processing of likes or rating takes on an external service. For example, he should check whether the user’s like for a given object is repeated and not allow such a vote. At the same time, the business logic of who can vote for what can already be implemented on the side of their own project.

    Of the additional features I would like to see:
    • The ability to separately vote for certain aspects of the objects (tags).
    • Versioning of voting (convenient for split testing, for one group of users we allow likes and dislikes, and for another only likes and we monitor the behavior of users on the service).
    • Adding events to the queue of messages about new likes that you can subscribe to and delay them (for recounts of ratings in the background, for example).

    Website integration with the service

    I think there should be 2 ways - from the backend and from the frontend (web client or mobile client). Since it is possible not to store information about votes on your side at all, you can make requests for creating likes or getting the number of likes for objects directly from the client (identifying yourself with some token). Thus, the page will be collected from several sources. You can also collect information about votes on the backend and inject it into the resulting data before sending them to the client, making requests to the external API. Perhaps even asynchronous, so that while waiting for a response, other data processing could be performed.

    There should be plug-ins for popular languages ​​(Ruby, PHP, JS) allowing, due to mixins or just adding new modules to the project, it is easy to add the ability to like / dislike or evaluate objects of the subject area.

    Benefits

    • No extra voice information in existing data structures at the storage level.
    • Minimum code to add a voting option to your website or mobile application.
    • The ability to integrate exclusively with client tools.
    • Relieves part of the load from the backend servers.
    • Several voting models at the same time (convenient mechanism for split tests).


    Instead of a conclusion

    This is how something like my dream voting service should look like. I would like to receive answers, can someone advise something similar? Or did you need such a service, would it be useful to you?

    Also popular now: