@rajeev02/app-shell 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +221 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,221 @@
1
+ # @rajeev02/app-shell
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@rajeev02/app-shell.svg)](https://www.npmjs.com/package/@rajeev02/app-shell)
4
+ [![license](https://img.shields.io/npm/l/@rajeev02/app-shell.svg)](https://github.com/Rajeev02/rajeev-sdk/blob/main/LICENSE)
5
+
6
+ **Feature-slice app architecture** with API client, onboarding, chat, cart & checkout (GST), feature flags, multi-step forms with Indian ID validation, and analytics.
7
+
8
+ Part of [Rajeev SDK](https://github.com/Rajeev02/rajeev-sdk) — cross-platform infrastructure libraries for building apps that work everywhere.
9
+
10
+ ## Why use this?
11
+
12
+ - **API client** — Offline-first HTTP client with caching (cache-first, stale-while-revalidate), retry, interceptors
13
+ - **Cart & checkout** — Add items, apply coupons, calculate GST, generate order summaries
14
+ - **Feature flags** — Enable/disable features at runtime with percentage rollouts, user targeting, A/B variants
15
+ - **Onboarding** — Configurable onboarding slides with progress tracking and completion callbacks
16
+ - **Chat engine** — Real-time messaging with typing indicators, read receipts, and message history
17
+ - **Form engine** — Multi-step forms with Indian ID validation (Aadhaar, PAN, IFSC, GSTIN, pincode)
18
+ - **Analytics** — Event tracking with session management, user properties, and batched uploads
19
+
20
+ ## ⚠️ Important: Backend Services Required
21
+
22
+ This is a **client-side orchestration layer** — it manages state, caching, and offline queues. Several modules require your own backend services:
23
+
24
+ | Module | Backend required? | What you need |
25
+ | -------------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
26
+ | `ApiClient` | **Yes** | Your REST API server (set as `baseUrl`) |
27
+ | `ChatEngine` | **Yes** | WebSocket or real-time server ([Firebase](https://firebase.google.com), [Ably](https://ably.com), [Socket.io](https://socket.io)) |
28
+ | `AnalyticsEngine` | **Yes** | Analytics endpoint or service ([Mixpanel](https://mixpanel.com), [Amplitude](https://amplitude.com), [PostHog](https://posthog.com), or custom) |
29
+ | `FeatureFlagManager` | **Yes** | Feature flag service ([LaunchDarkly](https://launchdarkly.com), [Unleash](https://www.getunleash.io/), or custom API) |
30
+ | `FormEngine` | **Yes** | Form submission endpoint (`onSubmit` callback) |
31
+ | `CartManager` | **No** | Client-side state only (GST calculation, coupons) |
32
+ | `OnboardingManager` | **No** | Client-side state only (slide progress, completion) |
33
+
34
+ **How callbacks work:** Modules like `ApiClient`, `ChatEngine`, and `AnalyticsEngine` accept configuration callbacks (`onRefreshToken`, `onFlush`, `onSubmit`) that call **your backend endpoints**. The library manages retry, caching, and offline queuing around them.
35
+
36
+ ## Platform Support
37
+
38
+ | Platform | Engine | Status |
39
+ | ---------- | ---------- | ------ |
40
+ | iOS 16+ | TypeScript | ✅ |
41
+ | Android 7+ | TypeScript | ✅ |
42
+ | Web | TypeScript | ✅ |
43
+
44
+ ## Installation
45
+
46
+ ```bash
47
+ npm install @rajeev02/app-shell
48
+ ```
49
+
50
+ ### Peer Dependencies
51
+
52
+ - `react` >= 18.3.0
53
+ - `react-native` >= 0.84.0 _(optional)_
54
+
55
+ ## Quick Start
56
+
57
+ ### API Client
58
+
59
+ ```typescript
60
+ import { ApiClient } from "@rajeev02/app-shell";
61
+
62
+ const api = new ApiClient({
63
+ baseUrl: "https://api.example.com",
64
+ timeout: 30_000,
65
+ retries: 3,
66
+ cacheStrategy: "stale-while-revalidate",
67
+ });
68
+
69
+ // Add auth interceptor
70
+ api.addRequestInterceptor((config) => ({
71
+ ...config,
72
+ headers: { ...config.headers, Authorization: `Bearer ${token}` },
73
+ }));
74
+
75
+ // Make requests
76
+ const users = await api.get("/users", { page: 1 });
77
+ const order = await api.post("/orders", { items: [...] });
78
+ ```
79
+
80
+ ### Cart & Checkout
81
+
82
+ ```typescript
83
+ import { CartManager } from "@rajeev02/app-shell";
84
+
85
+ const cart = new CartManager({ gstRate: 0.18, currency: "INR" });
86
+
87
+ cart.addItem({ id: "1", name: "iPhone 16", price: 79_999, quantity: 1 });
88
+ cart.addItem({ id: "2", name: "AirPods Pro", price: 24_999, quantity: 1 });
89
+
90
+ cart.applyCoupon({ code: "SAVE10", discountPercent: 10 });
91
+
92
+ const summary = cart.getSummary();
93
+ // → {
94
+ // items: 2,
95
+ // subtotal: 104998,
96
+ // gst: 18899,
97
+ // discount: -10499,
98
+ // total: 113398
99
+ // }
100
+ ```
101
+
102
+ ### Feature Flags
103
+
104
+ ```typescript
105
+ import { FeatureFlagManager } from "@rajeev02/app-shell";
106
+
107
+ const flags = new FeatureFlagManager();
108
+
109
+ flags.register({
110
+ id: "new_checkout",
111
+ name: "New Checkout Flow",
112
+ enabled: true,
113
+ rolloutPercentage: 50, // 50% of users
114
+ targetUsers: ["beta-group"],
115
+ variants: {
116
+ control: { buttonColor: "blue" },
117
+ treatment: { buttonColor: "green" },
118
+ },
119
+ });
120
+
121
+ if (flags.isEnabled("new_checkout", userId)) {
122
+ const variant = flags.getVariant("new_checkout", userId);
123
+ // → "control" or "treatment"
124
+ }
125
+ ```
126
+
127
+ ### Forms with Indian ID Validation
128
+
129
+ ```typescript
130
+ import { FormEngine, getKycFormConfig } from "@rajeev02/app-shell";
131
+
132
+ const form = new FormEngine(getKycFormConfig());
133
+
134
+ // Built-in Indian ID validators
135
+ form.validateField("aadhaar", "1234 5678 9012"); // → { valid: true }
136
+ form.validateField("pan", "ABCPE1234F"); // → { valid: true }
137
+ form.validateField("ifsc", "SBIN0001234"); // → { valid: true }
138
+ form.validateField("gstin", "22ABCDE1234F1Z5"); // → { valid: true }
139
+ form.validateField("pincode", "560001"); // → { valid: true }
140
+
141
+ // Multi-step form navigation
142
+ form.nextStep();
143
+ form.prevStep();
144
+ const progress = form.getProgress(); // → { current: 2, total: 4, percent: 50 }
145
+ ```
146
+
147
+ ### Chat Engine
148
+
149
+ ```typescript
150
+ import { ChatEngine } from "@rajeev02/app-shell";
151
+
152
+ const chat = new ChatEngine({
153
+ userId: "user-123",
154
+ onMessageReceived: (msg) => updateUI(msg),
155
+ onTypingStatusChanged: (userId, isTyping) =>
156
+ showTypingIndicator(userId, isTyping),
157
+ });
158
+
159
+ chat.sendMessage({
160
+ roomId: "support",
161
+ text: "Hi, I need help with my order",
162
+ type: "text",
163
+ });
164
+
165
+ chat.markAsRead("support", "msg-001");
166
+ chat.setTyping("support", true);
167
+ ```
168
+
169
+ ### Analytics
170
+
171
+ ```typescript
172
+ import { AnalyticsEngine } from "@rajeev02/app-shell";
173
+
174
+ const analytics = new AnalyticsEngine({
175
+ endpoint: "https://analytics.example.com/events",
176
+ batchSize: 20,
177
+ flushIntervalMs: 30_000,
178
+ });
179
+
180
+ analytics.setUserId("user-123");
181
+ analytics.setUserProperties({ plan: "pro", city: "Bengaluru" });
182
+
183
+ analytics.track("purchase_completed", {
184
+ amount: 999,
185
+ currency: "INR",
186
+ method: "upi",
187
+ });
188
+
189
+ analytics.trackScreen("HomeScreen");
190
+ ```
191
+
192
+ ## Modules
193
+
194
+ | Module | Description |
195
+ | -------------------- | --------------------------------------------- |
196
+ | `ApiClient` | HTTP client with caching, retry, interceptors |
197
+ | `CartManager` | Cart with GST, coupons, order summaries |
198
+ | `FeatureFlagManager` | Feature flags, A/B testing, rollouts |
199
+ | `OnboardingManager` | Configurable onboarding flow |
200
+ | `ChatEngine` | Real-time messaging |
201
+ | `FormEngine` | Multi-step forms with Indian ID validation |
202
+ | `AnalyticsEngine` | Event tracking and session management |
203
+
204
+ ## Indian ID Validators
205
+
206
+ | Validator | Format | Example |
207
+ | --------- | ------------- | ----------------- |
208
+ | Aadhaar | 12 digits | `1234 5678 9012` |
209
+ | PAN | `AAAAA0000A` | `ABCPE1234F` |
210
+ | IFSC | `AAAA0000000` | `SBIN0001234` |
211
+ | GSTIN | 15 chars | `22ABCDE1234F1Z5` |
212
+ | Pincode | 6 digits | `560001` |
213
+ | Phone | 10 digits | `9876543210` |
214
+
215
+ ## Full Documentation
216
+
217
+ 📖 [Complete API docs with all modules and types](https://github.com/Rajeev02/rajeev-sdk/blob/main/docs/usage/APP-SHELL.md)
218
+
219
+ ## License
220
+
221
+ MIT © 2026 [Rajeev Kumar Joshi](https://rajeev02.github.io)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rajeev02/app-shell",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Feature-Slice app architecture — API client, navigation, onboarding, chat, video, forms, cart, state, analytics",
5
5
  "main": "lib/index.js",
6
6
  "author": "Rajeev Kumar Joshi <rajeevjoshi91@gmail.com> (https://rajeev02.github.io)",