Google Summer of Code ’19 at Oppia Foundation

James John
5 min readAug 26, 2019

--

Introduction

Oppia is a platform that enables anyone to learn and teach anything they want in an effective and enjoyable way.
Learning in a slow environment would not be enjoyable, hence the need to optimize the speed of the platform.

About the project:

My project aimed at serving Oppia’s pages statically, which means getting rid of Jinja.
Jinja is a python templating engine and is used with the AppEngine webapp2 framework.
Since the jinja templates will have to be converted every time before rendering the page, a cached version of each page cannot be kept in the browser and this means that for every time a user visits a page, a freshly baked version of the page is sent to the user with all its dependencies.
On the other hand, serving the pages without Jinja will mean losing all the template inheritance and other features which Jinja offers, hence the new static solution should be able to provide similar functionalities to what was gotten using Jinja.

Technologies used:

The technologies I used to achieve this include:

  • AngularJs:
    AngularJS is the frontend library which is currently used at oppia.org. I used AngularJS to maintain similar template inheritance which was previously done using Jinja templates. This was possible through the use of transclusion components in the pages which provide slots for different sections of the page to be inserted.
  • Webpack:
    Webpack is the module bunder used at Oppia. It got introduced into the codebase shortly before the commencement of the GSoC program.
    I primarily used webpack for bundling scripts and static HTML templates which would then be injected into the page during the build process. This helped as this is what jinja was used for previously.

Milestone 1

My target for the first milestone was to remove jinja from the fairly static pages. These pages did not fetch much data from the backend and mostly used Jinja templates for template inheritance and for maintaining a consistent structure.

Pull Requests Made:

Milestone 2

The work for the second milestone was to extend the work on transclusion components to the more dynamic pages. This was somewhat tricky because the dynamic pages load lots of data from the backend into the page.

Pull Requests Made

Milestone 3

The final milestone was meant to remove jinja completely from the codebase and fix all the issues arising from the Jinja removal

Pull Requests Made

Speed Improvements

Speed improvements can easily be noticed in the pages as they are now lighter.
The time to first byte tests as carried out using chrome dev tools are shown below:
app.yaml 42ms
Jinja render147ms
Django template 119ms

Future Plans

Speed improvement is a continuous process. During GSoC, I have been able to implement static serving for Oppia pages which greatly reduces the initial page load time. Future work will be put into other areas to improve the page speed and ensure very fast loading pages.

Conclusion

I want to especially thank Vojtěch Jelínek for all the guidance, feedback, reviews and mentoring given to me throughout this period. I also want to thank Sean Lip for his guidance and for always ensuring that the code I wrote was of great quality. I would also love to thank my fellow GSoC students for their guidance when things went wrong.

I want to especially thank Google for the organizing the Google Summer of Code program which has helped launched me into the open-source world.

I also want to thank the Oppia Org Admins for accepting my proposal, guiding and mentoring me these 3 months.

These 3 months have been a thorough period of learning and coding. Working on a live project with such a great community, having a large number of people reviewing my code and an audience of users immediately waiting to use features which have been built. The joy of having thousands of people use what you’ve built is unexplainable.

I will continue contributing to Oppia and I’d love to help new contributors joining us.

--

--