Giter Site home page Giter Site logo

word-colors-api's Introduction

Word to Colors Generator API

This app takes in a word (or a phrase) as input and shows you associated colors of the object that the word or phrase represents.

Link to app deployed on cloud - https://ragav-word-colors.netlify.app/

Link to the API deployed on the cloud - https://word-colors-api.herokuapp.com

Link to UI code - https://github.com/ryarasi/word-colors

Basic info

  • This project is a dockerized FastAPI-based API with one endpoint that serves the word-colors app linked above.
  • All API secret keys for Google Search API and Ximilar API are stored safely as env variables.

Notable Packages/Technologies

Methodology

  • When the API receives the GET request from the client with the search term, we make a request to the Google Custom Search Engine API to request images for that query.
  • We get an array of upto 10 image urls as a response
  • We run these image urls through Ximilar API to get an array of dominant colors for each of those images.
  • The API has means to access the Google Custom Search API, which it uses to search for images for the query.
  • When the images return, we use the Ximilar API package to get an array of dominant colors as hex codes.
  • The API then neatly organizes the image links and the dominant colors for each image into a JSON and sends it back to the client.

How to run this app on your local machine

  • Download this code to your local machine
  • Make sure you have Python 3 installed. Instructions
  • Make sure you have Docker and Docker Compose installed. Instructions
  • Duplicate the env.sample file and rename it as .env and populate it with the API keys. You can obtain them by visiting the links shown there.
  • Make sure to populate it with the necessary API keys
  • Open your terminal and change directory to the project root folder and enter npm start to get started.
  • The API will be served and it can be accessed at http://0.0.0.0:/8000

How to deploy this to the cloud via Heroku

  • Create a Heroku account if you don't already have one.
  • Create a new project and go to the Deploy settings and connect it with the Git repo where this code exists
  • You can either set it to automatically deploy changes to a specific branch or trigger manual deploys
  • Once done, go to the settings page and add environment variables to the Config Vars section. Make sure to add all the variables in the .env file. Make srue that RELOAD is set to 0. It is 1 only for development environment.
  • Open a terminal and enter heroku login to login to the Heroku CLI. You may first need to install the Heroku CLI if you haven't already. Instructions
  • Once logged in, enter heroku stack:set container -a <your_heroku_app_name>. This will enable the build and deployment of docker container in the repo.
  • Now you can manually trigger a deploy and have it publish in the app url.

word-colors-api's People

Contributors

ryarasi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.