# pluggnkey/messagenotifier architecture

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

- Interactive diagram: https://gitdiagram.com/pluggnkey/messagenotifier
- Repository: https://github.com/pluggnkey/messagenotifier

## Overview

This Django service turns Google Sheets duty, weekend, and vacation records into date-specific assignments, applies Kazakhstan holiday and replacement rules, then exposes results through REST endpoints and sends scheduled Slack notifications. Its central orchestration layer combines data retrieval, cleanup, duty mapping, and messaging; supporting branches provide API-managed sheet updates and external-service health checks, including Telegram. Relationships below are based on README statements and the shown imports/calls; some documented capabilities are implemented in unsampled portions of the cited modules.

Main entry points: [`src/apps/duties/services/service.py`](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/service.py) (Duty service), [`src/apps/duties/services/health_check_services.py`](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/health_check_services.py) (Health checks), [`src/apps/duties/services/slack_service.py`](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/slack_service.py) (Slack client), [`src/apps/duties/services/kz_calendar_service.py`](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/kz_calendar_service.py) (Holiday calendar)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime orchestration"]
  node_scheduler["Message scheduler<br/>[total_scheduler.py]"]
  node_service["Duty service<br/>[service.py]"]
  node_health["Health checks"]
  node_retry["Retry policies<br/>[retry_client.py]"]
end

subgraph group_duty["Duty data and rules"]
  node_clean["Data cleanup"]
  node_duty_map["Duty mapping<br/>[data_duty.py]"]
  node_translit["Name transliteration<br/>[transliteration.py]"]
end

subgraph group_interfaces["API and notifications"]
  node_api["REST endpoints<br/>[views.py]"]
  node_handler["Message formatting<br/>[message_handler.py]"]
  node_notify["Slack notifications<br/>[service.py]"]
end

subgraph group_integrations["External integrations"]
  node_google["Sheets access<br/>[google_client.py]"]
  node_calendar["Holiday calendar"]
  node_slack_client["Slack client<br/>[slack_service.py]"]
  node_telegram["Telegram client"]
end

node_operator(("API caller"))
node_sheets_external[("Google Sheets")]
node_slack_external["Slack"]
node_calendar_external["Holiday API"]
node_telegram_external["Telegram"]

node_operator -->|"requests"| node_api
node_api -->|"calls"| node_service
node_api -->|"updates sheets"| node_google
node_scheduler -->|"schedules"| node_service
node_scheduler -->|"triggers"| node_notify
node_service -->|"loads records"| node_google
node_google -->|"reads and writes"| node_sheets_external
node_service -->|"cleans data"| node_clean
node_service -->|"builds assignments"| node_duty_map
node_service -->|"normalizes names"| node_translit
node_service -->|"gets holidays"| node_calendar
node_service -->|"gets user IDs"| node_slack_client
node_service -->|"formats messages"| node_handler
node_notify -->|"sends messages"| node_slack_client
node_slack_client -->|"calls API"| node_slack_external
node_calendar -->|"fetches holidays"| node_calendar_external
node_health -->|"checks connection"| node_google
node_health -->|"checks connection"| node_slack_client
node_health -->|"checks connection"| node_calendar
node_health -->|"checks connection"| node_telegram
node_telegram -->|"calls API"| node_telegram_external
node_slack_client -->|"uses retries"| node_retry
node_telegram -->|"uses retries"| node_retry
node_calendar -->|"uses retries"| node_retry
node_scheduler -->|"starts checks"| node_health

