How databox/databox-cli works
1. Overall shape
- This is a Node.js/TypeScript CLI for the Databox public API.
- The repository is organized around command handlers under src/commands, with shared utilities in src/lib, and executable entrypoints in bin/.
2. CLI entrypoints
- bin/run.js and bin/dev.js are the runtime launchers for the CLI.
- The project appears to use an oclif-style command framework: each file in src/commands/** maps to a subcommand exposed on the databox binary.
3. Command layer by domain
- Commands are grouped into clear functional domains:
- auth for API key setup/validation
- account for account discovery and resource listing
- data-source for data source lifecycle and inspection
- dataset for dataset lifecycle, ingestion, and ingestion status
- analyze for Genie AI queries over datasets
- This is the main architectural boundary for the repo: each command is a thin adapter around a specific API workflow.
4. Shared command base
- src/base-command.ts is likely the common superclass for all commands.
- It probably centralizes cross-cutting behavior such as config loading, API client creation, JSON vs table output selection, and error handling.
5. API integration boundary
- src/lib/api-client.ts is the main boundary to external Databox services.
- All CRUD/listing/ingestion operations likely go through this client rather than direct network calls in each command.
- The CLI therefore separates user interaction and argument parsing from HTTP/API access.
6. Configuration and authentication flow
- src/lib/config.ts manages persisted CLI state, especially the API key.
- The README says auth login stores credentials in ~/.config/databox-cli/config.json.
- Most commands depend on that stored key; auth login is the exception because it bootstraps access.
7. Output and user interaction
- src/lib/output.ts handles presentation concerns, especially the default human-readable tables versus --json output.
- src/lib/prompt.ts supports interactive flows such as confirming destructive actions or requesting missing auth input.
- This keeps command modules focused on business action rather than formatting or prompting logic.
8. Main data flows
- Account/resource discovery: account list, account datasets, account data-sources, account timezones fetch reference data from Databox and render it.
- Resource lifecycle: data-source create/delete, dataset create/delete/purge perform mutations against the API.
- Data ingestion: dataset ingest accepts inline JSON, file input, or stdin-style usage and sends records to Databox.
- Ingestion monitoring: dataset ingestion and dataset ingestions query job/status metadata after ingestion.
- Analysis: analyze ask-genie sends dataset questions to a separate Genie/agentic service.
9. External service boundary for analysis
- Most commands talk to the Databox API, but analyze ask-genie also depends on an agentic service.
- The README shows a distinct base URL defaulting to https://agentic-service.databox.com, configurable via --service-url or DATABOX_AGENTIC_SERVICE_URL.
- That makes analysis a separate subsystem from the core CRUD/ingestion API path.
10. Destructive command safeguards
- Commands like delete and purge support --force, implying interactive confirmation is otherwise required.
- This is a safety boundary in the CLI UX: mutation commands are designed to prevent accidental irreversible actions unless explicitly overridden.
11. Skills distribution as a secondary artifact
- The skills/ directory contains packaged SKILL.md files for agent tooling:
- databox-auth
- databox-accounts
- databox-data-sources
- databox-datasets
- databox-analyze
- These are not runtime dependencies of the CLI itself, but they are an important distribution layer for AI agents that use the CLI autonomously.
12. Testing structure mirrors the command tree
- test/commands/** mirrors src/commands/**, which suggests each command has focused unit tests.
- There is also test/env-concurrency.test.ts, indicating coverage for shared environment/config behavior, likely around parallel execution or shared state.
- test/helpers.ts provides common test setup/mocking, probably around API client and filesystem/config isolation.
13. Architecture summary for a diagram
- Draw the system as:
- User/terminal input
- → CLI command modules
- → shared base/helpers
- → Databox API for account/data source/dataset operations
- → separate agentic service for Genie analysis
- with config storage in the local filesystem and prompt/output utilities as cross-cutting supporting components.
Main entry points: base-command.ts Base Cmd · skills Skills · api-client.ts API Client · config.ts Config
Components 17
Runtime
CLI launchers and user entrypoints
Commands
Domain command families exposed by the databox binary
- Auth · Login and token validation
- Account · Account discovery and reference listing
- Data Source · Data source lifecycle and inspection
- Dataset · Dataset lifecycle, ingestion, and status
- Analyze · Genie query workflow
Shared Lib
Common command base and reusable CLI helpers
- Base Cmd · Shared superclass for CLI commands
src/base-command.ts - API Client · Main Databox API integration boundary
src/lib/api-client.ts - Config · Persisted CLI configuration and API key
src/lib/config.ts - Output · Table and JSON rendering
src/lib/output.ts - Prompt · Interactive confirmation and input handling
src/lib/prompt.ts
External
Remote services and local state boundaries
- User · Person running the CLI
- Databox API · Primary backend for CRUD, listing, and ingestion
- Genie Service · Separate analysis service for ask-genie
- Config File · Filesystem-backed CLI state under the user config directory
Skills
Packaged agent skill artifacts
- Skills · Packaged SKILL.md artifacts for autonomous agents
skills
Connections 27
- User → run.js: invokes · User runs the CLI
- User → dev.js: invokes · User runs the CLI in development mode
- run.js → Base Cmd: boots · Runtime launcher initializes the command framework
- dev.js → Base Cmd: boots · Dev launcher initializes the command framework
- Base Cmd → Config: loads · Commands share persisted configuration and auth state
- Base Cmd → Output: formats · Centralizes human-readable and JSON output
- Base Cmd → Prompt: prompts · Centralizes interactive confirmation and input flows
- Auth → Base Cmd: extends · Auth commands build on the shared base command
- Account → Base Cmd: extends · Account commands build on the shared base command
- Data Source → Base Cmd: extends · Data source commands build on the shared base command
- Dataset → Base Cmd: extends · Dataset commands build on the shared base command
- Analyze → Base Cmd: extends · Analyze command builds on the shared base command
- Auth → Config: stores key · Login persists API credentials locally
- Auth → API Client: validates · Validate uses the Databox API client
- Account → API Client: reads · Account discovery and listings go through the API client
- Data Source → API Client: mutates · Create, delete, and list operations use the Databox API
- Dataset → API Client: mutates · Dataset lifecycle, ingestion, and status operations use the Databox API
- Dataset → Prompt: confirms · Destructive dataset actions can require confirmation
- Data Source → Prompt: confirms · Destructive data source actions can require confirmation
- Analyze → Genie Service: queries · ask-genie sends questions to a separate service
- API Client → Databox API: calls · HTTP boundary to Databox backend services
- Config → Config File: persists · Config is stored in the local user configuration directory
- Skills → Auth: packages · Skill artifact mirrors the auth workflow
- Skills → Account: packages · Skill artifact mirrors the account workflow
- Skills → Data Source: packages · Skill artifact mirrors the data source workflow
- Skills → Dataset: packages · Skill artifact mirrors the dataset workflow
- Skills → Analyze: packages · Skill artifact mirrors the analysis workflow