I write my own web desktop OS for 3 years and this is what it looks like now
Tags: webdev, go, linux, ux
Published: 2021-04-04 15:04:41

This is a story about a poor student who just want a storage solution for his musics, video and photos using a Raspberry Pi. 

![2021-04-04_21-35-31](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1g2j9ssl40jr5jqd4kfr.png)
 
{% github tobychui/arozos %}

## How it looks like when it started 
Since 2016, I have been working on this project mainly for storing music and video files so that I can play them during my extra time between lectures in university. This is what it looks like back then.
![ArOZ Online Preview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uv24pddm1ylfoto6wpys.png)

The old version use PHP5 and later upgrade to PHP7 with Apache server as back-end. It didn't have a database connection although MySQL is installed on the same host that host the system. The system is glue together with a VB.net binary that scan and buffer the song list in background and the php script just render the list as a list of stream-able music files. 

The source code can still be found on [Github](https://github.com/tobychui/ArOZ-Omega-Online) (But please don't use it)

## Migration from PHP to Go
After using this system for a year or so, it started to get slow. One of the reason is that I am putting more and more large files into the system, and php itself cannot handle as many request as I needed to make a web desktop system native like. This is most noticeable when I am trying to copy a large file from one location to another location on disk. Hence, I must make a switch to another language. After some research, I decided to go with Go. The system, original named ArOZ Online System, was also renamed to ArozOS for simplicity. 

# How ArozOS looks like after 3 years
After 3 years of development, it basically recreate the native desktop experience on the web. Let starts with the desktop!
![2021-04-04_21-07-47](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gaw2eq704xyqxa69y9xy.png)
 

## Desktop
The desktop basically recreate a mix of Ubuntu 20.04 as well as Windows. You can see a Ubuntu GNOME like calendar with notification bar.  
![2021-04-04_21-07-52](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czys7lt3dojx0o6b6uhr.png)

You can also find a quick menu on the top right hand corner for powering off / restart your host (which can be disabled with startup parameter) and a shortcut for full screen and system settings
![2021-04-04_21-07-58](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ufwr2pasm26fnl5samiz.png)

Just like Windows, it is really easy to create new items on your desktop as well as changing your desktop wallpaper. 
 ![2021-04-04_21-08-04](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/izlsrricsn91zxf5sgv9.png)
 
![2021-04-04_21-08-19](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d2qgmphil9cr7u1v72wx.png)

The start menu is kind of remixed style of both world too.
![2021-04-04_21-57-11](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9vvua14byfqlujn5l77e.png)
 
And of course, my favorite rename UX ever: ![2021-04-04_22-56-57](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o5o0190f9924m5hj4ztq.png)
 (No pop-up box is just amazing)

## File Manager
After some period of time, I am starting to upload other stuffs to my system. The best way to provide a generic interface for all types of files is of course, a File Manager. So I build one into my system!

The File Manager on top of my web desktop system contains two viewing mode. The list mode and the grid mode.

![2021-04-04_22-00-40](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lkavkb5tt50akknax2qr.png)
 
![2021-04-04_22-00-27](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1634hpt7vi42yx3a1ued.png)

In Grid Mode, the File Manager will try to render everything to generate a thumbnail for easier file identification. It works on many different file types from video, music or even 3D model files.
![2021-04-04_22-58-36](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/au6m47coeesawxn61e5t.png)
 
 

The File Manager originally didn't have a way to sort files. As the number of files uploaded into the system are growing larger day by day, this was soon added to provide different sorting modes to make finding a file much easier.
![2021-04-04_22-01-29](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/txjnm9m28lj8zb8pga54.png)
  
And afterward, search mode (with the magical regex support of course!) was added to make finding files in a large folder much easier.

 ![2021-04-04_22-01-35](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tbk3svy049ilmvnirff2.png)

![2021-04-04_22-07-12](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nthkacjhg0mz5loqmwys.png)

Btw, it also got a dark theme mode for finding your movie at night.
![2021-04-04_22-07-48](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o1rqlrvrj0ok86b7o2zv.png)

### File Operations
The File Manager provide many basic file functions. You can find all of them in the context menu by right clicking any files or folders.
![2021-04-04_22-08-59](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p94k6swvgfv2o9gga5rn.png)
 
Just like a native OS, you can choose the open a file with a given WebApp with a default app selector.
![2021-04-04_22-09-09](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/px5rasyj0zv1ruk4mbza.png)
 
To make it much easier to use, I also implement drag & drop style of file operation support. So you can easily drag a file from one File Manager window to another and the system will start copying / moving the file for you.

![2021-04-04_22-09-45](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e7zu8dzrau58qqn8lhj1.png)
 
As Golang provide async way to handle request using go func, it makes it much easier to handle large file operations without freezing the whole system. The progress is powered by websocket and the backend will constantly return the file operation progress using the websocket connection.

### File Sharing
Once a while, I would want to share (large) files to my friend. In that case, I can just use my own Web Desktop File Manager's share function!
![2021-04-04_22-18-40](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/514vf96xoagxg2356k73.png)
(This is just an example. Do not give your friend links starting with domain named localhost) 
 
Then my friend can download the file directly from my web desktop cloud system. Very convenience right? 
![2021-04-04_22-20-32](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sxk4aohjuyvk8plpisbb.png)
 
## Back to basic: Music and Video
This system was originally created for Music and Video streaming. So after 3 years, these function still exists and even get better then before. With the latest PWA technology, the Music module now become something like this
![2021-04-04_22-23-16](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/omufy1ygiq2rhml2fzgo.png)
 
This interface can also be installed onto an Android phone as WebApp and even the player can be shown in native Android notification (which is call [mediaSession](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession) btw).
 
![2021-04-02_22-31-12](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cqb0ghaei6kc2grymg6e.png)

The video module also get updated and powered by latest HTML technology, it can playback video with streaming mode, making movie streaming possible anywhere with a computer and browser.
![2021-04-04_22-27-44](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yz744grv0pp1qw713enb.png)
 
## System Settings
### Basics
To manage such a complex system, a complex system setting menu is needed. We try to make it easier for anyone to manage the system so we go with the category approach that categorize system functions into different types. 
For the most basic one, we can see CPU usage as well as host hardware information from the setting interface.
![2021-04-04_22-29-58](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gglg5lkgk2csmdcgzts5.png)
 
![2021-04-04_22-30-38](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m9pv2wnznt41m37pxrbq.png)
 
### WebApps and Subservices.
Of course, as a web desktop platform, I also make an interface for those who need to manage their apps. Here is a list of apps I have written so far.
![2021-04-04_22-30-51](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6pz4h11foek4x3ytttfc.png)
 
 
It doesn't make sense to ask the user (aka me) to change the code every time I want to modify any web apps right? 
So I decided to split the webapps into two parts. WebApps are those only require basic permissions and do not interact with the host OS. They will be run inside a sandbox created using ECMA5 VM called [Otto](https://github.com/robertkrimen/otto). The other type is called Subservice, in which it will need extra permission to interact with the OS and require higher level of access to the backend file system.  

You can easily install and uninstall webapps using git link or zip files uploaded to the web desktop system.
![2021-04-04_22-31-31](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kja9rsx800wywqy1y6jt.png)

Subservices can only be toggled on / off. If you want to make changes to subservice (which might effect system stability), you have to do it with the terminal instead. Here, showing 3 subservice I use most of the time.
![2021-04-04_22-31-16](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ri49q7miwk05soerhw8.png)
 
Of course just like Windows, you can choose what application to open what file extensions using this menu.
![2021-04-04_22-30-59](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r41lqvd7r79pmqnvf2k7.png)
 
### Network and Connections
The web desktop can be accessed via FTP or WebDAV. So to make it easier for me to enable them only if I needed to, I make an interface for them in the System Setting module.
![2021-04-04_22-37-53](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w72n7ocx7dh3l8a8k9yj.png)

![2021-04-04_22-37-58](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gi6l12t0yinftznxf6ij.png)

Mounting WebDAV folder on Windows without TLS but with user isolation is quite tricky. I got a few hack to make it to works. But this makes the connection process a bit complex and difficult.

For devices with WiFi, you can even change the device WiFi connection via the system setting interface.
![2021-04-04_22-40-54](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mlxn40i4mz2adj3kvdse.png)
 

If you enabled uPnP in the startup parameter, you can also setup custom rules in port forwarding. So you can expose more ports for other web services running on the same host.
![2021-04-04_22-41-00](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ke9zravetqwy39d9d0ex.png)

### User System
First of all, a basic user setting page for changing user icons and password
![2021-04-04_22-40-09](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dhcdnqb7x27x645rcz4x.png)
 
Sometime my friend with no disk space will "borrow" some of my storage places to put his file temporally. In order to isolate users in the system, I created a structure that allows each users belongs to a permission group and then by assigning permission to the group, I can limit what a user can access. Then, I build an UI for setting up those complex group systems.
![2021-04-04_22-40-14](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uprujgx5rtj6bjk5gyf7.png)
 
I also make an UI for enabling the public register function, just in case my friend don't want to let me know his password for creating a new account.
![2021-04-04_22-40-20](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ozus2w0fghh04u2z87l5.png)

### Storage Management
Finally, to manage so many files, we will need disk manager. The System Setting have build in tools to visualize disk usage, help you find space in disk by locating large files and even DISK SMART thanks to a few PR by a user that actually use the system as his NAS OS.

![2021-04-04_22-52-05](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hbiw7rmdq53jhtaryuly.png)
 
![2021-04-04_22-52-11](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a62iwlr0yed40t91y3dz.png)
 
![2021-04-04_22-52-19](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zi31kbgf3gtrznzmlh3e.png)
 
To assign storage devices to permission group, a storage pool architecture was designed to fit this purpose. I doubt this system is the most basic way to implement this feature, but this can leave some space for future system expansion if I want to connect other cloud drive like Google Drive or OneDrive to the web desktop system. 

![2021-04-04_22-52-24](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pbwat5bnla3220odwsqx.png)
 
It also got an advance function that allow you to format a partition just like what you do on Windows Disk Manager
![2021-04-04_22-54-38](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ghnf9rojstrmzf3dot20.png)
 
## Others
There are so many other WebApps that I want to share but due to time limit, I can only show you the most basic one. Maybe later, when I got the time, I will share with you more WebApps I wrote for this system. Here are some screenshot of them![2021-04-04_22-58-50](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sthudz3mmsq7998eu283.png)
 
![2021-04-04_22-58-12](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fvkfs97g1kkrzzvfj92f.png)

# Know More
Feel free to leave a star if you are interested in this project :)
{% github tobychui/arozos %}