# guillaumelog/teams-exporter architecture

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

- Interactive diagram: https://gitdiagram.com/guillaumelog/teams-exporter
- Repository: https://github.com/guillaumelog/teams-exporter

## Overview

Teams Exporter is a local-first CLI for exporting direct and group chats into a browsable HTML archive, interactively soft-deleting selected sent messages and eligible OneDrive files, and experimentally cleaning activity notifications. The main workflow runs from CLI configuration and command dispatch through Graph authentication and retrieval, then local archive generation and rendering. Purge and notifications are separate command branches. The graph follows the excerpts and README; unsampled details are represented only where documented, and optional notification deletion is kept distinct.

Main entry points: [`src/teams_exporter/cli.py`](https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/cli.py) (Command dispatch), [`src/teams_exporter/graph.py`](https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/graph.py) (Graph client), [`src/teams_exporter/export.py`](https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/export.py) (Chat export), [`src/teams_exporter/render.py`](https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/render.py) (HTML rendering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and configuration"]
  node_cli["Command dispatch<br/>[cli.py]"]
  node_config["Configuration<br/>[config.py]"]
end

subgraph group_shared["Shared services"]
  node_logging["Logging setup<br/>[logging_setup.py]"]
  node_auth["Graph authentication<br/>[auth.py]"]
  node_graph["Graph client<br/>[graph.py]"]
end

subgraph group_archive["Conversation export"]
  node_exporter["Chat export<br/>[export.py]"]
  node_archive_data[("Local conversation data")]
  node_renderer["HTML rendering<br/>[render.py]"]
  node_templates["Archive templates and UI"]
end

subgraph group_cleanup["Remote cleanup"]
  node_purger["Interactive purge<br/>[purge.py]"]
  node_notification_cleaner["Notification cleanup<br/>[notifications.py]"]
end

node_user(("CLI user"))
node_microsoft_graph{{"Microsoft Graph"}}
node_browser(("Local browser"))
node_onedrive[("OneDrive")]
node_teams_service{{"Internal Teams endpoints"}}

node_user -->|"runs command"| node_cli
node_cli -->|"loads settings"| node_config
node_cli -->|"configures logging"| node_logging
node_cli -->|"dispatches export"| node_exporter
node_cli -->|"dispatches purge"| node_purger
node_cli -->|"dispatches cleanup"| node_notification_cleaner
node_cli -->|"builds Graph auth"| node_auth
node_cli -->|"builds Graph client"| node_graph
node_auth -->|"authenticates"| node_microsoft_graph
node_graph -->|"gets tokens"| node_auth
node_graph -->|"requests data"| node_microsoft_graph
node_exporter -->|"retrieves chats"| node_graph
node_exporter -->|"writes and reuses"| node_archive_data
node_exporter -->|"renders archive"| node_renderer
node_renderer -->|"renders pages"| node_templates
node_renderer -->|"writes HTML"| node_archive_data
node_browser -->|"browses archive"| node_archive_data
node_purger -->|"scans and deletes"| node_graph
node_purger -->|"deletes eligible files"| node_onedrive
node_notification_cleaner -->|"marks read; tries delete"| node_teams_service

click node_cli "https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/cli.py"
click node_config "https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/config.py"
click node_logging "https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/logging_setup.py"
click node_auth "https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/auth.py"
click node_graph "https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/graph.py"
click node_exporter "https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/export.py"
click node_renderer "https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/render.py"
click node_templates "https://github.com/guillaumelog/teams-exporter/tree/main/src/teams_exporter/templates"
click node_purger "https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/purge.py"
click node_notification_cleaner "https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/notifications.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_cli,node_config,node_user,node_browser toneBlue
class node_logging,node_auth,node_graph,node_onedrive toneAmber
class node_exporter,node_archive_data,node_renderer,node_templates toneMint
class node_purger,node_notification_cleaner toneRose
class node_microsoft_graph,node_teams_service toneIndigo
```

## Components

### CLI and configuration

- [Command dispatch](https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/cli.py): `src/teams_exporter/cli.py`
- [Configuration](https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/config.py): `src/teams_exporter/config.py`

### Shared services

- [Logging setup](https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/logging_setup.py): `src/teams_exporter/logging_setup.py`
- [Graph authentication](https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/auth.py): `src/teams_exporter/auth.py`
- [Graph client](https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/graph.py): `src/teams_exporter/graph.py`

### Conversation export

- [Chat export](https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/export.py): `src/teams_exporter/export.py`
- **Local conversation data**
- [HTML rendering](https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/render.py): `src/teams_exporter/render.py`
- [Archive templates and UI](https://github.com/guillaumelog/teams-exporter/tree/main/src/teams_exporter/templates): `src/teams_exporter/templates`

### Remote cleanup

- [Interactive purge](https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/purge.py): `src/teams_exporter/purge.py`
- [Notification cleanup](https://github.com/guillaumelog/teams-exporter/blob/main/src/teams_exporter/notifications.py): `src/teams_exporter/notifications.py`

### Other components

- **CLI user**
- **Microsoft Graph**
- **Local browser**
- **OneDrive**
- **Internal Teams endpoints**

## Connections

- CLI user → Command dispatch: runs command (evidence: `README.md`)
- Command dispatch → Configuration: loads settings (evidence: `src/teams_exporter/cli.py`)
- Command dispatch → Logging setup: configures logging (evidence: `src/teams_exporter/cli.py`)
- Command dispatch → Chat export: dispatches export (evidence: `src/teams_exporter/cli.py`)
- Command dispatch → Interactive purge: dispatches purge (evidence: `src/teams_exporter/cli.py`)
- Command dispatch → Notification cleanup: dispatches cleanup (evidence: `src/teams_exporter/cli.py`)
- Command dispatch → Graph authentication: builds Graph auth (evidence: `src/teams_exporter/cli.py`)
- Command dispatch → Graph client: builds Graph client (evidence: `src/teams_exporter/cli.py`)
- Graph authentication → Microsoft Graph: authenticates (evidence: `src/teams_exporter/auth.py`)
- Graph client → Graph authentication: gets tokens (evidence: `src/teams_exporter/graph.py`)
- Graph client → Microsoft Graph: requests data (evidence: `src/teams_exporter/graph.py`)
- Chat export → Graph client: retrieves chats (evidence: `src/teams_exporter/export.py`)
- Chat export → Local conversation data: writes and reuses (evidence: `src/teams_exporter/export.py`)
- Chat export → HTML rendering: renders archive (evidence: `src/teams_exporter/export.py`)
- HTML rendering → Archive templates and UI: renders pages (evidence: `src/teams_exporter/render.py`)
- HTML rendering → Local conversation data: writes HTML (evidence: `src/teams_exporter/render.py`)
- Local browser → Local conversation data: browses archive (evidence: `README.md`)
- Interactive purge → Graph client: scans and deletes (evidence: `src/teams_exporter/purge.py`)
- Interactive purge → OneDrive: deletes eligible files (evidence: `README.md`)
- Notification cleanup → Internal Teams endpoints: marks read; tries delete (evidence: `src/teams_exporter/notifications.py`)
