Skip to content

EugeneTseitlin/dash-go-code-challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Collaborative Etiquette follow on Twitter travis-ci MIT

 

 

Go Engineer Code Challenge

Code challenge for Dash Core Team candidates

The goal of this challenge is to create a backend application which receives, validates and displays data from users.

This repository is designed as a mono-repository for your application and external services. We've prepared an application skeleton for you and assume that your solution will be a light client. In the provided skeleton, please implement application logic which validates and persists sample user data in external service(s), to which your application should connect. Your application should also be able to retrieve this data back and verify its integrity.

Your solution must implement at least one of the following types of external services:

  1. Peer-to-peer service: This service runs on remote untrusted hosts. Networking and storage will be cheap for you - 0.0001 DASH per byte - but you can’t trust this service because a malicious operator may spoof (modify) your data, or a man-in-the-middle attack may occur. Code for this service should be placed here and the entrypoint of the service is here.
  2. Self-hosted service: This service runs on your server. Networking and storage will be much more expensive for you - 0.001 DASH per byte - but the data is located on your server, so you can trust it. Code for this service should be placed here and the entrypoint of the service is here.

For communication with your external service(s) we provide two HTTP Client instances. They use middleware to calculate inbound and outbound traffic.

Your mission

  • Use this repository as a template for the solution.
  • Write a brief spec for your solution.
  • Implement as many external services as you need to store sample data from the application.
  • Implement the store method. Validate and persist sample data in the external service(s).
  • Implement the fetch method. Fetch sample data back and ensure its integrity. When you fetch data back from the untrusted service, you should verify it for spoofing protection.
  • Write beautiful code. Code design (SOLID, Clean Architecture, 12factor) is important to us.
  • Run the application and review the results. Try to spend as little money as possible. Cost depends on the size of the request / response and elapsed time. The exact formula is found in the application skeleton code.
  • Share a link to your private solution repository with us or send us an archive containing your solution.

Requirements

External services

  • Services should be written in Go.
  • Services should be dockerized and started with docker compose in the root directory.
  • Data should be permanently persisted (i.e. available after a service restart).

Application

  • You should validate sample data in the store method. Return an error if any data is invalid.
  • You should check data integrity in the fetch method to avoid spoofing. Keep in mind that the fetch method will not have access to the original input data provided to the store method.
  • Make sure the data returned by the fetch method matches the input data from the store action.
  • You should use p2pClient for sending / retrieving data from a P2P service.
  • You should use selfHostedClient for sending / retrieving data from a hosted service.
  • You cannot store any data on the application side.

Sample data validation rules

The provided sample data contains a collection of various objects. Each type of object has its own validation rules as defined below:

User

  • id
    • Format: a-zA-Z0-9
    • Length: 256
    • Required
  • type
    • Value: user
    • Required
  • userName
    • Format: a-zA-Z0-9_.
    • Max length: 20
    • Required
  • firstName
    • Max length: 100
  • lastName
    • Max length: 100
  • email
    • According to RFC

Payment

  • id
    • Format: a-zA-Z0-9
    • Length: 256
    • Required
  • type
    • Value: payment
    • Required
  • fromUserId
    • Format: a-zA-Z0-9
    • Length: 256
    • Required
  • toMerchantId or toUserId
    • Format: a-zA-Z0-9
    • Length: 256
    • Required
  • amount
    • Format: float number Not equal or less than 0
    • Required
  • createdAt
    • Format: Date ISO 8601
    • Required

Merchant

  • id
    • Format: a-zA-Z0-9
    • Length: 256
    • Required
  • type
    • Value: merchant
    • Required
  • name
    • Format: a-zA-Z0-9
    • Max length: 20
    • Required

Summary

Follow the challenge mission according to the provided requirements and do your best. Good luck!

License

MIT © 2021 Dash Core Team

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published