Create real time polls in few steps supported for pc, mobile and another devices with internet connection
Before installing, download and install Node.js and create a cluster in MongoDB Atlas.
This project required use and install the files in backend and frontend branch:
- Clone the repository twice using
git clone https://github.com/Hector-f-Romero/ExPoll.gitfrom any terminal. - Go into one of us with
cd Expoll. - Remove current origin repository with
git remote remove origin. - Change to branch
backendand set the enviroment variables considering the file.example.env. - Run
npm install. - In the another clone, repeat the step 3 and change to branch
frontend - Set the enviroment variables considering the file
.example.env. - Run
npm install. - Test the application and enjoy.
This project was built using these technologies:
- Vite
- React
- Tailwind CSS
- NodeJS
- TypeScript
- Express
- MongoDB
- Socket.IO
Initially, I had thought to use in real time poll timer web sockets and use setInterval in the client side. However, this can lead in synchronization and security failures. Subsequently, I read about Server Side Events (SSE) and I implemented them for allowing communication in one way from the server to the client, avoiding giving this responsibility to the client.
Being my first time using these types of resources, I discovered that there are several libraries that offer to create these graphics with high customization and ease of use. Chart.js was implemented due to its extensive documentation and integration with React via react-chartjs-2.
My approach to working on backend always creates a challenge to create user interfaces that suit most devices that users can employ. Using Tailwind CSS and its syntax, it was possible to achieve a decent result on both mobile devices and computers using ResponsivelyApp as a guide
To add a security layer to the REST API, the use of JWT was implemented to verify that the user has authenticated through a token that is sent in the HTTP request of many endpoints, in addition to having a validation that will take the role of the user and verify that the path is accessible to him or not as specified roles allowed.
However, keeping authentication and authorization information on the client side was a difficult challenge when thinking about different techniques such as cookies, sessions and storage in localStorage. To avoid further delay in this decision, it was decided to save the authentication token in localStorage despite not recommending this in many internet forums and manage user information in a React context, as implementing Redux in this case was convenient because of the simple application.
For this first documented project, I have been looking many repositories to question what sections are important to put in this file and which not.
Creating.a.poll.mp4
Live.voting.mp4
To see more videos about the functioning of ExPoll, check this drive folder.
To expand knowledges about the process of planning and requirements of the application, check the next links: