# Step 3. Upvoting Features

## Step 3.1: User Management

{% embed url="<https://youtu.be/KelGl58bUjg>" %}
3:44
{% endembed %}

To set up user management, follow these steps:

1. Create an API endpoint on the "App users" (WebUser) data structure with a condition like "role like admin" on the user's session
2. Create a new web page with a security condition where "role == admin"
3. Add a Table component to that page.

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-MaysWNLZOun2qB4nrKh%2F-MazNGrkklHavbbxny6l%2Fusers.jpg?alt=media\&token=bed41cbf-c4e4-4398-9bca-33c813776523)

## Step 3.2: Configure Upvoting

{% embed url="<https://youtu.be/fBpqzR_IqVI>" %}
15:08
{% endembed %}

Let's add two new fields to `Features` data structure:

1. **Upvotes ("**&#x4E;umber")
2. **Users Upvoted IDs ("**&#x41;rrayLink → WebUser").

Next, create a new page for upvoting, which should be accessible to all authorized users:

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-Mb2B-5r7aRY0ltUDfrA%2F-Mb2C60Wpny5VbEwoTo3%2Fupvotes.jpg?alt=media\&token=c7ca5f77-1efd-4cad-84aa-e741dce988af)

Note that we've added the "Upvotes" field as a counter on the cards.

Now, we configure actions:

* Add a new data structure `upvotes` with the following fields:
  * `user_id`, type of `link→WebUser`
  * `feature_id`, type of `link→Features`
* Create an API endpoint for adding objects to `upvotes`
* Design a scenario for counting votes (avoiding duplication).

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-Mb2B-5r7aRY0ltUDfrA%2F-Mb2E7L_RAGwqjw-dXQQ%2Fscen1.jpg?alt=media\&token=0f282c6b-bd32-4289-86ca-40dfb4345015)

![Add an element to users\_upvoted\_ids ](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-Mb2B-5r7aRY0ltUDfrA%2F-Mb2ECY_akqbI4kbgUic%2Fscen2.jpg?alt=media\&token=53fee8ee-8cb7-4bb3-94e0-6e8899aebadf)

![Counting the length of users\_upvoted\_ids](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-Mb2B-5r7aRY0ltUDfrA%2F-Mb2EOIZLafQucIs3wrq%2Fscen3.jpg?alt=media\&token=3ece4e85-1553-41b2-8839-81835bc048c0)

Finally, we are sorting the cards by `upvotes`.
