Spotify Backend Developer Intern Challenge 2022 (Go, Gin, SQLite3)

Shopify Backend Developer Intern Challenge - Summer 2022

This is an API for managing inventory items. The API is written in Go and uses Gin and sqlite3.

Building From Source

In order to build from source, you need to have a modern Go toolchain (1.15+), a modern C/C++ toolchain (to build go-sqlite3), and sqlite3 installed.

You can download sqlite3 here. Make sure that after installing, sqlite3 is present in PATH.

After cloning the repository and installing all required tools, in order to build the server, inside of the repository directory, run go mod tidy && go build.

Running The Server

After building, on Linux and macOS, run ./SBC-2022 to launch the server. On Windows, run SBC-2022.exe.

The server (by default) runs on port 8080. To change the port, set the PORT environmental variable to the appropriate port.

API Features

  • CRUD operations for items and groups (a group can contain multiple items and not every item has to be in a group)
  • Input validation (server responds with appropriate error message and code for bad input)
  • Supports both JSON and XML for request bodies (but responds in JSON)

API Routes

  • GET /api/items
    • Responds with a list of items. Each item has an id, name, count, and (optional) group.
    • $ curl -X GET http://localhost:8080/api/items
      [{"id":1,"name":"apples","count":100,"group":{"id":1,"name":"fruits"}},{"id":2,"name":"bananas","count":150,"group":{"id":1,"name":"fruits"}},{"id":3,"name":"carrots","count":120}]
      
  • GET /api/items/:id
    • Responds with an item with the given id. An error message/code (404) is returned if no item exists with the given id.
    • $ curl -X GET http://localhost:8080/api/items/1
      {"id":1,"name":"apples","count":100,"group":{"id":1,"name":"fruits"}}
      
  • GET /api/groups
    • Responds with a list of groups. Each group has an id, name, and an (optional) list of items. Items that do not have a group are put in a pseudo-group (id: 0, name: "").
    • $ curl -X GET http://localhost:8080/api/groups
      [{"id":0,"name":"","items":[{"id":3,"name":"carrots","count":120}]},{"id":1,"name":"fruits","items":[{"id":1,"name":"apples","count":100},{"id":2,"name":"bananas","count":150}]}]
      
  • GET /api/groups/:id
    • Responds with a group with the given id. An error message/code (404) is returned if no group exists with the given id.
    • $ curl -X GET http://localhost:8080/api/groups/1
      {"id":1,"name":"fruits","items":[{"id":1,"name":"apples","count":100},{"id":2,"name":"bananas","count":150}]}
      
  • POST /api/items
    • Creates a new item and responds with the new item. The item name and count are required (the groupId is optional). The item name must be a non-empty string, and the item count must be a positive integer (greater than zero). Responds with an error message/code (404) if no group exists with the given groupId.
    • $ curl -X POST http://localhost:8080/api/items -H 'content-type: application/json' -d '{"name":"oranges","count":50,"groupId":1}'
      {"id":4,"name":"oranges","count":50,"group":{"id":1,"name":"fruits"}}
      
  • POST /api/groups
    • Creates a new group and responds with the new group. The group name is required and must be a non-empty string.
    • curl -X POST http://localhost:8080/api/groups -H 'content-type: application/json' -d '{"name":"vegetables"}'
      {"id":2,"name":"vegetables"}
      
  • PUT /api/items/:id
    • Updates an existing item and responds with the updated item. All unchanged and changed fields of the existing item are required. If the existing item was in a group and the groupId is omitted, the item is removed from the group it was originally in. Responds with an error message/code (404) if no item exists with the given id or no group exists with the given groupId.
    • $ curl -X PUT http://localhost:8080/api/items/1 -H 'content-type: application/json' -d '{"name":"pears","count":50}'
      {"id":1,"name":"pears","count":50}
      
  • PUT /api/groups/:id
    • Updates an existing group and responds with the updated group. The name of the group is required and must be a non-empty string. Responds with an error message/code (404) if no group exists with the given id.
    • $ curl -X PUT http://localhost:8080/api/groups/1 -H 'content-type: application/json' -d '{"name":"Fresh Fruits"}'
      {"id":1,"name":"Fresh Fruits","items":[{"id":1,"name":"apples","count":100},{"id":2,"name":"bananas","count":150}]}
      
  • DELETE /api/items/:id
    • Deletes an item with the given id and responds with an OK status code (200). Responds with an error message/code (404) if no item exists with the given id.
    • $ curl -X DELETE http://localhost:8080/api/items/1
      
  • DELETE /api/groups/:id
    • Deletes a group with the given id and responds with an OK status code (200). If the group contains any items, those items are also deleted. Responds with an error message/code (404) if no group exists with the given id.
    • $ curl -X DELETE http://localhost:8080/api/groups/1
      
