Skip to main content

Bookmark Entity Lifecycle

The state diagram illustrates the lifecycle of a Bookmark entity within the Etchblok API.

A bookmark begins its lifecycle in the Active state upon creation via a POST request. From there, it can be moved to the Archived state for long-term storage or to the Trashed state via a soft-delete operation (triggered by a DELETE request).

The system allows for full mobility between these states:

  • Restoration: Any bookmark in the Archived or Trashed state can be returned to the Active state using the /restore endpoint.
  • Archiving: Even a Trashed bookmark can be moved directly to the Archived state.
  • Trashing: An Archived bookmark can be moved to the Trashed state by deleting it.

Every transition between these states triggers an internal _touch() method which updates the updated_at timestamp of the entity. Notably, the API implements a soft-delete pattern; while the repository layer supports hard deletion, it is not exposed through the service or routing layers, meaning bookmarks remain in the Trashed state until manually restored or archived.

Key Architectural Findings:

  • Bookmarks are initialized to the 'active' status by default upon creation.
  • The 'DELETE' endpoint performs a soft-delete, transitioning the bookmark to the 'trashed' status rather than removing it from the database.
  • The 'archive' and 'restore' operations provide explicit transitions between 'active', 'archived', and 'trashed' states.
  • All state transitions are accompanied by a timestamp update via the private '_touch()' helper method.
  • The state machine is fully connected, allowing transitions between any two statuses (Active, Archived, Trashed) via the appropriate API endpoints.
Loading diagram...