# inji/mimoto architecture

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

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

## Overview

1. **What this repo is**
   - This is a Spring Boot 3 / Java 21 backend for Inji Mobile and Inji Web.
   - It is not just an API app; it is the orchestration layer for wallets, credentials, identity-provider login, verifiable presentations, and issuer/verifier configuration.

2. **Main runtime boundary**
   - The runnable service is `src/main/java/io/mosip/mimoto`.
   - HTTP endpoints are split by domain in `controller/`, and they delegate almost all work to `service/` implementations.
   - `MimotoServiceApplication` is the bootstrap entry point.

3. **Core domain areas exposed by the API**
   - Wallet management: create, unlock, lock, delete, and list wallets.
   - Credential management: request, store, verify, download, share, and render credentials.
   - Presentation flows: OpenID4VP / verifiable presentation generation and submission.
   - Issuer/verifier discovery and onboarding: issuer config, trusted verifiers, well-known metadata, and policy discovery.
   - User/IDP flows: login, token handling, and user metadata.

4. **Service-layer structure**
   - The `service/` package holds the orchestration logic; `service/impl/` contains the concrete workflows.
   - Important subservices include:
     - `WalletService`, `WalletLockService`, `WalletUnlockService`
     - `CredentialService`, `CredentialRequestService`, `CredentialShareService`, `CredentialVerifierService`
     - `PresentationService`, `PresentationSubmissionService`, `PresentationActionService`
     - `IssuersService`, `TrustedVerifierService`, `VerifierService`
     - `IdpService`, `TokenService`, `TokenDecoder`
   - Several flows are factory-based, especially credential format handling and signing algorithms.

5. **Persistence and state**
   - The application persists operational state in Postgres through Spring Data repositories.
   - Repositories cover wallets, credentials, verifiable presentations, trusted verifiers, user metadata, and proof-signing keys.
   - Redis is supported for distributed cache and session storage; the README explicitly calls out Caffeine as the default in-memory cache and Redis as the shared option for multi-instance deployments.

6. **Credential and wallet data model**
   - Domain objects under `model/` represent wallet state, credential metadata, verifiable credentials/presentations, passcode controls, trusted verifiers, and key metadata.
   - The wallet is a first-class security boundary: credentials are stored and accessed through wallet lock/unlock logic and encryption utilities.

7. **External identity and issuer integration**
   - The service integrates with external OIDC/OAuth2 providers, especially Google login, via `security/oauth2/`.
   - It also consumes issuer metadata and credential issuer configuration from JSON resources and remote well-known endpoints.
   - Several flows depend on external IDP, resident, and credential-issuance APIs represented by the many DTOs in `dto/resident`, `dto/idp`, `dto/mimoto`, and `dto/openid`.

8. **Presentation / verifier flow**
   - The repo includes a full OpenID4VP path: discover verifier, build presentation request, select matching credentials, submit presentation, and handle acceptance/rejection.
   - Trusted verifier registration and verifier policy/configuration are persistent concerns, not just request-time validation.

9. **Cryptography and key management**
   - Crypto is a major architectural boundary.
   - Key material is loaded from a PKCS#12 keystore and used for wallet encryption/decryption, signing, and onboarding/OIDC client operations.
   - The code includes algorithm-specific signing handlers for ES256, ES256K, Ed25519, and RS256, plus utilities for JWT/JWS, JOSE, and encryption/decryption.
   - There is also attestation verification support, both online and offline.

10. **Content generation and credential formats**
   - Credential formatting is abstracted behind `CredentialFormatHandler` and its factory.
   - The repository supports multiple formats, including LDP VC and SD-JWT variants.
   - It can also generate PDF representations of credentials, using HTML templates under `src/main/resources/templates/` and `credential-template.html`.

11. **Configuration model**
   - Runtime behavior is heavily configuration-driven.
   - The app reads issuer configs, trusted verifier configs, application properties, cache/session settings, and token/OAuth settings from `src/main/resources/` and environment-specific property files.
   - This means deployment correctness depends on external config more than on code changes.

12. **Supporting test rig in `api-test/`**
   - `api-test/` is a separate Maven-based test harness, not the main service.
   - It contains TestNG suites, YAML-driven scenario definitions, Handlebars templates, sample biometric/device artifacts, and certificates for exercising Mimoto APIs end to end.
   - This module is useful to diagram as a consumer/test client around the backend rather than part of the backend runtime itself.

