What is Tilt

Tilt is video creation app(same as beReal), the app activates your phone's front and back cameras at the same time
User can select any stream (front or back) as major stream and other will be shown as smaller screen with major.

Requirements (CRUD)

Functional

1. User can create Account on Tilt
2. Whenever new video is posted by friend, user get Push notification
3. Update self profile
4. User can add friends
5. (POST) User can create dualmode video & save on cloud
6. Delete friend
7. Delete account

Non-Functional

1. Highly available
2. Secure. Videos should not be leaked on internet

BOE

Metric Description
QPS(Queries per second) Very low, as in when someone opens app then request is sent to system and system sends the updates
BW Estimates
Storage Requirements DAU = 1 Million. 1 user uploads 2 videos/day. Video duration = 10 min(100MB)
Total video uploads = 1M x 2 = 2M.
Data = 2M x 100MB = 200 TB /day.
For 5 years = 200TB x 365 x 5 = 365 x 1015 bytes

API Design (CRUD)

REST API?
REST API Versioning(v1,v2)

1. User can create Account on tilt

2. User reads timeline whenever he opens the app

3. Update self profile

5. User can create dualmode video & save on cloud

5. Delete Account


curl -X POST -H "Content-Type: application/json" 
-d '{"name": "user_id"}' 
http://127.0.0.1:8080/v1/create_account -vvv
          

curl -X GET http://127.0.0.1:8080/v1/get_all_data
        

curl -X PUT -H "Content-Type: application/json" -d 
'{
  "user_id": "current_user_id", 
  "new_name": ["new_name"]
}' 
http://127.0.0.1:8080/v1/update -vvv
        
User saves video in device library
Directly send video to tilt server (in parts)

curl -X POST -H "Content-Type: application/json" 
http://127.0.0.1:8080/v1/upload_video
-d '{
  "user_id": "id1",
  "fragment_no": "fragement-n"
}' 
        

curl -X DELETE -H "Content-Type: application/json" 
http://127.0.0.1:8080/v1/delete_account
-d '{
  "user_id": "id1",
}'
        

// Create account
//url=toilt.amo.com
POST https://url/v1/create_account 
header {
  Authorization: {Bearer "API_KEY_TOKEN"},

  /*Mandatory added by HTTP Start*/
  Content-len: 0                        
  Host:        //Calculated when req is sent
  UserAgent: Postman
  Accept: */*       
  Accept-Encoding: gzip, deflate, br
  Connection: Keepalive
  /*Mandatory added by HTTP End*/
}
body {  //JSON
  "user_name": ""
}
        
  
GET https://url/v1/get_location
header {
  Authorization: {Bearer "API_KEY_TOKEN"},
  ..other fields..
}
body {  //JSON
  "my_username": "",
}
          
  
PUT http://url/v1/update
header {
  Authorization: {Bearer "API_KEY_TOKEN"},
  ..other fields..
}
body {  //JSON
  "userid": "", 
  "new_name": "",
}
        
    
PUT http://url/v1/upload
header {
  Authorization: {Bearer "API_KEY_TOKEN"},
  ..other fields..
}
body {  //JSON
  "user_id": "",
  "fragment_no": "1"
}
        
  
DELETE http://url/v1/delete_account
header {
  Authorization: {Bearer "API_KEY_TOKEN"},
  ..other fields..
}
body {  //JSON
  "my_username": ""
}
        

DB Schema

Graph DB

// user Table
| userid (pk) | username | creation_timestamp | last_seen |

// password table
| userid (pk) | username | password_hash | password_creation_date | expiry_time |
    
Friends, friends of friends, Likes, comments, videos relationship Would be stored on Graph DB
Videos, Comments: Stored on seperate Object store
Coments:

HLD

User uploading video, Friend is notified and Friend watches video

Tilt App
Storing videos on CDN:
  All videos are not stored directly on CDN
  As user uploads a new video its stored on object store (e.g., AWS S3, Azure Blob Storage)
  CDN caches content only when requested by users.
  Videos are stored with proper lifecycle policies (e.g., auto-deletion after a period for inactive videos).

Adaptive Caching Strategy on CDN:
- Only store videos on the CDN when they cross a popularity threshold (e.g., number of views, likes, or shares).
- Prioritize celebrity or influencer content for CDN storage due to higher demand
- Implement a Least Recently Used (LRU) cache eviction strategy on the CDN to optimize storage costs.