click node_scheduler "https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/scheduler/total_scheduler.py"
click node_service "https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/service.py"
click node_health "https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/health_check_services.py"
click node_api "https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/views.py"
click node_handler "https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/message_handler.py"
click node_notify "https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/service.py"
click node_google "https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/google_client.py"
click node_clean "https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/clear_data_google.py"
click node_duty_map "https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/data_duty.py"
click node_translit "https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/transliteration.py"
click node_calendar "https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/kz_calendar_service.py"
click node_slack_client "https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/slack_service.py"
click node_telegram "https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/telegram_integration.py"
click node_retry "https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/retry_client.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_scheduler,node_service,node_health,node_retry toneBlue
class node_clean,node_duty_map,node_translit,node_sheets_external toneAmber
class node_api,node_handler,node_notify,node_operator,node_calendar_external toneMint
class node_google,node_calendar,node_slack_client,node_telegram toneRose
class node_slack_external,node_telegram_external toneIndigo
```

## Components

### Runtime orchestration

- [Message scheduler](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/scheduler/total_scheduler.py): `src/apps/duties/scheduler/total_scheduler.py`
- [Duty service](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/service.py): `src/apps/duties/services/service.py`
- [Health checks](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/health_check_services.py): `src/apps/duties/services/health_check_services.py`
- [Retry policies](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/retry_client.py): `src/apps/duties/services/retry_client.py`

### Duty data and rules

- [Data cleanup](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/clear_data_google.py): `src/apps/duties/services/clear_data_google.py`
- [Duty mapping](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/data_duty.py): `src/apps/duties/services/data_duty.py`
- [Name transliteration](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/transliteration.py): `src/apps/duties/services/transliteration.py`

### API and notifications

- [REST endpoints](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/views.py): `src/apps/duties/views.py`
- [Message formatting](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/message_handler.py): `src/apps/duties/services/message_handler.py`
- [Slack notifications](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/service.py): `src/apps/duties/services/service.py`

### External integrations

- [Sheets access](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/google_client.py): `src/apps/duties/services/google_client.py`
- [Holiday calendar](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/kz_calendar_service.py): `src/apps/duties/services/kz_calendar_service.py`
- [Slack client](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/slack_service.py): `src/apps/duties/services/slack_service.py`
- [Telegram client](https://github.com/pluggnkey/messagenotifier/blob/main/src/apps/duties/services/telegram_integration.py): `src/apps/duties/services/telegram_integration.py`

### Other components

- **API caller**
- **Google Sheets**
- **Slack**
- **Holiday API**
- **Telegram**

## Connections

- API caller → REST endpoints: requests
- REST endpoints → Duty service: calls (evidence: `src/apps/duties/views.py`)
- REST endpoints → Sheets access: updates sheets (evidence: `src/apps/duties/views.py`)
- Message scheduler → Duty service: schedules (evidence: `src/apps/duties/scheduler/total_scheduler.py`)
- Message scheduler → Slack notifications: triggers (evidence: `src/apps/duties/scheduler/total_scheduler.py`)
- Duty service → Sheets access: loads records (evidence: `src/apps/duties/services/service.py`)
- Sheets access → Google Sheets: reads and writes (evidence: `src/apps/duties/services/google_client.py`)
- Duty service → Data cleanup: cleans data (evidence: `src/apps/duties/services/service.py`)
- Duty service → Duty mapping: builds assignments (evidence: `src/apps/duties/services/service.py`)
- Duty service → Name transliteration: normalizes names (evidence: `src/apps/duties/services/service.py`)
- Duty service → Holiday calendar: gets holidays (evidence: `src/apps/duties/services/service.py`)
- Duty service → Slack client: gets user IDs (evidence: `src/apps/duties/services/service.py`)
- Duty service → Message formatting: formats messages (evidence: `src/apps/duties/services/service.py`)
- Slack notifications → Slack client: sends messages (evidence: `src/apps/duties/services/service.py`)
- Slack client → Slack: calls API (evidence: `src/apps/duties/services/slack_service.py`)
- Holiday calendar → Holiday API: fetches holidays (evidence: `src/apps/duties/services/kz_calendar_service.py`)
- Health checks → Sheets access: checks connection (evidence: `src/apps/duties/services/health_check_services.py`)
- Health checks → Slack client: checks connection (evidence: `src/apps/duties/services/health_check_services.py`)
- Health checks → Holiday calendar: checks connection (evidence: `src/apps/duties/services/health_check_services.py`)
- Health checks → Telegram client: checks connection (evidence: `src/apps/duties/services/health_check_services.py`)
- Telegram client → Telegram: calls API (evidence: `src/apps/duties/services/telegram_integration.py`)
- Slack client → Retry policies: uses retries (evidence: `src/apps/duties/services/slack_service.py`)
- Telegram client → Retry policies: uses retries (evidence: `src/apps/duties/services/telegram_integration.py`)
- Holiday calendar → Retry policies: uses retries (evidence: `src/apps/duties/services/kz_calendar_service.py`)
- Message scheduler → Health checks: starts checks (evidence: `src/apps/duties/apps.py`)
