Moving to Voting Backend App... Where to start?

So I’ve posted a few times in the gitter backend help and folks there are very supportive and helpful, but I feel like I need something I can have easier access to reference and get some ideas/ tips from folks.

I have done all the microservice APIs in node, and those went pretty well. I’m happy with what I’ve learned.

Now working on the voting app. I took my microAPI skeleton app, did a tutorial on authenticaiton and now have this really basic app where I can login using local/google/facebook, etc and look at my profile page.

So that’s kind of cool but it doesn’t “do” anything.

I found another tutorial on mongoose and started creating a poll model with title, options, owner, created date etc. But now I have no idea what to DO with thsi mdoel.

Where do I put code that “runs”? Do I need a front end connected before I can test hte backend? (I know the answer is “no”) but I think my brain must be friend since I’m having a really hard time figuring out how to do this in a simple, sequential, testable way.

I figured making a poll should be easy enough, but where do I run code that makes a pool? How do I do that without a front end in place? Do I need to create dummy objects so that I don’t have to add stuff with a front end first?

Or should I make a front end and add objects to the database first so that there are then polls/ users to access in the api?

How did others approach this problem?

Moved to help/questions

1 Like

Break it up into small problems.

From a backend perspective, think about what needs to happen to meet the user stories. The actual code isn’t that hard - it’s mostly putting things in and reading from your database. You’ve already done that with the URL shortener :slight_smile:

I started off by writing a markdown file that specified all my routes, the purpose of them and how they linked up.

From there I tried to think how to best make each route do its thing. For example, I knew there would have to be a /vote route in order for users to vote. So the questions I asked myself were things like:

  • How will I record the votes?
  • What will that need to look like in the DB?
  • Will I need to track who voted for what?

There’s several ways to implement the vote tracking aspect of it - just pick something that makes sense to you: do you have a counter for each poll option and increment it? Do you throw a bunch of usernames into an array and just count them?

I tended to build the API and frontend together for this one. I didn’t use anything fancy, just EJS - so I just made simple forms for testing my POST requests and then styled them better when they were working.

One thing that did help, early on: I put one dummy poll in my DB manually first so I could make the home page showing polls, and pull some data in for the chart.

1 Like

Thanks guys, both of those responses make sense. P1xt, I have registered for that course and will get started on it this weekend!