# brookmaodev/youtubeautocomment architecture

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

- Interactive diagram: https://gitdiagram.com/brookmaodev/youtubeautocomment
- Repository: https://github.com/brookmaodev/youtubeautocomment

## Overview

YouTubeAutoComment is a small Express service that lets users connect a YouTube account, register channels and comments, and periodically checks those channels for new videos before posting comments. Its main runtime is concentrated in app.ts; the HTML pages provide the user-facing entry points, while Postgres and Google APIs support the workflow. The README documents Cloud Scheduler triggering /poll. The excerpts do not show the form submissions or all route details, so those links are omitted.

Main entry points: [`app.ts`](https://github.com/brookmaodev/youtubeautocomment/blob/main/app.ts) (Comment posting), [`static/index.html`](https://github.com/brookmaodev/youtubeautocomment/blob/main/static/index.html) (Home page), [`static/create.html`](https://github.com/brookmaodev/youtubeautocomment/blob/main/static/create.html) (Setup page), [`static/confirmation.html`](https://github.com/brookmaodev/youtubeautocomment/blob/main/static/confirmation.html) (Confirmation page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_home["Home page<br/>[index.html]"]
  node_channel_form["Setup page<br/>[create.html]"]
  node_confirmation["Confirmation page<br/>[confirmation.html]"]
end

subgraph group_runtime["Application workflows"]
  node_web_app["Express service<br/>[app.ts]"]
  node_oauth_setup["OAuth onboarding<br/>[app.ts]"]
  node_channel_setup["Channel setup<br/>[app.ts]"]
  node_video_polling["Video polling<br/>[app.ts]"]
  node_comment_posting["Comment posting<br/>[app.ts]"]
end

subgraph group_state["Application state"]
  node_postgres[("Postgres")]
end

subgraph group_external["External services"]
  node_youtube_api["YouTube API"]
  node_oauth_service["Google OAuth"]
end

node_user(("User"))
node_scheduler(("Cloud Scheduler"))

node_user -->|"opens"| node_home
node_user -->|"configures"| node_channel_form
node_web_app -->|"serves"| node_home
node_web_app -->|"serves"| node_channel_form
node_web_app -->|"serves"| node_confirmation
node_scheduler -->|"triggers"| node_video_polling
node_oauth_setup -->|"looks up channel"| node_youtube_api
node_oauth_setup -->|"stores account"| node_postgres
node_channel_setup -->|"validates channel"| node_youtube_api
node_channel_setup -->|"checks latest video"| node_youtube_api
node_channel_setup -->|"stores setup"| node_postgres
node_video_polling -->|"loads channels"| node_postgres
node_video_polling -->|"checks uploads"| node_youtube_api
node_video_polling -->|"updates latest video"| node_postgres
node_comment_posting -->|"loads comments"| node_postgres
node_comment_posting -->|"loads refresh tokens"| node_postgres
node_comment_posting -->|"refreshes tokens"| node_oauth_service
node_comment_posting -->|"posts comments"| node_youtube_api

click node_home "https://github.com/brookmaodev/youtubeautocomment/blob/main/static/index.html"
click node_channel_form "https://github.com/brookmaodev/youtubeautocomment/blob/main/static/create.html"
click node_confirmation "https://github.com/brookmaodev/youtubeautocomment/blob/main/static/confirmation.html"
click node_web_app "https://github.com/brookmaodev/youtubeautocomment/blob/main/app.ts"
click node_oauth_setup "https://github.com/brookmaodev/youtubeautocomment/blob/main/app.ts"
click node_channel_setup "https://github.com/brookmaodev/youtubeautocomment/blob/main/app.ts"
click node_video_polling "https://github.com/brookmaodev/youtubeautocomment/blob/main/app.ts"
click node_comment_posting "https://github.com/brookmaodev/youtubeautocomment/blob/main/app.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_channel_form,node_confirmation,node_user toneBlue
class node_web_app,node_oauth_setup,node_channel_setup,node_video_polling,node_comment_posting toneAmber
class node_postgres toneMint
class node_youtube_api,node_oauth_service,node_scheduler toneRose
```

## Components

### User interface

- [Home page](https://github.com/brookmaodev/youtubeautocomment/blob/main/static/index.html): `static/index.html`
- [Setup page](https://github.com/brookmaodev/youtubeautocomment/blob/main/static/create.html): `static/create.html`
- [Confirmation page](https://github.com/brookmaodev/youtubeautocomment/blob/main/static/confirmation.html): `static/confirmation.html`

### Application workflows

- [Express service](https://github.com/brookmaodev/youtubeautocomment/blob/main/app.ts): `app.ts`
- [OAuth onboarding](https://github.com/brookmaodev/youtubeautocomment/blob/main/app.ts): `app.ts`
- [Channel setup](https://github.com/brookmaodev/youtubeautocomment/blob/main/app.ts): `app.ts`
- [Video polling](https://github.com/brookmaodev/youtubeautocomment/blob/main/app.ts): `app.ts`
- [Comment posting](https://github.com/brookmaodev/youtubeautocomment/blob/main/app.ts): `app.ts`

### Application state

- **Postgres**

### External services

- **YouTube API**
- **Google OAuth**

### Other components

- **User**
- **Cloud Scheduler**

## Connections

- User → Home page: opens (evidence: `README.md`)
- User → Setup page: configures (evidence: `README.md`)
- Express service → Home page: serves (evidence: `app.ts`)
- Express service → Setup page: serves (evidence: `app.ts`)
- Express service → Confirmation page: serves (evidence: `app.ts`)
- Cloud Scheduler → Video polling: triggers (evidence: `README.md`)
- OAuth onboarding → YouTube API: looks up channel (evidence: `app.ts`)
- OAuth onboarding → Postgres: stores account (evidence: `app.ts`)
- Channel setup → YouTube API: validates channel (evidence: `app.ts`)
- Channel setup → YouTube API: checks latest video (evidence: `app.ts`)
- Channel setup → Postgres: stores setup (evidence: `app.ts`)
- Video polling → Postgres: loads channels (evidence: `app.ts`)
- Video polling → YouTube API: checks uploads (evidence: `app.ts`)
- Video polling → Postgres: updates latest video (evidence: `app.ts`)
- Comment posting → Postgres: loads comments (evidence: `app.ts`)
- Comment posting → Postgres: loads refresh tokens (evidence: `app.ts`)
- Comment posting → Google OAuth: refreshes tokens (evidence: `app.ts`)
- Comment posting → YouTube API: posts comments (evidence: `app.ts`)