Similar Resources

Zadig is a cloud native, distributed, developer-oriented continuous delivery product.

Zadig Developer-oriented Continuous Delivery Product ⁣ English | 简体中文 Table of Contents Zadig Table of Contents What is Zadig Quick start How to use?

May 12, 2021

go-awssh is a developer tool to make your SSH to AWS EC2 instances easy.

Describing Instances/VPCs data, select one or multiple instances, and make connection(s) to selected instances. Caching the response of API calls for 1day using Tmpfs.

Oct 11, 2021

Developer Self-Service Across Clusters

Monoskope (m8) Monoskope (short m8 spelled "mate") implements the management and operation of tenants, users and their roles in a Kubernetes multi-clu

Jul 6, 2022

Help developer to sync between local file and remote apollo portal web since portal web is so messy to use

apollo-synchronizer Help developer to sync between local file and remote apollo portal web since portal web is so messy to use Features download names

Oct 27, 2022

Koyeb is a developer-friendly serverless platform to deploy apps globally.

Koyeb is a developer-friendly serverless platform to deploy apps globally.

Koyeb Serverless Platform Deploy a Go Gin application on Koyeb Learn more about Koyeb · Explore the documentation · Discover our tutorials About Koyeb

Nov 14, 2022

⚔ Personal Golang starter kit with an engineer research perspective, expressjs developer friendly, and aims for rapid app development.

⚔ Personal Golang starter kit with an engineer research perspective, expressjs developer friendly, and aims for rapid app development.

Goku (WIP; Author Only) ⚔ Personal Golang starter kit with an engineer research perspective, expressjs developer friendly, and aims for rapid app deve

Jan 6, 2022

This is a sample application of golang's web framework gin and orm ent.

Gin Ent Sample This is a sample application of golang's web framework gin and orm ent. Components Web Framework: Gin ORM: ent SQL Migration tool: goos

Dec 5, 2021

How to get a Go / Golang app using the Gin web framework running natively on Windows Azure App Service WITHOUT using a Docker container

Go on Azure App Service View the running app - https://go-azure-appservice.azurewebsites.net 😎 This is an example repo of how to get a Go / Golang a

Nov 28, 2022

Grafana Tempo is a high volume, minimal dependency distributed tracing backend.

Grafana Tempo is a high volume, minimal dependency distributed tracing backend.

Grafana Tempo is an open source, easy-to-use and high-scale distributed tracing backend. Tempo is cost-efficient, requiring only object storage to ope

Jan 8, 2023
DevOps Roadmap 2022

Want to learn DevOps the right way in 2022 ? You have come to the right place I have created the complete DevOps roadmap that anyone can follow and be

Dec 28, 2022
Course system - The project of Group 28 for ByteCamp 2022 Winter

Course System This is the project of Group 28 for ByteCamp 2022 Winter. Quick St

Jul 20, 2022
Simple webhook to block exploitation of CVE-2022-0811

webhook-cve-2022-0811 This is a really simple webhook that just blocks pod creation if malicious sysctl values are configured. Build go test CGO_ENABL

Nov 9, 2022
Taina backend Backend service With Golang

taina-backend Backend service Getting Started Essential steps to get your backend service deployed A helloworld example has been shipped with the temp

Nov 17, 2021
Acropolis Backend is the Go backend for Acropolis - the central management system for Full Stack at Brown
Acropolis Backend is the Go backend for Acropolis - the central management system for Full Stack at Brown

Acropolis Backend Acropolis Backend is the Go backend for Acropolis — the centra

Dec 25, 2021
Go-backend-test - Creating backend stuff & openid connect authentication stuff in golang

Go Backend Coding Practice This is my practice repo to learn about creating back

Feb 5, 2022
Oct 7, 2022
Digitalocean-kubernetes-challenge - Deploy a GitOps CI/CD implementation
Digitalocean-kubernetes-challenge - Deploy a GitOps CI/CD implementation

DigitalOcean Kubernetes Challenge 2021 I chose to participate in the DigitalOcean Kubernetes Challenge in order to learn more about Kubernetes and to

Nov 9, 2022
Test - A program that validates your progress on the SQLite challenge

SQLite Challenge Tester This is a program that validates your progress on the SQ

Jan 6, 2022
Zadig is a cloud native, distributed, developer-oriented continuous delivery product.

Zadig Developer-oriented Continuous Delivery Product English | 简体中文 Table of Contents Zadig Table of Contents What is Zadig Quick start How to use? Ho

Jan 8, 2023