# jodenrey/tiktok-automation architecture

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

- Interactive diagram: https://gitdiagram.com/jodenrey/tiktok-automation
- Repository: https://github.com/jodenrey/tiktok-automation

## Overview

This is a full-stack service for configuring scheduled TikTok slideshow automations, generating and publishing carousel posts, and managing credits. The main workflow runs from automation setup through scheduled or manual dispatch, AI content creation, image retrieval, persistence, optional TikTok publishing, and credit consumption. The README documents these stages and product areas; sampled route and worker code confirms several entry points and integrations, but the automation pipeline implementation itself was not included in the excerpts.

Main entry points: [`src/lib/run-automation.ts`](https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/run-automation.ts) (Automation pipeline), [`src/app/api/slideshows`](https://github.com/jodenrey/tiktok-automation/tree/master/src/app/api/slideshows) (Slideshow API), [`src/lib/prisma.ts`](https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/prisma.ts) (PostgreSQL), [`src/app/(app)`](https://github.com/jodenrey/tiktok-automation/tree/master/src/app/(app)) (App pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_app["App pages"]
  node_results["Posts and analytics"]
  node_collections["Collections UI<br/>[page.tsx]"]
end

subgraph group_automation["Automation runtime"]
  node_automation_api["Automation API"]
  node_queue_lib["Scheduling and dispatch<br/>[queue.ts]"]
  node_worker["Automation worker"]
  node_pipeline["Automation pipeline<br/>[run-automation.ts]"]
end

subgraph group_content["Content generation"]
  node_slideshow_api["Slideshow API"]
  node_claude["Content generation<br/>[claude.ts]"]
  node_images["Image search<br/>[images.ts]"]
  node_publishing["TikTok publishing<br/>[tiktok.ts]"]
end

subgraph group_platform["Accounts and billing"]
  node_auth["Authentication"]
  node_auth_service["Auth config<br/>[auth.ts]"]
  node_credit_logic["Credit accounting<br/>[credits.ts]"]
  node_billing_api["Checkout API<br/>[route.ts]"]
  node_webhook["Stripe webhook<br/>[route.ts]"]
end

subgraph group_infra["Data and services"]
  node_db[("PostgreSQL<br/>[prisma.ts]")]
  node_redis["Redis queue"]
end

node_user(("User"))
node_anthropic["Anthropic Claude"]
node_image_sources["Image providers"]
node_tiktok["TikTok API"]
node_stripe["Stripe"]

node_user -->|"uses"| node_app
node_user -->|"registers"| node_auth
node_auth -->|"authenticates"| node_auth_service
node_auth_service -->|"reads and writes"| node_db
node_app -->|"manages automations"| node_automation_api
node_app -->|"generates or publishes"| node_slideshow_api
node_app -->|"views results"| node_results
node_app -->|"views library"| node_collections
node_automation_api -->|"reads and writes"| node_db
node_automation_api -->|"schedules jobs"| node_queue_lib
node_queue_lib -.->|"enqueues jobs"| node_redis
node_redis -.->|"delivers jobs"| node_worker
node_worker -->|"creates worker"| node_queue_lib
node_queue_lib -->|"runs automation"| node_pipeline
node_pipeline -->|"generates content"| node_claude
node_claude -.->|"requests generation"| node_anthropic
node_pipeline -->|"fetches slide images"| node_images
node_images -.->|"searches providers"| node_image_sources
node_pipeline -->|"persists slideshows and posts"| node_db
node_pipeline -->|"publishes when enabled"| node_publishing
node_publishing -.->|"posts carousel"| node_tiktok
node_pipeline -->|"consumes credits"| node_credit_logic
node_slideshow_api -->|"generates content"| node_claude
node_slideshow_api -->|"fetches images"| node_images
node_slideshow_api -->|"stores slideshow"| node_db
node_slideshow_api -->|"consumes credit"| node_credit_logic
node_slideshow_api -->|"publishes slideshow"| node_publishing
node_billing_api -->|"reads account"| node_db
node_billing_api -->|"creates checkout"| node_stripe
node_user -->|"buys credits"| node_billing_api
node_stripe -->|"sends events"| node_webhook
node_webhook -->|"grants credits"| node_db

click node_app "https://github.com/jodenrey/tiktok-automation/tree/master/src/app/(app)"
click node_automation_api "https://github.com/jodenrey/tiktok-automation/tree/master/src/app/api/automations"
click node_slideshow_api "https://github.com/jodenrey/tiktok-automation/tree/master/src/app/api/slideshows"
click node_results "https://github.com/jodenrey/tiktok-automation/tree/master/src/app/(app)/posts"
click node_collections "https://github.com/jodenrey/tiktok-automation/blob/master/src/app/(app)/collections/page.tsx"
click node_auth "https://github.com/jodenrey/tiktok-automation/tree/master/src/app/api/auth"
click node_auth_service "https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/auth.ts"
click node_queue_lib "https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/queue.ts"
click node_worker "https://github.com/jodenrey/tiktok-automation/blob/master/src/workers/automation-worker.ts"
click node_pipeline "https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/run-automation.ts"
click node_claude "https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/claude.ts"
click node_images "https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/images.ts"
click node_publishing "https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/tiktok.ts"
click node_credit_logic "https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/credits.ts"
click node_billing_api "https://github.com/jodenrey/tiktok-automation/blob/master/src/app/api/stripe/checkout/route.ts"
click node_webhook "https://github.com/jodenrey/tiktok-automation/blob/master/src/app/api/stripe/webhook/route.ts"
click node_db "https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/prisma.ts"

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_app,node_results,node_collections,node_user toneBlue
class node_automation_api,node_queue_lib,node_worker,node_pipeline toneAmber
class node_slideshow_api,node_claude,node_images,node_publishing,node_tiktok toneMint
class node_auth,node_auth_service,node_credit_logic,node_billing_api,node_webhook toneRose
class node_db,node_redis,node_anthropic,node_image_sources,node_stripe toneIndigo
```

## Components

### User experience

- [App pages](https://github.com/jodenrey/tiktok-automation/tree/master/src/app/(app)): `src/app/(app)`
- [Posts and analytics](https://github.com/jodenrey/tiktok-automation/tree/master/src/app/(app)/posts): `src/app/(app)/posts`
- [Collections UI](https://github.com/jodenrey/tiktok-automation/blob/master/src/app/(app)/collections/page.tsx): `src/app/(app)/collections/page.tsx`

### Automation runtime

- [Automation API](https://github.com/jodenrey/tiktok-automation/tree/master/src/app/api/automations): `src/app/api/automations`
- [Scheduling and dispatch](https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/queue.ts): `src/lib/queue.ts`
- [Automation worker](https://github.com/jodenrey/tiktok-automation/blob/master/src/workers/automation-worker.ts): `src/workers/automation-worker.ts`
- [Automation pipeline](https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/run-automation.ts): `src/lib/run-automation.ts`

### Content generation

- [Slideshow API](https://github.com/jodenrey/tiktok-automation/tree/master/src/app/api/slideshows): `src/app/api/slideshows`
- [Content generation](https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/claude.ts): `src/lib/claude.ts`
- [Image search](https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/images.ts): `src/lib/images.ts`
- [TikTok publishing](https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/tiktok.ts): `src/lib/tiktok.ts`

### Accounts and billing

- [Authentication](https://github.com/jodenrey/tiktok-automation/tree/master/src/app/api/auth): `src/app/api/auth`
- [Auth config](https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/auth.ts): `src/lib/auth.ts`
- [Credit accounting](https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/credits.ts): `src/lib/credits.ts`
- [Checkout API](https://github.com/jodenrey/tiktok-automation/blob/master/src/app/api/stripe/checkout/route.ts): `src/app/api/stripe/checkout/route.ts`
- [Stripe webhook](https://github.com/jodenrey/tiktok-automation/blob/master/src/app/api/stripe/webhook/route.ts): `src/app/api/stripe/webhook/route.ts`

### Data and services

- [PostgreSQL](https://github.com/jodenrey/tiktok-automation/blob/master/src/lib/prisma.ts): `src/lib/prisma.ts`
- **Redis queue**

### Other components

- **User**
- **Anthropic Claude**
- **Image providers**
- **TikTok API**
- **Stripe**

## Connections

- User → App pages: uses
- User → Authentication: registers
- Authentication → Auth config: authenticates
- Auth config → PostgreSQL: reads and writes
- App pages → Automation API: manages automations
- App pages → Slideshow API: generates or publishes
- App pages → Posts and analytics: views results
- App pages → Collections UI: views library
- Automation API → PostgreSQL: reads and writes
- Automation API → Scheduling and dispatch: schedules jobs
- Scheduling and dispatch → Redis queue: enqueues jobs
- Redis queue → Automation worker: delivers jobs
- Automation worker → Scheduling and dispatch: creates worker
- Scheduling and dispatch → Automation pipeline: runs automation
- Automation pipeline → Content generation: generates content
- Content generation → Anthropic Claude: requests generation
- Automation pipeline → Image search: fetches slide images
- Image search → Image providers: searches providers
- Automation pipeline → PostgreSQL: persists slideshows and posts
- Automation pipeline → TikTok publishing: publishes when enabled
- TikTok publishing → TikTok API: posts carousel
- Automation pipeline → Credit accounting: consumes credits
- Slideshow API → Content generation: generates content
- Slideshow API → Image search: fetches images
- Slideshow API → PostgreSQL: stores slideshow
- Slideshow API → Credit accounting: consumes credit
- Slideshow API → TikTok publishing: publishes slideshow
- Checkout API → PostgreSQL: reads account
- Checkout API → Stripe: creates checkout
- User → Checkout API: buys credits
- Stripe → Stripe webhook: sends events
- Stripe webhook → PostgreSQL: grants credits
