# teknobuddy/commentdmautomation architecture

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

- Interactive diagram: https://gitdiagram.com/teknobuddy/commentdmautomation
- Repository: https://github.com/teknobuddy/commentdmautomation

## Overview

This product lets an account owner configure per-reel comment automations in a dashboard, then processes Instagram comment webhooks to send a DM and public reply when a reel is active and either reply-to-all is enabled or a keyword matches. Configuration and refreshed tokens persist as JSON files. The graph distinguishes dashboard/API configuration, webhook decision stages, persistence, and Instagram API actions. The README documents privacy and data-deletion pages; their runtime links are not shown in the sampled source.

Main entry points: [`backend/services/instagram.py`](https://github.com/teknobuddy/commentdmautomation/blob/main/backend/services/instagram.py) (DM and reply delivery), [`backend/routers/admin.py`](https://github.com/teknobuddy/commentdmautomation/blob/main/backend/routers/admin.py) (Reel admin API), [`backend/routers/webhook.py`](https://github.com/teknobuddy/commentdmautomation/blob/main/backend/routers/webhook.py) (Comment webhook), [`backend/main.py`](https://github.com/teknobuddy/commentdmautomation/blob/main/backend/main.py) (FastAPI application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard and legal pages"]
  node_dashboard_ui["Automation dashboard<br/>[page.tsx]"]
  node_privacy["Privacy policy<br/>[page.tsx]"]
  node_deletion["Data deletion<br/>[page.tsx]"]
end

subgraph group_backend["Backend API and automation"]
  node_app["FastAPI application<br/>[main.py]"]
  node_admin_api["Reel admin API<br/>[admin.py]"]
  node_webhook["Comment webhook<br/>[webhook.py]"]
  node_decision{{"Automation decision<br/>[webhook.py]"}}
  node_media["Media and stats<br/>[admin.py]"]
end

subgraph group_state["Persistent configuration"]
  node_settings[("Reel settings<br/>[config_manager.py]")]
  node_tokens[("Token persistence<br/>[config_manager.py]")]
end

subgraph group_instagram["Instagram integration"]
  node_delivery["DM and reply delivery<br/>[instagram.py]"]
end

node_owner(("Account owner"))
node_instagram_api["Instagram Graph API"]
node_commenter(("Instagram commenter"))

node_owner -->|"configures reels"| node_dashboard_ui
node_dashboard_ui -->|"loads and updates"| node_admin_api
node_app -->|"registers routes"| node_admin_api
node_app -->|"registers routes"| node_webhook
node_app -->|"refreshes token"| node_delivery
node_admin_api -->|"serves reel data"| node_media
node_admin_api -->|"reads and updates"| node_settings
node_media -->|"fetches account media"| node_delivery
node_commenter -->|"comments on reel"| node_webhook
node_webhook -->|"parses comment"| node_decision
node_decision -->|"loads reel config"| node_settings
node_decision -->|"schedules DM and reply"| node_delivery
node_delivery -->|"sends DM and reply"| node_instagram_api
node_delivery -->|"reads and saves token"| node_tokens
node_instagram_api -->|"posts comment events"| node_webhook

click node_dashboard_ui "https://github.com/teknobuddy/commentdmautomation/blob/main/frontend/app/page.tsx"
click node_privacy "https://github.com/teknobuddy/commentdmautomation/blob/main/frontend/app/privacy/page.tsx"
click node_deletion "https://github.com/teknobuddy/commentdmautomation/blob/main/frontend/app/data-deletion/page.tsx"
click node_app "https://github.com/teknobuddy/commentdmautomation/blob/main/backend/main.py"
click node_admin_api "https://github.com/teknobuddy/commentdmautomation/blob/main/backend/routers/admin.py"
click node_webhook "https://github.com/teknobuddy/commentdmautomation/blob/main/backend/routers/webhook.py"
click node_decision "https://github.com/teknobuddy/commentdmautomation/blob/main/backend/routers/webhook.py"
click node_delivery "https://github.com/teknobuddy/commentdmautomation/blob/main/backend/services/instagram.py"
click node_media "https://github.com/teknobuddy/commentdmautomation/blob/main/backend/routers/admin.py"
click node_settings "https://github.com/teknobuddy/commentdmautomation/blob/main/backend/services/config_manager.py"
click node_tokens "https://github.com/teknobuddy/commentdmautomation/blob/main/backend/services/config_manager.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_dashboard_ui,node_privacy,node_deletion toneBlue
class node_app,node_admin_api,node_webhook,node_decision,node_media toneAmber
class node_settings,node_tokens,node_instagram_api toneMint
class node_delivery toneRose
class node_owner,node_commenter toneIndigo
```

## Components

### Dashboard and legal pages

- [Automation dashboard](https://github.com/teknobuddy/commentdmautomation/blob/main/frontend/app/page.tsx): `frontend/app/page.tsx`
- [Privacy policy](https://github.com/teknobuddy/commentdmautomation/blob/main/frontend/app/privacy/page.tsx): `frontend/app/privacy/page.tsx`
- [Data deletion](https://github.com/teknobuddy/commentdmautomation/blob/main/frontend/app/data-deletion/page.tsx): `frontend/app/data-deletion/page.tsx`

### Backend API and automation

- [FastAPI application](https://github.com/teknobuddy/commentdmautomation/blob/main/backend/main.py): `backend/main.py`
- [Reel admin API](https://github.com/teknobuddy/commentdmautomation/blob/main/backend/routers/admin.py): `backend/routers/admin.py`
- [Comment webhook](https://github.com/teknobuddy/commentdmautomation/blob/main/backend/routers/webhook.py): `backend/routers/webhook.py`
- [Automation decision](https://github.com/teknobuddy/commentdmautomation/blob/main/backend/routers/webhook.py): `backend/routers/webhook.py`
- [Media and stats](https://github.com/teknobuddy/commentdmautomation/blob/main/backend/routers/admin.py): `backend/routers/admin.py`

### Persistent configuration

- [Reel settings](https://github.com/teknobuddy/commentdmautomation/blob/main/backend/services/config_manager.py): `backend/services/config_manager.py`
- [Token persistence](https://github.com/teknobuddy/commentdmautomation/blob/main/backend/services/config_manager.py): `backend/services/config_manager.py`

### Instagram integration

- [DM and reply delivery](https://github.com/teknobuddy/commentdmautomation/blob/main/backend/services/instagram.py): `backend/services/instagram.py`

### Other components

- **Account owner**
- **Instagram Graph API**
- **Instagram commenter**

## Connections

- Account owner → Automation dashboard: configures reels (evidence: `README.md`)
- Automation dashboard → Reel admin API: loads and updates (evidence: `frontend/app/page.tsx`)
- FastAPI application → Reel admin API: registers routes (evidence: `backend/main.py`)
- FastAPI application → Comment webhook: registers routes (evidence: `backend/main.py`)
- FastAPI application → DM and reply delivery: refreshes token (evidence: `backend/main.py`)
- Reel admin API → Media and stats: serves reel data (evidence: `backend/routers/admin.py`)
- Reel admin API → Reel settings: reads and updates (evidence: `backend/routers/admin.py`)
- Media and stats → DM and reply delivery: fetches account media (evidence: `backend/routers/admin.py`)
- Instagram commenter → Comment webhook: comments on reel (evidence: `README.md`)
- Comment webhook → Automation decision: parses comment (evidence: `backend/routers/webhook.py`)
- Automation decision → Reel settings: loads reel config (evidence: `backend/routers/webhook.py`)
- Automation decision → DM and reply delivery: schedules DM and reply (evidence: `backend/routers/webhook.py`)
- DM and reply delivery → Instagram Graph API: sends DM and reply (evidence: `backend/services/instagram.py`)
- DM and reply delivery → Token persistence: reads and saves token (evidence: `backend/services/instagram.py`)
- Instagram Graph API → Comment webhook: posts comment events (evidence: `README.md`)
