quick-poll
quickly take a poll
Created Mar 23, 2024 - Last updated: Mar 23, 2024
What is Quick Poll?
Quick Poll is a a website on which you can take quickly polls. You first create your poll and then are able to share a link to that poll. But it doesn’t end there, that would be boring.
Quick Poll transmits the data the users enter live. That means whenever a user ticks something, your charts immediately update.
Philosophy
Observing decision-making
“Why would that matter?”, you may ask. Sometimes it isn’t just enough to know peoples opinion on something, but also how their opinion changes after receiving other information or thinking about their decision.
For example, You could see how question 2 would affect the votes on question 1, because, at least from my experience, people can change their minds all the time based on their surroundings.
Humans ideally do not just have a black and white opinion like normal polls may suggest. We’ve all been at that point in a poll where we are switching back and forth between two options.
With Quick Poll you can see these indecisive human patterns.
Privacy
“Isn’t this a privacy violation?” is a question that also came to my mind. If I would allow the poll admin to observe every single ones poll result individually - yes, then it would be a security violation. However, you can not observe votes individually.
You only see that anonymous cluster of votes, which is also way more interesting than one single person. After all, we are taking polls with as many people as possible, because that means we will get the most accurate result.
Technical View
Generally
The client was built with vanilla html, css and javascript.
The backend is written in plain go.
Communication protocols between client and backend are HTTP and WebSocket.
WebSocket communication
This is, in my opinion, the most interesting part of the project, as it allows data to flow flawlessly between client (poll takers), server and host (poll admin).
Multiple clients and the host are connected via individual websockets to the server:
---------- websocket
| client | -------------------
---------- |
|
---------- websocket |
| client | ---------------| |
---------- ---------- websocket --------
| server | -------------- | host |
---------- websocket ---------- --------
| client | ---------------| |
---------- |
|
---------- websocket |
| client | -------------------
----------
The clients immediately send their newly updated fields to the server, and the server updates its internal state.
The state is then sent to the host, for the charts to be immediately updated.
The host can send actions (e.g. start a poll) to the server, which then broadcasts the action to the clients.
Here is a visual representation of the data flow:
---------- input ->
| client | -------------------------
---------- <- action |
|
---------- input -> |
| client | ---------------------| |
---------- <- action ---------- state -> --------
| server | -------------- | host |
---------- input -> ---------- <- action --------
| client | ---------------------| |
---------- <- action |
|
---------- input -> |
| client | -------------------------
---------- <- action
Messages in-depth
In my project, I decided to send JSON objects around.
The default layout of a message:
{
"type": <message type>,
"data": <data corresponding to type>
}
There are also special cases, for example the input of a client is designed to be efficient, as it is sent pretty often (users like to click buttons). When a client changes their input, it only sends a small array containing the answers.
For example:
[2, "Blue", "George Washington", null]
In this case, we can see that the user already filled out the first three questions. The first questions seems to be a selection, number two and three seem to be inputs. Notice the null at the end? That is a question that wasn’t filled out yet.
Purpose
Quick Poll was built as a school project, where the task was to simply build a web app.
But different to my other experiences with my software, Quick Poll was actually kind of integrated in my everday use.
Sometimes when decisions had to be made in my school class, or someone wanted to make a quiz/poll (e.g. for a presentation), Quick Poll was used without me pushing that idea, which suggests to me, that this project fulfills it’s purpose successfully. That is an experience that (many developers will agree) is not self explanatory and very rewarding.
What I learned / I want to tell you
WebSockets are a great thing, and connecting clients live gives an immediate feeling of magic.
I can only recommend you to look into building one or two projects with WebSockets, because the learning curve isn’t as high as expected, but the results are very rewarding.
You can do that in any programming language, as it is only a network protocol, and it’s implemented everywhere.
No idea what to build? Let me give you a hand, you could build a simple…
- Chat app (no fancy UI needed)
- Game (like tictactoe over the network)
- (Web-)App for polls (That was also my approach)
And much much more!
Not feeling creative? You can always ask the LLM of your trust.