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:
- 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.
- 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.
- 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.
- 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).
- 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.
The provided sample data contains a collection of various objects. Each type of object has its own validation rules as defined below:
id
- Format:
a-zA-Z0-9
- Length:
256
- Required
- Format:
type
- Value:
user
- Required
- Value:
userName
- Format:
a-zA-Z0-9_.
- Max length:
20
- Required
- Format:
firstName
- Max length:
100
- Max length:
lastName
- Max length:
100
- Max length:
email
- According to RFC
id
- Format:
a-zA-Z0-9
- Length:
256
- Required
- Format:
type
- Value:
payment
- Required
- Value:
fromUserId
- Format:
a-zA-Z0-9
- Length:
256
- Required
- Format:
toMerchantId
ortoUserId
- Format:
a-zA-Z0-9
- Length:
256
- Required
- Format:
amount
- Format: float number
Not equal or less than
0
- Required
- Format: float number
Not equal or less than
createdAt
- Format: Date ISO 8601
- Required
id
- Format:
a-zA-Z0-9
- Length:
256
- Required
- Format:
type
- Value:
merchant
- Required
- Value:
name
- Format:
a-zA-Z0-9
- Max length:
20
- Required
- Format:
Follow the challenge mission according to the provided requirements and do your best. Good luck!
MIT © 2021 Dash Core Team