# Gyroscope (software)

Gyroscope is an open-source PHP framework and a code template system for building web backend systems. Gyroscope uses a specific and yet flexible user interaction model to reveal and explore the inner-relations of a database.

## User Interaction Model

The Gyroscope UI represents typical data relations such as one-to-many, many-to-many and foreign-key-reference with application-level visual concepts. For example, tables are typically shown as "Entry Points". The most significant columns in a data table are used to display the records in a "List View". Each item in the list view opens the record in a Tab where the rest of the columns are displayed in a key-value format.
One-to-many (1-N) relations are shown in the form of "Related Records". For example, in a Company Directory application a company may have multiple contact persons. In the "Companies" list view, each item points to a Company record. In the tabbed company record view, the basic information such as company name and address are displayed in the main section of the details view. The "Related Contacts" are listed on the side. Click on a contact item will open the contact details in a separate tab.
Many-to-many (N-N) relations are displayed as two 1-N views mirroring each other. For example, in a Film-Actor database where a film may have multiple actors, and an actor can be in multiple films, the Film details view lists the actors on its "Related Records" section. Clicking on an actor would pivot the view, by displaying in a separate tab, the basic information of the actor, putting his/her related films on the side.
Tabs in Gyroscope are not browser tabs. They are logically tabs within the web application. Gyroscope's tab system ensures that no duplicate tabs can open for the same record.

## Compatibility

The Gyroscope backend runs on all versions of PHP. Developer features such as the Code Generator requires PHP 5.4 and above because of the use of parent scoping in anonymous functions.
On the client side, Gyroscope supports all the XHR-enabled web browsers. This include legacy browsers as ancient as Internet Explorer 5.5. Features from modern browsers progressively enhance the Gyroscope user experience. For example, web socket, desktop notification, speech synthesis and voice recognition are used if they are available in the browser.
Gyroscope is agnostic of the data layer. Any data source that supports CRUD operations can drive a Gyroscope application. The default code generator uses MySQL syntax.

## Architecture

Gyroscope uses the Loader-Content-Handler-Handler (LCHH) architecture instead of explicit Model-View-Controller (MVC). In the LCHH architecture, a Loader, or a "DIV" container with a unique identifier is populated with default Content. Visual affordances, also known as "triggers" that are included in the Content invoke client-side handlers. These JavaScript handlers then sends XmlHTTPRequestObject (or AJAX) requests to Server-side Handlers. The Server-side scripts then perform updating, insertion or deletion functions before piggybacking the updated View back to the original Loader via AJAX callback and DOM update. The benefit of the LCHH architecture is that its execution path is identical to the life cycle of an HTTP request. This design has both performance and debugging advantages.
LCHH can be viewed as a subtle variant of MVC where the focus is on the View (Loader, Content) and Controller (Client-side Handler and Server-side Handler). The implementation of the data source, or the "Model" is largely left to developer's discretion.