How dotenvx/dotenvx works
dotenvx is a secure dotenv product: it encrypts secrets in .env files, distributes the encrypted files with code, and injects decrypted values when applications run. The primary workflow starts at the CLI run command, validates and resolves environment files, then launches the requested process with its environment; the README also documents encryption, key custody, commit protection, Armor, integrations, and SDK loading. Some implementation paths are represented at subsystem-directory level because their source was not sampled; edges are limited to README claims and relationships visible in indexed or excerpted files.
Main entry points: run.js Run action · dotenvx.js CLI commands · main.js SDK configuration · validate.js Env validation
Components 23
CLI workflow
- CLI commands
src/cli/dotenvx.js - Run action
src/cli/actions/run.js - Encrypt action
src/cli/actions/encrypt.js - Commit protection
src/cli/actions/protect.js
Environment processing
- SDK configuration
src/lib/main.js - Env validation
src/lib/services/validate.js - Envfile processing
src/lib/envfile - Environment resolution
src/lib/resolvers/envs.js - Encryption transform
src/lib/transforms/encrypt.js - Decryption
src/lib/decryptors - Command execution
src/lib/helpers/executeCommand.js
Keys and custody
- Key storage selection
src/lib/helpers/selectKeyStorage.js - Custody providers
src/lib/custodians - Session settings
src/db/session.js - Device keys
src/db/device.js - Armor operations
src/lib/services - External secret sources
src/lib/custodians/local
Security and services
- Armor API
src/lib/api - Event delivery
src/lib/events - Output redaction
src/lib/helpers/redactOutput.js
Other components
- Developer
- Application process
- Git
Connections 24
- Developer → CLI commands: invokes
README.md - CLI commands → Run action: routes command
src/cli/dotenvx.js - Run action → Env validation: validates inputs
src/cli/actions/run.js - Env validation → Envfile processing: processes files
- Env validation → Environment resolution: resolves values
- Run action → Command execution: launches command
src/cli/actions/run.js - Command execution → Application process: injects environment
README.md - Developer → Encrypt action: encrypts secrets
README.md - CLI commands → Encrypt action: routes command
src/cli/dotenvx.js - Encrypt action → Encryption transform: encrypts values
- Application process → SDK configuration: loads configuration
README.md - SDK configuration → Environment resolution: resolves envs
src/lib/main.js - SDK configuration → Decryption: decrypts values
- Developer → Key storage selection: selects custody
- Key storage selection → Custody providers: queries choices
src/lib/helpers/selectKeyStorage.js - Custody providers → Device keys: uses device keys
- Custody providers → External secret sources: reads secrets
src/lib/custodians/index.js - Developer → Commit protection: protects commits
README.md - Commit protection → Git: guards commits
- Developer → Armor operations: manages keys
- Armor operations → Armor API: calls service
- Armor operations → Session settings: uses session
src/cli/actions/armor/move.js - Run action → Output redaction: redacts output
src/cli/actions/run.js - Run action → Event delivery: emits events
src/cli/actions/run.js