How ndavd/bop works
Project Type and Purpose
• This is a command-line (REPL) multichain portfolio tracker supporting several blockchains (EVM, Solana, Ton, etc.).
• It fetches portfolio data locally and uses RPC calls to interact with blockchains and API calls (via Dexscreener) for token pricing.
• The data is stored locally (in an encrypted configuration file) and accessed in memory during REPL sessions.
Analyzing the File Structure
• The top-level directories include .github for workflows (CI/CD) and src, which contains the application’s source code.
• Under src, key directories include:
• chain – Implements chain-specific functionalities such as properties, handling different blockchain types (evm, sol, ton, etc.).
• dexscreener – Handles the interactions with the external DEX Screener API to retrieve token price information.
• repl – Contains the interactive REPL logic (command parsing, session management, data encryption/decryption, and input/output handling).
• utils – Provides supporting functions for tasks like text formatting, retry logic, and displaying spinners to indicate loading.
• The presence of Cargo.toml, Cargo.lock, etc., confirms it is a Rust project with dependency management.
a. Main Entry Point:
• ‘src/main.rs’ as the central starting module which initializes the application.
b. REPL Interface:
• REPL module (src/repl) as the primary user interface. It handles user commands, reads the local encrypted data file (.bop-data), and orchestrates interactions among various components.
c. Chain Module:
• ‘chain’ directory with submodules (chain_properties, chain_type, evm_chain, sol_chain, ton_chain, token, etc.). This module acts as an abstraction layer for querying different blockchains using RPC.
• That it is designed to allow swapping of default RPCs with custom ones.
d. Dexscreener Module:
• Dexscreener module, which interfaces with the Dexscreener API to fetch token prices.
e. Utility Functions:
• ‘utils’ components (like float, table, text, spinner, etc.) as supporting services used by both the chain and REPL modules to manage formatting and synchronous operations.
f. Data Storage:
• Local configuration storage (".bop-data" file) as a persistent data store that holds encrypted portfolio data.
g. External Interactions:
• Similarly, from the dexscreener module to the Dexscreener external API, indicating these as external service interactions.
Architectural Patterns and Design Principles
• Modular design: The project cleanly separates concerns by dividing blockchain-specific functionality (chain module), external API calls (dexscreener), and the user session handling (repl).
• That the project is structured as a modular monolith with distinct responsibilities distributed among well-named modules.
• That dependency inversion is applied since external services (RPC and Dexscreener) can be swapped (e.g., for custom RPC endpoints).