Hello Hello,
I used the past few weeks to renovate an old project of mine, and it's now ready for sharing.
It's a PDF creation service over the cloud. So the next time you need a site to generate PDF from scratch or overlay some content over an existing PDF (As you would when filling a form), You can have this available with some API calls to the service, instead of having to do it yourself. Server-less as the not so cool anymore, not so young anymore kids calls it. The service provides also storage for the PDFs, so you don't have to worry about that too.
And here's the deal. I'm not really gonna deploy it and make a biz out of it. At least that's not my intention now and wasn't 6 years ago when I last worked on this project. A different person might have...but I'm only here for the crafting, i'm afraid.
But that doesn't mean you can't. If you are interested here's the github link to the project. It's fully Opensource with an Apache 2 license which is very permissive: hummus services redux.
There is a live demo here - services.pdfhummus.com - but depending on how interesting or not it is to people I might take it off. It costs $$$ better spent fun and games.
And there's a really simple jQuery based web site I developed a few years back that implements form filling over this service, as an example. here's the code and this is the site - forms.pdfhummus.com. it's really old. doesn't even deal with dragging on yr touch device. Yap, you'll need a computer for this.
The service generation engine is built on top of my basic...but so far for my purposes powerful enough...layout engine called hummus-reports, which in turn is built on my hummusjs Node PDF lib, which in turn is built on my hummus C++ PDF lib. All open source, all free. Cause I can haha.
PDF files are extremely common. We get them as receipts from our services providers, we use them to share contracts, we fill && sign them when we submit a request to some bank or government branch or whatnot.
Well, if you got a project that needs PDF generation there's quite a few choices, and this one here is the one that says - You don't have to have a setup for this, just send a JSON description over and you'll get back a PDF. As simple as that. As an example (on top of the form filler I discussed) I once created a site for my Sisters business that allowed her to create invoices for her customer. Login and DB was taken care of by firebase, and PDF generation by an older version of this service....so the site was just static frontend.
There's documentation of what the JSON description can contain in the live site here or if it's not available you can find the sources here. If neither is convenient, there's the documentation of the underlying engine, here.
write text, including wrapping and placing inline images to flow with the text
append content from other PDFs
create overlay over existing PDF documents
encrypt documents with passwords
position elements dynamically based on other elements content to create tables and lists
This feature-set can be extended to support more things, based on what hummusjs can already and can be extended to do. like (again...not there...can be extended):
Parse digital forms, so you get a json of the values for a PDF
Get the text from a PDF, as a text file
Drop a password from an existing PDF (you'll have to provide the password of course..we're not doing hacking here...but you'll get back a password-less PDF) as well as Create/Change a password for an existing PDF, all based on hummus recrypt capability.
And many other tasks around PDF, built as a service rather than as a module to run on your server and take your precious application server time. And if you got multiple projects generating PDF files...well that just means you don't have to rebuild it.
There's not much of arch here, but what there is i'll describe. There's a frontend here, for the jobs management and a playground for one to test their JSONs prior to using in production, and API keys management.
There's backend to support it, and also implement API keys based access. So job generation in either way works off the same server. I could, if i'd want, make the generation functionality into a micro-service I can scale on demand, but for now that's good enough.
There's also a CRON job aimed at deleting files that are marked with expiration.
All this can be deployed to a Kubernetes cluster. Got XP on this project with Minikube for and Google's cloud GKE.
The DB for the service persists data about:
files generated from jobs
api tokens (used also for implementing the refresh tokens. access is jwt)
some auditing for the purpose of determining the users plan usage, like recording jobs created and files downloaded.
There's some side services:
Mongo DB used for storing the DB. did make a point to never send to the client and _id to avoid exposing that. bit of a security thing (though silly if the code is opensource haha). in case y'r reading the code and not understanding what's those uids.
AWS buckets. used for storing the PDF files. To my shame I didn't write a google storage alternative even though already 6 years ago i was deploying the project on google app engine (though I don't think they had buckets then), and I am deploying the project on their GKE now.
Google Recaptcha. used to secure login and signup from brute force attacks. You can turn it off, if you don't feel like dealing with this.
Sendgrid emails. Used for sending introduction emails to users signing up and notify site admin about them. You don't have to have this and this can be turned off easily. Google used to give free credits for them 6 years ago :( .
So if i don't mean to make a biz out of it, why bother. I have the old service code and nothing works there but why do anything about it.
Well very simple. I had the time. Just quit my job two weeks ago, and decided to take some time off. Away from people and their problems haha. I guess I could go to the beach. But I wouldn't mind some coding.
And then there's this code here of a server that's really old and I can reimplement it with more modern methods, and take this chance to close some knowledge gaps.
So, for instance, I did work with Kubernetes and had some minor exchange with ArgoCD, Kustomize and Terraform, but was always concerned about not knowing how to setup a cluster from scratch, as this was mostly at the hands of other devops. So I used this project to complete my knowledge there, and see that it's not too bad. The live service is hosted on GKE, and I created helm charts to deal with the deployments so I don't have to work hard. For local dev I used minikube to run a local cluster. Good fun. Didn't know much about minikube or helm prior...now I do and it's jolly good fun. Plus also how to create a cluster on GKE and hook it to my cloudflare setup and on to my DNS. so you can just go services.pdfhummus.com and it just bloody works (If i hadn't taken it down).
For my local setup I even went as far as setting up a cutesy EFK (Elsatic search, fluentd, kibana) just so i can easily track logs of the service. And Prometheus/Grafna...though frankly if I make this a live project I'll use datadog or something for all of this work. They do a fine job there and I don't mean to repeat it. But i reckon i'd have to pay...and this EFK setup is free for my local stuff...so good enough. Again..things i didn't know much about...now i know a little. Least enough to get good logs.
oh. The form filler sample site is sitting on bucket in aws, delivered through a cloudfront distribution (to allow https, which on a bucket only setup is not available. plus it gives cdn caps) and on to my cloudflare setup for DNS.
I also, for no good reason, never got around to writing a server in typescript, but just regular node (in the JS realm, that is). I got used to writing typescript for scripting and frontend, but never got to write a server with it. So now I did...and ok...I guess there's an example available for me now if I ever have to do it again. Bit bummed down by not being able to generate openapi from it like I could with fastapi over at python's...but it's not a deal breaker (nothing that's gonna make me use tsoa. you'll have to do better than that to get yr dynamic openapi generation from me. i'd rather build it in postman for a much smaller effort and retain my lovely middlewares style of writing and combining routes functionality thank you). Anyways, had some fun with setting this up. Wasn't working super nicely with module aliases (@lib/whatever) but now it does and now i got an example. oh - and the vscode setup to debug all his.
Over at the frontend I replaced the old Angular1 code with React, which was nice. Used a lot of sass back then, so replaced it with styled components+classnames+nesting, which provided me with the same convenient UI development method plus the occasional ability to write reusable components as styled components...when i choose to and when it's right. So a bit of getting practice for this method.
Oh..The old site used Boostrap for UI. So to make the transition easy...and allow me to copy the design, I implemented the UI with React Boostrap, and not something fancier as the kids like to today.
Beach time! Well, for the very least it'd be nice to not having an itch to scratch like this project around so I can really enjoy this time off.
I will probably be looking for my next workplace/project/thing in 2 months. So if you got something interesting that you think I can help you with, lemme know. For the very least i'll write down your contact details and approach when I'm done with "doing nothing". Got my github, here's my linkedin.