Skip to main content

CKAN: Development

CKAN code architecture

CKAN's code architecture is designed with specific coding standards in mind to maintain consistency with its intended design and architecture.

CKAN Code architecture

tip

Blueprints

CKAN is based on Flask and uses Blueprints. Default blueprints are defined along views in ckan.views and extended with the ckan.plugins.interfaces.IBlueprint plugin interface.

Views

Views process requests by reading and updating data with action functions and return a response by rendering Jinja2 templates. CKAN views are defined in ckan.views and templates in ckan.templates.

Template Helper Functions

Template helper functions are used for code that is reused frequently or code that is too complicated to be included in the templates themselves. They should never perform expensive queries or update data.

Action Functions

Whenever some code wants to get, create, update or delete an object from CKAN's model it should do so by calling a function from the ckan.logic.action package, and not by accessing ckan.model directly.

Logic

Logic includes action functions, auth functions, background tasks and business logic. Action functions have a uniform interface accepting a dictionary of simple strings lists, dictionaries or files. They return simple dictionaries or raise one of a small number of exceptions.

Models

Ideally SQLAlchemy should only be used within ckan.model and not from other packages such as ckan.logic.

Deprecation

Anything that may be used by extensions, themes or API clients needs to maintain backward compatibility at call-site. To deprecate a function use the ckan.lib.maintain.deprecated decorator and add "deprecated" to the function's docstring.

Contributing guide

CKAN is free open source software and contributions are welcome, whether they’re bug reports, source code, documentation or translations. The following sections will walk you through our processes for making different kinds of contributions to CKAN: