- user can login/logout
- user can post the article
- user can upload file
- user can searching
- user can like, comment, follow
- high availability, latency < 500ms
- total users: 100M
- daily active user: 1M
- 1 user upload 2 image per day
- image size < 5MB
--> Write 1 * 2 * 5MB * 1M = 10MB = 10TB
- QPS: Write: 1M * 2(image upload) / (24hours * 60 minutes * 60 seconds) == 25 QPS
- QPS: Read: 1M * 50 / (24hours * 60 minutes * 60 seconds) == 580 QPS
==> READ HEAVY
- No lost for image
Login: - request: { username, password} - response: { accessToken, refreshToken }
Logout - request: { token } - response: boolean
Post Article - request: { userId, title, description, content, hastag } - response: articleId
Upload File - request: { string base 64 } - response: file_url
Searching - request: { keyword } - response: [ article ]
Like - request: { userId, articleId } - response: boolean
Comment - request: { userId, articleId, content } - response: commentId | Comment
Follow - request: { currentUserId, toUserId } - response: boolean
Clone the repository
git clone https://github.com/anhtt2211/social-api.git
Switch to the repo folder
cd social-api
Install dependencies
npm install
Create file .env from .env.example and fill it
cp .env.example .env
Run migration
npm run migration:run <db_name>
Build images
docker-compose build
Run on docker
docker-compose up
npm start
- Start applicationnpm run start:watch
- Start application in watch modenpm run test
- run Jest test runnernpm run start:prod
- Build application
This example repo uses the NestJS swagger module for API documentation. NestJS Swagger - www.swagger.io