This sounds a lot like a tool I built for myself [1], sans the database. I agree that Markdown + Katex with a local server seems like the right move for most technical people. Lots of things like encryption, backups, and basic text search can be done via other Unix tools. I also agree that the big win is owning your data long-term, even if you get tired of maintaining the software.