Skip to content

Proposal for the shopify core library architecture

Juan Manuel García edited this page Dec 24, 2013 · 1 revision

We will build a django app that will allow shopify apps developers to install it right into their django projects. This is as simple as downloading a python package and putting its name in the INSTALLED_APPS list variable on the settings.py file.

This python package will be installed as any other package and it will provide the following built-in functionality for our django projects:

Views:

  • A BaseView Class with a bunch of the common behaviour methods we use when developing django class based views apps.
  • Oauth views for handling the oauth methods (this includes apps installation).
  • Login/Logout/Generic shopify views.
  • Generic webhooks views for receiving/logging webhooks easily.
  • Uninstall webhook view to add custom behaviour when someone uninstalls the app.

For all those views the developers will be able to redefine methods in order to add/overwrite custom functionality.

Urls:

For each view listed above there will be a default urls like "/shopify/install/" that the developers can override if they want.

Models:

  • Store model for saving the store basic data (id, name, url, permanent auth token, etc)
  • Logger model for logging the webhook data

For all the models the developers will be able to create foreign key/extend relationships between them and the user defined models.

Services:

  • A Base Service Class to add common behaviour we reuse when developing django apps.
  • Shopify service to allow the developers to interact with the shopify API easily.

Lib/Utils:

  • Common python/django utils we share across apps.
  • A python wrapper for the shopify API (This should allow developers make request both for public and private apps)

Templates:

  • Base layout templates.
  • Control Panel default template
  • Stats default template
  • Login/Install templates

Middleware:

  • A @shopify_login_required decorator will be processed as a middleware on each request to validate views that require shopify auth.

Javascript libs:

  • We can add many javascript methods to interact with the shopify cart and templates

Django Custom Commands:

  • A deploy command to make a centralized way to deploy to heroku.
  • A revert command to be able to revert the app state in case of failure.
  • Send test webhook data commands to allow developers to debug the webhooks methods by sending a dummy HTTP POST to a selected url.
  • Run customized test suites command.
  • Interactive ipython shopify api command. It will open a ipython instance with a selected auth token so developers can play with the API interactively.
  • Start django shopify project command. This will setup a new django project with the default configuration for shopify apps.

Heroku deployment:

  • We should use the heroku API to setup the apps for development and production with a django command. Developers should not waste time setting up heroku apps

Requirements.txt:

  • A list of frozen packages we are going to use for all the django apps

Packaging and source code hosting:

  • This project will be hosted in a git repo. We should define if it project can be open source or not. I think it's not a bad idea to make the repo public as many people can use and contribute to the project.
  • If we go with open source we then can make a python public package and push it to pip.