Giter VIP home page Giter VIP logo

fampay-yt-video-fetcher's Introduction

Backend Assignment (Intern) | FamPay

Project Goal

To make an API to fetch latest videos sorted in reverse chronological order of their publishing date-time from YouTube for a given tag/search query in a paginated response.

Basic Requirements:

  • ☑️ Server should call the YouTube API continuously in background (async) with some interval (say 10 seconds) for fetching the latest videos for a predefined search query and should store the data of videos (specifically these fields - Video title, description, publishing datetime, thumbnails URLs and any other fields you require) in a database with proper indexes.
  • ☑️ A GET API which returns the stored video data in a paginated response sorted in descending order of published datetime.
  • ☑️ A basic search API to search the stored videos using their title and description.
  • ☑️ Dockerize the project.
  • ☑️ It should be scalable and optimised.

Bonus Points:

  • ☑️ Add support for supplying multiple API keys so that if quota is exhausted on one, it automatically uses the next available key.
  • Make a dashboard to view the stored videos with filters and sorting options (optional)
  • ☑️ Optimise search api, so that it's able to search videos containing partial match for the search query in either video title or description.
    • Ex 1: A video with title How to make tea? should match for the search query tea how

Tech Stack Used

  • Programming Language: Go (Golang)
  • Web Framework: Echo
  • Database: MongoDB
  • Docker - Containerization for deployment
  • YouTube Data API v3 - For fetching video data from YouTube-

Instructions

Running Instructions

  • Clone the github repository :
  git clone https://github.com/deepcoder0/fampay-yt-video-fetcher.git
  cd fampay-yt-video-fetcher
  • Create .env file and Add fields as per sampleENV file. The Ports I used:

    • SERVER_ADDRESS = 0.0.0.0:8080
    • MONGODB_URI = mongodb://mongodb:27017
  • To build and run docker container :

  docker compose up --build -d

API Instructions

  • Access the API endpoints:
    • The API endpoints will be available at http://localhost:8080.

API Endpoints

  1. GET /fetch/:topic : A cron job has been set up to fetch YouTube videos without relying on an external API trigger. This job runs in every 10 seconds, retrieving video details and storing them in the database.

    curl --location 'http://localhost:8080/fetch/cricket'
    
  2. GET /search: Retrieve stored video data in a paginated response sorted by publishing datetime in descending order.

    curl --location 'http://localhost:8080/search?topic=cricket?page=1?pageSize=5'
    
    • By default, topic is null, so if not provided, it will fetch all videos
    • By default, page = 1 and pageSize = 10 here.
  3. GET /search/:query: Search stored video by search query, which tries to match query with video's Title or Description.

    curl --location 'http://localhost:8080/search/tea how'
    
    • By default, page = 1 and pageSize = 5 here.
  4. GET /healthcheck : To check if the server is up!

    curl --location 'http://localhost:8080/healthcheck'
    
  5. GET /dbReadiness : To check if the DB server is up!

    curl --location 'http://localhost:8080/dbReadiness'
    

To know more, I have attacked screenshots for all the cases in /screenshots. Please have a look.

fampay-yt-video-fetcher's People

Contributors

deepcoder0 avatar deepanshu-agarwal-ev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.