This demo is a minimal simulation of the email draft window which provides autocompletion facilities for selecting emails from known contacts. This simulation has 10k fake emails with fake first and last names, and typing in the text box instantly completes a prefix search, autocompleting any first/last name or email. This is a demo to showcase that the Dynamic Score-Decomposed Trie can service real queries in real-time, even when deduplication is needed because three terms in the data structure must map to a single contact (first/last name & email).

One of the nice features of this data structure is that it can be updated in real-time using the algorithms described here on the client's machine and quickly serialized and deserialized from the client's `localStorage` or `caches`. Once a client sends an email, all of the contacts being sent that email can have their `score` updated, which is the `timestamp` of the last time they have been contacted, which moves all the nodes that map to those clients to the top of the heap-like data structure, and can be serialized to `localStorage` or `caches` afterwards (not implemented for this demo).

This demo only performs prefix search on the first name, last name, and email of all emails stored in the corpus. At present, it does not split the email into multiple chunks like Gmail does, so one would not be able to search for some part of the email after a `.` or a `+` or a `@` symbol, like Gmail allows. This is possible to support but I simply did not design the demo to be feature-complete.

This demo also does not currently support refining previous queries like one can do in Gmail. E.g. one can type "@gmail " and be prefix searching in a list of all contacts with gmail providers. This should be easy enough to support for a real-world application, either through brute-force for small lists of contacts, or through producing a data structure to speed up queries for the specific refinement called for by prior prefix queries.

For a simple introduction to how this algorithm works and how the data structure looks, see this link. Press Ctrl+Shift+J to view the time it takes to perform each operation in the developer console. Also try refreshing the page to see how long it takes to deserialize the data structure from `localStorage` or `caches` after it is created on your first visit. Code for this demo is available here.

To: