/takehome-project

Take home assignment

Primary LanguageTypeScript

Engineering Take Home Assignment

Table of Contents

Introduction

This project is a backend service designed to understand how you reason around building an API. This service is built using TypeScript and Node.js, and it includes a mock service to simulate an external API.

Tip

This assignment should take you no more than one or two hours. (We don't want to take up too much of your time!) If you find yourself spending more time than that, feel free to stub out parts you don't have time to complete, and we can discuss them during the interview.

The goal of this project is to help provide context around a problem space of load balancing requests for an API that you are designing. We'll take the solution that you provide and discuss it during our interview.

A few things to keep in mind:

  • This project should run standalone, so you don't need to worry about persistence. Please do not add dependencies that require additional configuration!
  • We're looking for a solution that is simple, clean, and well-structured.
  • We're not looking for a production-ready solution, we're looking for a solution that is well thought out and easy to understand.
  • We'll take the solution that you provide and use that as the foundation for our interview.

Thank you for taking the time to complete this assignment. We're excited to see what you come up with!

Starting & Your Project

Please clone this repository to get started.

When your project is ready for review, please export your project into a zip file (excluding the node_modules folder). Use Google Drive, Dropbox, OneDrive, or similar file upload service to host your project, then share a link so we can download this file.

Your Tasks

1. Implement User Routes & Creation

2. Add Authentication to the Process Endpoint

The Submit endpoint is not protected by authentication. Please add authentication using your choice of method.

  • Add authentication to the POST /api/submit endpoint. You can use the accessToken field from the User model.

3. Add Rate Limiting

We want to limit the number of requests a user can create to our API in a single day and in bursts. Please implement the following rate limits on a per-account basis:

Stretch Goals

4. Log Usage (Stretch Goal)

We want to keep track of how many quota points a user has used, and when they have used them. Please create a solution around the following:

Setup Instructions

  1. Install Dependencies

    pnpm i
  2. Run the Development Server

    pnpmi dev

    This will start the main service on port 8080 and the mock service on port 8888.

API Endpoints

User Endpoints

Get Users

  • URL: /api/users
  • Method: GET
  • Description: Returns a list of users.

Create User

  • URL: /api/users
  • Method: POST
  • Description: Creates a new user.

Recipient Endpoints

Get Recipients

  • URL: /api/recipients
  • Method: GET
  • Description: Returns a list of recipients.

Process Endpoint

Submit

  • URL: /api/submit
  • Method: POST
  • Description: Submits a request to process a user.

Appendix / Additional Information

Mock Service

The mock service is designed to simulate an external API. It includes the following endpoints:

Get Users

  • URL: /users
  • Method: GET
  • Description: Returns a list of users.

Process User

  • URL: /process
  • Method: POST
  • Description: Processes a user and returns a success message with the user id and processed value.

For more details, refer to the Mock Service README.

Configuration

The project uses nodemon for development. The configuration can be found in nodemon.json.

Initial Configuration

The initial configuration logic is implemented in the initialConfiguration function in src/utils.ts. This function initializes the recipients and users data.

Types

The project uses TypeScript interfaces to define the data structures. The interfaces can be found in src/types.ts.

Mock Data

Mock data generation is implemented in src/mocks/mocker.ts. This file includes functions to create fake recipients and users.

Dependencies

The project dependencies are listed in package.json. Key dependencies include:

  • express
  • @faker-js/faker
  • express-rate-limit
  • ts-node
  • typescript