Skip to content

Latest commit

Β 

History

62 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎬 Streamline (Social-Api) β€” Full-Stack Video & Community Platform

A full-stack, production-grade video sharing and community platform built with React, TypeScript, Node.js, Express, and MongoDB. Features end-to-end authentication, Cloudinary media processing, advanced aggregation pipelines, a creator studio, tweet/community notes, playlists, and a modern responsive user interface.


🌟 Key Features

πŸ’» Modern Frontend (React + TypeScript + Tailwind CSS)

  • Video Feed & Explore: Discovery feeds with search query filtering, sorting, and pagination.
  • Video Watch Experience: Video player, real-time view tracking, video likes, comment management, and playlist integration.
  • Channel Profiles: Detailed creator channels showcasing published videos, tweets, playlists, and subscriber counts.
  • Creator Studio:
    • Dashboard: Channel metrics (total subscribers, views, video count, likes).
    • Video Upload: Multi-file media upload (video & thumbnail) with drag-and-drop and progress tracking.
    • Video Management: Edit metadata, update thumbnails, toggle publish/unpublish status, and delete videos.
  • Community Tweets: Create, edit, delete, and bulk-delete tweets with character limit validation.
  • Personal Library:
    • Subscriptions: Network list of subscribed channels with direct unsubscribe actions.
    • Watch History: Chronological view of watched videos.
    • Liked Videos: Curated list of all liked content.
    • Playlists: Create custom playlists, add/remove videos, and edit playlist details.
  • User Settings & Profile: Update avatar, cover photo, account details, and password.
  • Responsive UI/UX: Collapsible desktop sidebar, top navigation with search, and mobile bottom navigation.

βš™οΈ Robust Backend (Node.js + Express + MongoDB)

  • Authentication & Security:
    • Register with avatar & cover image processing (Multer β†’ Cloudinary).
    • JWT authentication with access and refresh token rotation.
    • Secure httpOnly cookie support and password hashing via bcrypt.
  • Media Pipeline: Direct video and image upload, storage, and optimization with Cloudinary.
  • MongoDB Aggregation Pipelines: High-performance queries with $lookup, $group, and $project for analytics, channel stats, and paginated comments/videos.
  • RESTful Architecture: Modular MVC structure with centralized error handling (ApiError) and standard responses (ApiResponse).
  • Interactive Documentation: OpenAPI/Swagger UI integration.

πŸ› οΈ Tech Stack

Domain Technology Description
Frontend React 19 Core UI Library
TypeScript Type Safety
Vite Build Tool & Fast HMR
Tailwind CSS Utility-first Styling
React Router Client-side Routing
Axios HTTP Client with Interceptors
Lucide React Modern UI Icons
Backend Node.js Server Runtime
Express.js v5 Web Framework
MongoDB + Mongoose Database & ODM
JWT (jsonwebtoken) Token-based Auth
Multer Multipart Form/File Handling
Cloudinary Cloud Media Hosting & Optimization
Swagger UI API Documentation
Monorepo / Dev Concurrently Single-command Full-Stack Development

πŸ“ Project Structure

social-api/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ public/             # Static temporary storage
β”‚   └── src/
β”‚       β”œβ”€β”€ config/         # Environment variables & OpenAPI spec
β”‚       β”œβ”€β”€ controllers/    # API business logic
β”‚       β”œβ”€β”€ db/             # MongoDB connection setup
β”‚       β”œβ”€β”€ middlewares/    # Auth (JWT) & Multer upload middlewares
β”‚       β”œβ”€β”€ models/         # Mongoose models (User, Video, Tweet, etc.)
β”‚       β”œβ”€β”€ routes/         # Express API routers
β”‚       β”œβ”€β”€ utils/          # Cloudinary helpers, ApiError, ApiResponse
β”‚       β”œβ”€β”€ app.js          # Express app configuration & middleware
β”‚       └── index.js        # Server entry point
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/             # Public assets
β”‚   └── src/
β”‚       β”œβ”€β”€ api/            # Axios API service layer
β”‚       β”œβ”€β”€ components/     # Reusable UI & feature components
β”‚       β”‚   β”œβ”€β”€ channel/    # Channel headers, tabs, cards
β”‚       β”‚   β”œβ”€β”€ comments/   # Comment sections & inputs
β”‚       β”‚   β”œβ”€β”€ layout/     # AppShell, Navbar, Sidebar
β”‚       β”‚   β”œβ”€β”€ playlist/   # Playlist modals & lists
β”‚       β”‚   β”œβ”€β”€ studio/     # Creator Studio cards & tools
β”‚       β”‚   β”œβ”€β”€ tweet/      # Tweet composer & lists
β”‚       β”‚   β”œβ”€β”€ ui/         # Base UI elements (Button, Modal, etc.)
β”‚       β”‚   └── video/      # Video player, grids, cards
β”‚       β”œβ”€β”€ context/        # Auth context & state management
β”‚       β”œβ”€β”€ pages/          # Application views / routes
β”‚       β”œβ”€β”€ router/         # React Router configuration & Protected Routes
β”‚       β”œβ”€β”€ types/          # TypeScript interface definitions
β”‚       └── utils/          # Storage & error formatting helpers
β”‚
β”œβ”€β”€ package.json            # Root configuration for concurrent execution
└── README.md

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher recommended)
  • MongoDB (Local instance or MongoDB Atlas connection string)
  • Cloudinary account for media storage

