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.
API Endpoints
All endpoints are prefixed with /api/
.
Additionally, all endpoints require a valid JWT token for authentication.
1. Authentication, Onboarding and User Profile
Endpoint | Description |
---|---|
POST /auth/signin | User login. Returns JWT token. |
POST /auth/signup | Register a new user. Returns JWT token. |
GET /users/:user | Fetch user profile and preferences. |
PUT /user/:userId | Update user profile and preferences. |
DELETE /user/:userId | Delete a user profile. |
GET /user/:userId/friends | Fetch friends of the user. |
2. Video Streaming and Engagement
Endpoint | Description |
---|---|
GET /videos/queue | Fetch the next set of videos in the user's queue. |
GET /videos/watching | Fetch the video metadata for the videos being currently watched |
POST /videos/:videoId/like | Like a video. |
POST /videos/:videoId/dislike | Dislike a video. |
GET /videos/:videoId/comments | Fetch comments on a video. |
POST /videos/:videoId/comments | Add a comment on a video. |
POST /videos/:videoId/share | Share a video with another user. |
3. Video Affinity
Endpoint | Description |
---|---|
GET /video/:videoId/affinities | Fetch affinity scores for a specific video. |
POST /video/:videoId/affinities | Create affinity score for a specific video |
PUT /video/:videoId/affinities/:affinityId | update affinity score for a specific video |
DEL /video/:videoId/affinities/:affinityId | delete affinity score for a specific video |
3. User Affinity
Endpoint | Description |
---|---|
GET /user/affinities | Fetch user's affinities based on topics and subtopics. |
GET /user/affinities/:affinityId | Fetches a specific affinity |
POST /user/affinities/:affinityId | Create a new user affinity |
PUT /user/affinities/:affinityId | Update the user affinity |
DEL /user/affinities/:affinityId | Delete the user affinity |