One of the main features of Tome is that it stores everything about a Drupal site - its content, configuration, and files - in one place. This is accomplished in part by how data is exported and stored.
The content export flow works like this:
- Content is edited in the user interface.
- Hooks in tome.module are invoked which call methods on the "tome.exporter" service.
- The exporter normalizes the entity. Tome implements custom normalizers to clean up data - for example revision and entity IDs are removed since UUIDs are used, computed fields and removed, and user fields that change every login are removed.
- The normalized data is saved using the "tome.storage.content" service. Entities are exported in the format "entity_type:uuid:langcode". If the entity is the default translation, the langcode is omitted. The storage serializes data as JSON, but can be swapped out if another format is desired.
- If the content being exported happens to be a file entity, the original file is copied to the export directory.
- The content index file is updated or created in the "meta" directory. The index file exists to track content dependencies, so that content can be imported in order without causing errors. For now, dependencies are only calculated based on the values of entity reference fields.
If content is deleted, it is also deleted from the content storage. If the content is a file, the original file is deleted. If the content is a default translation, all other translations will be deleted at that time.
Configuration (config) export is much more simple - an event subscriber is used to track changes to config and config translations, and the "config.storage.sync" service is used to write the changes to the filesystem. This is equivalent to running "drush config-export" after every config change.