1 ========================================
3 ========================================
5 OpenERP as a multitenant three-tiers architecture
6 =================================================
8 This section presents the OpenERP architecture along with technology details
9 of the application. The tiers composing OpenERP are presented. Communication
10 means and protocols between the application components are also presented.
11 Some details about used development languages and technology stack are then summarized.
13 OpenERP is a `multitenant <http://en.wikipedia.org/wiki/Multitenancy>`_, `three-tiers architecture
14 <http://en.wikipedia.org/wiki/Multitier_architecture#Three-tier_architecture>`_:
15 database tier for data storage, application tier for processing and functionalities
16 and presentation tier providing user interface. Those are separate layers
17 inside OpenERP. The application tier itself is written as a core; multiple
18 additional modules can be installed in order to create a particular instance
19 of OpenERP adapted to specific needs and requirements. Moreover, OpenERP
20 follows the Model-View-Controller (MVC) architectural pattern.
22 A typical deployment of OpenERP is shown on `Figure 1`_. This deployment is
23 called Web embedded deployment. As shown, an OpenERP system consists of
24 three main components:
26 - a PostgreSQL database server which contains all OpenERP databases.
27 Databases contain all application data, and also most of the OpenERP
28 system configuration elements. Note that this server can possibly be
29 deployed using clustered databases.
30 - the OpenERP Server, which contains all the enterprise logic and ensures
31 that OpenERP runs optimally. One layer of the server is dedicated to
32 communicate and interface with the PostgreSQL database, the ORM engine.
33 Another layer allows communications between the server and a web browser,
34 the Web layer. Having more than one server is possible, for example in
35 conjunction with a load balancing mechanism.
36 - the client, which allow users to access OpenERP. Two clients exist, a
37 desktop GTK client and a browser-based client
39 - the GTK client access directly to the OpenERP Server
40 - users can also use standard web browsers to access OpenERP. In that
41 case, an OpenERP application is loaded. It handles communications between
42 the browser and the Web layer of the server.
44 The database server and the OpenERP server can be installed on the same computer,
45 or distributed onto separate computer servers, for example for performance considerations.
48 .. figure:: _static/02_openerp_architecture.png
50 :alt: OpenERP 6.1 architecture for embedded web deployment
53 OpenERP 6.1 architecture for embedded web deployment
55 The next subsections give details about the different tiers of the OpenERP
61 The data tier of OpenERP is provided by a PostgreSQL relational database.
62 While direct SQL queries can be executed from OpenERP modules, most accesses
63 to the relational database are done through the server Object Relational
66 Databases contain all application data, and also most of the OpenERP system
67 configuration elements. Note that this server can possibly be deployed using
73 OpenERP provides an application server on which specific business applications
74 can be built. It is also a complete development framework, offering a range
75 of features to write those applications. Among those features, the OpenERP
76 ORM provides functionalities and an interface on top of the PostgreSQL server.
77 The OpenERP server also features a specific layer designed to communicate
78 with the web browser-based client. This layer connects users using standard
79 browsers to the server.
81 From a developer perspective, the server acts both as a library which brings
82 the above benefits while hiding the low-level details, and as a simple way
83 to install, configure and run the written applications. The server also contains
84 other services, such as extensible data models and view, workflow engine or
85 reports engine. However, those are OpenERP services not specifically related
86 to security, and are therefore not discussed in details in this document.
90 The Object Relational Mapping ORM layer is one of the salient features of
91 the OpenERP Server. It provides additional and essential functionalities
92 on top of PostgreSQL server. Data models are described in Python and OpenERP
93 creates the underlying database tables using this ORM. All the benefits of
94 RDBMS such as unique constraints, relational integrity or efficient querying
95 are used and completed by Python flexibility. For instance, arbitrary constraints
96 written in Python can be added to any model. Different modular extensibility
97 mechanisms are also afforded by OpenERP.
99 It is important to understand the ORM responsibility before attempting to
100 by-pass it and to access directly the underlying database via raw SQL queries.
101 When using the ORM, OpenERP can make sure the data remains free of any corruption.
102 For instance, a module can react to data creation in a particular table.
103 This behavior can occur only if queries go through the ORM.
105 The services granted by the ORM are among other :
107 - consistency validation by powerful validity checks,
108 - providing an interface on objects (methods, references, ...) allowing
109 to design and implement efficient modules,
110 - row-level security per user and group; more details about users and user
111 groups are given in the section Users and User Roles,
112 - complex actions on a group of resources,
113 - inheritance service allowing fine modeling of new resources
117 The web layer offers an interface to communicate with standard browsers.
118 In the 6.1 version of OpenERP, the web-client has been rewritten and integrated
119 into the OpenERP server tier. This layer relies on CherryPy for the routing
120 layer of communications, especially for session and cookies management.
124 By itself, the OpenERP server is a core. For any enterprise, the value of
125 OpenERP lies in its different modules. The role of the modules is to implement
126 any business requirement. The server is the only necessary component to
127 add modules. Any official OpenERP release includes a lot of modules, and
128 hundreds of modules are available thanks to the community. Examples of
129 such modules are Account, CRM, HR, Marketing, MRP, Sale, etc.
134 As the application logic is mainly contained server-side, the client is
135 conceptually simple. It issues a request to the server, gets data back
136 and display the result (e.g. a list of customers) in different ways
137 (as forms, lists, calendars, ...). Upon user actions, it sends queries
138 to modify data to the server.
140 Two clients can be used for user access to OpenERP, a GTK client and a
141 browser-based client. The GTK client communicates directly with the server.
142 Using the GTK client requires the client to be installed on the workstation
145 The browser-based client holds an OpenERP application that handles communications
146 between the browser and the Web layer of the server. The static code of the web
147 application is minimal. It consists of a minimal flow of HTML that is in charge
148 of loading the application code in Javascript. This client-side OpenERP application
149 sends user requests to the server, and gets data back. Data management is
150 done dynamically in this client. Using this client is therefore easy for
151 users, but also for administrators because it does not require any software
152 installation on the user machine.
155 MVC architecture in OpenERP
156 ===========================
158 According to `Wikipedia <http://en.wikipedia.org/wiki/Model-view-controller>`_,
159 "a Model-view-controller (MVC) is an architectural pattern used in software
160 engineering". In complex computer applications presenting lots of data to
161 the user, one often wishes to separate data (model) and user interface (view)
162 concerns. Changes to the user interface does therefore not impact data
163 management, and data can be reorganized without changing the user interface.
164 The model-view-controller solves this problem by decoupling data access
165 and business logic from data presentation and user interaction, by
166 introducing an intermediate component: the controller.
169 .. figure:: _static/02_mvc_diagram.png
171 :alt: Model-View-Controller diagram
174 Model-View-Controller diagram
176 For example in the diagram above, the solid lines for the arrows starting
177 from the controller and going to both the view and the model mean that the
178 controller has a complete access to both the view and the model. The dashed
179 line for the arrow going from the view to the controller means that the view
180 has a limited access to the controller. The reasons of this design are :
182 - From **View** to **Model** : the model sends notification to the view
183 when its data has been modified in order the view to redraw its content.
184 The model doesn't need to know the inner workings of the view to perform
185 this operation. However, the view needs to access the internal parts of the model.
186 - From **View** to **Controller** : the reason why the view has limited
187 access to the controller is because the dependencies from the view to
188 the controller need to be minimal: the controller can be replaced at
191 OpenERP follows the MVC semantic with
193 - model : The PostgreSQL tables.
194 - view : views are defined in XML files in OpenERP.
195 - controller : The objects of OpenERP.
198 Network communications
199 ======================
201 GTK clients communicate with the OpenERP server using XML-RPC protocol by
202 default. However, using a secured version XML-RPCS is possible when configurating
203 your OpenERP instance. In previous versions of OpenERP, a custom protocol
204 called NET-RPC was used. It was a binary version of the XML-RPC protocol,
205 allowing faster communications. However, this protocol will no longer be
206 used in OpenERP. The use of JSON-RPC is also planned for the 6.1 version
209 Web-based clients communicate using HTTP protocol. As for XML-RPC, it is
210 possible to configure OpenERP to use secured HTTPS connections.
215 Everything in OpenERP, and objects methods in particular, are exposed via
216 the network and a security layer. Access to the data model is in fact a ‘service’
217 and it is possible to expose new services. For instance, a WebDAV service and
218 a FTP service are available.
220 While not mandatory, the services can make use of the `WSGI
221 <http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface>`_ stack. WSGI is
222 a standard solution in the Python ecosystem to write HTTP servers, applications,
223 and middleware which can be used in a mix-and-match fashion. By using WSGI,
224 it is possible to run OpenERP in any WSGI compliant server. It is also
225 possible to use OpenERP to host a WSGI application.
227 A striking example of this possibility is the OpenERP Web layer that is
228 the server-side counter part to the web clients. It provides the requested
229 data to the browser and manages web sessions. It is a WSGI-compliant application.
230 As such, it can be run as a stand-alone HTTP server or embedded inside OpenERP.