# balaji1472/pro-hacks architecture

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

- Interactive diagram: https://gitdiagram.com/balaji1472/pro-hacks
- Repository: https://github.com/balaji1472/pro-hacks

## Overview

CopilotLens is a Windows background agent that measures M365 Copilot engagement without retaining prompt content or sending data over a network. Its workflow detects tracked-app focus, attaches UI Automation and input hooks to observe pane and prompt events, combines those with inactivity signals to accumulate per-user/app/day metrics, then periodically merges records into a local JSON file. The README documents DPI-aware hit testing and privacy safeguards; those are represented within UIA detection. Relationships follow the supplied README and source excerpts; unsampled implementation details are not inferred.

Main entry points: [`main.py`](https://github.com/balaji1472/pro-hacks/blob/main/main.py) (Agent orchestration), [`session_tracker.py`](https://github.com/balaji1472/pro-hacks/blob/main/session_tracker.py) (Session metrics), [`uia_detector.py`](https://github.com/balaji1472/pro-hacks/blob/main/uia_detector.py) (Pane and prompt detection), [`win32_hook.py`](https://github.com/balaji1472/pro-hacks/blob/main/win32_hook.py) (App focus hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_detect["Signal Detection"]
  node_main["Agent orchestration<br/>[main.py]"]
  node_focus["App focus hook<br/>[win32_hook.py]"]
  node_uia["Pane and prompt detection<br/>[uia_detector.py]"]
  node_idle["Inactivity monitor"]
end

subgraph group_tracking["Metric Tracking"]
  node_tracker["Session metrics<br/>[session_tracker.py]"]
end

subgraph group_output["Local Output"]
  node_emitter["JSON merge emitter<br/>[emitter.py]"]
  node_metrics["Metrics JSON file"]
end

node_user(("Workstation user"))

node_user -->|"changes focus"| node_focus
node_user -->|"interacts with pane"| node_uia
node_user -->|"provides input"| node_idle
node_main -->|"starts thread"| node_focus
node_main -->|"starts thread"| node_uia
node_main -->|"starts thread"| node_tracker
node_main -->|"starts thread"| node_idle
node_focus -->|"queues focus events"| node_main
node_main -->|"dispatches focus events"| node_uia
node_main -->|"dispatches focus events"| node_tracker
node_uia -->|"queues pane and prompt events"| node_tracker
node_idle -->|"queues activity events"| node_tracker
node_tracker -->|"flushes records"| node_emitter
node_emitter -->|"merges and writes"| node_metrics

click node_main "https://github.com/balaji1472/pro-hacks/blob/main/main.py"
click node_focus "https://github.com/balaji1472/pro-hacks/blob/main/win32_hook.py"
click node_uia "https://github.com/balaji1472/pro-hacks/blob/main/uia_detector.py"
click node_idle "https://github.com/balaji1472/pro-hacks/blob/main/inactivity_monitor.py"
click node_tracker "https://github.com/balaji1472/pro-hacks/blob/main/session_tracker.py"
click node_emitter "https://github.com/balaji1472/pro-hacks/blob/main/emitter.py"

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_main,node_focus,node_uia,node_idle,node_user toneBlue
class node_tracker toneAmber
class node_emitter,node_metrics toneMint
```

## Components

### Signal Detection

- [Agent orchestration](https://github.com/balaji1472/pro-hacks/blob/main/main.py): `main.py`
- [App focus hook](https://github.com/balaji1472/pro-hacks/blob/main/win32_hook.py): `win32_hook.py`
- [Pane and prompt detection](https://github.com/balaji1472/pro-hacks/blob/main/uia_detector.py): `uia_detector.py`
- [Inactivity monitor](https://github.com/balaji1472/pro-hacks/blob/main/inactivity_monitor.py): `inactivity_monitor.py`

### Metric Tracking

- [Session metrics](https://github.com/balaji1472/pro-hacks/blob/main/session_tracker.py): `session_tracker.py`

### Local Output

- [JSON merge emitter](https://github.com/balaji1472/pro-hacks/blob/main/emitter.py): `emitter.py`
- **Metrics JSON file**

### Other components

- **Workstation user**

## Connections

- Workstation user → App focus hook: changes focus (evidence: `readme.md`)
- Workstation user → Pane and prompt detection: interacts with pane (evidence: `readme.md`)
- Workstation user → Inactivity monitor: provides input (evidence: `readme.md`)
- Agent orchestration → App focus hook: starts thread (evidence: `main.py`)
- Agent orchestration → Pane and prompt detection: starts thread (evidence: `main.py`)
- Agent orchestration → Session metrics: starts thread (evidence: `main.py`)
- Agent orchestration → Inactivity monitor: starts thread (evidence: `main.py`)
- App focus hook → Agent orchestration: queues focus events (evidence: `readme.md`)
- Agent orchestration → Pane and prompt detection: dispatches focus events (evidence: `main.py`)
- Agent orchestration → Session metrics: dispatches focus events (evidence: `main.py`)
- Pane and prompt detection → Session metrics: queues pane and prompt events (evidence: `uia_detector.py`)
- Inactivity monitor → Session metrics: queues activity events (evidence: `inactivity_monitor.py`)
- Session metrics → JSON merge emitter: flushes records (evidence: `session_tracker.py`)
- JSON merge emitter → Metrics JSON file: merges and writes (evidence: `emitter.py`)
