How ilsuono/git-remote-g2g works
Main Components
• Server Command Utility (“git g2g”): Found in cmd/git-g2g, this is the entry point for starting a git server (that outputs a host ID used by clients).
• Client Command Utility (“git-remote-g2g”): Located in cmd/git-remote-g2g, this component integrates with git (triggered via “git clone g2g://…”), connecting to the server with the provided host ID.
• Internal Library Components:
• pkg/pack: Implements functionality around reading and scanning ‘packs’ (likely the transport or packaging of git data).
• pkg/specs: Defines constants and data structures (IDs and protocol specifications) that are used across the application.
• Build and Deployment Artifacts: Indicated by Dockerfile, Makefile, GitHub workflows, and goreleaser configuration. These are important for understanding how the system is built, tested, and deployed, though they are secondary to runtime architecture.
Relationships and Interactions
• API/Data Flow: Show how git operations on the client trigger underlying functions that make use of the “pkg/pack” and “pkg/specs” libraries. Similarly, the server side uses these libraries for processing incoming requests.
• P2P Network: Illustrate that both client and server are connected via a libp2p-based communication channel. This may be depicted as a central “libp2p Network” component that facilitates peer discovery and data message exchange.
Architectural Patterns and Design Principles
• Separation of Concerns: The cmd/ directories serve as clear entry points while the pkg/ directories encapsulate core functionality (business logic, pack handling, protocol specifications).
• Client-Server Communication over a P2P Network: This is an unusual design compared to centralized servers, so it’s important to emphasize the decoupled and distributed nature of the system.
• Modularity and Extensibility: The use of separate libraries (e.g., for pack handling and specs) suggests that new protocols or extensions could be added without major refactoring to the command utilities.
Relevant Technologies & Details
• Language: Go (as indicated by the .go files and go.mod).
• Networking Library: libp2p (as referenced in the README).
• Git Integration: Hooks or custom protocols that integrate with standard git commands (e.g., “git clone g2g://…”).
• Build Tools: Makefile, Dockerfile, GitHub Actions workflows, and goreleaser for building and deploying the application across platforms.
• “git g2g” (Server) and “git-remote-g2g” (Client).
• “pkg/pack” and “pkg/specs” as shared internal libraries.
• A separate cloud or network symbol labeled “libp2p Network” to represent the peer-to-peer communication medium.
• For example: “git-remote-g2g” → “libp2p Network” → “git g2g”.