Decimail Webmail has two components: a simple HTTP-to-IMAP/SMTP proxy and an email application written in Javascript. The HTTP-to-IMAP/SMTP proxy is required because Javascript can't communicate with a server using anything other than HTTP, but it does little more than wrap the email protocols' requests and responses with HTTP headers. The IMAP and SMTP syntax is generated and decoded by the Javascript.
One requirement of the proxy is to mate connectionless HTTP with connection-based IMAP. This aspect is inspired by Dolda Webmail, which uses a proxy process to maintain persistent IMAP connections between invokations of its server-side code.
HTTP is a purely request-response protocol, while in IMAP communications can be initiated by either end. So mating the two requires some sort of polling of the proxy by the browser. The approach taken is borrowed from Anyterm: for IMAP responses an "inverted" HTTP channel is used, with the server sending new data in an immediate response and the client acknowledging by sending a new request. In fact, the whole idea of using this architecture to build a highly-responsive webmail application is inspired by Anyterm.
The dynamic browser update is designed to look something like just about every email program. I haven't used Gmail but I bet it has something in common; certainly RoundCube, which I tried to use briefly, has some similarities.