# puviin/reddit-ai-judge architecture

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

- Interactive diagram: https://gitdiagram.com/puviin/reddit-ai-judge
- Repository: https://github.com/puviin/reddit-ai-judge

## Overview

DramaForge Scout is a web application for turning stories into analyzed courtroom narratives and generated audiovisual drama reels. The visible runtime includes a React client, tRPC API, AI/story routers, reel generation and caching, and storage helpers. The principal flow is supported at the router level, but the excerpts do not show the client’s calls into those procedures or the internal behavior of the Gemini and Scout routers; those connections are therefore omitted. Several client section components indicate distinct product stages, but their wiring is not established by the sampled source.

Main entry points: [`server/routers/drama.ts`](https://github.com/puviin/reddit-ai-judge/blob/main/server/routers/drama.ts) (Drama procedures), [`client/src/App.tsx`](https://github.com/puviin/reddit-ai-judge/blob/main/client/src/App.tsx) (App shell), [`server/routers.ts`](https://github.com/puviin/reddit-ai-judge/blob/main/server/routers.ts) (API router), [`server/storage.ts`](https://github.com/puviin/reddit-ai-judge/blob/main/server/storage.ts) (Media storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["App shell<br/>[App.tsx]"]
  node_home["Story workspace<br/>[Home.tsx]"]
  node_analysis_ui["Story analysis<br/>[StoryAnalysis.tsx]"]
  node_character_ui["Character bible<br/>[CharacterBible.tsx]"]
  node_courtroom_ui["Courtroom mode<br/>[CourtroomMode.tsx]"]
  node_theme_ui["Theme selection<br/>[ThemeSelection.tsx]"]
  node_pipeline_ui["Adaptation pipeline"]
  node_reel_ui["Drama reel<br/>[DramaReel.tsx]"]
  node_player_ui["Clip player<br/>[ClipPlayer.tsx]"]
  node_error_boundary["Error boundary<br/>[ErrorBoundary.tsx]"]
  node_theme_context["Theme provider<br/>[ThemeContext.tsx]"]
  node_trpc_client["tRPC client<br/>[main.tsx]"]
end

subgraph group_api["API and story services"]
  node_api_router["API router<br/>[routers.ts]"]
  node_gemini_router["Gemini services<br/>[gemini.ts]"]
  node_scout_router["Scout services<br/>[scout.ts]"]
  node_auth["Auth middleware<br/>[trpc.ts]"]
end

subgraph group_generation["Reel generation"]
  node_drama_router["Drama procedures<br/>[drama.ts]"]
end

subgraph group_persistence["Persistence and storage"]
  node_reel_cache[("Reel cache<br/>[schema.ts]")]
  node_database["Database access<br/>[db.ts]"]
  node_storage["Media storage<br/>[storage.ts]"]
  node_storage_proxy["Storage proxy<br/>[storageProxy.ts]"]
end

node_user(("Story creator"))
node_openai["OpenAI API"]
node_fal["fal.ai"]
node_elevenlabs["ElevenLabs"]
node_forge["Forge storage API"]
node_s3[("S3 object store")]

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_home
node_app -->|"wraps"| node_error_boundary
node_app -->|"provides theme"| node_theme_context
node_trpc_client -->|"renders"| node_app
node_trpc_client -.->|"calls API"| node_api_router
node_api_router -->|"registers"| node_drama_router
node_api_router -->|"registers"| node_gemini_router
node_api_router -->|"registers"| node_scout_router
node_drama_router -->|"uses procedures"| node_auth
node_gemini_router -->|"uses procedures"| node_auth
node_scout_router -->|"uses procedures"| node_auth
node_drama_router -->|"requests prompts"| node_openai
node_drama_router -->|"generates media"| node_fal
node_drama_router -->|"generates voice"| node_elevenlabs
node_drama_router -->|"stores media"| node_storage
node_drama_router -->|"reads and writes"| node_database
node_database -->|"uses schema"| node_reel_cache
node_storage -->|"requests URLs"| node_forge
node_storage -->|"uploads directly"| node_s3
node_storage_proxy -->|"requests signed URL"| node_forge

click node_app "https://github.com/puviin/reddit-ai-judge/blob/main/client/src/App.tsx"
click node_home "https://github.com/puviin/reddit-ai-judge/blob/main/client/src/pages/Home.tsx"
click node_analysis_ui "https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/sections/StoryAnalysis.tsx"
click node_character_ui "https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/sections/CharacterBible.tsx"
click node_courtroom_ui "https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/sections/CourtroomMode.tsx"
click node_theme_ui "https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/sections/ThemeSelection.tsx"
click node_pipeline_ui "https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/sections/AdaptionPipeline.tsx"
click node_reel_ui "https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/sections/DramaReel.tsx"
click node_player_ui "https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/sections/ClipPlayer.tsx"
click node_error_boundary "https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/ErrorBoundary.tsx"
click node_theme_context "https://github.com/puviin/reddit-ai-judge/blob/main/client/src/contexts/ThemeContext.tsx"
click node_trpc_client "https://github.com/puviin/reddit-ai-judge/blob/main/client/src/main.tsx"
click node_api_router "https://github.com/puviin/reddit-ai-judge/blob/main/server/routers.ts"
click node_drama_router "https://github.com/puviin/reddit-ai-judge/blob/main/server/routers/drama.ts"
click node_gemini_router "https://github.com/puviin/reddit-ai-judge/blob/main/server/routers/gemini.ts"
click node_scout_router "https://github.com/puviin/reddit-ai-judge/blob/main/server/routers/scout.ts"
click node_auth "https://github.com/puviin/reddit-ai-judge/blob/main/server/_core/trpc.ts"
click node_reel_cache "https://github.com/puviin/reddit-ai-judge/blob/main/drizzle/schema.ts"
click node_database "https://github.com/puviin/reddit-ai-judge/blob/main/server/db.ts"
click node_storage "https://github.com/puviin/reddit-ai-judge/blob/main/server/storage.ts"
click node_storage_proxy "https://github.com/puviin/reddit-ai-judge/blob/main/server/_core/storageProxy.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_home,node_analysis_ui,node_character_ui,node_courtroom_ui,node_theme_ui,node_pipeline_ui,node_reel_ui,node_player_ui,node_error_boundary,node_theme_context,node_trpc_client toneBlue
class node_api_router,node_gemini_router,node_scout_router,node_auth,node_forge,node_s3 toneAmber
class node_drama_router,node_openai toneMint
class node_reel_cache,node_database,node_storage,node_storage_proxy toneRose
class node_user,node_fal,node_elevenlabs toneIndigo
```

## Components

### Client experience

- [App shell](https://github.com/puviin/reddit-ai-judge/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Story workspace](https://github.com/puviin/reddit-ai-judge/blob/main/client/src/pages/Home.tsx): `client/src/pages/Home.tsx`
- [Story analysis](https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/sections/StoryAnalysis.tsx): `client/src/components/sections/StoryAnalysis.tsx`
- [Character bible](https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/sections/CharacterBible.tsx): `client/src/components/sections/CharacterBible.tsx`
- [Courtroom mode](https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/sections/CourtroomMode.tsx): `client/src/components/sections/CourtroomMode.tsx`
- [Theme selection](https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/sections/ThemeSelection.tsx): `client/src/components/sections/ThemeSelection.tsx`
- [Adaptation pipeline](https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/sections/AdaptionPipeline.tsx): `client/src/components/sections/AdaptionPipeline.tsx`
- [Drama reel](https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/sections/DramaReel.tsx): `client/src/components/sections/DramaReel.tsx`
- [Clip player](https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/sections/ClipPlayer.tsx): `client/src/components/sections/ClipPlayer.tsx`
- [Error boundary](https://github.com/puviin/reddit-ai-judge/blob/main/client/src/components/ErrorBoundary.tsx): `client/src/components/ErrorBoundary.tsx`
- [Theme provider](https://github.com/puviin/reddit-ai-judge/blob/main/client/src/contexts/ThemeContext.tsx): `client/src/contexts/ThemeContext.tsx`
- [tRPC client](https://github.com/puviin/reddit-ai-judge/blob/main/client/src/main.tsx): `client/src/main.tsx`

### API and story services

- [API router](https://github.com/puviin/reddit-ai-judge/blob/main/server/routers.ts): `server/routers.ts`
- [Gemini services](https://github.com/puviin/reddit-ai-judge/blob/main/server/routers/gemini.ts): `server/routers/gemini.ts`
- [Scout services](https://github.com/puviin/reddit-ai-judge/blob/main/server/routers/scout.ts): `server/routers/scout.ts`
- [Auth middleware](https://github.com/puviin/reddit-ai-judge/blob/main/server/_core/trpc.ts): `server/_core/trpc.ts`

### Reel generation

- [Drama procedures](https://github.com/puviin/reddit-ai-judge/blob/main/server/routers/drama.ts): `server/routers/drama.ts`

### Persistence and storage

- [Reel cache](https://github.com/puviin/reddit-ai-judge/blob/main/drizzle/schema.ts): `drizzle/schema.ts`
- [Database access](https://github.com/puviin/reddit-ai-judge/blob/main/server/db.ts): `server/db.ts`
- [Media storage](https://github.com/puviin/reddit-ai-judge/blob/main/server/storage.ts): `server/storage.ts`
- [Storage proxy](https://github.com/puviin/reddit-ai-judge/blob/main/server/_core/storageProxy.ts): `server/_core/storageProxy.ts`

### Other components

- **Story creator**
- **OpenAI API**
- **fal.ai**
- **ElevenLabs**
- **Forge storage API**
- **S3 object store**

## Connections

- Story creator → App shell: uses
- App shell → Story workspace: routes to (evidence: `client/src/App.tsx`)
- App shell → Error boundary: wraps (evidence: `client/src/App.tsx`)
- App shell → Theme provider: provides theme (evidence: `client/src/App.tsx`)
- tRPC client → App shell: renders (evidence: `client/src/main.tsx`)
- tRPC client → API router: calls API
- API router → Drama procedures: registers (evidence: `server/routers.ts`)
- API router → Gemini services: registers (evidence: `server/routers.ts`)
- API router → Scout services: registers (evidence: `server/routers.ts`)
- Drama procedures → Auth middleware: uses procedures (evidence: `server/routers/drama.ts`)
- Gemini services → Auth middleware: uses procedures (evidence: `server/routers/gemini.ts`)
- Scout services → Auth middleware: uses procedures (evidence: `server/routers/scout.ts`)
- Drama procedures → OpenAI API: requests prompts (evidence: `server/routers/drama.ts`)
- Drama procedures → fal.ai: generates media (evidence: `server/routers/drama.ts`)
- Drama procedures → ElevenLabs: generates voice (evidence: `server/routers/drama.ts`)
- Drama procedures → Media storage: stores media (evidence: `server/routers/drama.ts`)
- Drama procedures → Database access: reads and writes (evidence: `server/routers/drama.ts`)
- Database access → Reel cache: uses schema (evidence: `server/db.ts`)
- Media storage → Forge storage API: requests URLs (evidence: `server/storage.ts`)
- Media storage → S3 object store: uploads directly (evidence: `server/storage.ts`)
- Storage proxy → Forge storage API: requests signed URL (evidence: `server/_core/storageProxy.ts`)
