Skip to main content

Backend Service Component Architecture

This diagram illustrates the internal layered architecture of the Pagemark bookmark management API.

The system follows a standard layered pattern:

  • The API Layer consists of Flask Blueprints that handle HTTP requests and responses. These routes delegate all business logic to the service layer.
  • The Service Layer is centered around the BookmarkService singleton, which acts as an orchestrator. It coordinates between the SearchIndex for full-text search, the LRUCache for performance, and the BookmarkRepository for data persistence.
  • The Data Access Layer provides an abstraction over the storage mechanism. In this implementation, it uses an in-memory repository to manage the lifecycle of Domain Models (Bookmarks, Tags, and Collections).
  • The Infrastructure component handles application configuration, providing environment-specific settings to the Flask application factory.

Key interactions include the BookmarkService invalidating the cache on updates, the SearchIndex performing incremental indexing via the repository, and the consistent use of domain models across all layers for data transfer.

Key Architectural Findings:

  • The application uses a Singleton pattern for the BookmarkService to maintain shared state (cache and search index) across different route modules.
  • The SearchIndex implements a simple inverted index in-memory, which is rebuilt from the BookmarkRepository on startup.
  • A custom LRUCache is used internally by the service layer to optimize bookmark retrieval by ID.
  • The BookmarkRepository provides a clean abstraction for CRUD operations, currently backed by in-memory dictionaries but designed to be swappable for a real database.
  • Domain models (Bookmark, Tag, Collection) are shared across all layers, from the repository up to the API routes for serialization.
Loading diagram...