How ledgerhq/wallet-api works
Main Components
• API Specification & Core: This includes the “spec” folder (which contains the API docs for RPC, client, server, etc.) plus the “packages/core” folder that defines JSON-RPC, error handling, families, and core types.
• Client Implementation: Found within “packages/client” and “packages/client-react”, these federate the client side of the API. There’s also an example implementation under “examples/client-nextjs” that demonstrates how a front-end integrates the Wallet API, especially for React-based usage.
• Server Implementation: Located in “packages/server”, this part implements the server side of the Wallet API and includes internal handlers for specific modules (account, bitcoin, currency, etc.).
• Simulator & Tools: The “packages/simulator” enables testing and simulating different wallet interactions. Additionally, folders for “packages/manifest-validator-cli” and “packages/manifest-validator” provide tooling for validating dapp and wallet manifests.
• Documentation & Developer Tools: In “apps/docs” you have the documentation app (built with Next.js) that ties all the components and explains usage, while “apps/wallet-api-tools” provides additional UI tools around the API.
• Configuration & CI/CD: Notice the presence of various workflow configurations (.github/workflows), code style/linting (e.g., .eslintrc.js, .prettierrc), and version management (pnpm-workspace.yaml).
Relationships and Interactions
• The Client Implementation (in packages/client and client-react) acts as the consumer of the API and facilitates integration with front-end applications (e.g., the Next.js example).
• The Server Implementation (in packages/server) listens for JSON-RPC messages and dispatches them using the internal handlers from submodules. Underneath, this is built on top of the core (packages/core), which includes domain logic for accounts, currencies, and various supported crypto families.
• Tools like the Simulator and Manifest Validators work in tandem to test/validate the communication and interactions between clients and wallets.
• Documentation (apps/docs) and guides (rfc, spec folders) support developers along with CI/CD configurations ensuring quality and consistency.
Important Architectural Patterns and Design Principles
• Modularity: The monorepo is segmented into clearly defined packages (client, server, core, tools), enforcing separation of concerns.
• Extensibility: The structure for “families” in packages/core and the modular handlers in packages/server indicate an architecture ready to support many cryptocurrencies.
• Standard Interfaces: The use of JSON-RPC for communication suggests an emphasis on a standardized message-passing interface between wallet and application.
• Developer Experience: With thorough documentation, linting, CI/CD workflows, and examples, the project facilitates ease of integration and extension.
Final Checklist
• Every major package or component is represented with a clear label.
• Notes on how various subcomponents (like crypto family modules or internal handlers) fit within the larger architecture.
• A section for CI/CD and Developer Tools where applicable, to reflect modern development practices.
This level of detail will allow the principal software engineer to view the project as a network of interrelated modules—from core API definitions to client and server implementations along with testing/simulation infrastructure—all connected by the central JSON-RPC wallet interface that the project centers on.