Inspiration

I live on campus, but, I often work late in my dorm room and never know what's actually open. I would go to the Campus Center just to find that Forte Pizzeria is closed or that it is too late to head to GDS for a chicken fajita. Eventually, half a semester of this constant feeling of doubt led me to think up an idea of having a "status page" for NJIT restaurants on (and off coming soon) campus.

What it does

NJITFood does exactly what it says on the tin, it is a web application that shows what food is currently available at NJIT. It was designed to be simple to navigate, being only a single page, and to not require an external API so that it could hypothetically work offline and in areas of limited connectivity around campus (like in Cypress elevators).

How I built it

The site itself is a static webpage, hosted on GitHub pages, which makes an AJAX call to a static JSON file in the same repository. The reason for this is so that the JSON file will be cached, but so that the site's inner HTML content itself can be dynamically generated clientside.

I started by making the JSON file, which was just a listing of every restaurant and all of the hours that the particular restaurant is open. I decided to make this file manually rather than use Google Places or similar API's so that I can account for the hours that GDS is open but not serving hot food, for example. This also means that the site itself doesn't depend on external API's staying alive, and all of the data is in a Git repo, so it is crowd-sourced.

I wrote the initial parser for this JSON file in Python, as it is my favorite language to prototype in, and, once I had a working demo, I ported that Python to JavaScript to be run in the browser. Fun fact, the and keyword in Python is a && in most other languages, and, forgetting this caused me an extra half hour of debugging!

The interesting part about rewriting the parser logic in JavaScript second was that I came in today with next to no JavaScript experience, so the task of actually writing in the language came second to actually learning the syntax and idioms behind it.

Once the parser was written and working (it returns an array of generic objects that have the appropriate keys and values), I just had to append those entries to a table and render it. I wrote the front-end using Bootstrap 4, using Bootswatch's Materia (formerly known as Paper) theme, with custom CSS on top of it to stylize it for NJIT. The navigation bar uses NJIT Red, as does the custom favicon, which is a cross between a heart and a cookie.

Challenges I ran into

As I noted above, the biggest challenge for me was simply not knowing JavaScript while simultaneously writing a project essentially exclusively in the language. Beyond that, however, my second largest obstacle was trying not to make silly mistakes after staying awake for twenty-something hours. I don't normally stay up so late, and my only savior was the ACM tent and those Awake bars.

Accomplishments that I'm proud of

My biggest accomplishments for this project were writing working JavaScript code that actually behaves well and making a project that I think will benefit the NJIT community. I especially see this useful for night owls and commuters who don't have access to GDS and therefore rely on the other restaurants on campus.

What I learned

I learned today to not be afraid of JavaScript or asking for help. I came into this project with only a bookmark to an AJAX library and some front-end HTML experience, but, my JavaScript experience was limited by my lack of time or passion to learn it. I wanted to challenge myself by doing something out of my comfort zone, while allowing me to solve a real problem.

What's next for NJITFood

My stretch goal, so to speak, is adding off-campus restaurants and food trucks, as well as finding people to maintain this project after I graduate (which is still nearly four years away, so, I have some time!). I have a list of restaurants ready to add, I just did not have the time to verify the opening and closing times for each of them today, so I decided to just use the on-campus restaurants for now.

Additionally, I would love to use the Python version of the parser to make an accessible API for use in other applications. I currently have it running with Flask, a Python web framework, but it is not publicly accessible at this time.

Share this project:
×

Updates