Ask and you shall receive
Oct. 9, 2018, 9 a.m.
I noticed last friday while deploying new version of Makro to production that the codebase is now over 10 000 lines of code which is a personal record of mine. I hadn't really thought about the size of Makro that much lately. I've been just furiously developing new features and trying to deploy them each friday to production. Each friday being twice in this case. :)
But yeah. It sure has grown and gotten a lot bigger than I initially thought it would get. And for me that is really nice. I wasn't so sure if I'd ever manage to make a personal project go over 10k LoC. And it is going to get even bigger still.
So last friday I deployed Q & A to production like I said and it ended up being quite nice. The functionality of it is heavily inspired from Quora. But even though I did deploy it it's not ready yet. I have to add possibility to edit and delete stuff and make all user votes, comments, questions and answers to be show in profile page and so on. And on top of that I want to split the profile page in to pages so it isn't so cluttered and to avoid unnecessary API calls.
But back to the Q & A service. So far when I've been developing new features or fuctionality I haven't had to do that much thinking about how to implement it in the backend. It's been rather basic; handle the request, get data from DB and return it frontend. This time it was a bit different because I wanted user to be able to vote on answers and comments, comment on answer, reply to a comment and I wanted it to remember what the user had already voted.
At first I thought I'll store both the comments and votes on the answer (MongoDB) document but then I read that it will cause some performance issues if the he arrays where I'd store comments and votes would be updated often. And eventually the document would exceed it's maximum size which is 16mb if I remember correctly.
Then I made a separate collection for comments and then a new one for votes as well. Now each comment is stored as a single document which contains the postId that it is related to and if it is reply to a comment it will have replyTo key-value -pair that containes the username of the comment author that it is a reply to. The votes work quite similiary. Vote object is contains postId, userId and the actual vote.
Now both the comment and answer contain only pointsTotal which is updated when the user votes something.
In the future I probably will split the Q&A -part as it's own microservice just like the authentication part of the app. This is because of the sister app I'll start developing as soon as I'm done with this. Done in this case might mean that when I'm done with the profile and admin panel page redesign and with the missing features of the Q&A service.
And a couple other new small-ish features that I want to add. To be honest I'm not in a hurry with starting to code the sister app since I am enjoying this way too much and I want this to be a great (free) replacement for services like MyFitnessPal, FatSecret and Sulamo.