Giter VIP home page Giter VIP logo

unsplash-demo's Introduction

overview

Project is an express server that serves a static React frontend.

The application exposes the Unpslash image search api.

In addition, the server exposes the following endpoints

/photos - images to show on first load

/photos/search - query for images base on a search term

/spellcheck - simple input spellcheck. I decided to have the spellcheck on the backend so I did not have to serve up an english dictionary with my react app.

The spellcheck works by pruning all non-letter characters from the search term with a regex replace. Then if the term is not an english word it loops through the letters of the word looking for vowels. If it finds a vowel it replaces it with all the other vowels hoping to make a valid word. If a valid word is not made, the process is repeated for each new word generated; this time starting at the very next letter of the last replaced vowel.

On the front-end, I used styled components in conjuction with a UI library that I built/am building. The library is built with styled components so it is easily extensible.

To handle the search logic. I used observables from the rxjs library. Each time a search term change is triggerd, the change is broadcasted to the AsyncSearchStream located at client/utils/async-search. The stream then debounces the input by 500ms, filters search terms that are below 3 characters long, and removes inputs that are same as the last input. The stream then maps the term to a spellcheck suggestion from the /spellcheck endpoint and then to a unsplash query from the /photos/search endpoint.

TODO:

  • there are lots of obscure words in english. would be better to index suggestions based on frequency of use.
  • when searching for such obscure words often times there are only a handful of results and they are not displayed correctly/aesthetically
  • add tests
  • add more error handling

hosted at: https://unpslash-demo.herokuapp.com/

Time spent: 8 hrs

unsplash-demo's People

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.