How grishy/any-sync-bundle works
Main Components
• Command/Entry Point: The “cmd” package (with files like config.go, mongo.go, start.go, etc.) is clearly the starting point that wires up the application.
• Configuration Layer: Both the “config” directory and “lightcmp/lightconfig” contain configuration routines for the bundle.
• Core Business Modules:
– “lightcmp” package is subdivided into various modules:
• lightconsensusdb: Manages consensus-related data storage including schema (.sql);
• lightconsensusrpc: Exposes RPC handlers related to consensus functionalities;
• lightfilenodeindex & its “indexpb” subpackage: Handles indexing of file nodes, including protobuf definitions and tests;
• lightfilenoderpc: Manages RPC endpoints for file node operations, with associated tests;
• lightfilenodestore: Implements storage logic for file nodes using BadgerDB (plus mocks/tests);
• lightnodeconf: Provides node configuration management.
• Node and Synchronization Functionality: The “lightnode” folder contains components for consensus (core algorithm in consensus/consensus.go), node coordination (coordinator.go), file node handling (filenode/filenode.go), and overall node management and syncing (node.go and sync.go).
• Testing and Utility: Although you may not need to include test utilities in a high-level design, the “testutil” package shows there is support for block simulation etc.
Relationships and Interactions
• The entry point (cmd package) initializes the configuration, sets up the necessary modules, and starts the server.
• The configuration layer feeds into all modules to determine runtime settings (e.g., embedded vs external services).
• The “lightcmp” modules provide the core services:
– lightconfig, lightconsensusdb, and lightconsensusrpc work together to establish and expose consensus behavior.
– lightfilenodeindex and lightfilenoderpc handle file storage operations and their indexing services.
– lightfilenodestore acts as the underlying local storage mechanism, especially in the “light” version.
• The “lightnode” components build on top of these lower-level functionalities to provide distributed aspects (such as consensus and synchronization). The coordinator and consensus engines communicate internally via RPC (using the protocols defined in the light*-rpc packages) and likely manage interactions between nodes.
• Optionally, in the all-in-one bundle version, external components like MongoDB, Redis, and MinIO might be integrated (as seen via Docker configurations and environment variables) to extend the storage and caching layers.
Architectural Patterns and Design Principles
• Modularity in a Bundled Binary: Although multiple services exist logically, they are merged into one binary to simplify deployment. This means the system can be represented as a modular monolith with clearly decoupled components communicating through internal interfaces/RPC.
• RPC Communication: Several modules expose RPC interfaces, so emphasize the request/response flow between clients and services and among internal modules.