Difference between revisions of "ARK2"
(→REST / HATEOAS / Hypermedia) |
(→Frontend) |
||
Line 154: | Line 154: | ||
The frontend will be migrated to [http://getbootstrap.com/ Bootstrap], [https://jquery.com/ jQuery], and [http://twig.sensiolabs.org/ Twig], the most popular and well-supported frontend ui component and template systems. This will allow for easier customisation of ARK's appearance by third parties. | The frontend will be migrated to [http://getbootstrap.com/ Bootstrap], [https://jquery.com/ jQuery], and [http://twig.sensiolabs.org/ Twig], the most popular and well-supported frontend ui component and template systems. This will allow for easier customisation of ARK's appearance by third parties. | ||
− | + | For more details, see the [[ARK2/Frontend|Frontend]] page. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Migration === | === Migration === |
Revision as of 14:47, 30 October 2016
This page details the progress on development of ARK 2.0
Contents
- 1 Aims
- 2 Documentation
- 3 Design
- 3.1 Supported Platforms
- 3.2 Framework
- 3.3 Database Abstraction
- 3.4 Multi-Tenancy / Multi-Site / Multi-Config
- 3.5 Security
- 3.6 REST / HATEOAS / Hypermedia
- 3.7 Frontend
- 3.8 Migration
- 3.9 Build Tooling
- 3.10 Sysadmin Console
- 3.11 Translations / Localisation
- 3.12 Site Module
- 3.13 Address Book / Actors / Users
- 3.14 Action Logging / Activity Streams / Gamification
- 3.15 Command Bus Architecture / Application Services
- 3.16 Workflow Management
- 3.17 Document Management
- 3.18 CMS / Blog / Project Websites
- 3.19 Errors
- 3.20 Matrix / Graph
- 4 Branding / Community
Aims
The primary aims of ARK2 are:
- Full code re-write to modern standards using modern components
- Separate the ARK Database backend from the ARK Web frontend
- Implement a modern RESTful API to allow other frontends and apps to access and update the ARK Database
- Simplify the setup and configuration of ARK by moving the config into the database and providing online config tools
- Improve the overall performance and data integrity of ARK
- Make it possible to provide an ARK hosting service
Modern frontend
- HTML5
- Bootstrap 3 based
- Twig templates
- Front Controller / Single Page model
- Config driven pages views
Modern backend
- Modern RESTful API to access and update all ARK data
- Database abstraction
- Config driven model
- User Authentication via internal user/password and external OAuth2 providers (Facebook, Google, etc)
- User Authorisation via Role Based Access Control (RBAC) using hierarchical Roles and Permissions structure
Documentation
Details of ARK2 can be found in the following sections:
- Design - High Level Design Decisions
- Architecture - System Architecture
- Development - Development tools and procedures
- API - REST API implementation
- Frontend - Web Frontend
- Database - Database details
- Localization - Internationalization, Localization, and Translation
- Security - Security, Authentication, Authorisation, User Management
Design
High level design decisions for ARK2.
Supported Platforms
ARK will only actively support platforms that are actively supported by their maintainers. ARK may work on earlier versions but this is not guaranteed.
- HTML5 will be used
- Browser support restricted to those supported by Bootstrap 3
- PHP: A minimum of v5.6 will be supported (5.6 is in Security Support, 5.7 in active support, see http://php.net/supported-versions.php), v7 will be supported.
- MySQL/MariaDB v5.5 or later (lowest supported MySQL)
- PostgreSQL v9.2 or later
- SQLite 3.7.11 or later (required for multiple inserts)
- mod_rewrite will be required
- PHP intl extension and ICU will be required
For more details see the ARK2/Development page.
Framework
It is proposed to implement a new RESTful Request/Route/Response skeleton using a Front Controller model and token-based security, based on an external micro-framework and components adhering to the PSR standards and managed via Composer. This will reduce the amount of code maintained internally, update the code-base to modern web-app design principals, and provide a degree of future-proofing by allowing switching of components.
The Silex micro-framework and Symphony components have been selected due to their high quality, long support history, and wide use and support
For more details see the ARK2/Development page.
Database Abstraction
ARK2 will support the use of MySQL, PostgreSQL or SQLite as the database.
In ARK1, PDO is used to directly access only MySQL databases, and DB access statements are widely spread through the code base and manually coded. While PDO abstracts the connection, it doesn't abstract the SQL dialect so adding support for other databases such as Postgres or SQLite would require considerable work. It also makes migration to proper transaction support and performance improvements difficult, and is a security risk due to programmer error.
A Database Abstraction Layer (DAL) can abstract away the differences in SQL between database systems, and also provide Query Builders, Schema Management, and Migration tools to address the other issues. Most are built on PDO and can seamlessly integrate with legacy code to make for an easier migration path. The Doctrine DBAL DAL has been selected due to it's use in Symfony and the ORM extension being a Data Mapping ORM.
More details can be found on the ARK2/Database page.
Multi-Tenancy / Multi-Site / Multi-Config
A number of architectural issues surround Multi-Tenancy, Multi-Site and Multi-Config in an ARK instance. These primarily affect how a hosted ARK service will be run, but also how a standalone organisation will manage their ARK instances.
- An ARK instance is here defined as a combination of ARK users and the ARK site data they are able to access, usually under a single project/brand/organisation.
- A database is defined as a combination of a database user and the tables it can access, not the database server instance which can hold multiple database.
- Multi-tenancy is the ability to have multiple ARK instances in a single ARK install.
- Multi-site is the ability to have multiple sites within an ARK instance.
- Mulit-config is the ability to have multiple ARK schemas within an ARK instance, i.e. different sites having a different config.
Choosing an architecture involves a series of trade-offs around ease-of-development versus ease-of-maintenance. The simplest solution is the current structure, where an ARK instance has a single tenant with a single config across multiple sites. There are problems with this however:
- Each instance requires a separate code install, database and URL
- If a single organisation wants multiple ARK schemas (say trench-based rural and a full urban SCR) they must run separate ARK instances for each schema, meaning users must remember which instance has which sites and maintain separate user IDs, and the apps using the API must know this as well.
- Making significant upgrades to an organisation's config requires a separate ARK install
- Scaling up to 100's of instances creates 100's of installs and 100's of databases which will make support difficult and expensive even with automation
At the opposite extreme is an architecture where a single ARK install supports multiple tenants, sites and configs in a single database. While this solves the above issues by greatly simplifying maintenance there are a number of issues here too:
- Code and SQL is significantly more complicated, joins especially become difficult
- Key bloat on all tables as fields required for tenant and site which may affect performance
- Table bloat with all data being in a single set of tables which may affect performance
- Back up and archive is an issue as the data for different tenants needs to be separated, probably requiring custom code instead of standard tools
- Security is an issue with data access control now occurring in the app code
- A single tenant can overload the server and take all tenants down
- Distributing load across servers becomes difficult if not impossible
- Upgrading an install means all site configs must be upgraded too, you cannot leave a site on an old version
- Existing code and data would make ARK1 migration far more complex
A half-way house model would be to allow a single install to have multiple tenants, but each tenant has its own database instance:
- A simple key structure is kept, keeping the code simple
- Each tenants data is kept separate, solving the size, security and backup issues
- Load can be easily distributed by moving a tenant to another server by simply moving their database and/or redirecting their url
- Code maintenance is kept simple, but database management becomes more complex again
- Upgrading an install will still require upgrading all sites
Note: A practical limitation is imposed by MySQL and SQLite support which only allow a single 'namespace' per database, unlike PostgreSQL and others which support multiple 'namespaces' which would allow each tenant to have separate sets of tables within the same database.
The strongest case can be made for supporting Multi-Config, primarily as a a means of allowing larger clients to host all their data inside a single install with a single set of users (including LP ourselves). This has several implications however:
- It raises Site Code from an attribute of an item in a module, to being a key at a higher level than the modules themselves, i.e the modules available will change depending on the Site Code
- As a consequence it substantially changes the api to add the site code above the module
- It may make searching across site codes difficult
- ???
The full combination would allow a hosted ARK solution as follows:
- Lowest price tier (£5) / mass market / community dig type sites are hosted in a single multi-tenant install, only allowed a single site/config, may not allow own domain?
- Upgrade to lowest tier (£10) still in single multi-tenet install, but allowed say 5 sites/configs, maybe allow own domain?
- Next tier(s) (£15/£20/£25?) gives separate install, probably in own virtual host, own domain, with unlimited sites/configs?
- Possible top-tier for large-scale sites with guaranteed support contract
This would keep the maintenance burden on the lowest-profit sites to a minimum, while encouraging up-sells as and when needed.
Install management could be simplified by developing a set of built-in tools.
- Installs using git, run git pull to upgrade
- Doctrine migrations enable auto data updates
- Auto-check function for new releases and notify admin
- Admin panel to put site into maintenance mode, run code update, run data update
Splitting database roles may assist in this:
- User database - allows Multi-tenant to choose if shared users for all/some tenants, or any tenant to have own users
- Config database - The ARK configuration, schemas, forms, etc, allows multi-tenant to share all configs with all/some tenants, or any tenant to have own set
- Data database - The ARK data, each tenant will have their own database
The framework will manage three separate database connection variables, but where the database roles are shared by a database instance then the connection objects will be the same.
Security
ARK currently uses PEAR LiveUser for user authentication, authorisation, and user management, but this hasn't been updated since 2010. It is a security risk, and also lacks many features like federated login. The ARK API currently uses plain text user and password in the request URL which is insecure. ARK2 will require a new security solution, especially for the API calls from client apps. This solution will be token based, support username/password and OAuth2 authentication, and use Role-Based Access Control for authorization. HTTPS will be required for the API.
For more details, see the Security page.
REST / HATEOAS / Hypermedia
An evolution of the ARK data model and API to try realise the full ARK vision will be based arround the Hypermedia concepts of REST and HATEOAS as developed by Roy Fielding in his doctoral thesis in 2000. These concepts include resources, relationships, state, and discoverability, and are closely related to the Semantic Web. ARK modules will evolve to represent Resources that can be linked in together in the current flat relationship structure, or organised into configurable hierarchies such as the default Site/Module/Item mostly used by ARK instances. These concepts will be most easily exposed through a RESTful API.
For more details see the API page.
Frontend
The frontend will be migrated to Bootstrap, jQuery, and Twig, the most popular and well-supported frontend ui component and template systems. This will allow for easier customisation of ARK's appearance by third parties.
For more details, see the Frontend page.
Migration
A migration process from ARK 1 to ARK 2 will be provided.
Data migration. Existing tables will need to change from MyISAM to InnoDB. Change in place carries a degree of risk of data loss if the migration fails part way. Attempting to restart failed migrations is also prone to error. To protect users data, a new database will be created with new tables and the data copied across. Should migration fail users will easily be able to roll back to their old install, or keep retrying the migration until it does succeed. In effect the ARK init script will be run, followed by the migration script.
User migration. Users will be migrated from LiveUser to the new RBAC system. This will require a compatible default user config.
Config migration. A config migration script will be provided, but may require adapting for individual ARKs.
Build Tooling
Build tooling is required for a number of reasons:
- Bootstrap can be customised most easily by changing variables used in the Sass templates, which then requires a build step to compile them into CSS
- Production deployment is more efficient if CSS and JS is stripped, merged and minified, while development is easier if a map is generated for the original code
- Bower component management downloads the entire package, not just the assets required, an extra step is required to copy just the required assets into the web root folder
- All the steps required for packaging and release management can be automated, e.g. clean, compile, tag, package, etc
- The build tooling for the default ARK bootstrap and twig theme can be generalised to allow clients to build and deploy their own customised themes with minimal effort
The build tooling will be as follows:
- All build tooling will be isolated in the /build/ folder and will be excluded from any release packages or production deployments
- Nothing in the /build/ folder may be depended on by any code outside the /build/ folder or required for running ARK itself
- Node, npm, Bower and Gulp will be used to run the tooling (Bower requires Node/npm to be installed, so we may as well use its full power)
- Tooling should be cross-platform (Gulp provides this as opposed to bash scripts)
- Gulp will not be required as a global install, instead tasks will be aliased through Node scripts, e.g. 'npm run build' will call 'gulp build'
- Running tasks will only work inside the /build/ folder, trying to run outside the build folder should fail gracefully
Sysadmin Console
An sysadmin console will be provided for use on the command line. This will provide a number of tools:
- Database administration, such as creation, migration, backup, etc
- MultiArk installs
- ARK wide alerts
- Maintenance mode (immediate and schedule)
- Upgrade tools
- etc
Equivalents for some of these functions will be provided in an ARK Sysadmin panel (separate to the ARK Admin panel):
- ARK wide alerts
- Maintenance mode (immediate and schedule)
- etc
Translations / Localisation
A key to providing Ark-As-A-Service will be translating the user interface and schemas into as many languages as possible to maximise the potential user base. ARK1 does not have the tools to make this process easy to perform or manage, and it would be a waste of resources to build them. It is recommended to use one of the existing online open-source translation projects to crowd-source the translations. This will allow interested parties and potential clients to translate ARK for themselves and to grow a local community to support ARK in their country.
Changes will be made to the translation process to bring ARK into line with industry best practices and tooling, allowing for common features such as correct plural forms. This will be based on the Symfony Translation componant.
More details can be found on the ARK2/Localization page.
Site Module
A new core module for Sites will be added to support recording of metadata about a site. The data schema will be configurable the same as other modules, but certain default fields will be enforced. This will be a special case module that does not appear in the modules for a site.
Address Book / Actors / Users
Currently actors are allocated at a site level. This may not scale very well to a major corporate install, for example LP or WCC, with a staff of 30-50 and hundreds of sites. Repeatedly allocating new actor IDs for each site could result in a user possibly having hundreds of actor IDs which could make reporting harder, site creation more effort, and is not very RESTful.
It is proposed instead to to rename the Address Book module as the Actors module and add a new global level of actors in addition to site-specific actors. Users will be in the global list, and allocated to sites with roles. Choice can be made between global level roles across all sites, or site specific roles. Non-user global actors can also be defined, can be referred to without allocation. Local site actors can be created.
It is also proposed to have the Actors module be the only source of actors for the Action dataclass, simplifying the storage and access.
Action Logging / Activity Streams / Gamification
All user actions and events in ARK will be logged, enabling an standard Activity Stream at user level that can support gamification. The actual gamification is considered outside of the scope of core ARK2. Some inspiration for the implementation can be taken from Event Sourcing, but a full implementation will not be attempted.
- http://martinfowler.com/eaaDev/EventSourcing.html
- http://activitystrea.ms/
- https://www.w3.org/TR/activitystreams-core/
- https://github.com/barnabywalters/php-activitystreams
- https://github.com/redpanda/ActivityStreams
- http://jwage.com/post/54480997504/building-activity-streams
- https://dev.playlyfe.com/guides/getting-started.html
Command Bus Architecture / Application Services
A Command Bus / Event Bus architecture will be implemented to support execution or queuing of synchronous and asynchronous Commands and Events. Console Commands will be wrappers around Commands that parse input from the command line.
- http://php-and-symfony.matthiasnoback.nl/2015/01/a-wave-of-command-buses/
- https://github.com/SimpleBus/
- http://tactician.thephpleague.com/
- http://culttt.com/2014/11/10/creating-using-command-bus/
Workflow Management
Stretch goal. Needed for Avalon. Packages exist to define workflows using state machines.
Possible workflow scenarios:
- Post-ex
- Sample taking
- Avalon jobs and documents
- Data checking
Document Management
Stretch goal. Needed for Avalon. Management of documents and versions a la Sharepoint. Try use CMIS standard as used in LibreOffice.
CMS / Blog / Project Websites
Either provide an OoB Wordpress integration and host client websites, or add features to ARK to provide the basic project website features (home page, blog, contact us, calendar).
- https://github.com/bolt/bolt CMS built using Silex/Symfony
Errors
Standardised error codes will be used, based on the JSON API standard format. Error codes will be stored in a database table and exported via the API, with actual error messages translated via the standard methods, with detailed debug/help available on the ARK wiki via standardised links. Fatal errors will be thrown as exceptions, with the Controller responsible for catching the error and reporting it in the appropriate manner, i.e. via web or api. Non-fatal errors such as validation errors can be batched before return. While numeric error codes are convenient, they make code hard to read and debugging tracebacks harder, so all error conditions should be explicitly commented in the code, and error codes should be as unique as possible..
Matrix / Graph
PHP:
- https://github.com/clue/graph
- https://github.com/graphp/algorithms
- https://github.com/cpettitt/graphlib/wiki/API-Reference
Branding / Community
Two potential issues suggest an evolution of the ARK brand is required
- Building a development and support community may be easier if ARK is branded as a stand-alone project, rather than seen as owned/controlled by LP Archaeology
- Extending use of ARK and Hosted ARK to areas outside archaeology may be held back by emphasising the archaeology aspect in the branding
Branding as something like 'The ARK Project, sponsored by LP Archaeology', and coining a bacronym like 'ARK Recording Kit' might solve these issues.
The Hosted ARK would need a separate identity to the development project to keep the Open Source / Commercial split clear. A simple .com vs .org difference is probably not clear enough. Examples include:
- Salesforce.com vs Force.com
- Mediawiki vs Wikia
- Wordpress .com vs .org
Branding would thus consist of three parts:
- The project
- The products
- The service
The branding would need to be distinctive but consistent to make it clear they are part of a cohesive whole.
Words with Ark / Arc in them (but not arch) for possible project or theme names:
- Archive / ARKhive
- Arctic (very white/light theme?)
- Arcadia
- Arkose (type of sediment)
- Arkaeology (available in .com, .org, .net!)
- Arcade
- Archaic / Arcane / Arcanum / Arcana (more apt for ARK v1 ;-)
- Arcuate / Arcuated (Arc/bow shaped)
- Architrave
- Architect
- Archipeligo
- Archosaur
- Arktivity...