You are on page 1of 3

Backend Engineering Interview

Assignment (Golang)
Dear Candidate,

We are pleased to tell you that you have been selected for our Technical Interview step. As a
backend engineer, you play a critical role in building the backbone of our application, ensuring
scalability, security, and seamless functionality. We require someone that is able to write high
quality, secure, scalable, and high performance code.

1. Requirements
We want you to design and build a HTTP service that provides 4 endpoints.

1. Registration This endpoint accepts 3 data: 1) Phone number, 2) Full Name, and 3)
Password. The data should follow this validation below:

1. Phone numbers must be at minimum 10 characters and maximum 13 characters.


2. Phone numbers must start with the Indonesia country code “+62”.
3. Full name must be at minimum 3 characters and maximum 60 characters.
4. Passwords must be minimum 6 characters and maximum 64 characters,
containing at least 1 capital characters AND 1 number AND 1 special (non
alpha-numeric) characters.
2. Otherwise, return 400 Bad Requests with the error message containing ALL fields that
failed the validation and which rule they failed at.

This endpoint should store the newly created user in the database. The password
should be hashed and salted in the database. Successful request should return the ID of
the user,

3. Login This endpoint accepts 2 fields: 1) phone number and 2) password. This endpoint
will check the database whether the combination exists. Upon success, it will return the
ID of the user and the JWT with algorithm RS256. It will also increment the number of
successful login of that user in the database. Unsuccessful login will return HTTP 400
Bad Requests code.

4. Get My Profile This endpoint will accept JWT as a bearer token in the authorization
header. Upon successful verification, this will return the name of the user and the phone
number. Otherwise return HTTP 403 Forbidden code.

5. Update My Profile Similar to the endpoint above, this endpoint will also accept JWT as
bearer token in authorization header. In addition to that this endpoint will accept 2 fields:
1) Phone Number OR 2) Full Name. If the request is authorised then the endpoint will
update the fields that exist in the requests, i.e. if full name exists then it will update the
full name. However since one phone number can only belong to one user, if a user
wants to change to an already existing phone number returns HTTP 409 Conflict. If the
request is unauthorised, then return HTTP 403 Forbidden code.

2. Submission Guideline
We already provide a template for you to start with. You can download the template in the link
below

https://storage.googleapis.com/648010c1-f244-4641-98f2-73ff6c1b4e99/InterviewBackendSawit
ProGolang-20230607.zip

You must work on these directories and files:

1. handler

This is the directory where you implement the API handlers for your service

2. repository

This is the directory where you implement the database interaction.

3. api.yml

This is the OpenAPI file where you define the API contract for your service. We already
prepare a Makefile task make generate where you can generate OpenAPI stub. We
also add a sample code for you to try.

4. database.sql

This is the SQL file where you put database schema and sample code.

You should be able to finish this assignment under 5 hours of cumulative work. Once you are
done, please submit the code to a public GitHub repository and send us the link to the
repository. If you have any technical questions, please do not hesitate to reach out to our
recruitment person in charge.

3. Technology Stacks
Our technology stacks consist of
1. Echo as HTTP framework that runs on Golang 1.19
2. PostgresSQL as our database.
3. Google Cloud as our cloud platform.
4. Docker to let us automate our development.
5. OpenAPI 3 to enable us to define consistent API contracts between front ends.

4. Runtime Specification
We will run your application against the commands below

1. make init to initialize the repository.


2. make test to run the unit test.
3. docker-compose up to start the application including the database. From which, your
application should be accessible through base URL http://localhost:8080/

Your code should be able to run in below requirements

1. Unix/Linux operating system such as Ubuntu or MacOS


2. Golang version 1.19
3. Docker version 20
4. Docker Compose version 1.29

5. Evaluation Criteria
We will evaluate your work based on the following criteria:

1. Your proficiency in our tech stacks such as Golang, Echo, Docker, OpenAPI, and
PostgreSQL.
2. Your ability to write a high quality code including readability and modular design.
3. Your ability to write high coverage code testing.
4. Your ability to model data structures and design databases.
5. Your ability to design readable and complete API contracts with appropriate HTTP API
best practices.

You might also like