# bballer333/outlookctl architecture

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

- Interactive diagram: https://gitdiagram.com/bballer333/outlookctl
- Repository: https://github.com/bballer333/outlookctl

## Overview

1. **Overall shape**
   `outlookctl` is a Windows-only, local-only Python CLI for automating the classic Outlook desktop client through COM. It is not a network service or a web app; the main runtime boundary is between the CLI process and the already-running Outlook application in the same Windows session.

2. **Primary runtime entry point**
   The executable surface is `src/outlookctl/cli.py`, which exposes command-line subcommands for email and calendar workflows. The CLI is the orchestration layer: it parses arguments, invokes Outlook automation, applies safety checks for destructive actions, and emits JSON to stdout.

3. **Outlook integration boundary**
   `src/outlookctl/outlook_com.py` is the core adapter around Outlook COM objects. This is where the repository crosses from Python into Office automation. It encapsulates access to mail, folders, messages, calendar items, attachments, and sending operations against the user’s local Outlook session.

4. **Data model layer**
   `src/outlookctl/models.py` defines the structured output objects used by the CLI. The repository is built around JSON responses with stable schemas, so these models form the contract between Outlook COM results and downstream consumers such as scripts, LLM agents, and tests.

5. **Safety boundary for write actions**
   `src/outlookctl/safety.py` introduces a deliberate gate before sending email or meeting invites. The architecture separates “create draft / prepare item” from “actually send,” with explicit confirmation required for dispatching actions. This keeps the tool usable in agent-assisted workflows while reducing accidental sends.

6. **Audit trail**
   `src/outlookctl/audit.py` records send-related actions locally. This is a small but important subsystem because it creates a trace of sensitive operations without relying on external logging infrastructure. It supports the repo’s security posture: local, inspectable, and tied to the user workstation.

7. **User-facing skill integration**
   The `skills/outlook-automation/` tree packages the repository as a Claude Code skill, with reference docs for CLI usage, JSON schema, security, and troubleshooting. `tools/install_skill.py` installs that skill into Claude Code or Codex locations, making the repository usable both as a standalone CLI and as an AI-agent tool surface.

8. **Documentation as part of the architecture**
   The `docs/` directory mirrors the public reference material and explains the same contracts exposed by the CLI and skill. This documentation is operationally important because the system’s behavior depends on Outlook version, COM availability, confirmation semantics, and output schema.

9. **Testing boundaries**
   The `tests/` suite focuses on the stable, non-UI parts of the system: models, safety logic, CLI helper behavior, and calendar-related model handling. That suggests the repo’s test strategy is centered on deterministic logic rather than live Outlook automation, which is appropriate given the dependency on a local desktop app.

10. **Evaluation assets**
    The `evals/` directory contains scenario prompts for drafting replies, refusing sends, and summarizing. These are not runtime code, but they show the intended agent workflow boundary: the tool is meant to be driven by an assistant that can read, draft, and decide while the repo enforces the final send gate.

11. **Dependency and platform constraints**
    The repo is pinned to Python 3.12+, uses `uv` for environment management, and depends on Windows COM/pywin32 behavior through Outlook Classic. Those constraints are architectural, not incidental: the entire system assumes local desktop access, same-session Outlook availability, and no Microsoft Graph/OAuth dependency.

12. **Information flow to diagram**
    A useful architecture diagram would show: user or agent invokes the CLI; CLI routes to command handlers; handlers call COM adapter methods; COM returns Outlook entities; entities are mapped into JSON models; unsafe write paths pass through confirmation and audit logging; documentation and skills consume the same CLI/schema contract from the outside.

