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
BookmarkServicesingleton, 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
BookmarkServiceto maintain shared state (cache and search index) across different route modules. - The
SearchIndeximplements a simple inverted index in-memory, which is rebuilt from theBookmarkRepositoryon startup. - A custom
LRUCacheis used internally by the service layer to optimize bookmark retrieval by ID. - The
BookmarkRepositoryprovides 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...