# mosip/inji-wallet architecture

> Architecture diagram of the GitHub repository mosip/inji-wallet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mosip/inji-wallet
- Repository: https://github.com/mosip/inji-wallet

## Overview

- Mobile Application Frontend:
– Represent the core mobile client built with React Native and Expo.
– Include the primary UI elements (screens and components, e.g., AuthScreen, HomeScreen, Settings, etc.).
– Highlight the “components” and “screens” directories that make up the presentation layer.

- Business Logic & State Management:
– Capture the “machines” directory that contains state machines (for authentication, verifiable credential processes, backup/restore, QR login, etc.).
– Include shared modules such as “shared”, “lib” (with JSON-LD signatures for cryptographic operations), and utilities (keystore, crypto, telemetry).

- Platform-Specific Layers:
– Illustrate separate native code and configurations for Android (android folder) and iOS (ios folder).
– Explain how platform-specific build scripts, configuration files (e.g., gradle files, Xcode project files, Podfile), and native modules (e.g., RNWalletModule, RNOpenID4VPModule) integrate into the overall application.

- External Services & APIs:
– Mark the integration points with backend services using URLs defined in the .env configuration (e.g., Mimoto, ESignet, Telemetry endpoints).
– Show data flow from the mobile client to these external services, noting that they are consumed via network calls from shared API code in the “shared” directory.

- Testing & CI/CD:
– Include a component for the testing infrastructure “injitest” and indicate usage of mocks (__mocks__) and GitHub workflows.
– Show dependencies on continuous integration scripts for Android and iOS builds, as well as testing frameworks.

##### Relationships and Interactions
– From User Interactions (via various screens and UI components) to Business Logic managed by state machines.
– From state machines and shared service utilities to external API/backend services.
– From platform-specific modules to native hardware integrations (e.g., camera for QR scanning or biometric sensors).

- That the UI layer communicates with business logic/state machines (found in the “machines” directory) to handle events such as authentication, credential sharing, or scanning operations.

- Configuration and build management components (e.g., .env, app.config.ts, package.json) as “infrastructure” nodes that support both the development and CI/CD processes.

##### Important Architectural Patterns and Design Principles
- Separation of Concerns:
– The design clearly separates presentation (screens and UI components), business logic (state machines and shared utilities), and platform-specific integrations (Android, iOS native code).

- Modular Design:
– Each folder (components, screens, machines, shared, lib) represents a logical module.

- Layered Architecture:
– The highest layer (User Interface) sends events which are processed by intermediate layers (state machines, business logic) that then interact with lower-level services (cryptography, API calls, device hardware).

- Testability:
– Noting the dedicated “injitest” folder and extensive mocks, include a node that indicates automated testing and regression suites ensuring robustness.

##### Relevant Technologies and Frameworks
- React Native & Expo for building the mobile client.
- JavaScript/TypeScript for application logic (as seen by tsconfig and source files).
- Native Android (Gradle, Java) and iOS (Xcode, Swift/Objective-C) for platform-specific components.
- Integration with Flipper for debugging and testing workflows as indicated in configuration files.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile Application Frontend"
        UIComponents("UI Components"):::frontend
        Screens("Screens"):::frontend
    end

    subgraph "Business Logic & State Management"
        StateMachines("State Machines"):::business
        SharedUtil("Shared Utilities"):::business
        Library("Libraries"):::business
    end

    subgraph "Platform Specific Layers"
        Android("Android Native Code"):::platform
        iOS("iOS Native Code"):::platform
    end

    subgraph "External Services & APIs"
        External("External Services & APIs"):::external
    end

    subgraph "Testing & CI/CD"
        TestingInfra("Testing Infrastructure"):::testing
        CICD("CI/CD Pipelines"):::testing
    end

    UIComponents -->|"renders"| Screens
    Screens -->|"triggersState"| StateMachines
    StateMachines -->|"uses"| SharedUtil
    StateMachines -->|"uses"| Library
    SharedUtil -->|"calls"| External
    Library -->|"calls"| External
    SharedUtil -->|"nativeOps"| Android
    SharedUtil -->|"nativeOps"| iOS
    Screens -->|"testedBy"| TestingInfra
    StateMachines -->|"testedBy"| TestingInfra
    CICD -->|"builds"| Android
    CICD -->|"builds"| iOS

    click UIComponents "https://github.com/mosip/inji-wallet/tree/master/components"
    click Screens "https://github.com/mosip/inji-wallet/tree/master/screens"
    click StateMachines "https://github.com/mosip/inji-wallet/tree/master/machines"
    click SharedUtil "https://github.com/mosip/inji-wallet/tree/master/shared"
    click Library "https://github.com/mosip/inji-wallet/tree/master/lib"
    click Android "https://github.com/mosip/inji-wallet/tree/master/android"
    click iOS "https://github.com/mosip/inji-wallet/tree/master/ios"
    click External "https://github.com/mosip/inji-wallet/blob/master/shared/api.ts"
    click External "https://github.com/mosip/inji-wallet/blob/master/.env"
    click TestingInfra "https://github.com/mosip/inji-wallet/tree/master/injitest"
    click TestingInfra "https://github.com/mosip/inji-wallet/tree/master/__mocks__"
    click CICD "https://github.com/mosip/inji-wallet/tree/master/.github/workflows"

    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef business fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef platform fill:#A9DFBF,stroke:#186A3B,stroke-width:2px;
    classDef external fill:#F5CBA7,stroke:#AF601A,stroke-width:2px;
    classDef testing fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
```
