How vsindustries/idscan-sdk works
Purpose and entry points
idscan is a multi-module Android SDK for fully on-device identity-document scanning: PDF417/AAMVA barcode decoding, ICAO MRZ parsing, OCR-based extraction, normalization, and deterministic warnings. Public core entry points are IdScanSdk, IdScanProcessor, and request/config types in idscan-core/src/main/kotlin/com/idscan/core/IdScanSdk.kt, idscan-core/src/main/kotlin/com/idscan/core/IdScanProcessor.kt, and idscan-core/src/main/kotlin/com/idscan/core/IdScanRequest.kt. Android host apps normally use an Activity Result contract from exactly one UI flavor.
Module boundaries and runtime integration
idscan-core is pure Kotlin domain/pipeline logic; idscan-core-android adapts Android bitmaps, parceling, model assets, and localizer runtimes. Key boundary paths: idscan-core-android/src/main/kotlin/com/idscan/core/android/IdScanProcessorAndroid.kt, idscan-core-android/src/main/kotlin/com/idscan/core/android/model/AssetModelManifestProvider.kt. Android runtime requirement is API 23+; builds use JDK 21.
Scan UI flavors and capture control
Two parallel camera/UI distributions expose the host-facing IdScanContract, scanner activity, Compose screen, and live capture controller:
• Dynamic ML Kit delivery: idscan-ui-dynamic/src/main/kotlin/com/idscan/ui/dynamic/IdScanContract.kt, idscan-ui-dynamic/src/main/kotlin/com/idscan/ui/dynamic/camera/LiveScanController.kt, idscan-ui-dynamic/src/main/kotlin/com/idscan/ui/dynamic/readiness/MlKitReadinessProvider.kt.
• Bundled recognition: idscan-ui-bundled/src/main/kotlin/com/idscan/ui/bundled/IdScanContract.kt, idscan-ui-bundled/src/main/kotlin/com/idscan/ui/bundled/IdScanScannerActivity.kt, idscan-ui-bundled/src/main/kotlin/com/idscan/ui/bundled/ocr/TesseractTextRecognizerBinding.kt.
The host owns camera permission. Capture frames flow through CameraX-oriented adapters/controller, coordinate mapping, tracking/quality feedback, then processor invocation.
Processing pipeline
PipelineOrchestrator composes stages over PipelineInput: localize the document, assess image quality, then execute barcode, MRZ, and OCR branches; resolve fields and apply rules into a result. Primary paths: idscan-core/src/main/kotlin/com/idscan/core/pipeline/PipelineOrchestrator.kt, idscan-core/src/main/kotlin/com/idscan/core/pipeline/LocalizerStage.kt, idscan-core/src/main/kotlin/com/idscan/core/pipeline/QualityStage.kt.
Image preprocessing is a distinct boundary for grayscale, contrast, deskew, perspective warp, and escalation: idscan-core/src/main/kotlin/com/idscan/core/preprocess/BitmapPreprocessingPipeline.kt, idscan-core/src/main/kotlin/com/idscan/core/preprocess/EscalationPreprocessor.kt.
Extraction, parsing, and resolution
Barcode scanning produces payloads consumed by AAMVA parsing; OCR text is converted to field candidates; MRZ recognition detects/reconstructs candidates and validates TD1/TD2/TD3/MRV formats. Paths: idscan-core/src/main/kotlin/com/idscan/core/pipeline/BarcodeBranchStage.kt, idscan-core/src/main/kotlin/com/idscan/core/parser/aamva/AamvaParser.kt, idscan-core/src/main/kotlin/com/idscan/core/pipeline/MrzBranchStage.kt.
FieldResolverStage merges competing sources according to trust hierarchy and preserves provenance; rules then produce eligibility/quality/mismatch warnings. Paths: idscan-core/src/main/kotlin/com/idscan/core/pipeline/FieldResolverStage.kt, idscan-core/src/main/kotlin/com/idscan/core/pipeline/resolver/FieldMerger.kt, idscan-core/src/main/kotlin/com/idscan/core/pipeline/RulesStage.kt.
Results, privacy, and models
The stable output is IdScanResult, containing status, normalized fields, source provenance, warnings, optional retained frames, and model readiness state: idscan-core/src/main/kotlin/com/idscan/core/result/IdScanResult.kt, idscan-core/src/main/kotlin/com/idscan/core/result/IdScanResultFactory.kt. Logging is redacted via idscan-core/src/main/kotlin/com/idscan/core/log/RedactingLogger.kt.
Localizer model/runtime selection uses packaged manifests and a decision table: idscan-core-android/src/main/kotlin/com/idscan/core/android/localizer/RuntimePathSelector.kt, idscan-core-android/src/main/assets/model-manifest.json. OCR assets are checksum-pinned and fetched at build time; dynamic ML Kit is the material external service dependency, while bundled Tesseract supports environments without Play Services.
Delivery and assurance
Gradle convention/build logic implements publication, API, model-manifest, privacy, license, reproducibility, and dependency-boundary gates: build-logic/src/main/kotlin/com/idscan/buildlogic/VerifyModelManifestTask.kt, build-logic/src/main/kotlin/com/idscan/buildlogic/privacy/NetworkIsolationScanTask.kt. Benchmarks select and record LiteRT runtime behavior: idscan-benchmark/src/main/kotlin/com/idscan/benchmark/BenchmarkRunner.kt, idscan-benchmark/src/main/kotlin/com/idscan/benchmark/report/DecisionTableWriter.kt.
Components 22
Host integration
- Android host app · Owns camera permission and launches one contract.
- Core SDK API · Public requests, configuration, and processor entry points.
idscan-core/src/main/kotlin/com/idscan/core/IdScanSdk.kt
UI flavors
Choose exactly one scanner UI distribution.
- Dynamic ML Kit contract · Activity Result UI flavor using dynamic recognition delivery.
idscan-ui-dynamic/src/main/kotlin/com/idscan/ui/dynamic/IdScanContract.kt - Dynamic live capture · CameraX frames, coordinate mapping, tracking, and quality feedback.
idscan-ui-dynamic/src/main/kotlin/com/idscan/ui/dynamic/camera/LiveScanController.kt - ML Kit readiness · Checks availability of dynamically delivered ML Kit.
idscan-ui-dynamic/src/main/kotlin/com/idscan/ui/dynamic/readiness/MlKitReadinessProvider.kt - Bundled contract · Activity Result UI flavor for bundled recognition.
idscan-ui-bundled/src/main/kotlin/com/idscan/ui/bundled/IdScanContract.kt - Bundled scanner activity
idscan-ui-bundled/src/main/kotlin/com/idscan/ui/bundled/IdScanScannerActivity.kt - Bundled Tesseract OCR · Recognition option without Play Services.
idscan-ui-bundled/src/main/kotlin/com/idscan/ui/bundled/ocr/TesseractTextRecognizerBinding.kt
Core pipeline
- Pipeline orchestrator · Composes localization, quality, extraction, resolution, and rules.
idscan-core/src/main/kotlin/com/idscan/core/pipeline/PipelineOrchestrator.kt - Localization and quality · Finds the document and evaluates frame quality.
idscan-core/src/main/kotlin/com/idscan/core/pipeline/LocalizerStage.kt - Image preprocessing · Grayscale, contrast, deskew, warp, and escalation processing.
idscan-core/src/main/kotlin/com/idscan/core/preprocess/BitmapPreprocessingPipeline.kt - Barcode and AAMVA · Decodes barcode payloads and parses AAMVA data.
idscan-core/src/main/kotlin/com/idscan/core/pipeline/BarcodeBranchStage.kt - MRZ recognition · Reconstructs and validates ICAO MRZ formats.
idscan-core/src/main/kotlin/com/idscan/core/pipeline/MrzBranchStage.kt - OCR field extraction · Converts recognized text into field candidates.
- Field resolution · Merges sources by trust hierarchy and preserves provenance.
idscan-core/src/main/kotlin/com/idscan/core/pipeline/FieldResolverStage.kt - Warnings and rules · Produces eligibility, quality, and mismatch warnings.
idscan-core/src/main/kotlin/com/idscan/core/pipeline/RulesStage.kt - IdScan result · Status, normalized fields, provenance, warnings, frames, and readiness.
idscan-core/src/main/kotlin/com/idscan/core/result/IdScanResult.kt
Android runtime and models
- Android processor adapter · Adapts Android images, parceling, assets, and runtimes.
idscan-core-android/src/main/kotlin/com/idscan/core/android/IdScanProcessorAndroid.kt - Model runtime selection · Selects packaged localizer runtime using manifests and a decision table.
idscan-core-android/src/main/kotlin/com/idscan/core/android/localizer/RuntimePathSelector.kt - Model manifest
idscan-core-android/src/main/assets/model-manifest.json
Delivery and assurance
- Build verification gates · Enforces manifest, privacy, publication, API, license, and dependency boundaries.
build-logic/src/main/kotlin/com/idscan/buildlogic/VerifyModelManifestTask.kt - Runtime benchmarks · Records LiteRT runtime decisions.
idscan-benchmark/src/main/kotlin/com/idscan/benchmark/BenchmarkRunner.kt
Connections 24
- Android host app → Dynamic ML Kit contract: launches one flavor
- Android host app → Bundled contract: launches one flavor
- Dynamic ML Kit contract → Dynamic live capture: starts capture
- Bundled contract → Bundled scanner activity: starts scanner
- Dynamic live capture → Android processor adapter: frames
- Bundled scanner activity → Android processor adapter: frames
- Dynamic ML Kit contract → ML Kit readiness: checks
- Bundled scanner activity → Bundled Tesseract OCR: uses OCR
- Core SDK API → Pipeline orchestrator: processes request
- Android processor adapter → Core SDK API: adapts input
- Android processor adapter → Model runtime selection: selects localizer runtime
- Model runtime selection → Model manifest: reads
- Pipeline orchestrator → Localization and quality: localizes and scores
- Localization and quality → Image preprocessing: prepares/escalates image
- Image preprocessing → Barcode and AAMVA: barcode image
- Image preprocessing → MRZ recognition: MRZ image
- Image preprocessing → OCR field extraction: OCR image
- Barcode and AAMVA → Field resolution: candidates
- MRZ recognition → Field resolution: candidates
- OCR field extraction → Field resolution: candidates
- Field resolution → Warnings and rules: normalized fields
- Warnings and rules → IdScan result: result and warnings
- Build verification gates → Model manifest: verifies
- Runtime benchmarks → Model runtime selection: informs decision table