In the spirit of never stop learning I want to start a new project. It has been a long time since I learned anything new related to programming and I’ve been wanting to dust of the rust and build something for a while.
Background
It seems like every time I go to learn a new programming language I use our families private online photo album as my thing to redo. Over the years it has gone through a number of iterations. Each version in a new language went through a few versions before scrapping the old and re-writing it in a new language.
It started out as a Classic ASP script that was pretty easy to use. You would create a folder and dump images into it and it would render a simple gallery to look through them.
From there it went to a Flash version where it used XML files to store information about the images and then display them in a flash format. This is really where the organization started coming in. We created collections of albums which were usually simply a month, but not always, so something like “September 2019”. Inside that collection there could be a number of Albums. Examples of these would be “Noahs Birthday”, or “Back to School”. Then each album would contain images which had a couple fields of information like a title and note you could add to each one. This structure has carried over.
The next version was to move to PHP with a MySql database to store information about everything. This one stuck around for quite a while but re-written a few times and had new features added to it. So lots of iterations. This was one of the tricker ones to get sorted out because I had to write an importer to parse the XML files and insert them into the database.
One mistake I made here as well was to store all the images into one directory. I really liked the idea of the first one where things were organized by folders so that if I just wanted to browser through them the folders had meaning and I could go through them just on the file system. So if I backed everything up and didn’t have a web server to view things on I could still see and have some understanding of when and what the images were from. So in one of the PHP versions I corrected this and wrote a script to go through and create folders based on the Collection and Album names and move all the images into them.
The last iteration which has somehow hung around and kept working for more years than I intended was written in Node.js. It is pretty rough and I kept the MySql database to store everything in. The code for this is not ideal but it is working.
Besides learning some about Node.js I also added some new features which have been useful. I set things up so that when uploading they were automatically stored in shared Dropbox folder so things are automatically backed up there and in the folder structure I mentioned before so they can easily be viewed with out the app. The other fun addition was the automatic creation of different image sizes in a separate folder and sort of a cache. When an album is viewed it checks each image to see if there is a thumbnail version in the cache folder to show and if not it generates one and saves it. It does the same for a more medium size view of the image while keeping the high resolution original to have access to. The last thing was a rudimentary search function where it can search the title and comment fields and show all images that have the term you searched for in an exact word search.
Project outline
For this project it kind of exploded in scope really quickly when I started thinking about it. The first thought was that I wanted to learn to create an iOS app and figured the photo album would be a great way to do it. I figure the best way to do that would be to have an API for the photo album that the app could talk back and forth to.
The current version doesn’t have an API and needs a refresh anyway so I decided I’d start there and re-write it still in Node.js but with a bit better understanding of how it works now and have it be API driven as well. I’ve never created anything API driven before and so it introduces some challenges. One of them being how to secure things properly.
Another thing that has been on my list for a while is to learn React, so why not use it in the re-write. I’ve been using MySql for a long time and I have a good understanding of it, but I was never happy with the database code in the current photo album and so I’ve decided to look at a NoSql database like MongoDB. With that it led me to find Mongoose as well. I’ll have to create a migration script as well to move things from MySql to MongoDB.
This is going to be a pretty big undertaking and I have no illusions about how long it will likely take. Right now I’m still in the information gathering stage and gathering learning resources. I’m going to start with creating the API and then build the web version to interact with it. I’ll start with a blank database and then migrate over the existing data. Once that is all working well I’ll move on to creating the iOS app. Likely in parallel I’ll spend some time learning about iOS development and going through some tutorials.
I’m not going to set a deadline for myself as life is really busy but it will be a slow road. I plan to blog about the progress and start a GitHub Repo to store things in as I go. If you want to follow along I’ll be using the tag #project-photo-album