Main entry points: [`src/outlookctl/cli.py`](https://github.com/bballer333/outlookctl/blob/main/src/outlookctl/cli.py) (CLI), [`skills/outlook-automation/SKILL.md`](https://github.com/bballer333/outlookctl/blob/main/skills/outlook-automation/SKILL.md) (Skill spec), [`src/outlookctl/safety.py`](https://github.com/bballer333/outlookctl/blob/main/src/outlookctl/safety.py) (Safety), [`src/outlookctl/models.py`](https://github.com/bballer333/outlookctl/blob/main/src/outlookctl/models.py) (Models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_src["Source"]
  node_cli["CLI<br/>command entry<br/>[cli.py]"]
  node_outlook_com["Outlook COM<br/>automation adapter<br/>[outlook_com.py]"]
  node_models["Models<br/>json schemas<br/>[models.py]"]
  node_safety{{"Safety<br/>send gate<br/>[safety.py]"}}
  node_audit["Audit<br/>[audit.py]"]
end

subgraph group_docs["Docs"]
  node_docs_cli["CLI docs<br/>reference docs<br/>[cli.html]"]
  node_docs_schema["Schema docs<br/>reference docs<br/>[json-schema.html]"]
  node_docs_security["Security docs<br/>reference docs<br/>[security.html]"]
end

subgraph group_skills["Skill"]
  node_skill_md["Skill spec<br/>agent skill<br/>[SKILL.md]"]
  node_skill_cli_ref["Skill CLI<br/>skill ref<br/>[cli.md]"]
  node_skill_schema_ref["Skill schema<br/>skill ref<br/>[json-schema.md]"]
  node_skill_security_ref["Skill security<br/>skill ref<br/>[security.md]"]
end

subgraph group_tests["Tests"]
  node_test_models["Model tests<br/>unit tests<br/>[test_models.py]"]
  node_test_safety["Safety tests<br/>unit tests<br/>[test_safety.py]"]
  node_test_cli["CLI tests<br/>unit tests"]
  node_test_calendar["Calendar tests<br/>unit tests"]
end

subgraph group_evals["Evals"]
  node_evals["Scenarios<br/>prompt evals<br/>[README.md]"]
end

subgraph group_tools["Tools"]
  node_install_skill["Install skill<br/>installer<br/>[install_skill.py]"]
end

node_pyproject["Python env<br/>package config<br/>[pyproject.toml]"]
node_readme["README<br/>project guide<br/>[README.md]"]

node_cli -->|"reads/writes Outlook"| node_outlook_com
node_cli -->|"returns JSON"| node_models
node_cli -->|"gates send"| node_safety
node_cli -->|"records actions"| node_audit
node_outlook_com -->|"maps entities"| node_models
node_safety -->|"triggers trace"| node_audit
node_readme -->|"documents usage"| node_cli
node_readme -->|"documents policy"| node_safety
node_docs_cli -->|"reference"| node_cli
node_docs_schema -->|"reference"| node_models
node_docs_security -->|"reference"| node_safety
node_skill_md -->|"packages"| node_cli
node_skill_md -->|"includes"| node_skill_cli_ref
node_skill_md -->|"includes"| node_skill_schema_ref
node_skill_md -->|"includes"| node_skill_security_ref
node_install_skill -->|"installs"| node_skill_md
node_test_models -->|"verifies"| node_models
node_test_safety -->|"verifies"| node_safety
node_test_cli -->|"verifies"| node_cli
node_test_calendar -->|"verifies"| node_models
node_evals -->|"drives"| node_cli
node_pyproject -->|"configures runtime"| node_cli
node_pyproject -->|"platform deps"| node_outlook_com

click node_cli "https://github.com/bballer333/outlookctl/blob/main/src/outlookctl/cli.py"
click node_outlook_com "https://github.com/bballer333/outlookctl/blob/main/src/outlookctl/outlook_com.py"
click node_models "https://github.com/bballer333/outlookctl/blob/main/src/outlookctl/models.py"
click node_safety "https://github.com/bballer333/outlookctl/blob/main/src/outlookctl/safety.py"
click node_audit "https://github.com/bballer333/outlookctl/blob/main/src/outlookctl/audit.py"
click node_pyproject "https://github.com/bballer333/outlookctl/blob/main/pyproject.toml"
click node_readme "https://github.com/bballer333/outlookctl/blob/main/README.md"
click node_docs_cli "https://github.com/bballer333/outlookctl/blob/main/docs/cli.html"
click node_docs_schema "https://github.com/bballer333/outlookctl/blob/main/docs/json-schema.html"
click node_docs_security "https://github.com/bballer333/outlookctl/blob/main/docs/security.html"
click node_skill_md "https://github.com/bballer333/outlookctl/blob/main/skills/outlook-automation/SKILL.md"
click node_skill_cli_ref "https://github.com/bballer333/outlookctl/blob/main/skills/outlook-automation/reference/cli.md"
click node_skill_schema_ref "https://github.com/bballer333/outlookctl/blob/main/skills/outlook-automation/reference/json-schema.md"
click node_skill_security_ref "https://github.com/bballer333/outlookctl/blob/main/skills/outlook-automation/reference/security.md"
click node_install_skill "https://github.com/bballer333/outlookctl/blob/main/tools/install_skill.py"
click node_test_models "https://github.com/bballer333/outlookctl/blob/main/tests/test_models.py"
click node_test_safety "https://github.com/bballer333/outlookctl/blob/main/tests/test_safety.py"
click node_test_cli "https://github.com/bballer333/outlookctl/blob/main/tests/test_cli_helpers.py"
click node_test_calendar "https://github.com/bballer333/outlookctl/blob/main/tests/test_calendar_models.py"
click node_evals "https://github.com/bballer333/outlookctl/blob/main/evals/README.md"

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_cli,node_outlook_com,node_models,node_safety,node_audit toneBlue
class node_docs_cli,node_docs_schema,node_docs_security toneAmber
class node_skill_md,node_skill_cli_ref,node_skill_schema_ref,node_skill_security_ref toneMint
class node_test_models,node_test_safety,node_test_cli,node_test_calendar toneRose
class node_evals toneIndigo
class node_install_skill toneTeal
class node_pyproject,node_readme toneNeutral
```

## Components

### Source

Core runtime modules for the CLI and Outlook automation adapter.

- [CLI](https://github.com/bballer333/outlookctl/blob/main/src/outlookctl/cli.py): command entry · Parses subcommands, orchestrates workflows, and emits JSON output. · `src/outlookctl/cli.py`
- [Outlook COM](https://github.com/bballer333/outlookctl/blob/main/src/outlookctl/outlook_com.py): automation adapter · Wraps Outlook desktop COM objects for mail, calendar, folders, attachments, and send operations. · `src/outlookctl/outlook_com.py`
- [Models](https://github.com/bballer333/outlookctl/blob/main/src/outlookctl/models.py): json schemas · Structured response models and stable output contracts. · `src/outlookctl/models.py`
- [Safety](https://github.com/bballer333/outlookctl/blob/main/src/outlookctl/safety.py): send gate · Confirmation and policy checks before destructive or dispatching actions. · `src/outlookctl/safety.py`
- [Audit](https://github.com/bballer333/outlookctl/blob/main/src/outlookctl/audit.py): local audit · Local trace of send-related actions and sensitive operations. · `src/outlookctl/audit.py`

### Docs

User-facing reference material for the CLI, JSON schema, and safety behavior.

- [CLI docs](https://github.com/bballer333/outlookctl/blob/main/docs/cli.html): reference docs · Rendered documentation for command usage and behavior. · `docs/cli.html`
- [Schema docs](https://github.com/bballer333/outlookctl/blob/main/docs/json-schema.html): reference docs · Rendered documentation for the JSON response schema. · `docs/json-schema.html`
- [Security docs](https://github.com/bballer333/outlookctl/blob/main/docs/security.html): reference docs · Rendered documentation for confirmation and safety rules. · `docs/security.html`

### Skill

Claude Code skill packaging and its reference docs.

- [Skill spec](https://github.com/bballer333/outlookctl/blob/main/skills/outlook-automation/SKILL.md): agent skill · Claude Code skill packaging the repository for agent use. · `skills/outlook-automation/SKILL.md`
- [Skill CLI](https://github.com/bballer333/outlookctl/blob/main/skills/outlook-automation/reference/cli.md): skill ref · Skill reference for CLI usage. · `skills/outlook-automation/reference/cli.md`
- [Skill schema](https://github.com/bballer333/outlookctl/blob/main/skills/outlook-automation/reference/json-schema.md): skill ref · Skill reference for JSON output schema. · `skills/outlook-automation/reference/json-schema.md`
- [Skill security](https://github.com/bballer333/outlookctl/blob/main/skills/outlook-automation/reference/security.md): skill ref · Skill reference for confirmation and safety behavior. · `skills/outlook-automation/reference/security.md`

### Tests

Deterministic tests for models, safety, and CLI helpers.

- [Model tests](https://github.com/bballer333/outlookctl/blob/main/tests/test_models.py): unit tests · Validates structured models and schema behavior. · `tests/test_models.py`
- [Safety tests](https://github.com/bballer333/outlookctl/blob/main/tests/test_safety.py): unit tests · Exercises confirmation and refusal logic. · `tests/test_safety.py`
- [CLI tests](https://github.com/bballer333/outlookctl/blob/main/tests/test_cli_helpers.py): unit tests · Checks CLI helper behavior and command orchestration. · `tests/test_cli_helpers.py`
- [Calendar tests](https://github.com/bballer333/outlookctl/blob/main/tests/test_calendar_models.py): unit tests · Covers calendar model handling and related data shapes. · `tests/test_calendar_models.py`

### Evals

Scenario prompts used to exercise assistant workflows.

- [Scenarios](https://github.com/bballer333/outlookctl/blob/main/evals/README.md): prompt evals · Assistant scenarios for drafting, refusal, and summarization workflows. · `evals/README.md`

### Tools

Utility scripts for packaging and installation.

- [Install skill](https://github.com/bballer333/outlookctl/blob/main/tools/install_skill.py): installer · Installs the skill into Claude Code or Codex locations. · `tools/install_skill.py`

### Other components

- [Python env](https://github.com/bballer333/outlookctl/blob/main/pyproject.toml): package config · Defines the Python 3.12+ project and dependency/runtime constraints. · `pyproject.toml`
- [README](https://github.com/bballer333/outlookctl/blob/main/README.md): project guide · Top-level overview of installation, usage, and constraints. · `README.md`

## Connections

- CLI → Outlook COM: reads/writes Outlook · Command handlers call into the COM adapter to interact with local Outlook.
- CLI → Models: returns JSON · CLI transforms Outlook results into stable structured outputs.
- CLI → Safety: gates send · Dispatching actions pass through confirmation and refusal checks.
- CLI → Audit: records actions · Sensitive send-related operations are recorded locally.
- Outlook COM → Models: maps entities · COM objects are converted into structured response models.
- Safety → Audit: triggers trace · Confirmed send paths are logged for auditability.
- README → CLI: documents usage · Project overview describes the command surface and workflows.
- README → Safety: documents policy · Explains confirmation semantics and destructive-action handling.
- CLI docs → CLI: reference · Rendered docs mirror the public CLI behavior.
- Schema docs → Models: reference · Rendered docs mirror the output schema contract.
- Security docs → Safety: reference · Rendered docs explain confirmation and safety rules.
- Skill spec → CLI: packages · The skill exposes the CLI as an agent tool surface.
- Skill spec → Skill CLI: includes · Skill spec includes the CLI reference material.
- Skill spec → Skill schema: includes · Skill spec includes the JSON schema reference.
- Skill spec → Skill security: includes · Skill spec includes the security reference.
- Install skill → Skill spec: installs · Installer copies the skill package into assistant tool locations.
- Model tests → Models: verifies · Tests the stability of structured model output.
- Safety tests → Safety: verifies · Tests refusal and confirmation behavior.
- CLI tests → CLI: verifies · Tests helper behavior around command orchestration.
- Calendar tests → Models: verifies · Tests calendar-related model handling.
- Scenarios → CLI: drives · Scenario prompts are designed to exercise CLI-mediated assistant workflows.
- Python env → CLI: configures runtime · Project metadata pins Python and package dependencies.
- Python env → Outlook COM: platform deps · Declares the Windows/COM-oriented dependency environment.
