How 0siriz/keyweaver works
Project Type and Purpose
• This is an open-source command-line tool (KeyWeaver) written in Go.
• Purpose: to automate the setup and management of a Public Key Infrastructure (PKI), supporting from single to three-tiered Certification Authorities (CAs).
File Structure
• Top-level files: Makefile, ca.yaml (configuration template), README.md, go.mod, go.sum.
• cmd/keyweaver-cli: CLI entrypoint, root and subcommands under cmd/ca.
• pkg/: core libraries
• pkg/models: data structures (e.g. CA, certificate specs)
• pkg/cert: certificate generation logic
• pkg/storage: persistence layer (e.g. writing keys and certs to disk)
• No frontend or service layers—purely a CLI tool with pluggable back-ends.
README
• Confirms focus on PKI tooling and multi-tier CA generation.
a. Main Components
• CLI Runner (cmd/keyweaver-cli/main.go & root.go)
• Command Handlers (cmd/keyweaver-cli/cmd/ca/*.go)
• Configuration Loader (reads ca.yaml)
• Core Logic
– Models (pkg/models)
– Certificate Engine (pkg/cert)
– Storage Engine (pkg/storage)
• External I/O: file system (for keys, certs), optional HSM or KMS integration points.
b. Relationships and Interactions
1. User invokes CLI with subcommand (e.g. “keyweaver-cli ca init”).
2. Root command loads global flags, parses commands.
3. CA subcommand loads YAML config into pkg/models.
4. pkg/models passes structured input to pkg/cert to generate keys and certificates.
5. pkg/storage persists generated artifacts to disk (PEM files, directories).
6. CLI reports status/error back to user.
c. Architectural Patterns and Principles
• Separation of Concerns: CLI parsing vs. business logic vs. persistence.
• Pluggable modules: storage interface can be extended to support databases, cloud KMS, etc.
• Single Responsibility per package: models only define data, cert handles crypto, storage handles I/O.
d. Key Technologies
• Go’s standard library (crypto/x509, encoding/pem, file I/O).
• Cobra (or similar) for CLI parsing (inferred).
• YAML parsing (via ca.yaml) for flexible CA definitions.