A week of dev #3

Docker

Finally, I successfully setup everything for building docker container for Cyca and published it to the Docker Hub, and added an additional GitHub repository to provide you with examples on how to run this image.

It’s far from being fully satisfying. I’m not really fluent with docker – yet – and I guess the learning curve is a bit steep at the beginning, but once I will be used to it, it will surely get easier over time.

Websockets

In an effort to make Cyca more lightweight, I replaced laravel-echo-server with laravel-websockets. While the former requires nodejs, the latter is a plain-PHP implementation of a websockets server. Furthermore, it’s fully compatible with the Pusher API.

This replacement has many implications, including but not limited to:

  • Final javascript weights 30KB less
  • The docker image is a bit more simple to build and lighter
  • You can easily use Pusher instead of the local server

Optimisation

I’ve been working on optimising routes and controllers by removing what’s not currently – or planned – used. I’ve then been using the whitelist feature of Ziggy, the library to provides routes from Laravel to the javascript frontend, to load only the necessary routes.

It’s not a « reducing file size » kind of optimisation, but it produces less code, it removes code where it didn’t belong, and it makes routing a bit clearer, regardless we’re working on the backend or the frontend. It should also improve app performances a little.

I added APCu and opcache to the docker image. While the former is « just » a « new » cache driver available to Cyca, the latter increases php’s performances. In fact, it’s recommended by the PHP team in their docker image. And I can confirm: Cyca is faster than ever now ! This update gave a HUGE performance boost, especially when listing feed items ! I’ve always used opcache but my usual projects at my former employers were not SPAs, available from outside the internal network, or running on docker, so the feeling was less obvious. But here, with Cyca, it makes an amazing difference !

Credits for this integration goes to Monica’s developers: I use Monica, and, thanks to Free Software, their Dockerfile contains everything I needed. It was one of the great sources of inspiration that allowed me to publish Cyca on the Docker Hub, so, once again, thanks to them !

Finally, I’ve added a feature to automatically delete read feed items after a configurable amount of time. Everyday, Cyca, will check for feed items that were published earlier than 30 days (by default) and that are marked as read. If all users following corresponding parent feeds have marked these feed items as read, they will be purged.

Bug fixes

Despite overhauling the « next unread feed item selection » routines, I still had a tiny little bug: if you marked read the last document containing unread feed items, this document was still selected if you were in the « Unread feed items » folder, where the expected behaviour was to unselect this document.

And Cyca went light !

Here comes this week’s – another – headline: themes are coming to Cyca with the 0.3 version ! I let you read the corresponding announcement for details. It has been a lot of work, for the biggest commit to date. While I haven’t optimised compiled CSS as much as I wanted yet, I’m pretty happy with the result. Besides, the work done so far will surely help making things lighter later.

After publishing this big release, I wanted to dig deeper into optimising the CSS, and after playing a bit with tailwind’s purge options, I finally achieved my goal: shrink down resulting CSS to a ~10KB file.

What hadn’t been done – yet

While I initially wanted to upgrade Vue and Vuex to the next versions, I decided to postpone until Cyca’s CSS satisfies me. This upgrade will be anything but small, and I want to focus on the javascript when doing it. This week was about CSS and Docker so maybe now I can concentrate on that.

Tiny bits

During this week, I’ve also fixed and/or improved a lot of small things, mostly related to docker, documentations and queues management. You can see the complete changelog here.

There is, and always will be, room for improvement. But I think Cyca’s codebase is getting increasingly saner: I like what I am doing and it’s a good sign. It’s getting really fast, really optimised, and adding features shouldn’t be a problem on the middle to long term. It’s a particular feeling, as a developer, and generally speaking, as a creator: I think it’s not very common to be satisfied with your own work, so when you do, you’re getting optimistic ! You work better, your mood is better, and so on. I like being in this state right now, and I hope it will stay that way for a moment !

What’s next ?

For next week, after providing both dark and white themes, I’d like to create another, more colourful theme, and fix some of current themes issues at the same time. And I will try to reduce to the bare-minimum the code needed to be duplicated across themes, maybe with some kind of inheritance but this specifically may not be available next week as I’m absolutely not sure how I want to do it.

I also want to overhaul the pages related to accounts. While they look nice (at least, to me) when displaying very few information (like the login page), they really are not suited for long content (like the « My account » page) and won’t scale well.

One last thing…

I got rid of Wordpress and moved to a static site powered by Hugo. My first intention was to use something that can be used quickly, but in the end, it’s utterly hard to make Wordpress work correctly. Not to mention all the clutter that comes with it. I seriously don’t understand how it can run more than 25% of the web…

It still need some work but it’s operational.