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-appvia 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:
-
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
-
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.
-
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.
- Browser: uses
-
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
- Installation Guide - How to install within the monorepo or standalone.
- Configuration - Setting up client endpoints, platform headers, and hooks.
- Storage Adapters - Configuring web, mobile, and Node storage.
- API Modules - Explore all 16 client domain modules.
- Runnable Examples - Working code scripts you can execute immediately.
