Back-End

The Discite Backend Engine.

Back-End Design Principles

We designed our backend around the following principles:

  • Scalability: We want to be able to support as many users as possible, so our backend is designed to auto-scale when needed.
  • Security: It is important that user data is protected. We ensure all incoming requests are authorized using access tokens.
  • Modularity: We want the API to be extensible, so each user-facing feature is supported with its own collection and ways of interacting with it. This ensures each module does not affect other modules, and makes it easy to add new modules supporting new user-facing features.
  • Simplicity: We chose the simplest design patterns, using Express.js's structure of models and controllers.
  • Speed: We optimized our data-processing and database queries to make them as fast as possible.
  • Reliability: We implemented our backend with TypeScript, ensuring type-safety and avoiding type errors which are prone in vanilla JavaScript.
  • Testability: We have a testing-suite of over fifty tests, built using Cypress. Test Coverage

API Endpoints

All endpoints are prefixed with /api/.
Additionally, all endpoints require a valid JWT token for authentication.

1. Authentication, Onboarding and User Profile

EndpointDescription
POST /auth/signinUser login. Returns JWT token.
POST /auth/signupRegister a new user. Returns JWT token.
GET /users/:userFetch user profile and preferences.
PUT /user/:userIdUpdate user profile and preferences.
DELETE /user/:userIdDelete a user profile.
GET /user/:userId/friendsFetch friends of the user.

2. Video Streaming and Engagement

EndpointDescription
GET /videos/queueFetch the next set of videos in the user's queue.
GET /videos/watchingFetch the video metadata for the videos being currently watched
POST /videos/:videoId/likeLike a video.
POST /videos/:videoId/dislikeDislike a video.
GET /videos/:videoId/commentsFetch comments on a video.
POST /videos/:videoId/commentsAdd a comment on a video.
POST /videos/:videoId/shareShare a video with another user.

3. Video Affinity

EndpointDescription
GET /video/:videoId/affinitiesFetch affinity scores for a specific video.
POST /video/:videoId/affinitiesCreate affinity score for a specific video
PUT /video/:videoId/affinities/:affinityIdupdate affinity score for a specific video
DEL /video/:videoId/affinities/:affinityIddelete affinity score for a specific video

3. User Affinity

EndpointDescription
GET /user/affinitiesFetch user's affinities based on topics and subtopics.
GET /user/affinities/:affinityIdFetches a specific affinity
POST /user/affinities/:affinityIdCreate a new user affinity
PUT /user/affinities/:affinityIdUpdate the user affinity
DEL /user/affinities/:affinityIdDelete the user affinity

Copyright © 2024 Discite.