...

/

LeetCode API Design Decisions

LeetCode API Design Decisions

Understand the workflow and design considerations for the LeetCode API service.

Introduction

The LeetCode service involves many components that play a vital role in providing all the functionalities to the users. We will start by analyzing the high-level structure of the LeetCode service. It consists of multiple subservices; we will discuss each service's workflow and inner functionality in this lesson. The appropriate architectural styles, data formats, and protocols are debated later in this lesson.

Design overview

The design of the LeetCode API consists of five major services, as shown in the illustration below. As we can see, each service has a significant role and, therefore, accepts users’ requests directly, because it’s available as an endpoint to its users. Even if each service is elaborated on in detail along with its components, we’ll see how these services are interdependent and coupled to respond to user queries. Below, we explain the role of each service and the workflow to complete various functional requirements.

Requests from clients can ask the LeetCode service to perform operations such as listing coding problems, registering a coding contest, submitting a code, commenting on a topic, and so on. Each subservice is a complete service; we’ll discuss their workflows by analyzing the components involved in each service.

Press + to interact
Working architecture of a LeetCode service
Working architecture of a LeetCode service

The working of each of the components of the LeetCode service is given below:

Components and Services Details

Component or Service

Details

User Service

  • Deals with user's data
  • Handles requests related to user's registration and login

Problem Service

  • Handles requests related to practice problems
  • Communicates with other services for code execution requests
  • Maintains metadata of a user's performance

Contest Service

  • Performs contests related operations
  • Tackles requests such as contest registration, code submission, maintaining leaderboard, and so on

Interview Service

  • Handles scheduling of interview requests
  • Connects subservices, such as Zoom and the code execution service, for real-time communication and code evaluations

Discuss Service

  • Handles discuss queries
  • Connects with the pub-sub service to create topics and notify users

Cache

  • Caches responses to reduce number of calls to different endpoints

Workflow

In the following section, we will discuss different workflows in terms of the functional requirements we set for our LeetCode design problem. We’ve divided the workflow in terms of use cases and services.

User service

In addition to handling the registration and login requests of the users, the user service is also ...