# nayun1/reevely architecture

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

- Interactive diagram: https://gitdiagram.com/nayun1/reevely
- Repository: https://github.com/nayun1/reevely

## Overview

Reevely is a YouTube-channel comment monitoring and review service, with AI risk analysis, evidence archiving, notifications, and paid plans. Its scheduled comment job syncs channels and analyzes pending comments; users then review and manage findings in channel workspaces. Billing handles initial checkout and recurring charges separately. The tree documents admin and account areas, but most page implementations were not sampled, so their detailed wiring is not inferred. Edges below are limited to sampled calls or SOURCE INDEX import references.

Main entry points: [`src/app/api/cron/process-comments/route.ts`](https://github.com/nayun1/reevely/blob/develop/src/app/api/cron/process-comments/route.ts) (Scheduled jobs), [`src/lib/db/queries/channels.ts`](https://github.com/nayun1/reevely/blob/develop/src/lib/db/queries/channels.ts) (Channel queries), [`src/lib/db/schema.ts`](https://github.com/nayun1/reevely/blob/develop/src/lib/db/schema.ts) (Application data model), [`src/lib/db/queries/subscriptions.ts`](https://github.com/nayun1/reevely/blob/develop/src/lib/db/queries/subscriptions.ts) (Plan and subscription queries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Collection and analysis"]
  node_sync["YouTube comment sync<br/>[sync-comments.ts]"]
  node_analysis["Pending comment analysis"]
  node_ai["Comment risk analysis<br/>[analyze-comment.ts]"]
end

subgraph group_workspace["Channel workspace"]
  node_review["Review queue"]
  node_status["Review status action"]
  node_risk["Risk indicator<br/>[risk-badge.tsx]"]
  node_authors["Author comment feed"]
  node_commentapi["Comment actions API<br/>[route.ts]"]
  node_notifications["Notification records<br/>[notifications.ts]"]
  node_workspacepages["Channel workspace pages"]
end

subgraph group_accounts["Accounts and billing"]
  node_youtube["YouTube channel linking<br/>[connect-channel.ts]"]
  node_authcode["OAuth token exchange"]
  node_billingcheckout["Subscription checkout<br/>[route.ts]"]
  node_billingcron["Recurring billing job<br/>[route.ts]"]
  node_payments["Toss billing client<br/>[toss-client.ts]"]
  node_subscriptions["Plan and subscription queries<br/>[subscriptions.ts]"]
  node_accountpages["Account and plan pages"]
end

subgraph group_operations["Operations and administration"]
  node_scheduler["Scheduled jobs<br/>[route.ts]"]
  node_cronruns["Cron run records<br/>[cron-runs.ts]"]
  node_adminpages["Admin dashboard"]
end

subgraph group_data["Persistence"]
  node_channels["Channel queries<br/>[channels.ts]"]
  node_comments["Comment queries<br/>[comments.ts]"]
  node_dbschema[("Application data model<br/>[schema.ts]")]
end

node_creator(("Channel owner"))
node_youtubeapi{{"YouTube API"}}
node_toss{{"Toss Payments"}}

node_scheduler -->|"loads channels"| node_channels
node_scheduler -->|"checks plan interval"| node_subscriptions
node_scheduler -->|"syncs comments"| node_sync
node_sync -.->|"fetches comments"| node_youtubeapi
node_scheduler -->|"analyzes pending"| node_analysis
node_scheduler -->|"records run"| node_cronruns
node_scheduler -->|"sends alerts"| node_notifications
node_analysis -->|"analyzes comments"| node_ai
node_review -->|"renders actions"| node_status
node_review -->|"renders risk"| node_risk
node_authors -->|"loads feed data"| node_comments
node_commentapi -->|"checks channel"| node_channels
node_commentapi -->|"updates statuses"| node_comments
node_creator -.->|"uses workspace"| node_workspacepages
node_creator -.->|"manages account"| node_accountpages
node_creator -.->|"administers service"| node_adminpages
node_authcode -.->|"exchanges code"| node_youtubeapi
node_billingcheckout -->|"issues key, charges"| node_payments
node_billingcheckout -->|"creates subscription"| node_subscriptions
node_billingcheckout -->|"reconciles locks"| node_channels
node_billingcron -->|"charges renewal"| node_payments
node_billingcron -->|"updates billing state"| node_subscriptions
node_billingcron -->|"reconciles locks"| node_channels
node_payments -->|"calls billing API"| node_toss
node_channels -->|"queries tables"| node_dbschema
node_comments -->|"queries tables"| node_dbschema
node_subscriptions -->|"queries tables"| node_dbschema
node_notifications -->|"queries tables"| node_dbschema
node_cronruns -->|"queries tables"| node_dbschema

click node_scheduler "https://github.com/nayun1/reevely/blob/develop/src/app/api/cron/process-comments/route.ts"
click node_sync "https://github.com/nayun1/reevely/blob/develop/src/lib/youtube/sync-comments.ts"
click node_youtube "https://github.com/nayun1/reevely/blob/develop/src/lib/youtube/connect-channel.ts"
click node_authcode "https://github.com/nayun1/reevely/blob/develop/src/lib/youtube/exchange-auth-code.ts"
click node_analysis "https://github.com/nayun1/reevely/blob/develop/src/lib/ai/analyze-pending-comments.ts"
click node_ai "https://github.com/nayun1/reevely/blob/develop/src/lib/ai/analyze-comment.ts"
click node_review "https://github.com/nayun1/reevely/blob/develop/src/components/comments/review-queue-list.tsx"
click node_status "https://github.com/nayun1/reevely/blob/develop/src/components/comments/status-action-button.tsx"
click node_risk "https://github.com/nayun1/reevely/blob/develop/src/components/dashboard/risk-badge.tsx"
click node_authors "https://github.com/nayun1/reevely/blob/develop/src/components/authors/author-comment-feed.tsx"
click node_commentapi "https://github.com/nayun1/reevely/blob/develop/src/app/api/comments/bulk-status/route.ts"
click node_notifications "https://github.com/nayun1/reevely/blob/develop/src/lib/db/queries/notifications.ts"
click node_billingcheckout "https://github.com/nayun1/reevely/blob/develop/src/app/billing/success/route.ts"
click node_billingcron "https://github.com/nayun1/reevely/blob/develop/src/app/api/cron/process-billing/route.ts"
click node_payments "https://github.com/nayun1/reevely/blob/develop/src/lib/billing/toss-client.ts"
click node_subscriptions "https://github.com/nayun1/reevely/blob/develop/src/lib/db/queries/subscriptions.ts"
click node_channels "https://github.com/nayun1/reevely/blob/develop/src/lib/db/queries/channels.ts"
click node_comments "https://github.com/nayun1/reevely/blob/develop/src/lib/db/queries/comments.ts"
click node_cronruns "https://github.com/nayun1/reevely/blob/develop/src/lib/db/queries/cron-runs.ts"
click node_dbschema "https://github.com/nayun1/reevely/blob/develop/src/lib/db/schema.ts"
click node_workspacepages "https://github.com/nayun1/reevely/tree/develop/src/app/(app)/c/%5BchannelId%5D"
click node_accountpages "https://github.com/nayun1/reevely/tree/develop/src/app/(app)/mypage"
click node_adminpages "https://github.com/nayun1/reevely/tree/develop/src/app/admin/(dashboard)"

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_sync,node_analysis,node_ai toneBlue
class node_review,node_status,node_risk,node_authors,node_commentapi,node_notifications,node_workspacepages toneAmber
class node_youtube,node_authcode,node_billingcheckout,node_billingcron,node_payments,node_subscriptions,node_accountpages,node_youtubeapi toneMint
class node_scheduler,node_cronruns,node_adminpages toneRose
class node_channels,node_comments,node_dbschema,node_creator,node_toss toneIndigo
```

## Components

### Collection and analysis

- [YouTube comment sync](https://github.com/nayun1/reevely/blob/develop/src/lib/youtube/sync-comments.ts): `src/lib/youtube/sync-comments.ts`
- [Pending comment analysis](https://github.com/nayun1/reevely/blob/develop/src/lib/ai/analyze-pending-comments.ts): `src/lib/ai/analyze-pending-comments.ts`
- [Comment risk analysis](https://github.com/nayun1/reevely/blob/develop/src/lib/ai/analyze-comment.ts): `src/lib/ai/analyze-comment.ts`

### Channel workspace

- [Review queue](https://github.com/nayun1/reevely/blob/develop/src/components/comments/review-queue-list.tsx): `src/components/comments/review-queue-list.tsx`
- [Review status action](https://github.com/nayun1/reevely/blob/develop/src/components/comments/status-action-button.tsx): `src/components/comments/status-action-button.tsx`
- [Risk indicator](https://github.com/nayun1/reevely/blob/develop/src/components/dashboard/risk-badge.tsx): `src/components/dashboard/risk-badge.tsx`
- [Author comment feed](https://github.com/nayun1/reevely/blob/develop/src/components/authors/author-comment-feed.tsx): `src/components/authors/author-comment-feed.tsx`
- [Comment actions API](https://github.com/nayun1/reevely/blob/develop/src/app/api/comments/bulk-status/route.ts): `src/app/api/comments/bulk-status/route.ts`
- [Notification records](https://github.com/nayun1/reevely/blob/develop/src/lib/db/queries/notifications.ts): `src/lib/db/queries/notifications.ts`
- [Channel workspace pages](https://github.com/nayun1/reevely/tree/develop/src/app/(app)/c/%5BchannelId%5D): `src/app/(app)/c/[channelId]`

### Accounts and billing

- [YouTube channel linking](https://github.com/nayun1/reevely/blob/develop/src/lib/youtube/connect-channel.ts): `src/lib/youtube/connect-channel.ts`
- [OAuth token exchange](https://github.com/nayun1/reevely/blob/develop/src/lib/youtube/exchange-auth-code.ts): `src/lib/youtube/exchange-auth-code.ts`
- [Subscription checkout](https://github.com/nayun1/reevely/blob/develop/src/app/billing/success/route.ts): `src/app/billing/success/route.ts`
- [Recurring billing job](https://github.com/nayun1/reevely/blob/develop/src/app/api/cron/process-billing/route.ts): `src/app/api/cron/process-billing/route.ts`
- [Toss billing client](https://github.com/nayun1/reevely/blob/develop/src/lib/billing/toss-client.ts): `src/lib/billing/toss-client.ts`
- [Plan and subscription queries](https://github.com/nayun1/reevely/blob/develop/src/lib/db/queries/subscriptions.ts): `src/lib/db/queries/subscriptions.ts`
- [Account and plan pages](https://github.com/nayun1/reevely/tree/develop/src/app/(app)/mypage): `src/app/(app)/mypage`

### Operations and administration

- [Scheduled jobs](https://github.com/nayun1/reevely/blob/develop/src/app/api/cron/process-comments/route.ts): `src/app/api/cron/process-comments/route.ts`
- [Cron run records](https://github.com/nayun1/reevely/blob/develop/src/lib/db/queries/cron-runs.ts): `src/lib/db/queries/cron-runs.ts`
- [Admin dashboard](https://github.com/nayun1/reevely/tree/develop/src/app/admin/(dashboard)): `src/app/admin/(dashboard)`

### Persistence

- [Channel queries](https://github.com/nayun1/reevely/blob/develop/src/lib/db/queries/channels.ts): `src/lib/db/queries/channels.ts`
- [Comment queries](https://github.com/nayun1/reevely/blob/develop/src/lib/db/queries/comments.ts): `src/lib/db/queries/comments.ts`
- [Application data model](https://github.com/nayun1/reevely/blob/develop/src/lib/db/schema.ts): `src/lib/db/schema.ts`

### Other components

- **Channel owner**
- **YouTube API**
- **Toss Payments**

## Connections

- Scheduled jobs → Channel queries: loads channels (evidence: `src/app/api/cron/process-comments/route.ts`)
- Scheduled jobs → Plan and subscription queries: checks plan interval (evidence: `src/app/api/cron/process-comments/route.ts`)
- Scheduled jobs → YouTube comment sync: syncs comments (evidence: `src/app/api/cron/process-comments/route.ts`)
- YouTube comment sync → YouTube API: fetches comments
- Scheduled jobs → Pending comment analysis: analyzes pending (evidence: `src/app/api/cron/process-comments/route.ts`)
- Scheduled jobs → Cron run records: records run (evidence: `src/app/api/cron/process-comments/route.ts`)
- Scheduled jobs → Notification records: sends alerts (evidence: `src/app/api/cron/process-comments/route.ts`)
- Pending comment analysis → Comment risk analysis: analyzes comments (evidence: `src/lib/ai/analyze-pending-comments.ts`)
- Review queue → Review status action: renders actions (evidence: `src/components/comments/review-queue-list.tsx`)
- Review queue → Risk indicator: renders risk (evidence: `src/components/comments/review-queue-list.tsx`)
- Author comment feed → Comment queries: loads feed data (evidence: `src/components/authors/author-comment-feed.tsx`)
- Comment actions API → Channel queries: checks channel (evidence: `src/app/api/comments/bulk-status/route.ts`)
- Comment actions API → Comment queries: updates statuses (evidence: `src/app/api/comments/bulk-status/route.ts`)
- Channel owner → Channel workspace pages: uses workspace
- Channel owner → Account and plan pages: manages account
- Channel owner → Admin dashboard: administers service
- OAuth token exchange → YouTube API: exchanges code
- Subscription checkout → Toss billing client: issues key, charges (evidence: `src/app/billing/success/route.ts`)
- Subscription checkout → Plan and subscription queries: creates subscription (evidence: `src/app/billing/success/route.ts`)
- Subscription checkout → Channel queries: reconciles locks (evidence: `src/app/billing/success/route.ts`)
- Recurring billing job → Toss billing client: charges renewal (evidence: `src/app/api/cron/process-billing/route.ts`)
- Recurring billing job → Plan and subscription queries: updates billing state (evidence: `src/app/api/cron/process-billing/route.ts`)
- Recurring billing job → Channel queries: reconciles locks (evidence: `src/app/api/cron/process-billing/route.ts`)
- Toss billing client → Toss Payments: calls billing API (evidence: `src/lib/billing/toss-client.ts`)
- Channel queries → Application data model: queries tables (evidence: `src/lib/db/queries/channels.ts`)
- Comment queries → Application data model: queries tables (evidence: `src/lib/db/queries/comments.ts`)
- Plan and subscription queries → Application data model: queries tables (evidence: `src/lib/db/queries/subscriptions.ts`)
- Notification records → Application data model: queries tables (evidence: `src/lib/db/queries/notifications.ts`)
- Cron run records → Application data model: queries tables (evidence: `src/lib/db/queries/cron-runs.ts`)
