# techreagan/youtube-clone-nodejs-api architecture

> Architecture diagram of the GitHub repository techreagan/youtube-clone-nodejs-api, 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/techreagan/youtube-clone-nodejs-api
- Repository: https://github.com/techreagan/youtube-clone-nodejs-api

## Overview

VueTube is an Express REST API for a YouTube-style video and channel service. A client request enters the versioned API, reaches feature routes and controllers, and reads or changes MongoDB-backed records; protected operations use JWT authentication. The README also documents upload and watch actions, likes and dislikes, comments and replies, subscriptions, history, search, trending, and channel settings. Source excerpts and index references support the main route, controller, and model links; README-only capabilities are shown without asserting unverified implementation details.

Main entry points: [`models/Video.js`](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/Video.js) (Video records), [`app.js`](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/app.js) (Express API), [`routes/videos.js`](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/routes/videos.js) (Video routes), [`controllers/auth.js`](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/auth.js) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_server["Express API<br/>[app.js]"]
  node_auth_routes["Auth routes<br/>[auth.js]"]
  node_user_routes["User routes<br/>[users.js]"]
  node_video_routes["Video routes<br/>[videos.js]"]
  node_search_routes["Search routes<br/>[search.js]"]
end

subgraph group_identity["Identity and channels"]
  node_auth_ctrl["Authentication<br/>[auth.js]"]
  node_user_ctrl["Channel settings<br/>[users.js]"]
  node_user_model[("User records<br/>[User.js]")]
end

subgraph group_video["Video catalog"]
  node_video_ctrl["Video management<br/>[videos.js]"]
  node_video_model[("Video records<br/>[Video.js]")]
  node_category_ctrl["Categories<br/>[categories.js]"]
  node_category_model[("Category records<br/>[Category.js]")]
  node_search_ctrl["Video and channel search<br/>[search.js]"]
end

subgraph group_engagement["Viewer engagement"]
  node_comment_ctrl["Comments<br/>[comments.js]"]
  node_comment_model[("Comment records<br/>[Comment.js]")]
  node_reply_ctrl["Replies<br/>[replies.js]"]
  node_reply_model[("Reply records<br/>[Reply.js]")]
  node_feeling_ctrl["Likes and dislikes<br/>[feelings.js]"]
  node_feeling_model[("Feeling records<br/>[Feeling.js]")]
  node_subscription_ctrl["Subscriptions<br/>[subscriptions.js]"]
  node_subscription_model[("Subscription records<br/>[Subscription.js]")]
  node_history_ctrl["Watch history<br/>[histories.js]"]
  node_history_model[("History records<br/>[History.js]")]
end

subgraph group_shared["Shared services"]
  node_auth_middleware["JWT protection<br/>[auth.js]"]
  node_results_middleware["Paged results<br/>[advancedResults.js]"]
end

node_client(("API client"))
node_mongo[("MongoDB")]
node_email["SMTP email service"]

node_client -->|"calls REST API"| node_server
node_server -->|"mounts routes"| node_auth_routes
node_server -->|"mounts routes"| node_user_routes
node_server -->|"mounts routes"| node_video_routes
node_server -->|"mounts routes"| node_search_routes
node_auth_routes -->|"dispatches to"| node_auth_ctrl
node_user_routes -->|"dispatches to"| node_user_ctrl
node_video_routes -->|"dispatches to"| node_video_ctrl
node_search_routes -->|"dispatches to"| node_search_ctrl
node_auth_routes -->|"protects routes"| node_auth_middleware
node_user_routes -->|"protects routes"| node_auth_middleware
node_video_routes -->|"protects routes"| node_auth_middleware
node_auth_ctrl -->|"reads and updates"| node_user_model
node_auth_ctrl -->|"sends reset email"| node_email
node_user_ctrl -->|"manages records"| node_user_model
node_auth_middleware -->|"loads user"| node_user_model
node_video_ctrl -->|"manages videos"| node_video_model
node_category_ctrl -->|"manages categories"| node_category_model
node_search_ctrl -->|"searches videos"| node_video_model
node_search_ctrl -->|"searches channels"| node_user_model
node_comment_ctrl -->|"manages comments"| node_comment_model
node_comment_ctrl -->|"accesses video"| node_video_model
node_reply_ctrl -->|"manages replies"| node_reply_model
node_reply_ctrl -->|"accesses comments"| node_comment_model
node_feeling_ctrl -->|"manages reactions"| node_feeling_model
node_feeling_ctrl -->|"updates video reactions"| node_video_model
node_subscription_ctrl -->|"manages subscriptions"| node_subscription_model
node_subscription_ctrl -->|"queries videos"| node_video_model
node_history_ctrl -->|"manages history"| node_history_model
node_history_ctrl -->|"queries videos"| node_video_model
node_video_routes -->|"applies pagination"| node_results_middleware
node_results_middleware -.->|"queries model"| node_mongo
node_auth_ctrl -.->|"persists user data"| node_mongo
node_video_ctrl -.->|"persists video data"| node_mongo

