Course:CPSC312-2023/NotesApplication

From UBC Wiki

What is the problem?

Sometimes writing on paper can be a hassle. We have created a convenient and versatile notes application that allows users to quickly and efficiently jot down their thoughts and/or take detailed class notes – all in the terminal.

Our goal was to determine whether Haskell is suitable for building user focused apps that involve user management, a database, and an API-like structure. More specifically, we were looking to see if we could replicate the features and user experience of popular notes apps (ex. Apple Notes) within the terminal, all while structuring the codebase in a way which separates the code (as it would in large projects) between the client-side, server-side, and database logic. By trying to replicate how real, production level apps are made, we would be able to test if Haskell is suitable for such tasks.

What is the something extra?

Our main key feature is a full integration with a SQLite database. We have stored this database locally within the project (see: notes.db) and used it to store the users and their notes. On top of this, we were able to add:

User management: users can create an account, login, and store all their notes within that account

Search functionality: search for notes containing any search terms or phrases

Note stats: users can get the word count and most frequently used words in the note

What did we learn from doing this?

We have learned a lot about Haskell and how it should be quite suitable for creating the backend of scalable, user-focused apps. Building a notes app with many features, integrating it with an actual database, and replicating the structure of large scale apps was definitely possible and quite intuitive to do in Haskell.

We were able to integrate with a SQLite database quite seamlessly using the sqlite-simple package. This made it possible to run SQL queries easily and efficiently to interact with the database. Sometimes it is a slight challenge to convert between the types of the objects stored in the database and how they are represented in the code, but that proved to be fairly simple with the use of this library. Furthermore, structuring the code with many distinct, single-purpose modules was actually quite beneficial (even for a smaller scale project like this) because it helped us organize our code, catch bugs (by splitting up logic), and easily make changes to the code (ex. adding a date field to the Note type) as needed. Also, writing more computationally heavy code (ex. finding most frequently used words) was possible to do in a more efficient manner due to the lazy computation of Haskell. For these reasons, we learned that Haskell is quite suitable for such applications on the backend.

On the other side, we initially wanted to create a web app where Haskell would serve the frontend as well, but that turned out to be quite a bit more complicated than something like React. We found that there isn't much built in support and there aren't many libraries/packages that are really suitable for creating modern-day web apps (as compared to languages like JavaScript) and thus concluded that Haskell is likely not the best option for the frontend of a Notes app. We instead made the app fully contained in the terminal, which worked out quite well and helped make the app quick and easy to use.

Although we were able to complete most of the core features that would be included in a notes app, given some more time, we would definitely want to extend our app (which shouldn't be too difficult due to the organized structure of the code). Some more features we would like to support include password-protected notes, folders, tags for notes, export to PDF/.txt file, and more. Given what we have learned about Haskell, we are confident that these features could all be added to the app.

Overall, we conclude that Haskell definitely could be used on the backend in large scale projects and would be able to handle many of requirements of something like a Notes app. Although Haskell does not seem to be quite suitable for the frontend (i.e. creating web apps) and lacks extensive library support, it definitely has a place in the backend where it makes writing and more importantly updating code quite easy.

Submission

https://github.com/KavpreetGrewal/haskell-notes-app