1. Clone the Repository

git clone https://github.com/abmdevx/social-api.git
cd social-api

2. Configure Environment Variables

Backend (backend/.env)

Create a .env file in the backend/ directory:

PORT=8000
MONGO_URI=your_mongodb_connection_string
CORS_ORIGIN=http://localhost:5173

ACCESS_TOKEN_SECRET=your_access_token_secret
ACCESS_TOKEN_EXPIRY=1d

REFRESH_TOKEN_SECRET=your_refresh_token_secret
REFRESH_TOKEN_EXPIRY=10d

CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret

Frontend (frontend/.env)

Create a .env file in the frontend/ directory:

VITE_API_URL=http://localhost:8000/api/v1

3. Install Dependencies

You can install all dependencies from the root directory:

# Install root dependencies (concurrently)
npm install

# Install backend dependencies
npm install --prefix backend

# Install frontend dependencies
npm install --prefix frontend

4. Run the Application

Run both frontend and backend concurrently with a single command from the root directory:

npm run dev
  • Frontend Client: http://localhost:5173
  • Backend API: http://localhost:8000/api/v1
  • Swagger Documentation: http://localhost:8000/api-docs

πŸ“¬ API Endpoints Overview

Base URL: http://localhost:8000/api/v1

πŸ‘€ Users & Auth

Method Endpoint Auth Description
POST /users/register ❌ Register user with avatar & cover image
POST /users/login ❌ Authenticate user & issue tokens
POST /users/refresh-token ❌ Refresh access token using refresh token
POST /users/logout βœ… Log out current user & clear tokens
POST /users/change-password βœ… Change current account password
GET /users/get-current-user βœ… Fetch authenticated user data
PATCH /users/update-account βœ… Update user profile information
PATCH /users/change-avatar βœ… Update profile avatar
PATCH /users/change-cover-image βœ… Update channel cover image
GET /users/c/:username βœ… Get full channel profile
GET /users/history βœ… Get user watch history

πŸŽ₯ Videos

Method Endpoint Auth Description
POST /videos/upload-video βœ… Upload video file and thumbnail
GET /videos/get-all-videos βœ… Get paginated video feed with filters
GET /videos/v/:videoId βœ… Fetch single video details & track views
PATCH /videos/v/:videoId βœ… Update video title & description
PATCH /videos/v/:videoId/thumbnail βœ… Update video thumbnail
PATCH /videos/v/:videoId/publish βœ… Toggle video publish status
DELETE /videos/delete-videos βœ… Delete selected videos

🐦 Tweets (Community Notes)

Method Endpoint Auth Description
POST /tweets/create-tweet βœ… Post a new tweet
GET /tweets/get-tweets βœ… Fetch tweets for feed
PATCH /tweets/t/:tweetId βœ… Edit tweet content
DELETE /tweets/t/:tweetId βœ… Delete a tweet
DELETE /tweets/delete-bulk-tweets βœ… Bulk delete selected tweets

πŸ—¨οΈ Comments

Method Endpoint Auth Description
GET /comments/c/:videoId βœ… Get paginated comments for a video
POST /comments/c/:videoId/add-comment βœ… Post a comment on a video
PATCH /comments/c/:commentId/v/:videoId/update-comment βœ… Edit an existing comment
DELETE /comments/c/:commentId/v/:videoId/delete-comment βœ… Delete a comment

❀️ Likes

Method Endpoint Auth Description
POST /likes/l/:videoId βœ… Toggle like on a video
POST /likes/c/:commentId βœ… Toggle like on a comment
POST /likes/t/:tweetId βœ… Toggle like on a tweet
GET /likes/get-liked-videos βœ… Get all videos liked by current user

πŸ“‚ Playlists

Method Endpoint Auth Description
POST /playlists/create-playlist βœ… Create a new playlist
GET /playlists/p/:playlistId βœ… Get playlist by ID with videos
PATCH /playlists/p/:playlistId βœ… Update playlist name & description
DELETE /playlists/p/:playlistId βœ… Delete a playlist
GET /playlists/users/:userId/playlists βœ… Get all playlists belonging to a user
PUT /playlists/p/:playlistId/v/:videoId βœ… Add video to a playlist
DELETE /playlists/p/:playlistId/v/:videoId βœ… Remove video from a playlist

πŸ”” Subscriptions

Method Endpoint Auth Description
POST /subscriptions/c/:channelId βœ… Toggle subscribe/unsubscribe to channel
GET /subscriptions/c/:channelId βœ… Get all subscribers of a channel
GET /subscriptions/u/:subscriberId βœ… Get all channels a user has subscribed to

πŸ“Š Dashboard & Studio

Method Endpoint Auth Description
GET /dashboard/stats βœ… Get creator metrics (subs, views, videos, likes)
GET /dashboard/videos βœ… Get creator studio videos

βœ… = Requires Bearer Token Β Β |Β Β  ❌ = Public Route

About

A backend-focused project for building a social platform where users can share short posts and upload videos, inspired by Twitter and YouTube.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages