# mitsuha-24/code-analyzer architecture

> Architecture diagram of the GitHub repository mitsuha-24/code-analyzer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mitsuha-24/code-analyzer
- Repository: https://github.com/mitsuha-24/code-analyzer

## Overview

Telemetry Logger is a VS Code data-collection extension with an optional network collector and a MongoDB ingestion/research-data pipeline. The main workflow is editor activity → aggregated session summaries (and documented snapshot payloads) → local backup and optional POST → collector storage → scheduled or manual ingestion → normalized research records. The extension’s detailed internals are only partially excerpted, so its feature components and links rely on README statements; pipeline links are limited to shown code or indexed references.

Main entry points: [`server/pipeline/Ingest.js`](https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/Ingest.js) (JSONL ingestion), [`server/server.js`](https://github.com/mitsuha-24/code-analyzer/blob/main/server/server.js) (HTTP collector), [`server/pipeline/Cli.js`](https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/Cli.js) (Pipeline CLI), [`src/extension.ts`](https://github.com/mitsuha-24/code-analyzer/blob/main/src/extension.ts) (Session aggregation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["VS Code Capture"]
  node_editor_events(("Editor activity"))
  node_telemetry["Session aggregation<br/>[extension.ts]"]
  node_paste_signals["Paste analysis<br/>[extension.ts]"]
  node_activity_signals["Run and focus signals<br/>[extension.ts]"]
  node_snapshots["Code snapshots<br/>[server.js]"]
end

subgraph group_collection["Collection"]
  node_local_logs[("Local JSONL backup<br/>[server.js]")]
  node_collector["HTTP collector<br/>[server.js]"]
  node_admin_hooks["Ingest scheduling<br/>[hooks.js]"]
  node_raw_files[("Snapshot files<br/>[server.js]")]
end

subgraph group_pipeline["Ingestion Pipeline"]
  node_transform["Record transformation<br/>[Transform.js]"]
  node_ingest["JSONL ingestion<br/>[Ingest.js]"]
  node_db_config["Database connection<br/>[Db.js]"]
end

subgraph group_research["Research Data"]
  node_mongo[("MongoDB")]
  node_cli["Pipeline CLI<br/>[Cli.js]"]
  node_research_records[("Research records<br/>[Ingest.js]")]
  node_dataset_curation["Labels and splits<br/>[Cli.js]"]
end

node_developer(("VS Code user"))

node_developer -->|"creates activity"| node_editor_events
node_editor_events -->|"aggregates into"| node_telemetry
node_telemetry -->|"tracks paste edits"| node_paste_signals
node_telemetry -->|"tracks runs and focus"| node_activity_signals
node_telemetry -->|"writes summaries"| node_local_logs
node_telemetry -.->|"POSTs summaries"| node_collector
node_snapshots -->|"accepts snapshot payloads"| node_collector
node_collector -->|"appends summaries"| node_local_logs
node_collector -->|"materializes snapshots"| node_raw_files
node_collector -->|"routes admin requests"| node_admin_hooks
node_collector -->|"schedules on session end"| node_admin_hooks
node_admin_hooks -->|"dispatches ingestion"| node_ingest
node_ingest -->|"builds normalized records"| node_transform
node_ingest -->|"connects on demand"| node_db_config
node_ingest -->|"writes collections"| node_mongo
node_db_config -->|"opens connection"| node_mongo
node_ingest -.->|"reads snapshot content"| node_raw_files
node_ingest -->|"stores windows and events"| node_research_records
node_cli -->|"runs file ingestion"| node_ingest
node_cli -->|"runs bulk ingestion"| node_admin_hooks
node_cli -->|"opens database"| node_db_config
node_cli -->|"manages research data"| node_mongo
node_cli -->|"imports labels and splits"| node_dataset_curation
node_dataset_curation -->|"updates sessions"| node_mongo

click node_telemetry "https://github.com/mitsuha-24/code-analyzer/blob/main/src/extension.ts"
click node_paste_signals "https://github.com/mitsuha-24/code-analyzer/blob/main/src/extension.ts"
click node_activity_signals "https://github.com/mitsuha-24/code-analyzer/blob/main/src/extension.ts"
click node_snapshots "https://github.com/mitsuha-24/code-analyzer/blob/main/server/server.js"
click node_local_logs "https://github.com/mitsuha-24/code-analyzer/blob/main/server/server.js"
click node_collector "https://github.com/mitsuha-24/code-analyzer/blob/main/server/server.js"
click node_admin_hooks "https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/hooks.js"
click node_raw_files "https://github.com/mitsuha-24/code-analyzer/blob/main/server/server.js"
click node_transform "https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/Transform.js"
click node_ingest "https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/Ingest.js"
click node_db_config "https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/Db.js"
click node_cli "https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/Cli.js"
click node_research_records "https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/Ingest.js"
click node_dataset_curation "https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/Cli.js"

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_editor_events,node_telemetry,node_paste_signals,node_activity_signals,node_snapshots,node_developer toneBlue
class node_local_logs,node_collector,node_admin_hooks,node_raw_files toneAmber
class node_transform,node_ingest,node_db_config toneMint
class node_mongo,node_cli,node_research_records,node_dataset_curation toneRose
```

## Components

### VS Code Capture

- **Editor activity**
- [Session aggregation](https://github.com/mitsuha-24/code-analyzer/blob/main/src/extension.ts): `src/extension.ts`
- [Paste analysis](https://github.com/mitsuha-24/code-analyzer/blob/main/src/extension.ts): `src/extension.ts`
- [Run and focus signals](https://github.com/mitsuha-24/code-analyzer/blob/main/src/extension.ts): `src/extension.ts`
- [Code snapshots](https://github.com/mitsuha-24/code-analyzer/blob/main/server/server.js): `server/server.js`

### Collection

- [Local JSONL backup](https://github.com/mitsuha-24/code-analyzer/blob/main/server/server.js): `server/server.js`
- [HTTP collector](https://github.com/mitsuha-24/code-analyzer/blob/main/server/server.js): `server/server.js`
- [Ingest scheduling](https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/hooks.js): `server/pipeline/hooks.js`
- [Snapshot files](https://github.com/mitsuha-24/code-analyzer/blob/main/server/server.js): `server/server.js`

### Ingestion Pipeline

- [Record transformation](https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/Transform.js): `server/pipeline/Transform.js`
- [JSONL ingestion](https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/Ingest.js): `server/pipeline/Ingest.js`
- [Database connection](https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/Db.js): `server/pipeline/Db.js`

### Research Data

- **MongoDB**
- [Pipeline CLI](https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/Cli.js): `server/pipeline/Cli.js`
- [Research records](https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/Ingest.js): `server/pipeline/Ingest.js`
- [Labels and splits](https://github.com/mitsuha-24/code-analyzer/blob/main/server/pipeline/Cli.js): `server/pipeline/Cli.js`

### Other components

- **VS Code user**

## Connections

- VS Code user → Editor activity: creates activity (evidence: `README.md`)
- Editor activity → Session aggregation: aggregates into (evidence: `README.md`)
- Session aggregation → Paste analysis: tracks paste edits (evidence: `README.md`)
- Session aggregation → Run and focus signals: tracks runs and focus (evidence: `README.md`)
- Session aggregation → Local JSONL backup: writes summaries (evidence: `README.md`)
- Session aggregation → HTTP collector: POSTs summaries (evidence: `README.md`)
- Code snapshots → HTTP collector: accepts snapshot payloads (evidence: `server/server.js`)
- HTTP collector → Local JSONL backup: appends summaries (evidence: `server/server.js`)
- HTTP collector → Snapshot files: materializes snapshots (evidence: `server/server.js`)
- HTTP collector → Ingest scheduling: routes admin requests (evidence: `server/server.js`)
- HTTP collector → Ingest scheduling: schedules on session end (evidence: `server/server.js`)
- Ingest scheduling → JSONL ingestion: dispatches ingestion (evidence: `server/pipeline/hooks.js`)
- JSONL ingestion → Record transformation: builds normalized records (evidence: `server/pipeline/Ingest.js`)
- JSONL ingestion → Database connection: connects on demand (evidence: `server/pipeline/Ingest.js`)
- JSONL ingestion → MongoDB: writes collections (evidence: `server/pipeline/Ingest.js`)
- Database connection → MongoDB: opens connection (evidence: `server/pipeline/Db.js`)
- JSONL ingestion → Snapshot files: reads snapshot content
- JSONL ingestion → Research records: stores windows and events (evidence: `server/pipeline/Ingest.js`)
- Pipeline CLI → JSONL ingestion: runs file ingestion (evidence: `server/pipeline/Cli.js`)
- Pipeline CLI → Ingest scheduling: runs bulk ingestion (evidence: `server/pipeline/Cli.js`)
- Pipeline CLI → Database connection: opens database (evidence: `server/pipeline/Cli.js`)
- Pipeline CLI → MongoDB: manages research data (evidence: `server/pipeline/Cli.js`)
- Pipeline CLI → Labels and splits: imports labels and splits (evidence: `server/pipeline/Cli.js`)
- Labels and splits → MongoDB: updates sessions (evidence: `server/pipeline/Cli.js`)
