# olearydj/near-earth-object-monitor architecture

> Architecture diagram of the GitHub repository olearydj/near-earth-object-monitor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/olearydj/near-earth-object-monitor
- Repository: https://github.com/olearydj/near-earth-object-monitor

## Overview

#### 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: [`src/neo_monitor/cli.py`](https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/cli.py) (neo-monitor CLI), [`src/neo_monitor/output.py`](https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/output.py) (Artifact writer), [`src/neo_monitor/api.py`](https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/api.py) (NASA integration), [`src/neo_monitor/summarize.py`](https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/summarize.py) (Validation & summaries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["CLI Runtime"]
  node_entry_module["Module entry<br/>Python entry point<br/>[__main__.py]"]
  node_cli["neo-monitor CLI<br/>orchestrator<br/>[cli.py]"]
  node_metadata["Project metadata<br/>offline command path<br/>[metadata.py]"]
  node_selection["Filter &amp; rank selection<br/>CLI selection stage<br/>[cli.py]"]
  node_selected_rows["Selected records<br/>reporting rows"]
  node_display["Terminal reporting<br/>renderer<br/>[display.py]"]
end

subgraph group_core["Data Processing"]
  node_api["NASA integration<br/>transport boundary<br/>[api.py]"]
  node_raw_payload["Raw API payload<br/>untrusted JSON"]
  node_summarize["Validation &amp; summaries<br/>domain transformation<br/>[summarize.py]"]
  node_normalized_rows["Normalized records<br/>domain rows"]
  node_summary_metrics["Range summary metrics<br/>aggregates"]
end

subgraph group_artifacts["Artifacts &amp; Operations"]
  node_logging["Logging setup<br/>operations<br/>[logging_config.py]"]
  node_output["Artifact writer<br/>filesystem boundary<br/>[output.py]"]
  node_raw_json["Raw JSON artifacts<br/>generated data"]
  node_processed_csv["Processed CSV artifacts<br/>generated data"]
  node_packaging["Package environment<br/>packaging<br/>[pyproject.toml]"]
  node_lockfile["Resolved dependency lock<br/>[uv.lock]"]
end

node_nasa_api{{"NASA NEO Feed<br/>external API"}}

node_entry_module -->|"starts"| node_cli
node_packaging -->|"installs command"| node_cli
node_lockfile -->|"pins dependencies"| node_packaging
node_cli -.->|"--project-info"| node_metadata
node_cli -->|"configures"| node_logging
node_cli -->|"fetches requested range"| node_api
node_api -->|"requests feed"| node_nasa_api
node_api -->|"returns"| node_raw_payload
node_raw_payload -.->|"save evidence"| node_output
node_raw_payload -->|"validate and transform"| node_summarize
node_summarize -->|"produces"| node_normalized_rows
node_summarize -->|"computes"| node_summary_metrics
node_normalized_rows -->|"candidate rows"| node_selection
node_selection -->|"filtered, ranked, limited"| node_selected_rows
node_summary_metrics -->|"full-range summary"| node_display
node_selected_rows -->|"tables and charts"| node_display
node_selected_rows -->|"export rows"| node_output
node_output -->|"writes"| node_raw_json
node_output -->|"writes"| node_processed_csv

click node_entry_module "https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/__main__.py"
click node_cli "https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/cli.py"
click node_metadata "https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/metadata.py"
click node_logging "https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/logging_config.py"
click node_api "https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/api.py"
click node_summarize "https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/summarize.py"
click node_selection "https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/cli.py"
click node_display "https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/display.py"
click node_output "https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/output.py"
click node_packaging "https://github.com/olearydj/near-earth-object-monitor/blob/main/pyproject.toml"
click node_lockfile "https://github.com/olearydj/near-earth-object-monitor/blob/main/uv.lock"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry_module,node_cli,node_metadata,node_selection,node_selected_rows,node_display toneBlue
class node_api,node_raw_payload,node_summarize,node_normalized_rows,node_summary_metrics toneAmber
class node_logging,node_output,node_raw_json,node_processed_csv,node_packaging,node_lockfile toneMint
class node_nasa_api toneNeutral
```

## Components

### CLI Runtime

- [Module entry](https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/__main__.py): Python entry point · `src/neo_monitor/__main__.py`
- [neo-monitor CLI](https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/cli.py): orchestrator · Parses options and coordinates command flow. · `src/neo_monitor/cli.py`
- [Project metadata](https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/metadata.py): offline command path · Serves --project-info without NASA access. · `src/neo_monitor/metadata.py`
- [Filter & rank selection](https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/cli.py): CLI selection stage · Filters, ranks, and limits normalized rows. · `src/neo_monitor/cli.py`
- **Selected records**: reporting rows · Subset used by listings, charts, and processed CSV.
- [Terminal reporting](https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/display.py): renderer · Renders tables, summaries, and Rich or plain-text charts. · `src/neo_monitor/display.py`

### Data Processing

- [NASA integration](https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/api.py): transport boundary · Loads credentials and retrieves raw feed payloads. · `src/neo_monitor/api.py`
- **Raw API payload**: untrusted JSON · External evidence retained before validation.
- [Validation & summaries](https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/summarize.py): domain transformation · Validates feed fields, normalizes rows, and computes range metrics. · `src/neo_monitor/summarize.py`
- **Normalized records**: domain rows · Trusted rows used for selection, reporting, and export.
- **Range summary metrics**: aggregates · Computed from the full requested date range.

### Artifacts & Operations

- [Logging setup](https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/logging_config.py): operations · Routes diagnostics to stderr and detailed logs to file. · `src/neo_monitor/logging_config.py`
- [Artifact writer](https://github.com/olearydj/near-earth-object-monitor/blob/main/src/neo_monitor/output.py): filesystem boundary · Writes raw JSON evidence and processed CSV. · `src/neo_monitor/output.py`
- **Raw JSON artifacts**: generated data · Original API payloads.
- **Processed CSV artifacts**: generated data · Selected normalized rows.
- [Package environment](https://github.com/olearydj/near-earth-object-monitor/blob/main/pyproject.toml): packaging · Defines Python runtime and CLI packaging. · `pyproject.toml`
- [Resolved dependency lock](https://github.com/olearydj/near-earth-object-monitor/blob/main/uv.lock): dependency lock · `uv.lock`

### Other components

- **NASA NEO Feed**: external API · Public close-approach feed at api.nasa.gov.

## Connections

- 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