13. **Deployment and operations**
   - The repo includes Docker, docker-compose, Helm charts, K8s deploy scripts, DB schema/init scripts, and upgrade SQLs.
   - Operationally, the main dependencies are Postgres, optional Redis, and external OAuth/OIDC services; nginx is used in local docker-compose setups to serve static assets.
   - The database schema is managed under `db_scripts/` and versioned upgrades are provided under `db_upgrade_script/`.

14. **High-level data flow**
   - Client request enters a controller.
   - Controller delegates to a domain service.
   - Service may consult cache/session state, database repositories, keystore/crypto utilities, and external issuer/IDP/verifier services.
   - Results are persisted where needed, transformed into DTOs/models, and returned to the client.
   - For presentation and credential flows, the service often acts as the mediator between wallet state and external identity/issuer ecosystems.

Main entry points: [`src/main/java/io/mosip/mimoto/controller`](https://github.com/inji/mimoto/tree/master/src/main/java/io/mosip/mimoto/controller) (Controllers), [`src/main/java/io/mosip/mimoto/service/CredentialService.java`](https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/CredentialService.java) (Credential core), [`src/test/java/io/mosip/mimoto`](https://github.com/inji/mimoto/tree/master/src/test/java/io/mosip/mimoto) (Main tests), [`src/main/java/io/mosip/mimoto/service/WalletService.java`](https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/WalletService.java) (Wallet core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Backend runtime"]
  node_app(("Mimoto app<br/>spring boot entrypoint"))
  node_controllers["Controllers<br/>HTTP API layer"]
  node_wallet_core["Wallet core<br/>wallet orchestration<br/>[WalletService.java]"]
  node_credential_core["Credential core<br/>credential orchestration"]
  node_presentation_core["Presentation core<br/>openid4vp orchestration"]
  node_issuer_verifier["Issuer & verifier<br/>discovery/onboarding"]
  node_idp_auth["IDP auth<br/>login/token flow<br/>[IdpService.java]"]
  node_format_factory["Format factory<br/>credential format dispatch"]
  node_format_handlers["Format handlers<br/>vc format adapters"]
end

subgraph group_infra["Infrastructure"]
  node_crypto_core["Crypto core<br/>crypto/signing<br/>[CryptoUtil.java]"]
  node_oauth2_sec["OAuth2 security<br/>external login integration"]
  node_persistence[("Persistence<br/>postgres repositories")]
  node_session_cache["Session & cache<br/>cache/session layer"]
  node_external_apis["External APIs<br/>remote integrations"]
  node_data_model["Domain model<br/>wallet/credential entities"]
  node_config_files["Runtime config<br/>properties/json resources"]
end

subgraph group_test["Test harness"]
  node_main_tests["Main tests<br/>unit/integration tests"]
  node_api_test_rig["API test rig<br/>separate maven harness"]
end

subgraph group_ops["Operations"]
  node_ops_assets["Ops assets<br/>deploy/db assets"]
end

node_app -->|"starts"| node_controllers
node_controllers -->|"wallet routes"| node_wallet_core
node_controllers -->|"credential routes"| node_credential_core
node_controllers -->|"presentation routes"| node_presentation_core
node_controllers -->|"issuer/verifier routes"| node_issuer_verifier
node_controllers -->|"login routes"| node_idp_auth
node_wallet_core -->|"encrypts"| node_crypto_core
node_wallet_core -->|"stores wallet"| node_persistence
node_wallet_core -->|"session state"| node_session_cache
node_credential_core -->|"formats"| node_format_factory
node_credential_core -->|"signs/verifies"| node_crypto_core
node_credential_core -->|"stores creds"| node_persistence
node_credential_core -->|"fetches issuer data"| node_external_apis
node_presentation_core -->|"signs VP"| node_crypto_core
node_presentation_core -->|"stores VP"| node_persistence
node_presentation_core -->|"verifier calls"| node_external_apis
node_issuer_verifier -->|"discovers metadata"| node_external_apis
node_issuer_verifier -->|"stores trust"| node_persistence
node_idp_auth -->|"uses"| node_oauth2_sec
node_idp_auth -->|"tokens/profile"| node_external_apis
node_crypto_core -->|"loads keys"| node_config_files
node_main_tests -.->|"covers"| node_controllers
node_main_tests -.->|"covers"| node_wallet_core
node_main_tests -.->|"covers"| node_credential_core
node_main_tests -.->|"covers"| node_presentation_core
node_main_tests -.->|"covers"| node_crypto_core
node_api_test_rig -.->|"drives APIs"| node_controllers
node_ops_assets -->|"deploys with"| node_config_files
node_ops_assets -->|"provisions db"| node_persistence

click node_app "https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/MimotoServiceApplication.java"
click node_controllers "https://github.com/inji/mimoto/tree/master/src/main/java/io/mosip/mimoto/controller"
click node_wallet_core "https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/WalletService.java"
click node_credential_core "https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/CredentialService.java"
click node_presentation_core "https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/PresentationService.java"
click node_issuer_verifier "https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/IssuersService.java"
click node_idp_auth "https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/IdpService.java"
click node_format_factory "https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/CredentialFormatHandlerFactory.java"
click node_format_handlers "https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/impl/LdpVcCredentialFormatHandler.java"
click node_crypto_core "https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/util/CryptoUtil.java"
click node_oauth2_sec "https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/security/oauth2/CustomOAuth2UserService.java"
click node_persistence "https://github.com/inji/mimoto/tree/master/src/main/java/io/mosip/mimoto/repository"
click node_session_cache "https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/config/SessionCacheConfig.java"
click node_external_apis "https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/RestClientService.java"
click node_data_model "https://github.com/inji/mimoto/tree/master/src/main/java/io/mosip/mimoto/model"
click node_config_files "https://github.com/inji/mimoto/tree/master/src/main/resources"
click node_main_tests "https://github.com/inji/mimoto/tree/master/src/test/java/io/mosip/mimoto"
click node_api_test_rig "https://github.com/inji/mimoto/tree/master/api-test"
click node_ops_assets "https://github.com/inji/mimoto/tree/master/deploy"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_controllers,node_wallet_core,node_credential_core,node_presentation_core,node_issuer_verifier,node_idp_auth,node_format_factory,node_format_handlers toneBlue
class node_crypto_core,node_oauth2_sec,node_persistence,node_session_cache,node_external_apis,node_data_model,node_config_files toneAmber
class node_main_tests,node_api_test_rig toneMint
class node_ops_assets toneRose
```

## Components

### Backend runtime

Spring Boot service and its domain subsystems.

- [Mimoto app](https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/MimotoServiceApplication.java): spring boot entrypoint · Bootstrap for the backend service. · `src/main/java/io/mosip/mimoto/MimotoServiceApplication.java`
- [Controllers](https://github.com/inji/mimoto/tree/master/src/main/java/io/mosip/mimoto/controller): HTTP API layer · Domain controllers that expose wallet, credential, presentation, issuer, verifier, IDP, and user endpoints. · `src/main/java/io/mosip/mimoto/controller`
- [Wallet core](https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/WalletService.java): wallet orchestration · Create, unlock, lock, delete, and validate wallet state and passcode flows. · `src/main/java/io/mosip/mimoto/service/WalletService.java`
- [Credential core](https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/CredentialService.java): credential orchestration · Request, store, verify, download, share, and render credentials. · `src/main/java/io/mosip/mimoto/service/CredentialService.java`
- [Presentation core](https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/PresentationService.java): openid4vp orchestration · Build, submit, and manage verifiable presentations and OpenID4VP sessions. · `src/main/java/io/mosip/mimoto/service/PresentationService.java`
- [Issuer & verifier](https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/IssuersService.java): discovery/onboarding · Issuer configuration, trusted verifier registration, policy discovery, and verifier management. · `src/main/java/io/mosip/mimoto/service/IssuersService.java`
- [IDP auth](https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/IdpService.java): login/token flow · Identity-provider login, token handling, and user metadata flows. · `src/main/java/io/mosip/mimoto/service/IdpService.java`
- [Format factory](https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/CredentialFormatHandlerFactory.java): credential format dispatch · Selects format handlers for credential processing and signing workflows. · `src/main/java/io/mosip/mimoto/service/CredentialFormatHandlerFactory.java`
- [Format handlers](https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/impl/LdpVcCredentialFormatHandler.java): vc format adapters · Representative handlers for LDP VC and SD-JWT credential formats. · `src/main/java/io/mosip/mimoto/service/impl/LdpVcCredentialFormatHandler.java`

### Infrastructure

Persistence, security, crypto, and external integration boundaries.

- [Crypto core](https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/util/CryptoUtil.java): crypto/signing · Encryption, decryption, JWT/JWS, keystore access, and algorithm-specific signing. · `src/main/java/io/mosip/mimoto/util/CryptoUtil.java`
- [OAuth2 security](https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/security/oauth2/CustomOAuth2UserService.java): external login integration · Google/OIDC login integration and authentication handlers. · `src/main/java/io/mosip/mimoto/security/oauth2/CustomOAuth2UserService.java`
- [Persistence](https://github.com/inji/mimoto/tree/master/src/main/java/io/mosip/mimoto/repository): postgres repositories · Spring Data repositories for wallets, credentials, presentations, verifiers, user metadata, and proof keys. · `src/main/java/io/mosip/mimoto/repository`
- [Session & cache](https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/config/SessionCacheConfig.java): cache/session layer · Session state and caching configuration using in-memory and Redis-backed options. · `src/main/java/io/mosip/mimoto/config/SessionCacheConfig.java`
- [External APIs](https://github.com/inji/mimoto/blob/master/src/main/java/io/mosip/mimoto/service/RestClientService.java): remote integrations · Issuer, verifier, resident, IDP, and data-share calls coordinated through REST clients and DTOs. · `src/main/java/io/mosip/mimoto/service/RestClientService.java`
- [Domain model](https://github.com/inji/mimoto/tree/master/src/main/java/io/mosip/mimoto/model): wallet/credential entities · Wallet, credential, presentation, trusted verifier, and key metadata models. · `src/main/java/io/mosip/mimoto/model`
- [Runtime config](https://github.com/inji/mimoto/tree/master/src/main/resources): properties/json resources · Application properties, keystore, issuer config, trusted verifier config, and templates. · `src/main/resources`

### Test harness

Main test suites and separate API rig.

- [Main tests](https://github.com/inji/mimoto/tree/master/src/test/java/io/mosip/mimoto): unit/integration tests · Controller, service, security, util, and factory tests for the backend. · `src/test/java/io/mosip/mimoto`
- [API test rig](https://github.com/inji/mimoto/tree/master/api-test): separate maven harness · Standalone test client and scenario runner for end-to-end API validation. · `api-test`

### Operations

Deployment, database, and packaging assets.

- [Ops assets](https://github.com/inji/mimoto/tree/master/deploy): deploy/db assets · Docker, compose, Helm, Kubernetes, schema, and upgrade scripts. · `deploy`

## Connections

- Mimoto app → Controllers: starts · Bootstraps the HTTP API runtime and wiring.
- Controllers → Wallet core: wallet routes · Wallet endpoints delegate to wallet services.
- Controllers → Credential core: credential routes · Credential endpoints delegate to credential services.
- Controllers → Presentation core: presentation routes · Presentation endpoints delegate to VP workflows.
- Controllers → Issuer & verifier: issuer/verifier routes · Issuer, verifier, and trusted-verifier endpoints.
- Controllers → IDP auth: login routes · IDP and token endpoints.
- Wallet core → Crypto core: encrypts · Wallet lock/unlock and secure storage use cryptography.
- Wallet core → Persistence: stores wallet · Persists wallet state and metadata.
- Wallet core → Session & cache: session state · Uses session and cache state for wallet flow coordination.
- Credential core → Format factory: formats · Chooses credential format handlers.
- Credential core → Crypto core: signs/verifies · Credential processing uses signing and verification utilities.
- Credential core → Persistence: stores creds · Persists credential records and metadata.
- Credential core → External APIs: fetches issuer data · Requests and downloads credential data from remote services.
- Presentation core → Crypto core: signs VP · Presentation construction and submission use crypto and JWT tools.
- Presentation core → Persistence: stores VP · Persists verifiable presentation and trust state.
- Presentation core → External APIs: verifier calls · Interacts with verifier and presentation endpoints.
- Issuer & verifier → External APIs: discovers metadata · Reads issuer well-known endpoints and verifier config.
- Issuer & verifier → Persistence: stores trust · Persists trusted verifiers and onboarding state.
- IDP auth → OAuth2 security: uses · External login is handled by OAuth2 security components.
- IDP auth → External APIs: tokens/profile · Calls IDP and resident APIs for auth and user data.
- Crypto core → Runtime config: loads keys · Reads keystore and cryptographic configuration.
- Main tests → Controllers: covers · Primary test surface for API behavior.
- Main tests → Wallet core: covers · Service tests cover wallet workflows.
- Main tests → Credential core: covers · Service tests cover credential workflows.
- Main tests → Presentation core: covers · Service tests cover presentation workflows.
- Main tests → Crypto core: covers · Utility and signing tests validate crypto behavior.
- API test rig → Controllers: drives APIs · Separate harness exercises the backend end to end.
- Ops assets → Runtime config: deploys with · Operational assets package the runtime configuration and templates.
- Ops assets → Persistence: provisions db · Database schema and upgrade scripts define persistent state.
