How psmri/ubi-verification-sdk works
Project type and purpose
• This is a standalone, backend Node.js SDK/service built on Fastify that exposes a single HTTP API (/verification) for credential verification.
• It is designed to be modular and extensible: new “verifier” modules can be dropped in (online or offline) without touching core logic.
File structure
• Top‐level files:
• Dockerfile / docker-compose.yml / deploy.sh → containerization & deployment
• .env.example → environment configuration (PORT, external API URLs, credentials)
• README.md, package.json → project metadata & scripts
• src/config/swagger.yaml → API docs definition
• src/index.js → Fastify server bootstrap (register routes, plugins, swagger)
• src/services/verificationService.js → core service that drives verification
• src/services/verifiers/ → pluggable verifier modules
• VerifierInterface.js → base abstract class
• VerifierFactory.js → selects/verifier instantiation logic based on method & issuerName
• online-verifiers/DhiwayVerifier.js → example online verifier calling external Dhiway API
• offline-verifier/SignatureVerifier.js → example offline verifier applying signature checks
README for additional insights
• Fastify for performance & swagger for interactive docs
• Single API endpoint (POST /verification) with body { credential, config }
• Health check endpoint (GET /health)
• Emphasis on extensibility: add new verifiers by subclassing VerifierInterface
• No direct database or message queues—pure request/response service
A. HTTP Layer (Fastify Server)
• Listens on PORT
• Routes: /health, /documentation, /verification
B. Verification Service (service layer)
• Receives validated request payload
• Delegates to VerifierFactory
C. VerifierFactory
• Reads config.method & config.issuerName
• Instantiates appropriate verifier subclass
D. Concrete Verifier(s)
• Online: DhiwayVerifier → makes HTTPS call to Dhiway external API
• Offline: SignatureVerifier → runs local crypto checks
E. External Dependency
• Dhiway API (or other online providers as added)
F. Configuration & Docs
• swagger.yaml → drives /documentation UI
• .env / .env.example → runtime config (PORT, external URLs)
G. Container/Deployment
• Dockerfile / docker-compose.yml → container boundary
Architectural patterns & design principles
• Layered architecture: HTTP → Service → Factory → Verifier
• Dependency inversion via VerifierInterface (plug‐in pattern)
• Single Responsibility: each module has one concern
• Open/Closed: new verifiers can be added without modifying core
Essential elements
• Clear labels for each component (e.g., “Fastify HTTP Server”, “VerificationService”)
• Callouts for extensibility points (“Add new verifier here”)