Over a million developers have joined DZone.

My Forkable Base for Building Apps That Run 100% on Github

Running your own API on Github is an interesting idea. This API evangelist shows you how to do it and invites you to use some of the tools he's already created.

· Integration Zone

Is iPaaS solving the right problems? Not knowing the fundamental difference between iPaaS and dPaaS could cost you down the road. Brought to you in partnership with Liaison Technologies.

GitHub provides a very powerful platform for developing applications. When you use the base GitHub functionality in conjunction with Github Pages and the Github API, some pretty interesting approaches to application deployment emerge.

I learned this approach from Development Seed while working with the White House to open up data across federal government agencies, but it's an approach I have evolved and improved upon while developing what I am going to call GitHub micro tools.

My GitHub micro tools run 100% on GitHub, using GitHub Pages as the front-end, the GitHub repo as a backend, and the GitHub API as the communication between—with GitHub OAuth as the security broker of who can put the application to work.

I needed to use this approach across several different micro tools, so I thought I'd create a base template that I can use as forkable base for these tools I'm building while also sharing the approach with others.

Apps Running 100% on GitHub

I like my apps like my APIs: small and reusable. Building applications that run entirely on GitHub makes sense to me because it is focused on developing apps that anyone can fork and put to use under their own account, relying on GitHub to do all the heavy lifting and cutting out the middleman (me). Each micro tool runs as a GitHub repository, which comes with all the benefits of GitHub like versioning, social coding, issue management, and much more. You can fork my project on GitHub and begin using it in your Github user account or organization.

GitHub Pages as Application Front-End

One of the interesting features that GitHub provides with each repository is the ability to launch a simple static site using GitHub Pages. I use these static project sites to run all my API projects and it's something I have been evolving it to be a front-end for this approach to providing micro tools. GitHub pages provide a simple place to put all my applications where I can store and manage in a very static, secure, and stable way (well, the security and stability are offloaded to Github).

Static Jekyll Application Front-End

Jekyll provides a simple, static way to help tame the front-end of the applications I am building. The static content management system provides tools for managing the look and feel of each application and the pages within, and allows me to have a blog if I want. Additionally, Jekyll provides a YAML and JSON core, which when combined with Liquid and JavaScript opens up to some pretty interesting opportunities for building applications.

Github API as an App Connector

With the base of an application, I am using the GitHub API as the connector for reading and writing data and content to the base GitHub repository for this application, in addition to relying on the native features available in Jekyll and Liquid. The API allows any application to access its underlying data store when a user is properly authenticated using a GitHub personal OAuth token.

Github OAuth for Authentication

To allow this application interaction to securely occur, I am relying on GitHub OAuth as the gatekeeper. For this example, I am using GitHub personal tokens retrieved from within any GitHub account instead of using a proxy or service like OAuth.io because I want this solution to be forkable and self-contained. Your tokens will not give you access to this application when it exists under my GitHub account, but if you fork it, your tokens will give you access to only your forked version. All you do is pass a token into this page using ?token=[your token here], and the API will allow for writing to the underlying repository.

Cookie.js to Store the OAuth Token

Once the OAuth token is passed into the URL I use cookies.js to store the token for use across all potential pages of a micro tool. This approach helps prevent it from being included in any links and passed between pages. Once each cookie expires, the user is required to pass another valid token in through the URL to set the cookie again, opening up API access to the applications backend. This project is meant to be interactive.

Github.js to Communicate With API

With a valid OAuth token, I use Github.js as the client side JavaScript client for interacting with the GitHub API. While Github.js allows for using almost all available API endpoints, most application functionality will be just about reading and writing YAML and JSON files using repository paths. For most of the application functionality, I will rely on Liquid for reading YAML and JSON data, and Github.js for writing of data to the underlying repo using the GitHub API. If you have a valid GitHub OAuth token passed in and have access to the Github repository for this application.

Forkable Base for Apps That Run 100% On GitHub

I hope this provides a base project that demonstrates what is possible when you build applications on top of GitHub. I am going to fork it and build another prototype that reads and writes to a YAML file in the _data folder for the underlying repo, exploring what is possible when it comes to using GitHub as a data-driven micro tool platform.

The code that makes this happen is pretty simple and the GitHub repository is meant to be pretty self-contained. Here's a list of technologies at play here:

You can find the front for this app here, and the repo behind this project over at my Github account. Have fun, and feel free to submit any issues if you have any questions or comments.

Discover the unprecedented possibilities and challenges, created by today’s fast paced data climate and why your current integration solution is not enough, brought to you in partnership with Liaison Technologies.

Topics:
github ,forking workflow ,api

Published at DZone with permission of Kin Lane, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}