TLDR: a side-project Wordle Solver, and the GitHub repository (with files/lines specifically linked throughout the rest of this post).
A New Side Project
“Side projects are good and fun. So is Wordle.”
I always try to have a side-project in the mix. In software development it’s quite important to stay pliable (a la Tom Brady), adaptable, and stay current to the latest in software languages, frameworks, and hosting paradigms (not necessarily Cloud just for the sake of ‘Cloud’). It’s also important from a Product aspect. With a side project you (as an engineer/technologist) have total control over the direction of the implementation. The act of organizing/prioritizing what you want to implement can vastly help in your professional life where there is not as much control over the direction of Product (but on your own you will have recognized pitfalls, best-practices, or tools.) And the value goes 4x when you collaborate on a side-project with 1+ other people.
Wordle Trie Search
“Using less electricity is good.”
One day my former roommate from college (Alex, a very bright computer scientist) sent me a text with a link to his Github repository. He had a very advanced start on a Wordle guess validation algorithm, implemented using a recursively traversable trie structure containing ~all/most of the English words in the 5 character space. (What’s nice about search trees is that search operations are much more efficient than a naive/linear approach.)
Immediately I’m mentally committed. This Wordle thing had taken off, I had played it a couple times and I loved the idea of being able to work with Alex again and build something in the Wordle arena.
Updating the Algorithm
“He will win who knows when to fight and when not to fight.”— Sun Tzu
Alex had the algorithm at an 80% complete state. Though we recognized it was not using all the information of a guess which had a correct letter but wrong location. This code change/commit fixed the algorithm and would preclude unnecessary traversals of the trie.
For the Internet
“Real artists ship.”— Steve Jobs
(No I’m not claiming to be an artist. Just a technologist.)
I didn’t start this project, so I went looking for how I could bring extra value (i.e. enter a space for implementation that wasn’t being served yet).
Software is useless unless you have a channel to distribute it. That’s why the Internet is so valuable. Professionally I was already very familiar with the Java Spring framework, so I committed myself to creating a REST API to expose the underlying algorithm.
I created a Spring sub-project within the same repo, and referenced the algorithm and supporting files using symlinks which actually worked with the build! I thought this was a neat way to include Alex’s code. (I don’t know if I would recommend this approach professionally, it’s a little hacky.)
A nice addition by our third collaborator, Tyler, brought in some github workflows driving some unit tests. This helped identify if anything was broken by a feature/bugfix branch. Bonus: the unit tests in the ‘sub-project’ Spring application could be run consecutively after the root level tests.
For the Internet, take two
Wrapping the algorithm in Spring was not the correct idea. I had not thought through on how I wanted to host the application. An executable jar could have been compiled, but would have needed a virtual host or container to run on. So instead I spent a weekend to wrap the algorithm a second time but using the AWS Lambda Handler so it could be run serverless. (This could cut low-traffic hosting from $20/month down to about $2.) Also some AWS ClouFormation automation helped (from an AWSDocs repo) with the iteration and deployments. Though I manually integrated an API GW to the Lambda.
“If there’s a ‘trick’ to it, the UI is broken.”— Douglas Anderson
A little Bootstrapv4 CSS can go a long way, visually. I’m not a front-end developer but being able to sling together some bare HTML, Bootstrap, forms and JQuery:ajax makes possible a lot of webapp creation.
I also included a fun animated background from a codepen project.
The HTML page is completely static and I uploaded to AWS S3 and aliased a Route53 record for a domain I own.
Lastly, it’s not quite a security thing (rather towards exclusivity), I modified the application to include an Access-Control-Allow-Origin in the header for every request to the API/algorithm. This will instruct browsers to stop other websites from using my API, though anyone could curl against it if desired. Or the repository is public, someone could deploy their own Lambda!
Thanks, and Wordle on!
can we get one for SWordle? 😀