Architecture guide

Jump to: navigation, search
Architecture guide
Describes some parts of the software architecture of Semantic MediaWiki
Table of Contents

This page explains the software architecture of Semantic MediaWiki on a high level. It is intended to help developers to get started with SMW development by understanding the main concepts. Another important goal of this page is to clarify the architectural choices that are underlying the PHP implementation.

Due to the nature of PHP code and extension development, the actual source code may make it difficult to separate architecture (deliberate, essential design decisions) from implementation (pragmatic, opportunistic realization decisions). This page tries to fix at least the main concepts.

The source code repository should be consulted for details on the code described below. While general architecture decisions are fairly stable, this page can still become outdated.

Source code documentation contains an auto-generated doxygen styled code browser.

Information found in the Architecture notes section have not yet been finalized.

Core concepts (Datamodel)

Help:Datamodel contains the most essential architectural choice of SMW is in its data model. This specifies the way in which semantic information is represented within the system – actually it specifies what semantic information is in SMW.

The "system perspective" describes on how to directly manipulate data on database level in order for them to be managed, stored, and queried. This section describes the basic software components that are involved in representing those data.

The "user perspective" incorporates the basic data model and its technical realization through the use of dataitems and SemanticData containers and adds a representation layer (which is the user facing input/output) in form of datavalues.

  • Help:DataValue
  • Help:Datatype values are organized in datatypes that define how user inputs are interpreted and how data is presented in outputs.

Functional components

The user-visible functions of SMW can roughly be divided into the following main groups:

  • Data input (annotation, writing)
  • Data inspection and output (browsing, special pages)
  • Query answering and query formatting
  • Data export
  • Maintenance tools (scripts and special pages used by site admins)

Naturally, this is only a rough user view, and some features may belong to more than one group. Each of these units has dedicated code, but all of this code is based on a common data model that provides a unified internal presentation of handling semantic data. This is the core of the SMW architecture, explained in more detail below. Moreover, there are additional facilities for internationalization that are relevant throughout the code.

Storage backend

The storage backend is responsible for getting/querying and modifying semantic data and properties (using the Store and ValueLookupStore interface).

The core deploys two different store implementations:



Semantic MediaWiki provides several hooks that can help other extensions to make use of SMW's internal data interface. Hooks lists existing hooks with their input/output parameters.

Data extension and updates

Extending the data object (a.k.a. SemanticData) should happen through MediaWiki's ParserOutput to avoid any conflicts when updates are deferred and to ensure that during an edit session extensions have access to the same SemanticData object.

A short introduction on how to extend a SemanticData object can be found here.

Internationalization (i18n)

Internationalization manged by together with encapsulation contained in

  • Localizer
  • NumberFormatter
  • ExtraneousLanguage


  • The initial review of this page was in Feb 2011, SMW 1.5.5.
  • Up to 2016-01 the first parts already reflected the status in SMW 1.6.0.
  • 2016-01 the page is starting to be updated to SMW 2.4 state

See also