This is a service for gitting the latest movies from IMDB API, feed the database with the latest movies and expose it throgh a gRPC connection. This service fetches a new movie from IMDB every 3 seconds and if the latest movie is not exists in the database it will insert it into the database.
- ✅ Implement a cron job that polls the IMDB API every 3 seconds to keep the database up-to-date with the latest movie releases.
- ✅ GetLatestMovies
- extensive details of the latest movie
- ✅ SearchMovies
- by title
- by description
- by released_date
- ✅ UpdateFavourites
- add to favorites list
- remove from favorites list
- ✅ GetMovieDetials
- id
- title
- description
- poster
- genres
- ⌛ Authentication
- ⌛ Proper Logging
- ⌛ Localized Error Messages
- Golang go 1.20.7 or higher
- Protocol Buffer Compiler
- Docker
- Access Token Auth (You need to get a one from IMDB API)
If you are used to postamn "like me :)" then you can find there api here:
You can just simply fork it and use it directly from postman 😎
You have to compile the protocol buffers every time you change the pf :)
$ cd movies # you should be in the root directory before executing the below commands 👇
$ export PATH="$PATH:$(go env GOPATH)/bin"
$ protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative grpc/proto/movies.proto
DB_HOST=
DB_USER=
DB_PASSWORD=
DB_NAME=
DB_PORT=
ACCESS_TOKEN_AUTH=
RUN_SEEDERS=
RUN_FACTORIES=
DB_HOST=postgres
DB_USER=movies
DB_PASSWORD=movies
DB_NAME=movies
DB_PORT=5432
ACCESS_TOKEN_AUTH=fOrSEcUrItyREaSoNs
RUN_SEEDERS=true
RUN_FACTORIES=false
$ mv .env.example .env
$ sudo chmod -R 777 postgres_data
$ docker-compose up
- You need to login into pgadmin and then create a server and this server must match the postgres container name, because the name of the container is in fact the host :)
- Method 1: You can consume these gRPC API endpoints by the client CLI
$ cd movies
$ go run grpc/client/client.go
1: Get latest movies
2: Search movies
3: Update Favorites
4: Get movie details
$ Enter a number (1-4):
- Method 2: You can consume these gRPC API endpoints by importing the "movies/grpc/proto/movies.proto" to the postman then you can test them!
I find these resources are good to understand how gRPC works in general :)
- (An Introduction to Programming in Go) https://www.golang-book.com/books/intro
- (Introduction to gRPC) https://grpc.io/docs/what-is-grpc/introduction
- (gRPC Introduction) https://www.youtube.com/watch?v=XRXTsQwyZSU