How zmap/zannotate works
Main Components
• Command Line Interface (CLI) – Represent the various command entry points (e.g., the zannotate command in cmd/zannotate and additional tools like mrt2json).
• Command Modules – Show the “cmd” directory with its subcommands, emphasizing that they serve as the main executables which delegate work to core libraries.
• External Resources – Indicate Maxmind GeoIP2 Database (geoip2.mmdb) as an external dependency, plus the MRT routing data input.
• Auxiliary Tools – Note the presence of the “asnames” Python tool and any other helpers (zmrt, zrouting) that might provide specialized functionality or auxiliary data processing.
• Configuration & Build – Include support files like conf.go, BUILDING.md, .travis.yml (for CI/CD), and go.mod/go.sum, which collectively outline build and dependency management aspects.
Relationships and Interactions
• Data Flow: Begin with the input (data piped to the CLI) and show it flowing into the CLI module.
– IPs from the input are passed through the GeoIP2 annotation module (geoip2.go) that interacts with the external Maxmind database.
– For AS/Routing information, data flows into the routing modules (routing.go, parts in zrouting and zmrt) to look up and enrich annotations.
Architectural Patterns / Design Principles
• Modular Design: Emphasize that functionality is split across dedicated packages (e.g., one for geoip, one for AS/routing, one for MRT handling). This modularization helps in isolating responsibilities and simplifies testing.
• Separation of Concerns: Differentiate between the CLI “front-end” and the processing “back-end” modules.
• Single Responsibility: Each module (e.g., geoip2.go vs. routing.go) handles one specific part of the overall annotation process.
• Extensibility: With components like asnames in Python and separate command directories, the system is built to allow for new annotation sources or commands to be added.