How codershubhammate/block-chain-based-secure-notarization-system works
1. This is a multi-surface notarization platform, not a single app.
The repo contains three primary runtime surfaces: a web portal (Web-App), a desktop console (Frontend Desktop Application), and a backend orchestration layer (backend). All three are tied together by a shared document/notary/governance model and by the same blockchain contracts.
2. The web portal is the main end-user entry point.
Web-App is a Next.js application with dashboard pages for uploading, verifying, versioning, documents, tokens, and governance. It includes auth UX, wallet/session hooks, liveness/face-scan components, and client-side helpers for API calls, web3, encryption, and PDF handling. The public/models directory shows that liveness checks are partially performed in-browser with bundled face-recognition models.
3. The desktop application is a role-focused console for notaries/admins.
Frontend Desktop Application is a packaged desktop frontend with Electron-style entry points (main.js, preload.js) and separate role-based screens for admin and notary workflows. It also includes a Remote Auth sub-application, suggesting a desktop-assisted remote-signing or remote-login path. This surface is optimized for operational users rather than general customers.
4. The backend is the system’s central orchestrator.
backend/src is the main service layer and is organized into clear runtime boundaries:
- routes for auth, documents, upload, tokens, governance, notaries, users, transactions, disputes, and system
- middleware for auth, actor context, correlation IDs, rate limiting, and circuit breaking
- services for storage, config, logging, identity sync, reputation, secrets, maintenance, and startup guards
- workers for reconciliation, identity sync, reputation updates, cleanup, and scavenging
This is the piece that mediates between UI, database, object storage, and blockchain.
5. Persistent state is split between PostgreSQL and object storage.
The backend/migrations and deployment_validation/migrations trees show a heavily evolved PostgreSQL schema with tables for users, documents, upload intents, wallet nonces, governance, token audits, notary applications, and system logs. Files and document payloads are not stored in the database; the backend’s storage service points to AWS S3 as the document vault, with signed URLs used for upload/download flows.
6. Blockchain is the source of truth for finalized actions.
The contracts directory contains the on-chain layer: DocumentRegistry, NotaryRegistry, NTK, NTKR, and BBSNSMultiSig. These contracts model document finalization, identity/role registry, reputation/token mechanics, and multi-signature governance. ABIs and tests are present, along with deployment scripts, so the repo treats chain interactions as a first-class subsystem rather than a thin integration.
7. Backend-to-chain interaction is explicitly mediated.
The backend’s src/blockchain folder contains a connection layer, nonce manager, KMS-backed signer, registry/notary helpers, and a circuit-breaker state. The readme’s EIP-712 flow matches this: the backend fetches the nonce, assembles a typed payload, collects a signature from the remote wallet, and relays the transaction to the chain. That makes the backend a trusted relay and policy gate, not just a pass-through API.
8. The document lifecycle is an end-to-end state machine.
A typical flow is: intent creation → S3 upload → payment/token verification → notary assignment → signature/chain relay → on-chain confirmation. The backend/src/services/document-status.service.js, upload and documents routes, plus workers/reconciliation* indicate that document state is tracked in both DB and chain, with background jobs reconciling drift and cleaning stale intents.
9. Identity, liveness, and role assignment are core security boundaries.
The repo contains liveness checks in both client and backend, auth nonces, remote auth, notary registration, wallet normalization, and reputation-related migrations. This suggests identity is not a simple username/password model; it is a combined system of wallet binding, liveness verification, and role status that feeds into notary/admin privileges and document authorization.
10. Governance is a dedicated subsystem, not an admin afterthought.
Governance is represented by the multisig contract, governance routes/UI, proposal targeting, remote confirm/sign pages, and token audits/deposits. Admin actions appear to be separated from ordinary notarization, with explicit approval workflows and threshold-based execution. That makes governance a distinct path through the system, likely involving multiple signers and on-chain confirmations.
11. Operational reliability is handled through workers and safety middleware.
The backend includes circuit breakers, rate limiting, correlation/audit-session middleware, and a startup guard. Workers handle eventual-consistency tasks such as identity sync, reconciliation, cleanup of upload intents, and reputation adjustments. Architecturally, this means the system tolerates asynchronous side effects and retries rather than forcing every action to complete synchronously in the request path.
12. The repo includes a large validation/audit layer alongside the product code.
There are extensive scripts, audits, migration checkers, end-to-end tests, and a deployment_validation mirror of the backend. This indicates a strong separation between the operational product and the validation/hardening environment, with tools for schema verification, contract checks, token role checks, and forensic audits. For an architecture diagram, this should be shown as an adjacent compliance/ops lane rather than part of the live request path.
13. The main external dependencies are material to the architecture.
The system depends on PostgreSQL for structured state, AWS S3 for document storage, a blockchain network for finality, and a relayer/private key or KMS-backed signing authority for relay transactions. Those integrations are not incidental; they define how data moves and where trust boundaries sit.
14. Net effect: the architecture is a layered notarization pipeline.
User-facing clients collect intent and identity evidence, the backend enforces policy and manages state, background workers keep the database consistent, object storage holds the documents, and smart contracts provide final immutable state. The key diagram boundary is therefore: clients → backend/orchestrator → DB/S3/blockchain, with governance and validation as cross-cutting subsystems.
Main entry points: server.js API Core · blockchain Chain Bridge · abi Deployments · migrations PostgreSQL
Components 20
Client surfaces
End-user web and desktop entry points.
- Web App · Primary customer-facing portal for notarization, identity, documents, and governance.
Web-App - Desktop Console · Operational desktop frontend for admin and notary workflows.
Frontend Desktop Application - Remote Auth · Separate remote authentication/signing surface bundled with the desktop ecosystem.
Frontend Desktop Application/Remote Auth
Backend core
Live orchestration, policy, and APIs.
- API Core · Main backend application shell and request entry point.
backend/src/server.js - Routes · Auth, upload, document, token, governance, notary, user, transaction, dispute, and system endpoints.
backend/src/routes - Middleware · Authentication, actor context, correlation, rate limiting, and circuit breaking.
backend/src/middleware - Services · Storage, configuration, logging, identity sync, reputation, secrets, maintenance, and startup guards.
backend/src/services - Chain Bridge · Backend blockchain connection, nonce management, KMS signer, and registry helpers.
backend/src/blockchain - Workers · Reconciliation, cleanup, identity sync, reputation, and scavenging jobs.
backend/src/workers - Doc State · Document lifecycle tracking and state reconciliation across DB and chain.
backend/src/services/document-status.service.js
On-chain layer
Smart contracts and deployment artifacts.
- Documents · On-chain finalization and document registry.
contracts/contracts - Notary Registry · On-chain notary identity and role registry.
contracts/contracts - Token System · NTK and NTKR token/reputation mechanics.
contracts/contracts - Multisig Gov · Threshold governance and multisig execution layer.
contracts/contracts - Deployments · ABIs, deployment scripts, and contract test artifacts.
contracts/abi
Persistent state
Database and object storage boundaries.
- PostgreSQL · Structured system state, audits, intents, roles, governance, and identity records.
backend/migrations - S3 Vault · Document payload vault used for upload/download flows via signed URLs.
backend/src/services/storage.service.js
Validation and ops
Audit, validation, and recovery tooling.
- Validation Suite · Scripts and audits for schema, roles, relayer, balances, and end-to-end verification.
backend/scripts/audit - Deployment Mirror · Parallel migration and runtime mirror for deployment validation and forensic checks.
deployment_validation - Docs · Architecture, security, governance, database, installation, and walkthrough documentation.
documentation
Connections 30
- Web App → API Core: API calls · Customer flows submit auth, document, token, and governance requests.
- Desktop Console → API Core: ops calls · Desktop console uses backend APIs for notary/admin workflows.
- Remote Auth → API Core: remote auth · Remote login and signing paths are brokered through backend APIs.
- API Core → Routes: routes · Application shell exposes domain endpoints through route handlers.
- API Core → Middleware: guards · Requests pass through policy, identity, and resilience middleware.
- API Core → Services: orchestrates · Backend services handle config, storage, logging, sync, and startup policy.
- API Core → Chain Bridge: relays · Backend assembles signed transactions and interacts with chain infrastructure.
- API Core → Workers: queues jobs · Long-running consistency and sync tasks are handled asynchronously.
- Routes → Doc State: updates · Document and upload endpoints drive the lifecycle state machine.
- Doc State → PostgreSQL: persists · Document status and audit state are stored in PostgreSQL.
- Routes → PostgreSQL: reads/writes · Domain endpoints operate against structured relational state.
- Services → S3 Vault: stores files · Document payloads are written to object storage and served through signed URLs.
- Services → PostgreSQL: reads/writes · Configuration, audit, identity, and reputation data live in PostgreSQL.
- Chain Bridge → Documents: finalizes docs · Registry helper layer submits document finalization transactions.
- Chain Bridge → Notary Registry: role sync · Notary and registry helpers mediate role and identity on chain.
- Chain Bridge → Token System: token ops · NTK and NTKR interactions support deposits, audits, and rewards.
- API Core → Multisig Gov: governance · Governance routes trigger proposal and threshold-signature flows.
- Deployments → Documents: deploys · ABIs and deployment scripts define contract interfaces and rollout.
- Deployments → Notary Registry: deploys · Deployment artifacts cover registry contracts and tests.
- Deployments → Token System: deploys · Deployment artifacts cover token and reputation contracts.
- Deployments → Multisig Gov: deploys · Deployment artifacts cover multisig governance contracts.
- Validation Suite → API Core: audits · Validation scripts exercise live API, schema, and runtime behavior.
- Validation Suite → Chain Bridge: verifies · Audit scripts check nonce, relayer, roles, balances, and signatures.
- Validation Suite → PostgreSQL: checks schema · Schema and constraint audits validate database integrity.
- Validation Suite → Deployments: checks chain · Bytecode, ABI, and deployment audits validate contract artifacts.
- Deployment Mirror → API Core: mirrors · Parallel validation runtime mirrors the live backend architecture.
- Deployment Mirror → PostgreSQL: mirrors · Validation migrations and state checks mirror production schema.
- Deployment Mirror → Chain Bridge: verifies · Validation scripts re-run relayer and chain-role checks.
- Docs → API Core: documents · System and architecture docs explain backend flows and boundaries.
- Docs → Multisig Gov: documents · Governance and security docs describe multisig execution and policy.