/carbtographer

Application that recommends macro friendly meals from local restaurants

Primary LanguageGo

Carbtographer

Application that recommends macro friendly meals from local restaurants.

Netlify Status

Build Status CodeFactor Go Report Card Coverage Status

Frontend Link: https://carbtographer.com

Backend Link: https://api.carbtographer.com

NOTICE

Recently ported Node.js backend to a Golang backend.

Node.js back end on node-backend branch here.

Frontend

Frontend built in React.js, Redux and Styled Components

Enviroment Variables

You will require a Mapbox Access Token to make authenticated requests.

You can generate one following the intructions here: Mapbox: Access tokens

  • REACT_APP_MAP_BOX_KEY - your Mapbox Access Token (API Key)
  • REACT_APP_BACKEND_URL - your backend link

Usage

With all enviroment variables in place you can now run it locally

CD into client

cd client

Install node modules

npm i

Run

npm run start

Backend

Enviroment Variables

You will require a Yelp API Key to make authenticated requests. Locally ran Postgress and Redis server to test locally

You can generate one following the intructions here: Creating an app on Yelp's Developers site

  • PORT- your server PORT
  • YELP_API - your Yelp Key (API Key)
  • DB_HOST - your database Host URL
  • DB_PORT- your database PORT
  • DB_USER - your database user
  • DB_NAME - your database name
  • DB_PASSWORD - your database password
  • ENVIROMENT - must be PRO or DEV
  • JWT_KEY - jwt secret key
  • CACHE_ADDRS - redis server address
  • CACHE_PASSWORD - redis server password
  • CACHE_DB - redis databse number

Run locally

Enable go modules

export GO111MODULE=on

Scrape Info

go run main.go -scrape

Run migrations

go run main.go -migrate

Run Postgress seeds

go run main.go -seed

Run Redis seeds

go run main.go -seed-cache

Run server

go run main.go -serve


ENDPOINTS

GET /

{
    status: 200,
    message: "server live on port: ####"
}

GET /names

Returns all restaurant names in database

[
    {
        id: 1
        name: "Name"
    }
]

GET /locations/{lat}/{lon}

Returns restaurant info based on lat and long

lat: latitude
lon: longitude

[
  {
    "id": "id",
    "name": "Name",
    "coordinates": {
      "latitude": 0.0,
      "longitude": 0.0
    },
    "photos": [
      "url"
    ],
    "distance": 20.0
  }
]

GET /items/{id}

Returns all items for any given restaurant ID

id: restaurant ID

[
    {
        "id": 0,
        "name": "item name",
        "type": "type",
        "protein": 0,
        "carbs": 0,
        "fats": 0,
        "calories": 0,
        "calperpro": 0.0
        "sodium": 0,
        "r_id": 0
    }
]

GET /*

404 Endpoint

{
    status: 404,
    message: "route not found"
}