Introduction & Architecture

Welcome to the @tracklr/sdk documentation.

@tracklr/sdk is the official TypeScript API Client SDK powering the entire Tracklr Business Suite:

  • πŸ›’ Retail Web App (retail-web-app)
  • πŸ“± Retail Mobile App (retail-mobile-app via Capacitor)
  • 🏭 Production Business (production-business)
  • πŸ”Œ 3rd-Party Integrations & Automation Scripts

Why @tracklr/sdk?

In multi-application, multi-tenant architectures, applications frequently drift if each manages its own HTTP calls, authentication states, and platform-specific headers. @tracklr/sdk solves this by providing:

  1. Strict Multi-Tenant Scoping: Every request automatically injects:

    • Authorization: Bearer <accessToken>
    • X-Tenant-ID: <businessId>
    • X-Business-Slug: <slug>
    • X-Client-Platform: web | mobile | desktop
  2. Zero-Race Mutex Token Refresh: When an access token expires and an API call triggers 401 Unauthorized:

    • The SDK locks outgoing refreshes with a thread-safe mutex.
    • All incoming concurrent API requests are paused and placed into an in-memory queue.
    • A single token refresh request is dispatched to /api/auth/token/refresh/.
    • Once refreshed, all queued requests are updated with the new token and replayed seamlessly.
  3. Pluggable Storage Adapters: Seamlessly run anywhere:

    • Browser: uses localStorage.
    • Capacitor Mobile: uses Capacitor Preferences or Secure Storage.
    • Node.js: uses in-memory or custom Redis token storage.
  4. 16 Typed Business Modules: Full auto-completion and compile-time type validation across Retail, Manufacturing, Inventory, Accounts, and RBAC.


Architectural Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Tracklr Client Applications                     β”‚
β”‚  [Retail Web App]       [Retail Mobile App]      [Production Business] β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                         β”‚                         β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β–Ό
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚           @tracklr/sdk            β”‚
                   β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
                   β”‚  β”‚ TracklrClient (Facade)      β”‚  β”‚
                   β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
                   β”‚  β”‚ 16 Typed Business Modules   β”‚  β”‚
                   β”‚  β”‚ (Auth, Retail, Production,  β”‚  β”‚
                   β”‚  β”‚  Finance, Staff, Admin...)  β”‚  β”‚
                   β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
                   β”‚  β”‚ HttpClient (Engine)         β”‚  β”‚
                   β”‚  β”‚  - Header Injectors         β”‚  β”‚
                   β”‚  β”‚  - Mutex Refresh Queue      β”‚  β”‚
                   β”‚  β”‚  - Pluggable Storage Adapterβ”‚  β”‚
                   β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚ (JSON / HTTPS)
                                     β–Ό
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚      Tracklr Backend Services     β”‚
                   β”‚       https://biz.henotaceai.ng   β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Quick Navigation