diff --git a/packages/mobile-sdk-alpha/README.md b/packages/mobile-sdk-alpha/README.md index dc258b40b..60442bef9 100644 --- a/packages/mobile-sdk-alpha/README.md +++ b/packages/mobile-sdk-alpha/README.md @@ -49,7 +49,11 @@ const nfc = parseNFCResponse(rawBytes); ## Migration checklist -Track progress in [MIGRATION_CHECKLIST.md](./MIGRATION_CHECKLIST.md). +Track progress in [MIGRATION_CHECKLIST.md](./docs/MIGRATION_CHECKLIST.md). + +## Architecture checklist + +Plan implementation with [ARCHITECTURE.md](./docs/ARCHITECTURE.md) and task prompts in [ARCHITECTURE_PROMPTS.md](./docs/ARCHITECTURE_PROMPTS.md). ## Dev scripts diff --git a/packages/mobile-sdk-alpha/docs/ARCHITECTURE.md b/packages/mobile-sdk-alpha/docs/ARCHITECTURE.md new file mode 100644 index 000000000..b4241be36 --- /dev/null +++ b/packages/mobile-sdk-alpha/docs/ARCHITECTURE.md @@ -0,0 +1,27 @@ +# Architecture + +> Detailed task prompts are listed in [ARCHITECTURE_PROMPTS.md](./ARCHITECTURE_PROMPTS.md). + +## Overview + +The alpha SDK follows an adapter-first, React Native–oriented design. Tree-shakable named exports and `"sideEffects": false` keep bundles lean. While React Native is the only supported platform today, the structure below leaves room to add web, Capacitor, or Cordova targets without major refactors. + +## Architecture Checklist (easy → hard) + +1. **Modular feature directories** – group new capabilities (e.g., `liveness/`, `detection/`) in their own folders and re-export from `src/index.ts`. +2. **Bridge layer for native events** – wrap `NativeModules`/`NativeEventEmitter` so features register listeners through a shared adapter. +3. **Exception classes** – add typed errors (`InitError`, `LivenessError`, etc.) and surface them instead of generic `Error`. +4. **SDK lifecycle management** – evolve `createSelfClient` into an SDK class with `initialize`/`deinitialize` and stored config. +5. **Package targets** – keep React Native build first, but scaffold entry points for web and future environments (Capacitor/Cordova). +6. **Dogfood in `/app`** – integrate the SDK into the monorepo's `app` workspace to validate real flows. +7. **Android demo app** – ship a minimal React Native Android project demonstrating MRZ → NFC → proof generation. + +## Working in Parallel + +Architecture tasks above can proceed alongside the SDK migration checklist. Steps completed in the migration doc (currently through step 2) unblock items 3–5, so teams can tackle architecture and migration independently. + +## Additional Notes + +- Favor small, sensical abstractions over premature generality. +- Maintain tree-shakability by avoiding side effects in new modules. +- Document new APIs and flows under `docs/` as they solidify. diff --git a/packages/mobile-sdk-alpha/docs/ARCHITECTURE_PROMPTS.md b/packages/mobile-sdk-alpha/docs/ARCHITECTURE_PROMPTS.md new file mode 100644 index 000000000..0bd4d915d --- /dev/null +++ b/packages/mobile-sdk-alpha/docs/ARCHITECTURE_PROMPTS.md @@ -0,0 +1,88 @@ +# Architecture Prompts + +Each item from the architecture checklist expands into concrete tasks. Pick items independently to parallelize work. + +> **Note**: This document uses standard Markdown `
` and `` tags for collapsible sections. + +## Pre-flight checks + +Run these commands before committing changes: + +```bash +yarn workspace @selfxyz/mobile-sdk-alpha nice +yarn workspace @selfxyz/mobile-sdk-alpha build +yarn workspace @selfxyz/mobile-sdk-alpha types +yarn workspace @selfxyz/mobile-sdk-alpha test +yarn lint +yarn build +``` + +## 1. Modular feature directories + +
+Split features into dedicated folders + +1. Under `src/`, create folders like `liveness/` and `detection/` as features are added. +2. Re-export feature APIs from `src/index.ts` to keep tree shaking intact. + +
+ +## 2. Bridge layer for native events + +
+Introduce shared event bridge + +1. Add `src/bridge/nativeEvents.ts` wrapping `NativeModules` and `NativeEventEmitter`. +2. Expose `addListener` and `removeListener` helpers so modules can register without touching React Native directly. + +
+ +## 3. Exception classes + +
+Add typed error hierarchy + +1. Create `src/errors/` with classes like `InitError` and `LivenessError` extending `Error`. +2. Replace generic throws with these classes and document them in the README. + +
+ +## 4. SDK lifecycle management + +
+Move to an SDK class + +1. Convert `createSelfClient` into a class exposing `initialize()` and `deinitialize()`. +2. Store configuration and adapters on the instance to avoid global state. + +
+ +## 5. Package targets + +
+Scaffold additional entry points + +1. Add build outputs for web, Capacitor, and Cordova under `dist/`. +2. Configure `package.json` `exports` to point to the new bundles. + +
+ +## 6. Dogfood in `/app` + +
+Integrate with monorepo app + +1. Add `@selfxyz/mobile-sdk-alpha` to `app/package.json` and wire flows to use the SDK. +2. Validate builds and tests in the `app` workspace. + +
+ +## 7. Android demo app + +
+Provide minimal Android sample + +1. Under `samples/android/`, scaffold a basic React Native project showing MRZ → NFC → proof generation. +2. Document setup steps in `samples/android/README.md`. + +
diff --git a/packages/mobile-sdk-alpha/MIGRATION_CHECKLIST.md b/packages/mobile-sdk-alpha/docs/MIGRATION_CHECKLIST.md similarity index 100% rename from packages/mobile-sdk-alpha/MIGRATION_CHECKLIST.md rename to packages/mobile-sdk-alpha/docs/MIGRATION_CHECKLIST.md diff --git a/packages/mobile-sdk-alpha/MIGRATION_PROMPTS.md b/packages/mobile-sdk-alpha/docs/MIGRATION_PROMPTS.md similarity index 100% rename from packages/mobile-sdk-alpha/MIGRATION_PROMPTS.md rename to packages/mobile-sdk-alpha/docs/MIGRATION_PROMPTS.md