# melnikoff-oleg/social-media architecture

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

- Interactive diagram: https://gitdiagram.com/melnikoff-oleg/social-media
- Repository: https://github.com/melnikoff-oleg/social-media

## Overview

Social Media AI is a local web app for finding successful competitor Instagram Reels and turning them into brand-specific concepts. The main workflow is: select a creator-category configuration, scrape recent Reels, rank each creator’s videos by views, analyze selected videos with Gemini, generate concepts with Claude, and save results for review. The README also describes creator management and refreshing profile metrics, configuration editing, and browsing saved videos. Edges reflect the pipeline and API calls shown in excerpts; page-to-API wiring beyond the pipeline context is not asserted.

Main entry points: [`app/src/lib/pipeline.ts`](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/pipeline.ts) (Run and rank), [`app/src/lib/apify.ts`](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/apify.ts) (Reel scraping), [`app/src/lib/csv.ts`](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/csv.ts) (CSV persistence), [`app/src/app/api/creators/route.ts`](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/api/creators/route.ts) (Creator API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Web interface"]
  node_home["App entry<br/>[page.tsx]"]
  node_creator_ui["Creator management<br/>[page.tsx]"]
  node_config_ui["Config editor<br/>[page.tsx]"]
  node_run_ui["Run monitor<br/>[page.tsx]"]
  node_video_ui["Video library<br/>[page.tsx]"]
  node_pipeline_context["Pipeline state"]
end

subgraph group_api["Application API"]
  node_creator_api["Creator API<br/>[route.ts]"]
  node_refresh_api["Creator refresh<br/>[route.ts]"]
  node_config_api["Config API<br/>[route.ts]"]
  node_pipeline_api["Pipeline endpoint<br/>[route.ts]"]
  node_video_api["Video API<br/>[route.ts]"]
  node_image_api["Image proxy<br/>[route.ts]"]
end

subgraph group_workflow["Content workflow"]
  node_pipeline["Run and rank<br/>[pipeline.ts]"]
  node_types["Domain types<br/>[types.ts]"]
end

subgraph group_integrations["Data and services"]
  node_apify["Reel scraping<br/>[apify.ts]"]
  node_gemini["Video analysis<br/>[gemini.ts]"]
  node_claude["Concept generation<br/>[claude.ts]"]
  node_csv[("CSV persistence<br/>[csv.ts]")]
end

node_user(("Operator"))
node_apify_service["Apify"]
node_gemini_service["Google Gemini"]
node_anthropic_service["Anthropic Claude"]
node_video_source["Video URLs"]

node_user -->|"uses"| node_home
node_user -->|"manages creators"| node_creator_ui
node_user -->|"sets instructions"| node_config_ui
node_user -->|"starts runs"| node_run_ui
node_user -->|"reviews results"| node_video_ui
node_pipeline_context -->|"posts run"| node_pipeline_api
node_pipeline_api -->|"runs"| node_pipeline
node_pipeline -->|"reads and writes"| node_csv
node_pipeline -->|"scrapes creators"| node_apify
node_pipeline -->|"downloads videos"| node_video_source
node_pipeline -->|"uploads and analyzes"| node_gemini
node_pipeline -->|"generates concepts"| node_claude
node_creator_api -->|"reads and writes"| node_csv
node_creator_api -->|"fetches stats"| node_apify
node_refresh_api -->|"refreshes stats"| node_apify
node_config_api -->|"reads and writes"| node_csv
node_apify -->|"requests data"| node_apify_service
node_gemini -->|"uploads and analyzes"| node_gemini_service
node_claude -->|"requests concepts"| node_anthropic_service

click node_home "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/page.tsx"
click node_creator_ui "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/creators/page.tsx"
click node_config_ui "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/configs/page.tsx"
click node_run_ui "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/run/page.tsx"
click node_video_ui "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/videos/page.tsx"
click node_pipeline_context "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/context/pipeline-context.tsx"
click node_creator_api "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/api/creators/route.ts"
click node_refresh_api "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/api/creators/refresh/route.ts"
click node_config_api "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/api/configs/route.ts"
click node_pipeline_api "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/api/pipeline/route.ts"
click node_video_api "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/api/videos/route.ts"
click node_image_api "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/api/proxy-image/route.ts"
click node_pipeline "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/pipeline.ts"
click node_apify "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/apify.ts"
click node_gemini "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/gemini.ts"
click node_claude "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/claude.ts"
click node_csv "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/csv.ts"
click node_types "https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/types.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_home,node_creator_ui,node_config_ui,node_run_ui,node_video_ui,node_pipeline_context toneBlue
class node_creator_api,node_refresh_api,node_config_api,node_pipeline_api,node_video_api,node_image_api toneAmber
class node_pipeline,node_types,node_apify_service toneMint
class node_apify,node_gemini,node_claude,node_csv toneRose
class node_user,node_gemini_service,node_anthropic_service,node_video_source toneIndigo
```

## Components

### Web interface

- [App entry](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/page.tsx): `app/src/app/page.tsx`
- [Creator management](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/creators/page.tsx): `app/src/app/creators/page.tsx`
- [Config editor](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/configs/page.tsx): `app/src/app/configs/page.tsx`
- [Run monitor](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/run/page.tsx): `app/src/app/run/page.tsx`
- [Video library](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/videos/page.tsx): `app/src/app/videos/page.tsx`
- [Pipeline state](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/context/pipeline-context.tsx): `app/src/context/pipeline-context.tsx`

### Application API

- [Creator API](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/api/creators/route.ts): `app/src/app/api/creators/route.ts`
- [Creator refresh](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/api/creators/refresh/route.ts): `app/src/app/api/creators/refresh/route.ts`
- [Config API](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/api/configs/route.ts): `app/src/app/api/configs/route.ts`
- [Pipeline endpoint](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/api/pipeline/route.ts): `app/src/app/api/pipeline/route.ts`
- [Video API](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/api/videos/route.ts): `app/src/app/api/videos/route.ts`
- [Image proxy](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/app/api/proxy-image/route.ts): `app/src/app/api/proxy-image/route.ts`

### Content workflow

- [Run and rank](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/pipeline.ts): `app/src/lib/pipeline.ts`
- [Domain types](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/types.ts): `app/src/lib/types.ts`

### Data and services

- [Reel scraping](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/apify.ts): `app/src/lib/apify.ts`
- [Video analysis](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/gemini.ts): `app/src/lib/gemini.ts`
- [Concept generation](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/claude.ts): `app/src/lib/claude.ts`
- [CSV persistence](https://github.com/melnikoff-oleg/social-media/blob/main/app/src/lib/csv.ts): `app/src/lib/csv.ts`

### Other components

- **Operator**
- **Apify**
- **Google Gemini**
- **Anthropic Claude**
- **Video URLs**

## Connections

- Operator → App entry: uses
- Operator → Creator management: manages creators
- Operator → Config editor: sets instructions
- Operator → Run monitor: starts runs
- Operator → Video library: reviews results
- Pipeline state → Pipeline endpoint: posts run (evidence: `app/src/context/pipeline-context.tsx`)
- Pipeline endpoint → Run and rank: runs (evidence: `app/src/app/api/pipeline/route.ts`)
- Run and rank → CSV persistence: reads and writes (evidence: `app/src/lib/pipeline.ts`)
- Run and rank → Reel scraping: scrapes creators (evidence: `app/src/lib/pipeline.ts`)
- Run and rank → Video URLs: downloads videos (evidence: `app/src/lib/pipeline.ts`)
- Run and rank → Video analysis: uploads and analyzes (evidence: `app/src/lib/pipeline.ts`)
- Run and rank → Concept generation: generates concepts (evidence: `app/src/lib/pipeline.ts`)
- Creator API → CSV persistence: reads and writes (evidence: `app/src/app/api/creators/route.ts`)
- Creator API → Reel scraping: fetches stats (evidence: `app/src/app/api/creators/route.ts`)
- Creator refresh → Reel scraping: refreshes stats (evidence: `app/src/app/api/creators/refresh/route.ts`)
- Config API → CSV persistence: reads and writes (evidence: `app/src/app/api/configs/route.ts`)
- Reel scraping → Apify: requests data (evidence: `app/src/lib/apify.ts`)
- Video analysis → Google Gemini: uploads and analyzes (evidence: `app/src/lib/gemini.ts`)
- Concept generation → Anthropic Claude: requests concepts (evidence: `app/src/lib/claude.ts`)
