Technical Choices

Before starting to work on the project, we had to decide on the technology we would use for constructing this system. In this section, we will introduce the tools we used for development in this project and justify those choices.

Concurrency

Since most, if not all, of the system’s use cases are I/O intensive, it is natural to employ an asynchronous input/output framework to solve concurrency issues. Trio was picked for the ease of flow control offered by structured concurrency.

Web Server and Framework

As asynchronous input/output was chosen, ASGI was needed to cooperate the asynchronous routines in the application and the server. For server, Hypercorn was picked for its first-class support for Trio. The application was built on top of Quart, a microframework similar to Flask but for ASGI, for its flexibility.

Templating Language

We use Jinja2 for templating, which is the default choice for Quart. It provides us with various tools that help secure the website easier. For example, it allows HTML escaping [jinja2esc], which helps avoid XSS injection.

Persistency

For persistency, there are two separate concerns: storing the system’s metadata, which is a collection of small chunks of plain text, and storing the files uploaded by the users. In the former case, RethinkDB, a document-oriented database, was chosen for recursive and less-structured data support. Such database, however, is performance-wise unsuitable for larger files, so IPFS, which is a distributed file system that provides similar abstraction, is used instead in the latter case.

By choosing RethinkDB instead of SQL, we do not have to worry about SQL injection or similar database attack. This is because the query language ReQL is not based on string parsing [rethinkdbdoc], but built as methods in the implementing language.

jinja2esc

The Pallets Project. “Template Designer Documentation”. Jinja Documentation (2.11.x). Retrieved 2021-01-18. https://jinja.palletsprojects.com/en/2.11.x/templates/#html-escaping

rethinkdbdoc

RethinkDB. “Introduction to ReQL”. Retrieved 2021-01-18. https://rethinkdb.com/docs/introduction-to-reql/#reql-embeds-into-your-programming-language