How divesh1207/videosfilter works
Project type and purpose
• This is a full-stack MERN web application called “Videos Filter.”
• Purpose: Let users log in with Google OAuth, fetch their YouTube “Liked Videos” via the YouTube Data API, store any needed metadata in MongoDB, then display and filter those videos through a React/Tailwind frontend.
File structure
• Top-level “client” folder: Vite + React (JSX), Tailwind, Framer Motion, OAuth callback component, public/static assets, and deployment config (vercel.json).
• Top-level “server” folder: Express app (server.js), controllers (authController, videoController), routes (authRoutes, videoRoutes), middlewares (authMiddleware), services (nlpService), configuration (db.js, keys.js), Mongoose models (User, Video).
• Presence of package.json in both indicates independent front-end/back-end projects.
• No Docker/Docker-Compose—likely two distinct deployments (Vercel for client, Heroku/AWS/GCP for server).
Extract architecture insights from the README
• Tech stack: React + Tailwind CSS + Framer Motion on front; Node.js + Express on back; MongoDB; Google OAuth 2.0; YouTube Data API; JWT for session management.
• Workflow: OAuth login → obtain access & refresh tokens → fetch liked videos → apply filters → display results.
• CORS settings, token refresh logic, MVC/Layered code structure.
Main components
a. Frontend (Client–React App)
b. Backend (Express REST API)
c. Database (MongoDB)
d. External Services:
– Google OAuth 2.0 Authorization Server
– YouTube Data API
e. (Optional) NLP Service layer inside backend for advanced filtering
Relationships and data flows
• User (Browser) ←→ React App (Login page, Navbar, OAuthCallback component)
• React invokes GET /api/auth/google → Redirect to Google OAuth.
• Google redirects back with auth code → React calls POST /api/auth/callback.
• Backend exchanges code for access/refresh tokens → issues JWTs.
• React stores JWT (e.g., in HttpOnly cookie or localStorage).
• React requests liked videos: GET /api/videos?filter=… → Express middleware validates JWT → videoController calls nlpService (optional) → videoController fetches from YouTube Data API if not cached, stores or updates Video documents in MongoDB → returns filtered list.
• MongoDB:
• User collection stores user info + refresh token.
• Video collection stores metadata about liked videos (title, desc, date, stats).
Architectural patterns & design principles
• Layered (MVC-style):
• Routes → Controllers → Services → Models
• Stateless REST API with JWT for auth
• Single-page application front end (client-side routing via React Router)
• External API integration (YouTube Data API)
• Separation of concerns: UI, API, data persistence, external auth