An open API service indexing awesome lists of open source software.

https://github.com/codebanesr/anywhr-backend

Find your travel destinations, from famous movie spot
https://github.com/codebanesr/anywhr-backend

Last synced: 4 months ago
JSON representation

Find your travel destinations, from famous movie spot

Awesome Lists containing this project

README

          

# anywhr-backend
Find your travel destinations, from famous movie spot

# Documentation Coverage for frontend
http://3.1.20.178:3000/documentation

#### Entry point
` app.js is the entry point of the application, however when running in production run bin/www`

#### Features
>Implemented real time search functionality using rxjs's debounce, distinct until changed operator
>on angular form's input element, which exposes an event that is fired everytime value of input box
>changes
>![Alt text](./git_images/Screenshot 2019-12-29 at 2.37.47 AM.png?raw=true "Real Time Search")

> Movie Location and definition from wiki pages
> On clicking any one of the locations, the app will look for that title on wikipedia and populate
> results on the grey area
>![Alt text](./git_images/Screenshot 2019-12-29 at 2.38.18 AM.png "Movie Location Scroller")

>Pagination implementation in angular
>![Alt text](./git_images/Screenshot 2019-12-29 at 2.38.31 AM.png?raw=true "Pagination")

Example
` http://3.1.20.178:3000/movie?title=180 `

### Running locally
`git clone https://github.com/shanurrahman/anywhr-backend.git`
`cd anywhr-backend`
`npm install`
`browse localhost:3000`

### To improve upon the frontend
`cd ..`
`git clone https://github.com/shanurrahman/anywhr-frontend.git`
`npm run compodoc`
`ng build --prod`

Now run your backend server
`cd ../anywhr-backend && npm start`
goto : localhost:3000

Note:
* For this process to run both anywhr-frontend and backend should be in the same folder

### Using Docker
From the root directory
`docker build --tag="anywhr:anywhr" ./`
docker image ls => find the id of your image and do a `docker run -d --restart=always -p 3000:3000 image_name:version`
In our case it is going to be `docker run -d --restart=always -p 3000:3000 `
goto `localhost:3000`

* you can also use the image id if tag was not created

> Building an image from dockerfile
>![Alt text](./git_images/docker/starting a container.png "Dockerdoc")

> Running docker container from that image
>![Alt text](./git_images/docker/Screenshot 2019-12-29 at 3.05.49 PM.png "Dockerdoc")
>![Alt text](./git_images/docker/Screenshot 2019-12-29 at 3.04.58 PM.png "Dockerdoc")
>![Alt text](./git_images/docker/Screenshot 2019-12-29 at 3.05.49 PM.png "Dockerdoc")

### Production build instructions
update the .env file, your db credentials, put NODE_ENV=development to enable full logging
* You may use this docker image inside a docker stack and use it with production but that will require
* docker and docker compose installation first, for an app of this size I would not actually recommend
* going with that approach, Here I am using pm2 and pm2-logrotate for the same purpose

##### npm install

##### Install pm2 globally
```
$ pm2 stop
$ pm2 restart
$ pm2 delete
```
`$ sudo pm2 start bin/www`

##### Install pm2 logrotate, prevents memory leak issues on the server
`pm2 install pm2-logrotate`

### Notes to the reviewer [Handling memory leaks in postgres]
> For one line postgres statements that dont require a transaction block we can simply use pg pools
> that way we dont have to deal with closing the database queries
> More on it here
> https://node-postgres.com/api/pool

#### Database tables
```
create table movie
(
title varchar(256) not null
constraint movie_pkey
primary key,
release_year varchar(128),
fun_facts varchar(339),
production_company varchar(256) default 'N/A'::character varying,
distributor varchar(256),
director varchar(79),
writer varchar(49),
actor_1 varchar,
actor_2 varchar,
actor_3 varchar
);
```

```
create table movie_location
(
title varchar(45) not null,
locations varchar(110)
);

```