# lewyi/endfield-auto-checkin architecture

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

- Interactive diagram: https://gitdiagram.com/lewyi/endfield-auto-checkin
- Repository: https://github.com/lewyi/endfield-auto-checkin

## Overview

This Discord bot lets users save an Arknights: Endfield account token, then performs manual or daily attendance check-ins and reports results. The main flow runs from a Discord command through cookie lookup, game authentication, role binding and attendance submission; a separate command explains how to obtain the token. The excerpts show these flows and SQLite access. The README confirms the 24/7 automation purpose; channel configuration and some startup details are incomplete, so those links are omitted.

Main entry points: [`cogs/checkin.py`](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py) (Manual check-in), [`bot.py`](https://github.com/lewyi/endfield-auto-checkin/blob/main/bot.py) (Bot runtime), [`cogs/entercookie.py`](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/entercookie.py) (Token entry modal), [`cogs/getcookie.py`](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/getcookie.py) (Token guide)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discord["Discord interface"]
  node_bot["Bot runtime<br/>[bot.py]"]
  node_cookie_command["Cookie command<br/>[entercookie.py]"]
  node_cookie_modal["Token entry modal<br/>[entercookie.py]"]
  node_cookie_guide["Token guide<br/>[getcookie.py]"]
end

subgraph group_accounts["Account storage"]
  node_user_accounts[("Saved tokens<br/>[UserData.db]")]
end

subgraph group_attendance["Attendance workflow"]
  node_manual_checkin["Manual check-in<br/>[checkin.py]"]
  node_daily_scheduler["Daily scheduler<br/>[checkin.py]"]
  node_daily_runner["Daily check-in runner<br/>[checkin.py]"]
end

subgraph group_game["Game service"]
  node_oauth["OAuth grant<br/>[checkin.py]"]
  node_credential["Credential exchange<br/>[checkin.py]"]
  node_sign_token["Sign token refresh<br/>[checkin.py]"]
  node_role_binding["Role binding<br/>[checkin.py]"]
  node_signing["Request signing<br/>[checkin.py]"]
  node_attendance_api["Attendance submission<br/>[checkin.py]"]
end

node_user(("Discord user"))
node_discord_service(("Discord service"))
node_game_service(("Endfield service"))

node_bot -->|"starts bot"| node_discord_service
node_bot -->|"loads extensions"| node_cookie_command
node_bot -->|"loads extensions"| node_cookie_guide
node_bot -->|"loads extensions"| node_manual_checkin
node_user -->|"enters token"| node_cookie_command
node_cookie_command -->|"opens modal"| node_cookie_modal
node_cookie_modal -->|"checks and saves"| node_user_accounts
node_cookie_modal -->|"sends result"| node_discord_service
node_user -->|"requests guide"| node_cookie_guide
node_cookie_guide -->|"sends guide"| node_discord_service
node_user -->|"requests check-in"| node_manual_checkin
node_manual_checkin -->|"reads token"| node_user_accounts
node_manual_checkin -->|"calls check-in"| node_oauth
node_daily_scheduler -->|"runs daily"| node_daily_runner
node_daily_runner -->|"reads tokens"| node_user_accounts
node_daily_runner -->|"calls check-in"| node_oauth
node_manual_checkin -->|"reports result"| node_discord_service
node_daily_runner -->|"reports results"| node_discord_service
node_oauth -->|"requests grant"| node_game_service
node_oauth -->|"passes code"| node_credential
node_credential -->|"requests credential"| node_game_service
node_credential -->|"passes credential"| node_sign_token
node_sign_token -->|"refreshes token"| node_game_service
node_sign_token -->|"passes credentials"| node_role_binding
node_role_binding -->|"signs request"| node_signing
node_signing -->|"requests roles"| node_game_service
node_role_binding -->|"passes role"| node_attendance_api
node_attendance_api -->|"signs request"| node_signing
node_attendance_api -->|"submits attendance"| node_game_service

click node_bot "https://github.com/lewyi/endfield-auto-checkin/blob/main/bot.py"
click node_cookie_command "https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/entercookie.py"
click node_cookie_modal "https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/entercookie.py"
click node_cookie_guide "https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/getcookie.py"
click node_user_accounts "https://github.com/lewyi/endfield-auto-checkin/blob/main/data/UserData.db"
click node_manual_checkin "https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py"
click node_daily_scheduler "https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py"
click node_daily_runner "https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py"
click node_oauth "https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py"
click node_credential "https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py"
click node_sign_token "https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py"
click node_role_binding "https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py"
click node_signing "https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py"
click node_attendance_api "https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.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_bot,node_cookie_command,node_cookie_modal,node_cookie_guide,node_user toneBlue
class node_user_accounts toneAmber
class node_manual_checkin,node_daily_scheduler,node_daily_runner toneMint
class node_oauth,node_credential,node_sign_token,node_role_binding,node_signing,node_attendance_api toneRose
class node_discord_service,node_game_service toneIndigo
```

## Components

### Discord interface

- [Bot runtime](https://github.com/lewyi/endfield-auto-checkin/blob/main/bot.py): `bot.py`
- [Cookie command](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/entercookie.py): `cogs/entercookie.py`
- [Token entry modal](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/entercookie.py): `cogs/entercookie.py`
- [Token guide](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/getcookie.py): `cogs/getcookie.py`

### Account storage

- [Saved tokens](https://github.com/lewyi/endfield-auto-checkin/blob/main/data/UserData.db): `data/UserData.db`

### Attendance workflow

- [Manual check-in](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py): `cogs/checkin.py`
- [Daily scheduler](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py): `cogs/checkin.py`
- [Daily check-in runner](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py): `cogs/checkin.py`

### Game service

- [OAuth grant](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py): `cogs/checkin.py`
- [Credential exchange](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py): `cogs/checkin.py`
- [Sign token refresh](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py): `cogs/checkin.py`
- [Role binding](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py): `cogs/checkin.py`
- [Request signing](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py): `cogs/checkin.py`
- [Attendance submission](https://github.com/lewyi/endfield-auto-checkin/blob/main/cogs/checkin.py): `cogs/checkin.py`

### Other components

- **Discord user**
- **Discord service**
- **Endfield service**

## Connections

- Bot runtime → Discord service: starts bot (evidence: `bot.py`)
- Bot runtime → Cookie command: loads extensions (evidence: `bot.py`)
- Bot runtime → Token guide: loads extensions (evidence: `bot.py`)
- Bot runtime → Manual check-in: loads extensions (evidence: `bot.py`)
- Discord user → Cookie command: enters token (evidence: `cogs/entercookie.py`)
- Cookie command → Token entry modal: opens modal (evidence: `cogs/entercookie.py`)
- Token entry modal → Saved tokens: checks and saves (evidence: `cogs/entercookie.py`)
- Token entry modal → Discord service: sends result (evidence: `cogs/entercookie.py`)
- Discord user → Token guide: requests guide (evidence: `cogs/getcookie.py`)
- Token guide → Discord service: sends guide (evidence: `cogs/getcookie.py`)
- Discord user → Manual check-in: requests check-in (evidence: `cogs/checkin.py`)
- Manual check-in → Saved tokens: reads token (evidence: `cogs/checkin.py`)
- Manual check-in → OAuth grant: calls check-in (evidence: `cogs/checkin.py`)
- Daily scheduler → Daily check-in runner: runs daily (evidence: `cogs/checkin.py`)
- Daily check-in runner → Saved tokens: reads tokens (evidence: `cogs/checkin.py`)
- Daily check-in runner → OAuth grant: calls check-in (evidence: `cogs/checkin.py`)
- Manual check-in → Discord service: reports result (evidence: `cogs/checkin.py`)
- Daily check-in runner → Discord service: reports results (evidence: `cogs/checkin.py`)
- OAuth grant → Endfield service: requests grant (evidence: `cogs/checkin.py`)
- OAuth grant → Credential exchange: passes code (evidence: `cogs/checkin.py`)
- Credential exchange → Endfield service: requests credential (evidence: `cogs/checkin.py`)
- Credential exchange → Sign token refresh: passes credential (evidence: `cogs/checkin.py`)
- Sign token refresh → Endfield service: refreshes token (evidence: `cogs/checkin.py`)
- Sign token refresh → Role binding: passes credentials (evidence: `cogs/checkin.py`)
- Role binding → Request signing: signs request (evidence: `cogs/checkin.py`)
- Request signing → Endfield service: requests roles (evidence: `cogs/checkin.py`)
- Role binding → Attendance submission: passes role (evidence: `cogs/checkin.py`)
- Attendance submission → Request signing: signs request (evidence: `cogs/checkin.py`)
- Attendance submission → Endfield service: submits attendance (evidence: `cogs/checkin.py`)
