How olearydj/near-earth-object-monitor works
Purpose and Entry Points
Near-Earth Object Monitor is a Python 3.11+ command-line pipeline for retrieving NASA NEO Feed close-approach data, deriving normalized object records and aggregate metrics, presenting results, and optionally persisting artifacts. The installed neo-monitor command is implemented in src/neo_monitor/cli.py; module execution enters through src/neo_monitor/__main__.py.
Command Orchestration
src/neo_monitor/cli.py owns argument parsing and the end-to-end control flow: date selection, output modes, filtering/ranking, persistence, logging, and no-network project metadata mode. It coordinates specialized modules rather than embedding API, transformation, or rendering behavior. src/neo_monitor/metadata.py provides the --project-info path, which is an explicit early boundary that avoids NASA access.
External Data Acquisition
src/neo_monitor/api.py is the NASA NEO Feed integration boundary. It obtains the API key from environment or local .env, requests the external feed, and surfaces request/API failures to the CLI. NASA’s public API at api.nasa.gov is the only indicated external service. Raw response handling is intentionally separated from later validation so evidence can be saved before the external payload is judged usable.
Validation and Domain Transformation
src/neo_monitor/summarize.py isolates core data logic from transport and presentation. It validates NASA fields used by the application, extracts internal object rows from date-grouped feed data, and computes range-wide summary metrics: count, hazardous count, closest approach, fastest object, and largest estimated diameter. This is the main trust boundary: untrusted NASA JSON becomes records suitable for filtering, ranking, exporting, and display.
Selection and Reporting Flow
The CLI applies row-level filters—hazardous-only, minimum estimated diameter, and maximum lunar miss distance—then ranks selected rows by closest approach, speed, or size and optionally limits them. Aggregate summaries remain based on the full requested range, while listing, charts, and processed CSV use the selected subset. src/neo_monitor/display.py renders readable summaries/tables and Rich-backed bar charts; it also supports plain-text output where Rich styling is unsuitable.
Artifact Output
src/neo_monitor/output.py owns filesystem output boundaries. It writes the original API payload to requested raw JSON paths and writes normalized, filtered/ranked rows to CSV. Typical generated destinations are data/raw/ and data/processed/ (ignored by Git), preserving a distinction between external source evidence and processed reporting data.
Operations and Runtime
src/neo_monitor/logging_config.py configures optional diagnostics without contaminating normal command output: verbose operational messages go to stderr, while a log file receives more detailed debugging information. Runtime dependencies and CLI packaging are defined by pyproject.toml; uv.lock pins the resolved environment. API behavior is designed to be mockable, with stable external-payload examples under tests/fixtures/neo-feed-sample.json and tests/fixtures/neo-feed-invalid.json.
Main entry points: cli.py neo-monitor CLI · output.py Artifact writer · api.py NASA integration · summarize.py Validation & summaries
Components 18
CLI Runtime
- Module entry
src/neo_monitor/__main__.py - neo-monitor CLI · Parses options and coordinates command flow.
src/neo_monitor/cli.py - Project metadata · Serves --project-info without NASA access.
src/neo_monitor/metadata.py - Filter & rank selection · Filters, ranks, and limits normalized rows.
src/neo_monitor/cli.py - Selected records · Subset used by listings, charts, and processed CSV.
- Terminal reporting · Renders tables, summaries, and Rich or plain-text charts.
src/neo_monitor/display.py
Data Processing
- NASA integration · Loads credentials and retrieves raw feed payloads.
src/neo_monitor/api.py - Raw API payload · External evidence retained before validation.
- Validation & summaries · Validates feed fields, normalizes rows, and computes range metrics.
src/neo_monitor/summarize.py - Normalized records · Trusted rows used for selection, reporting, and export.
- Range summary metrics · Computed from the full requested date range.
Artifacts & Operations
- Logging setup · Routes diagnostics to stderr and detailed logs to file.
src/neo_monitor/logging_config.py - Artifact writer · Writes raw JSON evidence and processed CSV.
src/neo_monitor/output.py - Raw JSON artifacts · Original API payloads.
- Processed CSV artifacts · Selected normalized rows.
- Package environment · Defines Python runtime and CLI packaging.
pyproject.toml - Resolved dependency lock
uv.lock
Other components
- NASA NEO Feed · Public close-approach feed at api.nasa.gov.
Connections 19
- Module entry → neo-monitor CLI: starts
- Package environment → neo-monitor CLI: installs command
- Resolved dependency lock → Package environment: pins dependencies
- neo-monitor CLI → Project metadata: --project-info
- neo-monitor CLI → Logging setup: configures
- neo-monitor CLI → NASA integration: fetches requested range
- NASA integration → NASA NEO Feed: requests feed
- NASA integration → Raw API payload: returns
- Raw API payload → Artifact writer: save evidence
- Raw API payload → Validation & summaries: validate and transform
- Validation & summaries → Normalized records: produces
- Validation & summaries → Range summary metrics: computes
- Normalized records → Filter & rank selection: candidate rows
- Filter & rank selection → Selected records: filtered, ranked, limited
- Range summary metrics → Terminal reporting: full-range summary
- Selected records → Terminal reporting: tables and charts
- Selected records → Artifact writer: export rows
- Artifact writer → Raw JSON artifacts: writes
- Artifact writer → Processed CSV artifacts: writes