Skip to content
/ fampay Public

This repository contains the solution of Fampay Backend Assignment

Notifications You must be signed in to change notification settings

Rashu99/fampay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend Assignment | FamPay

# Problem Statement

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.

Tech / Framework Used

  • Python (Django, DRF)
  • Postgres
  • Celery
  • Celery Beat
  • Redis -> Broker

# APIs Details

1. Get Videos API

curl request with default pagination:-

curl --location --request GET 'http://127.0.0.1:8000/youtube/getVideos'

curl request with passing page limit in query params:-

curl --location --request GET 'http://127.0.0.1:8000/youtube/getVideos?page_limit=15'

2. Search Videos API

curl request:-

curl --location --request GET 'http://127.0.0.1:8000/youtube/searchVideos?query=puri food'

3. Add Auth Key API

curl request:-

curl --location --request POST 'http://127.0.0.1:8000/youtube/addAuthKey' \
--header 'Content-Type: application/json' \
--data-raw '{
  "auth_key": "your_key"
}'

# How to run the Project?

I have dockerize the project as mentioned in the assignment requirements. So it is simple to run the project through docker.

Steps to run

  1. Clone the project
  2. Should have docker installed on the system (If not, download it from official site)
  3. Move to the root of project
  4. Run command
    $ docker-compose build
    
  5. Then Run
    $ docker-compose up
    

Project will start running in docker container

# How to Test?

As soon as you run the project in docker, cron job will start every 30 sec and try to fetch data from youtube. But as there is no auth key in database, it will throw error no api key found

So as a next step, hit the 3rd API (Add Auth Key API) with valid api key and wait for atleast 30 seconds as scheduler will run every 30 seconds.

Now you can test 1st and 2nd API as well

# Dashboard to see all the stored videos

For this task I have used django admin portal, which provides all the feature liking listing of video, filtering, sorting etc.

To see dashboard, we have to first create superuser. Run the below command to create superuser

$ docker-compose run app python manage.py createsuperuser

It will ask User, email and password. After entering all the details, hit the below url in any browser

127.0.0.1:8000/admin/

Login with the credentials and check the dashboard for videos

Releases

No releases published

Packages

No packages published