Architecture for Quiz App

Options

What do people recommend for structuring the backend for a quiz app that:

  1. Users sign up
  2. Users join groups
  3. Each day a prompt is posted to the group
  4. A group member can only see the response of other members once they themselves have submitted a response

Currently I have these tables:

  • Group
  • User (with table reference to group)
  • Prompt (text questions)
  • Response (text response with table references to user and prompt)

Am thinking a reverse add-on might work whereby GET /groups endpoint would:

  • Return groups in which authenticated user is a member
  • For each group:
    • Return responses (ideally grouped by prompt) where authenticated user is among the users who provided a response

Answers

  • Chris Coleman
    Chris Coleman Administrator

    ADMIN

    Options

    Hi, Shaun. It sounds like you're on the right track. It sounds like you would need the Prompt or the Group table to have a reference to the other to make sure that questions belong to certain groups.

  • shaunmwa
    shaunmwa Member
    Options

    Ah okay. I may have been thinking about this wrong. I might need an additional table to house raw questions (e.g., question text, question category, question likes/feedback).

    For the MVP of this, every group is going to get the same question each day. So it sounds like I should have some process that runs each day that pulls a question from the questions table and, for each active group, creates an entry in prompts that links to both the question being asked as well as the group (and then any responses from those group members that are created). In other word, the prompt table represents "questions asked to a group" vs. just a list of raw questions (which is how I was thinking of it before).

    This setup then would allow for more complex logic in the future. For example: when choosing a question to convert into a prompt for a particular group, scan list of existing prompts asked to that group and the underlying question_ids and ensure not selecting a question that has already been asked. Or, only use questions of a certain category when creating prompts for a particular group. etc. etc

    Does this sound like it makes sense?

  • Chris Coleman
    Chris Coleman Administrator

    ADMIN

    Options

    Yes, great idea! I hadn't considered preparing for questions that have already been asked.

  • shaunmwa
    shaunmwa Member
    Options

    Ah okay. I may have been thinking about this wrong. I might need an additional table to house raw questions (e.g., question text, question category, question likes/feedback).

    For the MVP of this, every group is going to get the same question each day. So it sounds like I should have some process that runs each day that pulls a question from the questions table and, for each active group, creates an entry in prompts that links to both the question being asked as well as the group (and then any responses from those group members that are created). In other word, the prompt table represents "questions asked to a group" vs. just a list of raw questions (which is how I was thinking of it before).

    This setup then would allow for more complex logic in the future. For example: when choosing a question to convert into a prompt for a particular group, scan list of existing prompts asked to that group and the underlying question_ids and ensure not selecting a question that has already been asked. Or, only use questions of a certain category when creating prompts for a particular group. etc. etc

    Does this sound good?