Git Product home page Git Product logo

mean-typeahead's Introduction

MEAN Typeahead

A demo project for fast typeaheads. Based on the MEAN stack and capable of quickly filtering through thousands of records without a noticeable delay.

If you're not familiar with the MEAN stack, here is a nice video overview.

Why?

Typeaheads are becoming more commonplace on the web and in applications. They can be a huge productivity boost in certain situations. The Google search site is a perfect example. It may be easy to implement a typeahead on the client, but what happens when you need to filter over thousands of records? For satisfactory performance, the full stack needs to be addressed.

Why Mongodb?

Simplicity. No schema. Fast. Indexed fields supported by anchored regex. By that, I mean that mongodb can use indexes when queried with an anchored regular expression like /^aar/. This aligns perfectly with our requirement to incrementally search as each character is typed by the user.

Why Angularjs?

Angularjs allows for clear and concise code to accomplish this. Uses the angular-bootstrap module to really make this concise.

The Setup

This project was initially generated by Yeoman. For the curious:

  • yo version 1.0.4
  • generator-angular version 0.6.0-rc.2

After generating the project, I removed a few things but otherwise leveraged as much as possible.

Since this is a node.js project, you'll need node.js installed on your development machine. Those instructions can be found here. If you haven't done it already, install the following tools:

npm install -g bower
npm install -g grunt-cli

Project Installation

From the root directory:

npm install
bower install

The Database

You'll need a development mongodb database to play with. We won't cover that here, but you'll likely need to change the server/mongodb.js file to match your configuration.

Running the Server

cd server
node server.js

You should see some logging output telling you the status of the database connection.

Running the Client (development mode)

grunt server

You should see the development server start on port 9000. Depending on your configuration, your browser may be launched to open the start page.

Running the Client (from the node.js server)

grunt build

The node.js server serves the build files and the site becomes available on http://localhost:3000 by default. In this configuration, both the site and the API are served from the same origin.

Then What?

If your browser isn't already launched, navigate to http://localhost:9000 (or port 3000 - see above). You'll see a basic layout with the following fields:

  • Database Record Count. This tells you how many widgets are currently in the database.
  • The Typeahead Control. The magic happens here.
  • The "Add More Data" Button. Populates the database with more random data.

The widgets have numbers for names - this just makes it easier to randomly create them. Imagine searching for serial numbers or something like that.

Todo

  • Timing measurements on UI
  • Configurable query limits and dropdown list sizes
  • PRs ???

License

MIT license. Copyright 2013 by Aaron Nielsen.

mean-typeahead's People

Contributors

spitimage avatar

Stargazers

 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.