Skip to content

places-app/places-recommendation

Repository files navigation

Places Recommendation Service

The places recommendation service uses a item based collaborative filtering algorithm. The recommendation engine will compare all places pinned by a user against all places in the system and return the top 10 places that are similar to that user's places.

The recommendation engine has two workers, one that will run hourly to get place types for each newly pinned place, and another that will run once a day to generate place recommendations for each user.

The worker that gets place types will query from the main postgres database to get the Google Place ID (gPlaceId). Using the gPlaceId it will make an API call to Places API to get place details and types. After getting all places, it will save the last place ID into redis.

The worker that generates recommendations will query from the main postgres database to get all users and user's places. After the recommendation engine has generated recommendations, it will save all users and their recommended places to redis.

Table of Contents

  1. Getting started
  2. Redis Schema
  3. Tech
  4. Directory Layout
  5. Team
  6. Contributing

Getting started

Clone and install dependencies:

$ npm install

Create env/development.env and set environment variables. Follow env/.env.sample.

To run locally:

Prerequisites

  • Install and run redis-server
$ npm install redis-server
$ redis-server

Start server

$ npm start

To run on docker:

Prerequisites

  • Create a docker machine
$ docker-compose up

Redis schema

  • Key / Value
  • Place_ID / number (last placeId)
  • User ID (number) / Recommendations (array of places)

Tech

node / express server node-cron for workers redis for database

Directory Layout

Use the diagram below as an example and starting point

├── /.github/                         # Github configs
│   ├── PULL_REQUEST_TEMPLATE         # Pull request template
├── /config/                          # Configs
│   ├── middleware.js                 # Middleware config
├── /controllers/                     # Controllers
│   ├── PlaceDetailsController.js     # Place details controller
│   ├── RecommendationsController.js  # Recommendations controller
│   ├── UserPlacesController.js       # User places controller
├── /db/                              # Database configs
│   ├── db.js                         # Postgres config
│   ├── redis.js                      # Redis config
├── /engine/                          # Recommendation files
│   ├── recommendation.js             # Recommendation engine
├── /env/                             # Environment variables
│   ├── .env.sample                   # Sample env file
├── /node_modules/                    # 3rd-party libraries and utilities
├── /routes/                          # Routes
│   ├── /api-routes.js                # API routes
├── /server/                          # Server
│   ├── server.js                     # Http server
├── /test/                            # Tests
│   ├── /places-api-test.js           # Places API test
├── /utils/                           # Utilities
│   ├── /api.js                       # Axios request functions
│   ├── /helpers.js                   # Helper functions
├── /workers/                         # Workers
│     ├── GetPlaceDetails.js          # Get place details worker
│     ├── GetUserPlaces.js            # Get user places worker
├── .eslintrc                         # ESLint settings
├── .gitignore                        # Git ignore
├── .docker-compose.yml               # Docker compose
├── DockerFile                        # Docker file
├── package.json                      # List of 3rd party libraries and utilities to be installed
└── README.md                         # Read me

Team

Contributing

See CONTRIBUTING.md for contribution guidelines.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published