# dfnwtf/latrinebot architecture

> Architecture diagram of the GitHub repository dfnwtf/latrinebot, 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/dfnwtf/latrinebot
- Repository: https://github.com/dfnwtf/latrinebot

## Overview

Latrine Bot’s public repository is an integration toolkit for a hosted token-automation service, not the service engine itself. A user can query or operate supported API workflows through the CLI or SDK, embed live project data in a widget, or independently check holder eligibility with the calculator. The README documents the private service’s recurring claim, reward acquisition, burn/airdrop, and wait cycle; its implementation is not present here. Source excerpts show the client, CLI, calculator, and widget behavior, but not the full API or widget polling/rendering flow.

Main entry points: [`sdk/src/client.ts`](https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/client.ts) (API client), [`widgets/src/embed.ts`](https://github.com/dfnwtf/latrinebot/blob/main/widgets/src/embed.ts) (Widget embed), [`cli/src/cli.ts`](https://github.com/dfnwtf/latrinebot/blob/main/cli/src/cli.ts) (CLI commands), [`sdk/src/errors.ts`](https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/errors.ts) (API errors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sdk["TypeScript SDK"]
  node_sdk_client["API client<br/>[client.ts]"]
  node_sdk_errors["API errors<br/>[errors.ts]"]
  node_sdk_types["API types<br/>[types.ts]"]
  node_sdk_auth["Auth and sessions<br/>[client.ts]"]
  node_sdk_projects["Projects and setup<br/>[client.ts]"]
  node_sdk_metrics["Metrics and events<br/>[client.ts]"]
  node_sdk_public["Public realm features<br/>[client.ts]"]
end

subgraph group_cli["Command-line client"]
  node_cli_app["CLI commands<br/>[cli.ts]"]
end

subgraph group_widgets["Live widgets"]
  node_widget_embed["Widget embed<br/>[embed.ts]"]
  node_widget_themes["Theme presets<br/>[themes.ts]"]
end

subgraph group_calculator["Eligibility calculator"]
  node_eligibility_calc["Eligibility calculator<br/>[app.js]"]
end

node_operator(("Project operator"))
node_site_host(("Embed host"))
node_holder(("Token holder"))
node_latrine_api{{"Hosted Latrine API"}}

node_operator -->|"runs commands"| node_cli_app
node_cli_app -->|"uses client"| node_sdk_client
node_sdk_client -->|"sends API requests"| node_latrine_api
node_sdk_client -->|"throws errors"| node_sdk_errors
node_sdk_client -->|"uses response types"| node_sdk_types
node_sdk_client -->|"provides auth routes"| node_sdk_auth
node_sdk_client -->|"provides project routes"| node_sdk_projects
node_sdk_client -->|"provides metrics routes"| node_sdk_metrics
node_sdk_client -->|"provides public routes"| node_sdk_public
node_site_host -->|"mounts widget"| node_widget_embed
node_widget_embed -->|"loads live data"| node_latrine_api
node_widget_embed -->|"applies theme"| node_widget_themes
node_holder -->|"checks eligibility"| node_eligibility_calc
node_latrine_api -->|"runs service cycle"| node_operator

click node_cli_app "https://github.com/dfnwtf/latrinebot/blob/main/cli/src/cli.ts"
click node_sdk_client "https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/client.ts"
click node_sdk_errors "https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/errors.ts"
click node_sdk_types "https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/types.ts"
click node_sdk_auth "https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/client.ts"
click node_sdk_projects "https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/client.ts"
click node_sdk_metrics "https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/client.ts"
click node_sdk_public "https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/client.ts"
click node_widget_embed "https://github.com/dfnwtf/latrinebot/blob/main/widgets/src/embed.ts"
click node_widget_themes "https://github.com/dfnwtf/latrinebot/blob/main/widgets/src/themes.ts"
click node_eligibility_calc "https://github.com/dfnwtf/latrinebot/blob/main/calculator/app.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_sdk_client,node_sdk_errors,node_sdk_types,node_sdk_auth,node_sdk_projects,node_sdk_metrics,node_sdk_public toneBlue
class node_cli_app toneAmber
class node_widget_embed,node_widget_themes,node_latrine_api toneMint
class node_eligibility_calc toneRose
class node_operator,node_site_host,node_holder toneIndigo
```

## Components

### TypeScript SDK

- [API client](https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/client.ts): `sdk/src/client.ts`
- [API errors](https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/errors.ts): `sdk/src/errors.ts`
- [API types](https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/types.ts): `sdk/src/types.ts`
- [Auth and sessions](https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/client.ts): `sdk/src/client.ts`
- [Projects and setup](https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/client.ts): `sdk/src/client.ts`
- [Metrics and events](https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/client.ts): `sdk/src/client.ts`
- [Public realm features](https://github.com/dfnwtf/latrinebot/blob/main/sdk/src/client.ts): `sdk/src/client.ts`

### Command-line client

- [CLI commands](https://github.com/dfnwtf/latrinebot/blob/main/cli/src/cli.ts): `cli/src/cli.ts`

### Live widgets

- [Widget embed](https://github.com/dfnwtf/latrinebot/blob/main/widgets/src/embed.ts): `widgets/src/embed.ts`
- [Theme presets](https://github.com/dfnwtf/latrinebot/blob/main/widgets/src/themes.ts): `widgets/src/themes.ts`

### Eligibility calculator

- [Eligibility calculator](https://github.com/dfnwtf/latrinebot/blob/main/calculator/app.js): `calculator/app.js`

### Other components

- **Project operator**
- **Embed host**
- **Token holder**
- **Hosted Latrine API**

## Connections

- Project operator → CLI commands: runs commands (evidence: `README.md`)
- CLI commands → API client: uses client (evidence: `cli/src/cli.ts`)
- API client → Hosted Latrine API: sends API requests (evidence: `sdk/src/client.ts`)
- API client → API errors: throws errors (evidence: `sdk/src/client.ts`)
- API client → API types: uses response types (evidence: `sdk/src/client.ts`)
- API client → Auth and sessions: provides auth routes (evidence: `sdk/src/client.ts`)
- API client → Projects and setup: provides project routes (evidence: `sdk/src/client.ts`)
- API client → Metrics and events: provides metrics routes (evidence: `sdk/src/client.ts`)
- API client → Public realm features: provides public routes (evidence: `sdk/src/client.ts`)
- Embed host → Widget embed: mounts widget (evidence: `README.md`)
- Widget embed → Hosted Latrine API: loads live data (evidence: `widgets/src/embed.ts`)
- Widget embed → Theme presets: applies theme (evidence: `widgets/src/embed.ts`)
- Token holder → Eligibility calculator: checks eligibility (evidence: `calculator/app.js`)
- Hosted Latrine API → Project operator: runs service cycle (evidence: `README.md`)
