# thinkst/canarytokens architecture

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

- Interactive diagram: https://gitdiagram.com/thinkst/canarytokens
- Repository: https://github.com/thinkst/canarytokens

## Overview

Canarytokens is a deception and activity-monitoring platform: operators create and manage many kinds of tokens, place them in systems or documents, and receive alerts when they are triggered. The graph emphasizes the frontend/API, token records and persistence, alert delivery, and the AWS infrastructure workflow. Several relationships are supported only by the SOURCE INDEX import references; unsampled subsystems are represented by their exact enclosing directories, and uncertain runtime wiring is omitted.

Main entry points: [`frontend/app.py`](https://github.com/thinkst/canarytokens/blob/master/frontend/app.py) (Frontend API), [`canarytokens/canarydrop.py`](https://github.com/thinkst/canarytokens/blob/master/canarytokens/canarydrop.py) (Canarydrop records), [`canarytokens/aws_infra/data_generation.py`](https://github.com/thinkst/canarytokens/blob/master/canarytokens/aws_infra/data_generation.py) (Asset generation), [`canarytokens/aws_infra/plan_generation.py`](https://github.com/thinkst/canarytokens/blob/master/canarytokens/aws_infra/plan_generation.py) (Plan generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_product["Token product"]
  node_frontend_api["Frontend API<br/>[app.py]"]
  node_token_models["Token models"]
  node_token_lifecycle["Token lifecycle<br/>[tokens.py]"]
  node_canarydrop["Canarydrop records<br/>[canarydrop.py]"]
  node_query_layer["Query layer<br/>[queries.py]"]
  node_redis_store[("Redis store<br/>[redismanager.py]")]
  node_settings["Runtime settings<br/>[settings.py]"]
end

subgraph group_aws["AWS decoys"]
  node_aws_orchestration["AWS workflows<br/>[operations.py]"]
  node_aws_plans["Plan generation<br/>[plan_generation.py]"]
  node_aws_data["Asset generation<br/>[data_generation.py]"]
  node_aws_state["AWS state"]
  node_aws_queries["AWS queries<br/>[db_queries.py]"]
end

subgraph group_alerts["Trigger and alerting"]
  node_email_alerts["Email alerts"]
  node_webhook_alerts["Webhook alerts"]
  node_webhook_format["Webhook formatting"]
end

subgraph group_integrations["External services"]
  node_aws_service["AWS ID service"]
  node_zendesk["Zendesk"]
  node_ticket_checker["Exposed-key checker"]
end

node_operator(("Operator"))

node_operator -->|"uses API"| node_frontend_api
node_frontend_api -->|"creates records"| node_canarydrop
node_frontend_api -->|"validates requests"| node_token_models
node_frontend_api -->|"routes AWS work"| node_aws_orchestration
node_frontend_api -->|"requests generation"| node_aws_data
node_frontend_api -->|"uses email channel"| node_email_alerts
node_canarydrop -->|"reads and writes"| node_query_layer
node_canarydrop -->|"validates history"| node_token_models
node_query_layer -.->|"uses connection"| node_redis_store
node_settings -->|"imports models"| node_token_models
node_settings -.->|"configures connection"| node_redis_store
node_aws_plans -->|"generates names"| node_aws_data
node_aws_plans -->|"queries assets"| node_aws_queries
node_aws_plans -->|"uses state"| node_aws_state
node_aws_data -->|"queries assets"| node_aws_queries
node_aws_data -->|"uses token record"| node_canarydrop
node_aws_state -->|"uses AWS operations"| node_aws_orchestration
node_aws_state -->|"uses token record"| node_canarydrop
node_webhook_alerts -->|"formats payloads"| node_webhook_format
node_webhook_alerts -->|"reads trigger data"| node_canarydrop
node_ticket_checker -.->|"manages tickets"| node_zendesk
node_frontend_api -.->|"calls configured API"| node_aws_service

click node_frontend_api "https://github.com/thinkst/canarytokens/blob/master/frontend/app.py"
click node_token_models "https://github.com/thinkst/canarytokens/tree/master/canarytokens/models"
click node_token_lifecycle "https://github.com/thinkst/canarytokens/blob/master/canarytokens/tokens.py"
click node_canarydrop "https://github.com/thinkst/canarytokens/blob/master/canarytokens/canarydrop.py"
click node_query_layer "https://github.com/thinkst/canarytokens/blob/master/canarytokens/queries.py"
click node_redis_store "https://github.com/thinkst/canarytokens/blob/master/canarytokens/redismanager.py"
click node_settings "https://github.com/thinkst/canarytokens/blob/master/canarytokens/settings.py"
click node_aws_orchestration "https://github.com/thinkst/canarytokens/blob/master/canarytokens/aws_infra/operations.py"
click node_aws_plans "https://github.com/thinkst/canarytokens/blob/master/canarytokens/aws_infra/plan_generation.py"
click node_aws_data "https://github.com/thinkst/canarytokens/blob/master/canarytokens/aws_infra/data_generation.py"
click node_aws_state "https://github.com/thinkst/canarytokens/blob/master/canarytokens/aws_infra/state_management.py"
click node_aws_queries "https://github.com/thinkst/canarytokens/blob/master/canarytokens/aws_infra/db_queries.py"
click node_email_alerts "https://github.com/thinkst/canarytokens/blob/master/canarytokens/channel_output_email.py"
click node_webhook_alerts "https://github.com/thinkst/canarytokens/blob/master/canarytokens/channel_output_webhook.py"
click node_webhook_format "https://github.com/thinkst/canarytokens/blob/master/canarytokens/webhook_formatting.py"
click node_ticket_checker "https://github.com/thinkst/canarytokens/tree/master/aws-exposed-key-checker-infra/lambda_source/exposed_key_checker"

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_frontend_api,node_token_models,node_token_lifecycle,node_canarydrop,node_query_layer,node_redis_store,node_settings toneBlue
class node_aws_orchestration,node_aws_plans,node_aws_data,node_aws_state,node_aws_queries toneAmber
class node_email_alerts,node_webhook_alerts,node_webhook_format toneMint
class node_aws_service,node_zendesk,node_ticket_checker toneRose
class node_operator toneIndigo
```

## Components

### Token product

- [Frontend API](https://github.com/thinkst/canarytokens/blob/master/frontend/app.py): `frontend/app.py`
- [Token models](https://github.com/thinkst/canarytokens/tree/master/canarytokens/models): `canarytokens/models`
- [Token lifecycle](https://github.com/thinkst/canarytokens/blob/master/canarytokens/tokens.py): `canarytokens/tokens.py`
- [Canarydrop records](https://github.com/thinkst/canarytokens/blob/master/canarytokens/canarydrop.py): `canarytokens/canarydrop.py`
- [Query layer](https://github.com/thinkst/canarytokens/blob/master/canarytokens/queries.py): `canarytokens/queries.py`
- [Redis store](https://github.com/thinkst/canarytokens/blob/master/canarytokens/redismanager.py): `canarytokens/redismanager.py`
- [Runtime settings](https://github.com/thinkst/canarytokens/blob/master/canarytokens/settings.py): `canarytokens/settings.py`

### AWS decoys

- [AWS workflows](https://github.com/thinkst/canarytokens/blob/master/canarytokens/aws_infra/operations.py): `canarytokens/aws_infra/operations.py`
- [Plan generation](https://github.com/thinkst/canarytokens/blob/master/canarytokens/aws_infra/plan_generation.py): `canarytokens/aws_infra/plan_generation.py`
- [Asset generation](https://github.com/thinkst/canarytokens/blob/master/canarytokens/aws_infra/data_generation.py): `canarytokens/aws_infra/data_generation.py`
- [AWS state](https://github.com/thinkst/canarytokens/blob/master/canarytokens/aws_infra/state_management.py): `canarytokens/aws_infra/state_management.py`
- [AWS queries](https://github.com/thinkst/canarytokens/blob/master/canarytokens/aws_infra/db_queries.py): `canarytokens/aws_infra/db_queries.py`

### Trigger and alerting

- [Email alerts](https://github.com/thinkst/canarytokens/blob/master/canarytokens/channel_output_email.py): `canarytokens/channel_output_email.py`
- [Webhook alerts](https://github.com/thinkst/canarytokens/blob/master/canarytokens/channel_output_webhook.py): `canarytokens/channel_output_webhook.py`
- [Webhook formatting](https://github.com/thinkst/canarytokens/blob/master/canarytokens/webhook_formatting.py): `canarytokens/webhook_formatting.py`

### External services

- **AWS ID service**
- **Zendesk**
- [Exposed-key checker](https://github.com/thinkst/canarytokens/tree/master/aws-exposed-key-checker-infra/lambda_source/exposed_key_checker): `aws-exposed-key-checker-infra/lambda_source/exposed_key_checker`

### Other components

- **Operator**

## Connections

- Operator → Frontend API: uses API (evidence: `frontend/app.py`)
- Frontend API → Canarydrop records: creates records (evidence: `frontend/app.py`)
- Frontend API → Token models: validates requests (evidence: `frontend/app.py`)
- Frontend API → AWS workflows: routes AWS work (evidence: `frontend/app.py`)
- Frontend API → Asset generation: requests generation (evidence: `frontend/app.py`)
- Frontend API → Email alerts: uses email channel (evidence: `frontend/app.py`)
- Canarydrop records → Query layer: reads and writes (evidence: `canarytokens/canarydrop.py`)
- Canarydrop records → Token models: validates history (evidence: `canarytokens/canarydrop.py`)
- Query layer → Redis store: uses connection
- Runtime settings → Token models: imports models (evidence: `canarytokens/settings.py`)
- Runtime settings → Redis store: configures connection
- Plan generation → Asset generation: generates names (evidence: `canarytokens/aws_infra/plan_generation.py`)
- Plan generation → AWS queries: queries assets (evidence: `canarytokens/aws_infra/plan_generation.py`)
- Plan generation → AWS state: uses state (evidence: `canarytokens/aws_infra/plan_generation.py`)
- Asset generation → AWS queries: queries assets (evidence: `canarytokens/aws_infra/data_generation.py`)
- Asset generation → Canarydrop records: uses token record (evidence: `canarytokens/aws_infra/data_generation.py`)
- AWS state → AWS workflows: uses AWS operations (evidence: `canarytokens/aws_infra/state_management.py`)
- AWS state → Canarydrop records: uses token record (evidence: `canarytokens/aws_infra/state_management.py`)
- Webhook alerts → Webhook formatting: formats payloads (evidence: `canarytokens/channel_output_webhook.py`)
- Webhook alerts → Canarydrop records: reads trigger data (evidence: `canarytokens/channel_output_webhook.py`)
- Exposed-key checker → Zendesk: manages tickets
- Frontend API → AWS ID service: calls configured API
