How orochi-network/zkdatabase works
Project Type and Purpose
• zkDatabase is a decentralized database service that leverages Zero-Knowledge Proofs (ZKP) to offload computational proving from client-side applications, improving performance, usability, and security.
• The goal is to bridge the gap between Web3’s promises and current Web2 realities by providing a serverless, scalable, and secure infrastructure for decentralized applications (zkApps).
File Structure
• The monorepo is organized into multiple packages (e.g., packages/api, packages/kubo, packages/mina-service, packages/serverless, packages/smart-contract, packages/storage, packages/zkdb). Each package serves a specific domain function such as API interfaces, smart contracts, database storage, permissions, and wallet or authentication services.
• Build configurations (e.g., rollup.config.js, Dockerfiles, tsconfig.json) indicate a well-modularized, multi-environment project that supports both on-chain (smart contract) and off-chain (service and data management) components.
Extract Architectural Insights from the README
• The README explicitly breaks down the zkDBaaS architecture into key components:
a. zkApp: the client-side application with UI and a dedicated smart contract for managing application-level logic.
b. zkDatabase Smart Contract: deployed on the Mina blockchain for managing data commitments and proof generation.
c. zkDatabase Client: provides an API interface that handles data updates and queries, acting as an intermediary between client applications and underlying services.
d. zkDatabaser aaS: the core service layer that handles tasks like authorizing updates, data storage in MongoDB, proof generation, and blockchain interactions.
e. MongoDB replica set: the database back-end that ensures high availability and scalability.
• The README outlines clear data flows for both data updates and queries, emphasizing an interaction flow where requests traverse from the zkApp to the client, onto the aaS layer, with smart contracts and the database working in tandem.
a. Main Components:
• zkApp (Client Interface): includes the user interface (zkApp UI) and application-specific smart contract logic.
• zkDatabase Smart Contract: interacts with the Mina blockchain.
• zkDatabase Client: the intermediary interface between zkApps and backend services.
• zkDatabaser aaS: the core service that processes data updates/queries, validates permissions (using public key authentication), and orchestrates proof generation.
• MongoDB Replica Set: the storage layer for transactional data and proofs.
b. Relationships and Interactions:
• Data Updates: zkApp → zkDatabase Client → zkDatabaser aaS → (Authorization & Data Storage) → Smart Contract (for proof commitment).
• Data Queries: zkApp → zkDatabase Client → zkDatabaser aaS → (Data retrieval from MongoDB & Lookup Proof) → zkDatabase Client → zkApp.
• Integration with external systems (Mina blockchain and MongoDB).
• Internal service interactions, for example, how the smart contract interacts with the aaS component for proof commitments.
c. Architectural Patterns and Design Principles:
• Microservices/Modular Architecture: The multi-package structure (API, serverless services, smart-contract operations, etc.) indicates separation of concerns.
• Serverless and offloading strategy: Emphasize how computationally intensive proof generation is moved off the client.
• Security: Public key authentication and session management play a critical part.
• Scalability: Use of a MongoDB Replica Set ensures the database layer can handle high loads.
d. Relevant Technologies:
• Technologies visible include TypeScript, Node.js libraries (as suggested by package.json and ESLint/Prettier configurations), Docker for containerization, MongoDB for the database, and Mina blockchain for the smart contract integration.
Instructing the Principal Software Engineer
• Clear labels for each major component: zkApp, zkDatabase Client, zkDatabaser aaS, zkDatabase Smart Contract, MongoDB Replica Set.
– Rectangles for service components (zkDatabase Client, zkDatabaser aaS).