Giter Club home page Giter Club logo

autocomplete's Introduction

Frontend repo

Autocomplete UI
Ceeit on Air

System design

System design

Trie data structure

With small data we can store it in the relational databases. However, fetching the top k search queries from a relational database is inefficient. The data structure trie (prefix tree) is used to overcome the problem.

Trie

To sort the result we need to store the frequency along with the node.

Query Frequency
tree 10
try 29

Data gathering service

Updating the tree in realtime is not practical for 2 reasons:

  • Users may enter billions of queries per day. Updating the trie on every query significantly slows down the query service.
  • Top suggestions may not change much once the trie is built. Thus, it is unnecessary to update the trie frequently. So, we need to build the data gathering service.

Data gathering service

Query logs

It stores raw data about search queries.

Query Time
tree 1668312111347
try 1668312101354

Aggregation services

The query logs is usually very large and data is not in the right format. We need to aggregate data so it can be easily proccess later.

Aggregated data

Query Frequency
tree 1000
try 967

Workers

Workers perform asynchronous jobs at regular intervals.

Trie cache

Cache most recent queries for a faster retrieval.

Trie DB

Trie is converted to hash table form and save to noSQL database.

Query services

Service that perform search autocomplete. We can futher optimize query service by cache the result in the browser. Query service

Shard map manager

The next thing we want to look at is scaling the database. Shard map manager

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

autocomplete's People

Contributors

yud-bet 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.