Requirements of the LeetCode API

Understand the functional and non-functional requirements for the LeetCode API service.

Introduction to LeetCode API

LeetCode is a service that enables software developers to improve their programming abilities and put them to the test. While practicing programming, we need to evaluate our solutions. In this chapter, we aim to design an API for LeetCode that will allow users to attempt to solve many problems and verify their solutions’ correctness. If they’re unable to solve a problem, the API can provide them multiple solutions. Our API will include functionality to conduct programming contests where programmers participate to showcase and highlight their skills.

Finally, we will incorporate a discussion feature as part of the API that enables users to talk about general issues and interview experiences as well as propose solutions to programming problems. The API also provides a feature for users to conduct interviews to hire potential talent.

Requirements

LeetCode API offers various services to the users, and as a result, the functional requirements increase. To keep the scope of this design problem tractable, we will limit our functional and non-functional requirements to the following.

Functional requirements

  • List questions: The API should allow users to list practice problems by selecting a difficulty level or searching for a topic.

  • Register contest: The users should be able to register for contests they want to participate in.

  • Submit code: The users practicing or participating in contests should be able to submit one or multiple solutions for evaluation.

  • Leaderboard: A contest's result is generated as a leaderboard. Participants must be allowed to fetch the leaderboard to analyze results.

  • History: A user should be able to track their performance metrics, submitted solutions, and results of contests.

  • Interview: Users or companies should be able to interview candidates using the LeetCode API.

Functional and non-functional requirements of LeetCode API design
Functional and non-functional requirements of LeetCode API design

Non-functional requirements

  • Availability: The LeetCode API must always be available to handle thousands of contestants' submissions.

  • Scalability: The API should be able to handle the increasing number of users and contestants.

  • Security: The LeetCode API’s security concerns are more about the data processed by the API than the communication between the client and server. So, the API must refrain from accepting data other than code to secure the system and prevent results from manipulation.

  • Low latency: The API should provide low latency to the users while providing different services.

Prerequisites

We have already discussed some functional requirements in detail in earlier design chapters. We’ll use them as building blocks for the LeetCode service as discussed below:

  • Search service: The search service will allow users to search for problems related to a specific topic or keyword.

  • Comment service: The comment service will be a building block for implementing the discussion feature.

  • Pub-sub service: The pub-sub service has multiple roles in the LeetCode. It will be used as a building block for discussion features, as well as contest services to push notifications to subscribers.

  • Zoom API: We will integrate the Zoom service into our design problem to schedule and conduct interviews.

How will we design the LeetCode API?

  1. LeetCode API Design Decisions: In this lesson, we will discuss the workflow of the LeetCode service. We will also make requirements-based technical decisions for LeetCode.

  2. LeetCode API model: We’ll model our API for LeetCode using those technical design decisions in this lesson. The main focus will be on data entities and message formats for communication.

  3. LeetCode API Design Evaluation and Latency Budget:: In this lesson, we will analyze the techniques to achieve our non-functional requirements. The service's response time will also be analyzed for efficient performance.