How origintrail/ot-node works
Project Type and Purpose
• Type: Backend Node.js application (no traditional “frontend”)
• Purpose: An OriginTrail DKG (Decentralized Knowledge Graph) node that exposes HTTP/RPC APIs and CLI commands, connects to blockchains, triple stores, a relational DB, and a p2p network, and implements the OT protocol (ASK, PUBLISH, GET, UPDATE, FINALITY, etc.).
Top-Level Architectural Layers
A. Interface Layer
• CLI entrypoint (bin/ot-node.js or index.js)
• HTTP API Controllers
• v0 controllers (REST endpoints: publish, get, update, info, etc.)
• v1 controllers (new protocol endpoints: ask, finality, direct-query, etc.)
• RPC Controllers (gRPC or custom RPC for ASK, PUBLISH, GET, UPDATE, FINALITY)
B. Application Layer
• Command Resolver & Executor
• Business-Logic Service Layer (expand these!)
• ask-service
• auth-service
• data-service
• get-service
• publish-service
• update-service
• finality-service
• paranet-service
• blockchain-events-service
• protocol-service
• pending-storage-service
• sharding-table-service
• operation-service & operation-id-service
• messaging-service
• crypto-service & signature-service
• triple-store-service
• ual-service (Uniform Asset Locator)
• validation-service & json-schema-service
• auth-service
C. Module/Plugin Layer
Each service invokes one or more “module managers” that load concrete implementations via dependency injection:
• Blockchain Module (eth, polygon, gnosis, parachain, hardhat)
• Triple-Store Module (Blazegraph, Fuseki, GraphDB, Neptune)
• Repository Module (Sequelize + MySQL)
• Network Module (libp2p p2p)
• HTTP-Client Module (Express HTTP Client + middleware: auth, rate-limiting, validation)
• Auto-Updater Module
• Telemetry Module (Quest Telemetry)
• Validation Module (Merkle-validation)
D. Infrastructure Layer
• Blockchain Networks (RPC endpoints BC1, BC2)
• Triple Store (Java process: Blazegraph / Fuseki / GraphDB / AWS Neptune)
• Relational Database (MySQL)
• P2P Network (libp2p peers)
• External Services (Papertrail logging, telemetry ingestion)
Component Relationships & Data Flows
• Controllers receive client requests → pass to Command Resolver
• Command Resolver selects appropriate Command → delegates to Service Layer
• Service Layer coordinates:
• Data retrieval/storage via triple-store (SPARQL) and repository (SQL)
• Blockchain interactions via Blockchain Module
• P2P messaging via Network Module
• Protocol orchestration (ASK, PUBLISH, UPDATE, FINALITY)
• Validation & cryptographic operations
• Telemetry logging
• Modules talk to external systems (DB, triple store, chains, peers)
• Responses bubble back to controllers → returned to client
Architectural Patterns & Design Principles
• Layered architecture (Interface → Application → Modules → Infrastructure)
• Dependency Injection for swapping module implementations
• Command pattern for protocol operations
• Repository pattern (Sequelize) for DB access
• Module Manager pattern for pluggable services
• Separation of concerns: Controllers vs. Services vs. Modules
Final Checklist
• All Interface endpoints (HTTP v0, HTTP v1, RPC, CLI)
• Command Resolver & Executor
• Module Managers + Implementations
• Infrastructure elements (Blockchain RPC, Triple-Store, MySQL, P2P Network)