Skip to main content

Bookmark API Component Architecture

The Bookmark API follows a classic layered architecture for a Flask-based REST service.

At the top level, the Routes Layer (blueprints) handles incoming HTTP requests and delegates all business logic to the app.services.bookmark_service. This service acts as a Facade, orchestrating interactions between the data storage, search indexing, and caching mechanisms.

The app.services.bookmark_service is implemented as a singleton to ensure consistent state across different route modules. It manages:

The Model Layer defines the core domain entities (Bookmark, Tag, Collection) which are used across all layers of the application for data transfer and validation.

Key Architectural Findings:

  • The application uses a Singleton pattern for the BookmarkService to maintain a shared state across Flask blueprints.
  • The BookmarkRepository provides an in-memory storage abstraction, decoupling the service layer from the actual storage implementation.
  • Search functionality is implemented as a separate SearchIndex component that rebuilds itself from the repository on startup.
  • An internal LRU Cache is used within the service layer to optimize bookmark retrieval.
  • The architecture strictly follows a layered approach where routes never touch the repository directly, always going through the service layer.
Loading diagram...