Skip to content

backend clone of youtube - media storage and sharing api written in go using microservice architecture

License

Notifications You must be signed in to change notification settings

rzaf/youtube-clone

Repository files navigation

youtube-clone

media storage and sharing api written in go using microservice architecture.

  • for simplicity and data integrity used a central database for user related data except media files
  • written in a request-response architecture
  • services communicate to each other using gRPC

services diagram

request-response

gateway service

main api of app for user related data (users,medias,comments,playlists,likes,tags,followings)

file service

  • has a Rest api for recieving and uploading media files (photo,video,music)
  • stores all media files and its meta data (other services communicate with file service to know media file url exist and belong to which user)
  • media files are stored in system files and meta data is stored in a mongodb database
  • handles video,music formating and compression (using ffmpeg)

database service

  • central database (postgres) for storing all user user related data (users,medias,comments,playlists,likes,tags,followings)
  • other services communicate with database service to get user related data

notification service

  • recieves notifications from other services to send to user
  • send emails to users for verifications and notifications

api endpoints

protected routes require authentication with api key

gateway service routes

USERS

type url protected
GET api/users/{username}
GET api/users
GET api/users/search/{term}
POST api/users/
POST api/users/sign-in
POST api/users/{username}/verify/{code}
POST api/users/resend-email
PUT api/users/{username}/profile-photo
GET /users/{username}/followings
PUT api/users/{username}/channel-photo
PUT api/users/{username}/newApiKey
PUT api/users/{username}
DELETE api/users/{username}
POST api/follows/{username}
DELETE api/follows/{username}

MEDIAS

type url protected
GET api/medias
GET api/medias/search/{term}
GET api/medias/{url}
POST api/medias
PUT api/medias/{url}
DELETE api/medias/{url}
POST api/medias/{url}/tag/{name}
DELETE api/medias/{url}/tag/{name}
POST api/medias/{url}/playlists/{playlistUrl}
PUT api/medias/{url}/playlists/{playlistUrl}
DELETE api/medias/{url}/playlists/{playlistUrl}

COMMENTS

type url protected
GET api/comments/{commentUrl}
GET api/comments/medias/{url}
GET /comments/{commentUrl}/replies
POST api/comments/medias/{url}
PUT api/comments/{commentUrl}
DELETE api/comments/{commentUrl}

LIKES

type url protected
POST api/medias/{url}/likes
DELETE api/medias/{url}/likes
POST api/comments/{url}/likes
DELETE api/comments/{url}/likes

PLAYLISTS

type url protected
GET api/playlists
GET api/playlists/search/{term}
GET api/playlists/{url}
GET api/playlists/{url}/medias
POST api/playlists
PUT api/playlists/{url}
DELETE api/playlists/{url}

file service routes

type url protected
GET api/photos/{url}
GET api/videos/{url}
GET api/musics/{url}
POST api/photos/upload
POST api/videos/upload
POST api/musics/upload

build

make build builds go files
make all builds go files and generate pb files
make build-run builds everything and run docker container
make run run docker container
make remove stops and removes docker container

features

  • video,music,photo storage and sharing
  • video and music streaming
  • swagger documentations (at /docs)
  • user subscribing (following)
  • comment and reply on medias
  • media and comment likes
  • searching users,medias,playlists
  • multi media playlists
  • email verification
  • user upload limit
  • notifications:
    • new media from following user (subscribing)
    • new comment on users media
    • new reply on users commnet
    • new like on users media,comment,reply
    • new follower (subscriber)

todo

  • image compression
  • multiple video quality and bitrate
  • video subtitle
  • video thumbnail from video
  • adding image to musics

About

backend clone of youtube - media storage and sharing api written in go using microservice architecture

Topics

Resources

License

Stars

Watchers

Forks

Languages