This post refers back to my COLOBackcountry project. The project takes advantage of the standard Rails MVC pattern to serve up some of the content, and relies on an internal API for the rest. The app basically has a few static pages (main/index, about, etc.) and show pages for the individual ski routes. The pages are rendered in the normal way and the map data are pulled in from a GeoJSON API. This gives the app a very modular character which will lend itself to breaking the app down into a service-oriented architecture in the future.
General Architecture and Design Considerations
This app has only a few controllers and only a few pages. In order to separate concerns, I ended up building several POROs (Plain Old Ruby Objects) for various data processing needs such as geospatial operations.
One problem I came across was where to put these POROs. On the one hand, they are somewhat akin to models, and on the other, they are their own sort of thing and do not inherit from
ActiveRecord::Base. I ended up keeping them in
app/models/, but in the future would consider moving them to
lib/. I turned my GPXParser into a gem, despite its measly single class.
There were a few chalanges around serializing the ski routes into GeoJSON. My solution doesn't seem terribly elegant, but it does work well. Basically the serializer does a lot of string manipulation, iterating through each point of the polyline. It works, but I would like to figure out a cleaner method, even if that just means adding a layer of abstraction.