# gopavasanth/video-cut-tool-back-end architecture

> Architecture diagram of the GitHub repository gopavasanth/video-cut-tool-back-end, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gopavasanth/video-cut-tool-back-end
- Repository: https://github.com/gopavasanth/video-cut-tool-back-end

## Overview

##### Project type and purpose
- This is a full-stack, monolithic Node.js/Express application called “VideoCutTool.”
- It provides a web UI for cutting video clips and uploading them to Wikimedia Commons via MediaWiki OAuth.
- Key use cases: user authentication (OAuth), video selection/cutting, server-side processing and MongoDB storage of metadata, and uploading to an external service.

##### File structure
- Top level:
- app.js       – main Express application setup
- bin/www      – HTTP server launcher
- config.js    – configuration (OAuth keys, ports)
- monitor.sh   – health-check and restart script
- eventEmitter.js, websockets.js – cross-module event handling / real-time notifications
- Directories:
- routes/      – Express route handlers (index.js, controller.js, utils.js)
- models/      – Mongoose schemas and upload helper (User.js, Video.js, wikiUploadUtils.js)
- public/      – static assets (JS, CSS, client-side code)
- views/       – server-rendered templates (EJS and Jade)
- test-*       – unit/integration tests for core logic and MongoDB interactions
- Configuration & deployment:
- .gitignore, .gitreview, COPYING – standard repo metadata
- monitor.sh and bin/monitor.sh – production process monitoring

##### README for additional insights
- Relies on MediaWiki OAuth; callback URL configured in config.js
- npm install / npm start for local dev; monitor.sh for production uptime
- Mentors and credits indicate it’s a GSoC project, no microservices—single code base

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        Browser["Client Browser"]:::frontend
        Public["Static Assets (public/)"]:::frontend
        Templates["Templates (views/)"]:::frontend
    end

    subgraph "Application Layer"
        App["Express App (app.js)"]:::backend
        Server["HTTP Server (bin/www)"]:::backend
        Config["Configuration (config.js)"]:::backend
        subgraph "Routing"
            Index["routes/index.js"]:::backend
            Controller["routes/controller.js"]:::backend
            Utils["routes/utils.js"]:::backend
        end
        EB["Event Bus (eventEmitter.js)"]:::backend
        WS["WebSocket Handler (websockets.js)"]:::backend
    end

    subgraph "Data Layer"
        UserModel["models/User.js"]:::database
        VideoModel["models/Video.js"]:::database
        WikiUtil["models/wikiUploadUtils.js"]:::database
        Mongo["MongoDB"]:::database
    end

    subgraph "External Services"
        MW["MediaWiki Commons API"]:::external
    end

    subgraph "Monitoring"
        MonLocal["monitor.sh"]:::ops
        MonProd["bin/monitor.sh"]:::ops
    end

    Browser -->|HTTP GET/POST| Server
    Browser --> Public
    Browser --> Templates

    Server --> App
    App --> Config
    App --> Public
    App --> Templates

    App --> Index
    Index --> Controller
    Controller --> Utils

    Controller -->|read/write| Mongo
    Controller --> WikiUtil
    WikiUtil -->|OAuth & upload| MW

    Controller --> EB
    EB --> WS
    WS -->|WebSocket| Browser

    MonLocal -->|health-check| Server
    MonProd -->|health-check| Server

    click Public "https://github.com/gopavasanth/video-cut-tool-back-end/tree/master/public/"
    click Templates "https://github.com/gopavasanth/video-cut-tool-back-end/tree/master/views/"
    click App "https://github.com/gopavasanth/video-cut-tool-back-end/blob/master/app.js"
    click Server "https://github.com/gopavasanth/video-cut-tool-back-end/tree/master/bin/www"
    click Config "https://github.com/gopavasanth/video-cut-tool-back-end/blob/master/config.js"
    click Index "https://github.com/gopavasanth/video-cut-tool-back-end/blob/master/routes/index.js"
    click Controller "https://github.com/gopavasanth/video-cut-tool-back-end/blob/master/routes/controller.js"
    click Utils "https://github.com/gopavasanth/video-cut-tool-back-end/blob/master/routes/utils.js"
    click EB "https://github.com/gopavasanth/video-cut-tool-back-end/blob/master/eventEmitter.js"
    click WS "https://github.com/gopavasanth/video-cut-tool-back-end/blob/master/websockets.js"
    click UserModel "https://github.com/gopavasanth/video-cut-tool-back-end/blob/master/models/User.js"
    click VideoModel "https://github.com/gopavasanth/video-cut-tool-back-end/blob/master/models/Video.js"
    click WikiUtil "https://github.com/gopavasanth/video-cut-tool-back-end/blob/master/models/wikiUploadUtils.js"
    click MonLocal "https://github.com/gopavasanth/video-cut-tool-back-end/blob/master/monitor.sh"
    click MonProd "https://github.com/gopavasanth/video-cut-tool-back-end/blob/master/bin/monitor.sh"

    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#87CEFA,stroke:#000,stroke-width:1px
    classDef database fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#98FB98,stroke:#000,stroke-width:1px
    classDef ops fill:#FFD700,stroke:#000,stroke-width:1px
```
