How google/nearby works
Main Components
• Nearby Connections Module (folder: “connections/”): This is the core networking library. It covers device discovery, peer-to-peer connection management, data exchange, and cross-platform implementations (native C/C++, Swift, Dart, etc.).
• Nearby Presence Module (folder: “presence/”): This extends connections by providing mechanisms for authentication (identity model), proximity detection (via sensor fusion), and additional resource management.
• Nearby for Embedded Systems (folder: “embedded/”): A specialized, lightweight implementation for embedded environments, focusing on Fast Pair.
• Shared/Supporting Components:
– Proto definitions and generated code are found in “proto/”, “compiled_proto/”, and “internal/proto/”.
– The “sharing/” directory provides additional functionality for sharing data (files, attachments) and incorporates its own analytics, certificates, and connectivity nuances.
– Third-party libraries (in “third_party/”) are integrated for supporting functionalities like cryptography (mbedtls, micro-ecc), serialization (protobuf, json), and various secure communications protocols.
Architectural Patterns & Design Principles
• Layered Architecture: Indicate that on one side there is the low-level protocol/crypto layer (e.g., proto definitions, mbedtls, ukey2) and on top of that lie the higher-level logic for connection management and presence.
• Testability: The presence of many “test” directories (internal/test, unit tests for broadcast, encryption, etc.) indicates a well-decoupled design that relies on interface-based programming and dependency injection. You may annotate or separate these as supporting components.
Final Assembly
Happy diagramming!