How equador8078/dangle-video-watching-platform works
Project Type and Purpose
• This is a full-stack web application (“Dangle”) inspired by YouTube, built on the MERN stack.
• Purpose: allow authenticated users to upload, watch, comment on, and manage videos, backed by AI-powered search and recommendation.
File Structure
• Top-level split into two folders:
• yt-backend: Express.js server, controllers, services, models, middleware, routes, and public static handlers.
• yt-frontend: React/Vite client with components, contexts, assets, routing, styling (Tailwind).
• Additional root files: .env sample, package.json scripts to orchestrate both halves.
• Patterns:
• Backend uses MVC‐like structure (models, controllers, routes).
• Frontend uses component-driven UI + Context API for state (AuthContext, PanelContext, SubscriptionContext).
README for Insights
• Tech stack enumerated (React, Express, MongoDB, Cloudinary, TensorFlow.js).
• Features highlight authentication (JWT), video storage (Cloudinary + Multer), comments, playlists, history, AI chat search, and recommendation.
• Points to live demo and environment variables.
Main Components
a. Frontend (React SPA)
• Entry: main.jsx → App.jsx → React Router
• Key UI modules: VideoSection, VideoCard, Chat/Search widget, Playlist manager, Upload form.
• Context layers: AuthContext, SubscriptionContext, PanelContext.
b. Backend (Express REST API)
• Controllers: user, video, comments, playlist, chat/embedding.
• Services: authentication, Cloudinary integration.
• Middleware: JWT authentication.
• Models: MongoDB schemas via Mongoose.
c. Data Layer
• MongoDB cluster (stores users, videos metadata, comments, playlists, watch history).
• Cloudinary (actual video/image storage).
d. AI & External Services
• TensorFlow.js + Universal Sentence Encoder (runs in browser or server to compute embeddings).
• Cosine similarity module for recommendations.
e. Client-Server Interaction
• Axios calls from frontend to backend API endpoints.
• Static asset upload via Multer → Cloudinary SDK.
Relationships and Data Flow
• User → React UI
• Clicks “Upload” → POST /api/video → Multer middleware → Cloudinary → MongoDB save.
• Auth workflow → /api/auth/login or signup → JWT cookie issued.
• React UI → Express API
• GET /api/video/:id → video metadata + secure Cloudinary URL.
• POST /api/comments → create comment in MongoDB.
• GET /api/chat/search → embedding endpoint returns search results.
• Backend → MongoDB & Cloudinary
• Mongoose drives CRUD.
• Cloudinary SDK handles file transfers.
• Recommendation engine
• On video view, compute or retrieve precomputed embeddings → cosine similarity → suggested video list.
Architectural Patterns and Principles
• Separation of concerns:
• Frontend UI vs. Backend API vs. Data store vs. Media store.
• Layered architecture: Controllers → Services → Models in backend.
• Stateless JWT authentication.
• Component-based UI with Context for state.
• API-first design exposing RESTful endpoints.