# dylgrave/tiktok-story-viewer architecture

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

- Interactive diagram: https://gitdiagram.com/dylgrave/tiktok-story-viewer
- Repository: https://github.com/dylgrave/tiktok-story-viewer

## Overview

Storyroom is a web viewer for public TikTok Stories, profile content, and LIVE broadcasts. The main workflow is username entry, Story lookup, then playback; profile exploration and LIVE viewing are parallel capabilities. Server routes apply validation and rate limits before provider-backed services retrieve and normalize data. The README documents encrypted personal API-key sessions and server-side media handles. Some route and UI wiring is documented or indexed but not excerpted, so those links are marked unverified rather than asserted as direct calls.

Main entry points: [`src/components/tiktok-story-search/TikTokStorySearch.tsx`](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/tiktok-story-search/TikTokStorySearch.tsx) (Storyroom search), [`src/app/api/tiktok/story/route.ts`](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/app/api/tiktok/story/route.ts) (Story route), [`src/app/api/tiktok/profile/route.ts`](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/app/api/tiktok/profile/route.ts) (Profile route), [`src/components/tiktok-story-search/useStorySearch.ts`](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/tiktok-story-search/useStorySearch.ts) (Search state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Search and playback"]
  node_search["Storyroom search"]
  node_search_state["Search state<br/>[useStorySearch.ts]"]
  node_story_player["Story player<br/>[StoryViewer.tsx]"]
  node_story_audio["Shared audio<br/>[useStoryAudio.ts]"]
  node_story_icon["Story icons<br/>[StoryIcon.tsx]"]
  node_copy["Interface copy<br/>[copy.ts]"]
end

subgraph group_profile["Profile exploration"]
  node_profile_explorer["Profile explorer"]
  node_profile_state["Profile loading state"]
  node_profile_empty["Empty profile view"]
end

subgraph group_server["Application services"]
  node_profile_api["Profile route<br/>[route.ts]"]
  node_profile_facade["Profile service<br/>[profile-service.ts]"]
  node_story_api["Story route<br/>[route.ts]"]
  node_story_service["Story cache<br/>[story-service.ts]"]
  node_live_api["LIVE status route<br/>[route.ts]"]
  node_username["Username validation<br/>[username.ts]"]
  node_rate_limit["Lookup limiting<br/>[rate-limit.ts]"]
end

subgraph group_provider["Konbini integration"]
  node_profile_provider["Profile retrieval<br/>[profile-service.ts]"]
  node_profile_normalize["Profile normalization<br/>[normalize.ts]"]
  node_story_provider["Story provider<br/>[story-provider.ts]"]
  node_provider_client["Provider client<br/>[client.ts]"]
  node_live_service["LIVE service<br/>[live.ts]"]
end

subgraph group_settings["Credentials and media"]
  node_media_api["Media route<br/>[route.ts]"]
  node_media_service["Media handles<br/>[media.ts]"]
  node_key_settings["API key settings<br/>[ApiKeySettings.tsx]"]
  node_key_route["Key settings route<br/>[route.ts]"]
end

node_visitor(("Viewer"))

node_visitor -->|"enters username"| node_search
node_search -->|"starts search"| node_search_state
node_search_state -->|"validates input"| node_username
node_search_state -.->|"requests Stories"| node_story_api
node_story_api -->|"validates input"| node_username
node_story_api -->|"checks allowance"| node_rate_limit
node_story_api -->|"gets Stories"| node_story_service
node_story_service -->|"requests Stories"| node_story_provider
node_story_provider -->|"fetches provider data"| node_provider_client
node_story_api -.->|"supplies results"| node_story_player
node_search -->|"renders playback"| node_story_player
node_search -->|"shares audio state"| node_story_audio
node_search -->|"renders explorer"| node_profile_explorer
node_search -->|"renders empty view"| node_profile_empty
node_profile_explorer -->|"uses explorer state"| node_profile_state
node_profile_state -.->|"loads sections"| node_profile_api
node_profile_api -->|"validates input"| node_username
node_profile_api -->|"checks allowance"| node_rate_limit
node_profile_api -->|"gets section"| node_profile_facade
node_profile_facade -->|"delegates retrieval"| node_profile_provider
node_profile_provider -->|"fetches profile data"| node_provider_client
node_profile_provider -->|"normalizes records"| node_profile_normalize
node_live_api -->|"checks LIVE status"| node_live_service
node_live_service -->|"fetches LIVE data"| node_provider_client
node_media_api -->|"resolves media"| node_media_service
node_key_settings -.->|"saves key"| node_key_route

click node_search "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/tiktok-story-search/TikTokStorySearch.tsx"
click node_search_state "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/tiktok-story-search/useStorySearch.ts"
click node_story_player "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/story-viewer/StoryViewer.tsx"
click node_story_audio "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/story-viewer/useStoryAudio.ts"
click node_story_icon "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/story-icons/StoryIcon.tsx"
click node_profile_explorer "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/profile-explorer/ProfileExplorer.tsx"
click node_profile_state "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/profile-explorer/useProfileExplorer.ts"
click node_profile_empty "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/profile-explorer/ProfileExplorerEmpty.tsx"
click node_profile_api "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/app/api/tiktok/profile/route.ts"
click node_profile_facade "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/tiktok-profile/profile-service.ts"
click node_profile_provider "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/konbini/profile-service.ts"
click node_profile_normalize "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/konbini/normalize.ts"
click node_story_api "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/app/api/tiktok/story/route.ts"
click node_story_service "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/tiktok/story-service.ts"
click node_story_provider "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/konbini/story-provider.ts"
click node_provider_client "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/konbini/client.ts"
click node_live_api "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/app/api/tiktok/live/route.ts"
click node_live_service "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/konbini/live.ts"
click node_media_api "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/app/api/tiktok/media/route.ts"
click node_media_service "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/konbini/media.ts"
click node_key_settings "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/tiktok-story-search/ApiKeySettings.tsx"
click node_key_route "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/app/api/settings/key/route.ts"
click node_username "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/lib/username.ts"
click node_rate_limit "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/lib/rate-limit.ts"
click node_copy "https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/lib/copy.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_search,node_search_state,node_story_player,node_story_audio,node_story_icon,node_copy,node_visitor toneBlue
class node_profile_explorer,node_profile_state,node_profile_empty toneAmber
class node_profile_api,node_profile_facade,node_story_api,node_story_service,node_live_api,node_username,node_rate_limit toneMint
class node_profile_provider,node_profile_normalize,node_story_provider,node_provider_client,node_live_service toneRose
class node_media_api,node_media_service,node_key_settings,node_key_route toneIndigo
```

## Components

### Search and playback

- [Storyroom search](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/tiktok-story-search/TikTokStorySearch.tsx): `src/components/tiktok-story-search/TikTokStorySearch.tsx`
- [Search state](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/tiktok-story-search/useStorySearch.ts): `src/components/tiktok-story-search/useStorySearch.ts`
- [Story player](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/story-viewer/StoryViewer.tsx): `src/components/story-viewer/StoryViewer.tsx`
- [Shared audio](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/story-viewer/useStoryAudio.ts): `src/components/story-viewer/useStoryAudio.ts`
- [Story icons](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/story-icons/StoryIcon.tsx): `src/components/story-icons/StoryIcon.tsx`
- [Interface copy](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/lib/copy.ts): `src/lib/copy.ts`

### Profile exploration

- [Profile explorer](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/profile-explorer/ProfileExplorer.tsx): `src/components/profile-explorer/ProfileExplorer.tsx`
- [Profile loading state](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/profile-explorer/useProfileExplorer.ts): `src/components/profile-explorer/useProfileExplorer.ts`
- [Empty profile view](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/profile-explorer/ProfileExplorerEmpty.tsx): `src/components/profile-explorer/ProfileExplorerEmpty.tsx`

### Application services

- [Profile route](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/app/api/tiktok/profile/route.ts): `src/app/api/tiktok/profile/route.ts`
- [Profile service](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/tiktok-profile/profile-service.ts): `src/services/tiktok-profile/profile-service.ts`
- [Story route](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/app/api/tiktok/story/route.ts): `src/app/api/tiktok/story/route.ts`
- [Story cache](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/tiktok/story-service.ts): `src/services/tiktok/story-service.ts`
- [LIVE status route](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/app/api/tiktok/live/route.ts): `src/app/api/tiktok/live/route.ts`
- [Username validation](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/lib/username.ts): `src/lib/username.ts`
- [Lookup limiting](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/lib/rate-limit.ts): `src/lib/rate-limit.ts`

### Konbini integration

- [Profile retrieval](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/konbini/profile-service.ts): `src/services/konbini/profile-service.ts`
- [Profile normalization](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/konbini/normalize.ts): `src/services/konbini/normalize.ts`
- [Story provider](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/konbini/story-provider.ts): `src/services/konbini/story-provider.ts`
- [Provider client](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/konbini/client.ts): `src/services/konbini/client.ts`
- [LIVE service](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/konbini/live.ts): `src/services/konbini/live.ts`

### Credentials and media

- [Media route](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/app/api/tiktok/media/route.ts): `src/app/api/tiktok/media/route.ts`
- [Media handles](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/services/konbini/media.ts): `src/services/konbini/media.ts`
- [API key settings](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/components/tiktok-story-search/ApiKeySettings.tsx): `src/components/tiktok-story-search/ApiKeySettings.tsx`
- [Key settings route](https://github.com/dylgrave/tiktok-story-viewer/blob/main/src/app/api/settings/key/route.ts): `src/app/api/settings/key/route.ts`

### Other components

- **Viewer**

## Connections

- Viewer → Storyroom search: enters username (evidence: `src/components/tiktok-story-search/TikTokStorySearch.tsx`)
- Storyroom search → Search state: starts search (evidence: `src/components/tiktok-story-search/TikTokStorySearch.tsx`)
- Search state → Username validation: validates input (evidence: `src/components/tiktok-story-search/useStorySearch.ts`)
- Search state → Story route: requests Stories
- Story route → Username validation: validates input (evidence: `src/app/api/tiktok/story/route.ts`)
- Story route → Lookup limiting: checks allowance (evidence: `src/app/api/tiktok/story/route.ts`)
- Story route → Story cache: gets Stories (evidence: `src/app/api/tiktok/story/route.ts`)
- Story cache → Story provider: requests Stories (evidence: `src/services/tiktok/story-service.ts`)
- Story provider → Provider client: fetches provider data (evidence: `src/services/konbini/story-provider.ts`)
- Story route → Story player: supplies results
- Storyroom search → Story player: renders playback (evidence: `src/components/tiktok-story-search/TikTokStorySearch.tsx`)
- Storyroom search → Shared audio: shares audio state (evidence: `src/components/tiktok-story-search/TikTokStorySearch.tsx`)
- Storyroom search → Profile explorer: renders explorer (evidence: `src/components/tiktok-story-search/TikTokStorySearch.tsx`)
- Storyroom search → Empty profile view: renders empty view (evidence: `src/components/tiktok-story-search/TikTokStorySearch.tsx`)
- Profile explorer → Profile loading state: uses explorer state (evidence: `src/components/profile-explorer/ProfileExplorer.tsx`)
- Profile loading state → Profile route: loads sections
- Profile route → Username validation: validates input (evidence: `src/app/api/tiktok/profile/route.ts`)
- Profile route → Lookup limiting: checks allowance (evidence: `src/app/api/tiktok/profile/route.ts`)
- Profile route → Profile service: gets section (evidence: `src/app/api/tiktok/profile/route.ts`)
- Profile service → Profile retrieval: delegates retrieval (evidence: `src/services/tiktok-profile/profile-service.ts`)
- Profile retrieval → Provider client: fetches profile data (evidence: `src/services/konbini/profile-service.ts`)
- Profile retrieval → Profile normalization: normalizes records (evidence: `src/services/konbini/profile-service.ts`)
- LIVE status route → LIVE service: checks LIVE status (evidence: `src/app/api/tiktok/live/route.ts`)
- LIVE service → Provider client: fetches LIVE data (evidence: `src/services/konbini/live.ts`)
- Media route → Media handles: resolves media (evidence: `src/app/api/tiktok/media/route.ts`)
- API key settings → Key settings route: saves key (evidence: `README.md`)
