Sunday, January 13, 2013

Code Review: githubsurvivor -- Python web application written in Flask

"GitHub Survivor is a simple bug dashboard that shows an overview of bugs in a GitHub-hosted repo. We use it at 99designs to keep an eye on the bug count and remind ourselves to close bugs."
Interesting concept, nice charts and ability to infer state of git repos by mere glance at dashboard. With Fafadia Tech's continued passion and linking for both Flask and Python, this writeup serves to give you under the hood look at the code with 99 designs open-sourced it about 3 months ago.


  • First quick look at dependencies and packages this project uses:
    • mongoengine==0.7.3
    • Flask==0.9
    • PyGithub==1.6
    • python-dateutil==2.1
  • Apart from now standard Flask + MongoDB setup, this project uses Python wrappers for github APIs.
  • Less is used to for generating css files 
  • Authors have used a Make file with all and cleanup options used to compile from less syntax to css style sheets
  • All static assets is stored in resources folder called res
  • Project configuration is present is external python file: config.example.py (obviously this is just for reference)
  • Jinja2 templating engine is used. All templates exists in templates folder 
  • Template inheritance and block are amongst some Jinja features that are used. Look at base.jinja2 which is extended in most of other templates. 
  • bin directory contains command for setting up, serving and running tasks
  • MVC pattern is followed for organizing code. models folder contains one python file per model, containing document definitions and method calls 
  • sync.py file contains all logic for syncing data from github along with some other helper methods
  • Main webapp logic is written in __init__.py file under web directory 
  • reporting.py file is used for reporting purposes and timeutils.py for handing timezone, date formatting etc

Overall the code is minimalistic and clean. A good reference to learn from.

No comments:

Post a Comment