Skip to content

Instantly share code, notes, and snippets.

@Advait-M
Last active March 8, 2021 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Advait-M/27f0f1582db447e24975597addf5c74e to your computer and use it in GitHub Desktop.
Save Advait-M/27f0f1582db447e24975597addf5c74e to your computer and use it in GitHub Desktop.
Hack the North 2021 Backend Challenge

Hack the North 2021 Backend Challenge

Introduction

On the Hack the North Backend Team, you will be responsible for helping us build important applications and internal tools. In past years, this has included the Discord bot, QR code scanning system, the registration system, the push notification system for our mobile apps, and internal analytics/payment tools. Being a part of the team means that you will be writing code, designing interfaces, and playing a role in making decisions for the many projects we take on.

This small challenge will help us determine how you work, including your ability to be resourceful, and how you think about your work.

Please email advait@hackthenorth.com if you have any questions.

Alternate Project Submission

If you believe you have an existing project that demonstrates the same skills and competencies as this challenge, you may submit that instead of completing this backend challenge. If you choose to do so, we will use your project to check for the same skills and competencies that we expect most applicants to demonstrate when completing the backend challenge. However, we understand that an existing project will not be exactly the same as this backend challenge so the rough criteria that we would use to evaluate an existing project is as follows:

  • Demonstrates the ability to utilize SQL queries that are more complex than simple SELECTs (either raw SQL queries or through an ORM)
  • Understanding of different SQL table relationships
  • Overall design and implementation, specifically with respect to code quality and architecture
  • Knowledgeable with various API design principles (GraphQL or REST principles)

Note that the project you submit should be done entirely by yourself!

Challenge

You've just created a new hackathon series and it's wildly successful! However, the number of applications is quickly becoming too much for your Excel spreadsheet. The goal is to develop a basic GraphQL or REST API server to store and work with your hackathon participants' data. Please remember to document your API within your repository's README!

Data

We have 1,000+ fake user profiles at https://gist.github.com/Advait-M/e45603da554150067b5c4551a2bf4419. The JSON schema is:

{
  "name": <string>,
  "picture": <string>,
  "company": <string>,
  "email": <string>,
  "phone": <string>,
  "skills": [
    {
      "name": <string>,
      "rating": <int>
    }
  ]
}

Database

You can either download the user data from the link above and use the local JSON file, or make an HTTP request when running the program that inserts the data to a database.

For simplicity, we recommend using SQLite for the database as it is the easiest to setup and likely already exists on your computer. However, if you are more familiar with other databases, e.g. PostgreSQL, feel free to use them!

We are particularly interested in seeing how you define your database table(s) and partition the data appropriately.

Frameworks and Languages

You may use any language with any framework of your choice for creating a backend server capable for handling requests e.g. Python/Flask, Node/Express, etc. We have provided boilerplate code for Express with Node.js for GraphQL or REST APIs (see Docker files below).

Please note that using a particular language/framework will not penalize you in any way - feel free to use whichever technologies you are most comfortable with or want to learn more about! Similarly, we will not penalize you for choosing to use GraphQL or REST API principles - both are completely acceptable!

Your backend server should serve as a quick interface to the database. The key requirement is to allow us to see the user data in a JSON format, through a GraphQL or REST API.

Potential Boilerplate

Below, we have provided Dockerfiles and associated project files for different options. Please note, you do not have to use any of these files - feel free to use your own setup! Additionally, please do not consider these to be exemplary methods of structuring your project - they are simply provided to help you get up and running as quickly as possible. You may modify project structure in any way you wish, including adding any libraries/frameworks.

  1. Express app (Node.js) for GraphQL (SQLite as a database)
  2. Express app (Node.js) for REST (SQLite as a database)
  3. Flask app (Python) for GraphQL (Flask-GraphQL with Graphene, SQLite as a database)
  4. Flask app (Python) for REST (SQLite as a database)

API

At the minimum, this is what it should have:

All Users Endpoint

This endpoint should return a list of all user data from the database in a JSON format.

Example GraphQL (feel free to change format):

query {
  users {
    name
    email
    skills {
      name
      rating
    }
    ...
  }
}

Example REST:

GET localhost:5000/users/ or similar

User Information Endpoint

This endpoint should return the user data for a specific user. Depending on your database schema, it is up to you to decide what identifies a single user and design an endpoint that will give the full details about that user.

Example GraphQL (feel free to change format):

query {
  user(INSERT_IDENTIFIER: FOO) {
    name
    email
    skills {
      name
      rating
    }
    ...
  }
}

Example REST:

GET localhost:5000/users/123 or similar

Updating User Data Endpoint

This endpoint should allow you to update a given user's data by accepting data in a JSON format and return the updated user data as the response. The important design consideration for this endpoint is that it must support partial updating. This will either be a new mutation (GraphQL) or a PUT only method to the same URL as the user information endpoint above (REST).

Example GraphQL (feel free to change format):

query {
  updateUser(INSERT_IDENTIFIER: FOO, data: {phone: "+1 (555) 123 4567"}) {
    name
    phone
    ...
  }
}

Example REST:

Submitting the following JSON:

  {
    "phone": "+1 (555) 123 4567"
  }

to the given URL: PUT localhost:5000/users/123 or similar

should update their phone number to +1 (555) 123 4567 and return the full user data with the new phone number.

Note: If a user has new skills, these skills should be added to the database. Any existing skills should have their ratings updated.

Skills Endpoints

These endpoint should show a list of skills and aggregate info about them. Note that in the context of your hackathon, users do not gain/lose skills very often.

Try to implement the following (in SQL or with an ORM):

  • Number of users with each skill (frequency)
  • Query parameter filtering - minimum/maximum frequency

Example GraphQL (feel free to change format):

query {
  skills(data: {min_frequency: 5, max_frequency: 10}) {
    name
    frequency
  }
}

Example REST:

GET localhost:5000/skills/?min_frequency=5&max_frequency=10 or similar

Notes

  • You may have two separate applications if you'd like.
    • You can include a script to create the appropriate database tables and insert the default data.
    • The second application can assume that the database already exists and launch the app to start listening for requests.
  • You are free to use any existing library or dependency for the language of your choice (don't forget to document).
  • You can reference any online resources or documentation, however, please do not plagiarize.

If you've implemented the basic requirements quickly, feel free to make improvements as you see fit, especially if the improvements you implement are part of a larger vision for your application as a product for hackathon attendees. You may also outline any improvements you'd make in your README.

Please submit your entry by emailing it as a link to a GitHub repository (make sure it is accessible to us). Remember to provide documentation in the README! If you are not able to complete all components of the challenge - don't worry & please submit your challenge anyhow, we'd love to take a look! Good luck! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment