Zephyre

What is it?

Zephyre is an opinionated ruby MVC framework that makes it easy to build small-scale projects. I built Zephyre (pronounced seh-fire) as a project that would help me learn the inner workings of bigger libraries such as Ruby on Rails and Sinatra. I have made Zephyre available as a Ruby Gem here, and it has 1,245 downloads at the time of writing. Zephyre is open source, so anyone wishing to contribute can do so on GitHub. This project was one of those that really pushed me out of my comfort zone, forcing me to create a Ruby gem, which is something I had never done in the past. Doing so puts you in the mindset that forces you to think of how a developer will interact with what you've built, which is pretty different from the standard way of working where you think of the user interaction. Throughout the process of creating the project, I had to consider things such as route handling, resource distribution, and ease of use. In simpler terms, I had these questions that I needed to answer while building: How can the developer define their own routes? How will I enforce a project structure that is clean and make sense? What happens with CSS and Javascript files, which aren't explicitly defined as routes?

In order to address all these questions, I did a few different things. First, to address the issue of project structure, I thought about what the tried and true methods were. Rails was a huge inspiration here; I really liked the way they walked the user through setup. Although it is possible to set up a rails application from absolute scratch, doing so requires memorization of filenames and locations that Rails uses by default. Instead of forcing the user to do so, Rails conveniently provides command line tools that allow the user to generate a project within seconds. I saw this as an obvious way of enforcing an application structure in the Zephyre framework, and so I implemented command line tools as well. Typing zephre claim example_project will generate a Zephyre application that is ready for the developer to work with. After generating a project and starting the server, visiting localhost:9000 will show the developer this page:

Route handling was also inspired by rails. I come from an MVC background, so having a route point to a function within a controller was the obvious way to go for me. The only issue with routing arose when the need for css and javascript files was introduced. Since the routes for those files were never defined, the developer had no way of loading those files into their application. A solution to this issue was creating a dedicated directory within the project that would contain all the external resources for the framework. I then created a helper function within the framework that the developer would be able to use in order to dynamically include these assets. Finally, I updated my routing logic to default to searching the assets directory if no pre-defined action was defined for a specific route. With this method, assets were successfully being loaded into the page.

One of my favorite accomplishments in Zephyre is that it includes the same templating engine as Sinatra and Rails do, which allows developers to write ruby code inside of their HTML code, allowing for much more powerful and dynamic web layouts. Zephyre is an opinionated framework, meaning it pre-determines a set of tools that will be available to the developer by default. The tools I chose to include were Bootstrap and JQuery, since they are in wide use and it is rare to see a website built without these two frameworks/libraries. In the future I plan to add Sass as the default CSS framework as well.

Who should use Zephyre?

Anyone who is looking for an MVC framework that is lighter than Rails, but still has enough helpers and abstraction that you can spend time building your app. I wouldn't recommend using Zephyre in a production environment because it simply is not developed enough to be used for production, and likely has security vulnerabilities that stem from a lack of completion. Zephyre is built for small applications and prototyping. Keep in mind that if you DO decide to use Zephyre, you should be comfortable with potentially breaking updates, as the framework will be going through iterations and changes often in its early stages.