click node_server "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/app.js"
click node_auth_routes "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/routes/auth.js"
click node_user_routes "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/routes/users.js"
click node_video_routes "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/routes/videos.js"
click node_search_routes "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/routes/search.js"
click node_auth_ctrl "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/auth.js"
click node_user_ctrl "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/users.js"
click node_user_model "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/User.js"
click node_video_ctrl "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/videos.js"
click node_video_model "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/Video.js"
click node_category_ctrl "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/categories.js"
click node_category_model "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/Category.js"
click node_search_ctrl "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/search.js"
click node_comment_ctrl "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/comments.js"
click node_comment_model "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/Comment.js"
click node_reply_ctrl "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/replies.js"
click node_reply_model "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/Reply.js"
click node_feeling_ctrl "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/feelings.js"
click node_feeling_model "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/Feeling.js"
click node_subscription_ctrl "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/subscriptions.js"
click node_subscription_model "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/Subscription.js"
click node_history_ctrl "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/histories.js"
click node_history_model "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/History.js"
click node_auth_middleware "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/middleware/auth.js"
click node_results_middleware "https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/middleware/advancedResults.js"

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_server,node_auth_routes,node_user_routes,node_video_routes,node_search_routes,node_client toneBlue
class node_auth_ctrl,node_user_ctrl,node_user_model,node_mongo toneAmber
class node_video_ctrl,node_video_model,node_category_ctrl,node_category_model,node_search_ctrl toneMint
class node_comment_ctrl,node_comment_model,node_reply_ctrl,node_reply_model,node_feeling_ctrl,node_feeling_model,node_subscription_ctrl,node_subscription_model,node_history_ctrl,node_history_model toneRose
class node_auth_middleware,node_results_middleware,node_email toneIndigo
```

## Components

### API entry

- [Express API](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/app.js): `app.js`
- [Auth routes](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/routes/auth.js): `routes/auth.js`
- [User routes](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/routes/users.js): `routes/users.js`
- [Video routes](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/routes/videos.js): `routes/videos.js`
- [Search routes](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/routes/search.js): `routes/search.js`

### Identity and channels

- [Authentication](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/auth.js): `controllers/auth.js`
- [Channel settings](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/users.js): `controllers/users.js`
- [User records](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/User.js): `models/User.js`

### Video catalog

- [Video management](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/videos.js): `controllers/videos.js`
- [Video records](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/Video.js): `models/Video.js`
- [Categories](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/categories.js): `controllers/categories.js`
- [Category records](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/Category.js): `models/Category.js`
- [Video and channel search](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/search.js): `controllers/search.js`

### Viewer engagement

- [Comments](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/comments.js): `controllers/comments.js`
- [Comment records](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/Comment.js): `models/Comment.js`
- [Replies](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/replies.js): `controllers/replies.js`
- [Reply records](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/Reply.js): `models/Reply.js`
- [Likes and dislikes](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/feelings.js): `controllers/feelings.js`
- [Feeling records](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/Feeling.js): `models/Feeling.js`
- [Subscriptions](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/subscriptions.js): `controllers/subscriptions.js`
- [Subscription records](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/Subscription.js): `models/Subscription.js`
- [Watch history](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/controllers/histories.js): `controllers/histories.js`
- [History records](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/models/History.js): `models/History.js`

### Shared services

- [JWT protection](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/middleware/auth.js): `middleware/auth.js`
- [Paged results](https://github.com/techreagan/youtube-clone-nodejs-api/blob/master/middleware/advancedResults.js): `middleware/advancedResults.js`

### Other components

- **API client**
- **MongoDB**
- **SMTP email service**

## Connections

- API client → Express API: calls REST API (evidence: `README.md`)
- Express API → Auth routes: mounts routes (evidence: `app.js`)
- Express API → User routes: mounts routes (evidence: `app.js`)
- Express API → Video routes: mounts routes (evidence: `app.js`)
- Express API → Search routes: mounts routes (evidence: `app.js`)
- Auth routes → Authentication: dispatches to (evidence: `routes/auth.js`)
- User routes → Channel settings: dispatches to (evidence: `routes/users.js`)
- Video routes → Video management: dispatches to (evidence: `routes/videos.js`)
- Search routes → Video and channel search: dispatches to (evidence: `routes/search.js`)
- Auth routes → JWT protection: protects routes (evidence: `routes/auth.js`)
- User routes → JWT protection: protects routes (evidence: `routes/users.js`)
- Video routes → JWT protection: protects routes (evidence: `routes/videos.js`)
- Authentication → User records: reads and updates (evidence: `controllers/auth.js`)
- Authentication → SMTP email service: sends reset email (evidence: `controllers/auth.js`)
- Channel settings → User records: manages records (evidence: `controllers/users.js`)
- JWT protection → User records: loads user (evidence: `middleware/auth.js`)
- Video management → Video records: manages videos (evidence: `controllers/videos.js`)
- Categories → Category records: manages categories (evidence: `controllers/categories.js`)
- Video and channel search → Video records: searches videos (evidence: `controllers/search.js`)
- Video and channel search → User records: searches channels (evidence: `controllers/search.js`)
- Comments → Comment records: manages comments (evidence: `controllers/comments.js`)
- Comments → Video records: accesses video (evidence: `controllers/comments.js`)
- Replies → Reply records: manages replies (evidence: `controllers/replies.js`)
- Replies → Comment records: accesses comments (evidence: `controllers/replies.js`)
- Likes and dislikes → Feeling records: manages reactions (evidence: `controllers/feelings.js`)
- Likes and dislikes → Video records: updates video reactions (evidence: `controllers/feelings.js`)
- Subscriptions → Subscription records: manages subscriptions (evidence: `controllers/subscriptions.js`)
- Subscriptions → Video records: queries videos (evidence: `controllers/subscriptions.js`)
- Watch history → History records: manages history (evidence: `controllers/histories.js`)
- Watch history → Video records: queries videos (evidence: `controllers/histories.js`)
- Video routes → Paged results: applies pagination (evidence: `routes/videos.js`)
- Paged results → MongoDB: queries model
- Authentication → MongoDB: persists user data
- Video management → MongoDB: persists video data
