Here I have developed the PhotoAlbumApp. Considering the requirements and that the project is a social photo sharing application, I decided to build the backend web service on Python and postgeSQL. I developed the web service in mind of keeping it simple, low boilerplate code, easy to test, and modern. I used the Tornado framework for the web server, SQLAlchemy as the object relational model, and dependencies are handled with virtualenv (deploy the isolated python environment with 'source venv/bin/activate'). The dependencies can be viewed in the requirements.txt file. The service is built similar to a model-view-controller design. The models are represented by the models.py file, the controllers rely on queries.py and server.py, and the view is mainly the json that is returned through the requests.
The models.py code contains the logic to map python objects to the Users, Albums, and Photos PostgreSQL tables. The queries.py code contains the methods that grabs the necessary data from the database and returns the rows as objects. The server.py code implements the RESTful API and is what runs the web server (using the command 'python server.py'). To setup up the database the user must first set the database connection string in settings.py file (ex 'postgresql://test@localhost:5432/photoalbums'). The user would then create a database called photoalbums using command 'createdb photoalbums'. Then run the command 'python models.py', which will create all the necessary tables in the database. The user can then start creating photos, users, and albums to the database using the API. The user can also choose to populate the tables with the photos and albums json data, by executing the POST request '/photoAlbums/init'. This request will run a method that parses the '/json/albums.json' and '/json/photos.json' and adds the entities into the database.
Testing was conducted through the use of the Postman application. There I tested running the API by running the different CRUD methods that I designed from the code challenge requirements.