Data Layer low complexity mobile
0
Dependencies
0
Dependents
1
Entities
0
Integrations

Description

In-memory and disk cache for organization-specific branding assets and design token overrides. Preloads logo images and color tokens after org selection to eliminate rendering delays when the user reaches branded screens. Invalidates on org switch to prevent stale branding bleed.

Feature: Organization Selection & Onboarding

org-branding-cache

Summaries

The Organization Branding Cache delivers a polished white-label experience to partner organizations by ensuring that branded logos and color schemes load instantly the moment a user selects their organization, rather than appearing with a noticeable delay. In B2B SaaS platforms, the quality of white-label branding is a key factor in partner satisfaction and renewal decisions — a branded experience that flickers or loads slowly undermines the perception of professionalism and can erode trust in the product. By preloading assets immediately after org selection and clearing them on org switch, this component ensures that each partner's brand identity is presented accurately and promptly, reinforcing the platform's value proposition as a premium, customizable solution that integrates seamlessly into each partner's own brand identity.

The Organization Branding Cache is a low-complexity mobile component with no external service dependencies, making it one of the lower-risk items on the implementation schedule. It can be developed and tested independently once the organization selection flow and the list of branding asset types (logos, color tokens) are defined. Testing requirements are straightforward: verify that assets load correctly after org selection, that switching organizations clears the previous org's assets (no branding bleed), and that the cache provides synchronous access for render performance. The main coordination point is with the design team to finalize the set of design tokens that will be overridable per organization and with the backend team to confirm the format and delivery mechanism for branding assets (URL-based vs base64, CDN vs Supabase storage).

Budget time for this asset delivery design decision early, as it affects the preloading implementation.

The Organization Branding Cache uses a two-tier caching strategy: in-memory for runtime synchronous access (critical for avoiding async gaps during widget builds) and disk cache for persistence across cold starts. The `preloadBrandingAssets(orgId)` method should be called immediately after org selection is confirmed, fetching logo images (returned as `ImageProvider` for direct use in Flutter `Image` widgets) and color token overrides (stored as a `Map` keyed by token name). Synchronous getters `getOrgLogo` and `getColorToken` return nullable values — callers should fall back to default branding when null. The `invalidate(orgId)` method clears all cached data for a specific org (used on org switch), while `clear()` wipes the entire cache (used on logout).

Implement disk persistence using `path_provider` + file-based image caching (or integrate with `cached_network_image`'s cache manager). No external service dependencies simplifies testing — use mock asset URLs and verify cache hit/miss behavior in unit tests.

Responsibilities

  • Cache org logo assets after selection
  • Store color token overrides per org
  • Invalidate cached assets on org context switch
  • Provide synchronous access to cached branding for render performance

Interfaces

preloadBrandingAssets(String orgId) -> Future<void>
getOrgLogo(String orgId) -> ImageProvider?
getColorToken(String orgId, String tokenKey) -> Color?
invalidate(String orgId) -> void
clear() -> void

Related Data Entities (1)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/org-branding 6 endpoints
GET /api/v1/org-branding
GET /api/v1/org-branding/:orgId
POST /api/v1/org-branding
PUT /api/v1/org-branding/:orgId
DELETE /api/v1/org-branding/:orgId
POST /api/v1/org-branding/:orgId/preload