Skip to content

Twitch Clone build with Nest.js and Next.js ๐Ÿ‘พ๐ŸŸฃ๐ŸŽฅ๐Ÿ”ด๐Ÿ”ฅ

License

Notifications You must be signed in to change notification settings

BernieTv/Twitch-Clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

48 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Twitch Clone

A feature-rich Twitch clone built with modern web technologies! ๐ŸŽฎโœจ This project replicates core functionalities of Twitch, incorporating live streaming, real-time chat, authentication, and much more. ๐ŸŒŸ

๐Ÿ› ๏ธ Tech Stack

Here are the technologies that power this Twitch clone:

  • Backend:

    • ๐ŸŸข Nest.js - A progressive Node.js framework.
    • โš™๏ธ GraphQL - API query language for flexibility.
    • ๐Ÿ’พ Prisma - Modern ORM for database access.
  • Frontend:

    • โšก Next.js 15 - The React framework for production.
    • ๐Ÿ”„ Apollo Client - State management for GraphQL.
    • ๐ŸŒ Next Intl - Internationalization support.
  • Authentication:

    • ๐Ÿ” OTP Authentication for secure login.
  • Real-Time Streaming:

    • ๐Ÿ“น LiveKit - Scalable WebRTC for real-time communications.
  • Payments:

    • ๐Ÿ’ณ Stripe - Secure and seamless payment integration.
  • Validation:

    • โœ… Zod - Schema declaration and validation.
  • Caching:

  • ๐ŸŽ๏ธ Redis - Lightning-fast in-memory data store.

  • UI Components:

    • ๐ŸŽจ Shadcn UI - Accessible and reusable components.
  • State Management:

    • ๐Ÿ“Š Zustand - Simplified state management for React.
  • Bundler:

    • โšก Bun - Ultra-fast JavaScript runtime and bundler.
  • Messaging Integration:


๐ŸŒŸ Features

  • ๐Ÿ”ด Live Streaming and Real-Time Chat
  • ๐ŸŒ Multi-Language Support with Translations
  • ๐Ÿ”’ Secure OTP Authentication
  • ๐Ÿ’ธ Stripe-Powered Payment Integration
  • ๐ŸŽ›๏ธ User-Friendly Dashboard and Controls
  • ๐Ÿ“š Modular and Scalable Codebase
  • โšก Ultra-Fast Bundling with Bun
  • ๐Ÿ“ฉ Telegram Notifications for Updates and Alerts
  • ๐ŸŽ๏ธ Enhanced Performance with Redis Caching

๐Ÿ›‘ Prerequisites

Before you get started, ensure you have the following installed:

  • Node.js (v18 or higher) ๐ŸŸข
  • Bun (optional, for faster builds) โšก
  • Docker (for database and LiveKit setup) ๐Ÿณ
  • A Stripe account ๐Ÿ’ณ
  • A Telegram Bot API key ๐Ÿ“ฉ
  • LiveKit API keys โšก

๐Ÿš€ Getting Started

Follow these steps to set up the project locally:

1๏ธโƒฃ Clone the Repository

$ git clone https://github.com/BernieTv/twitch-clone.git
$ cd twitch-clone

2๏ธโƒฃ Install Dependencies

# cd to backend server
cd backend && yarn

# cd to frontend folder
$ cd frontend && bun install

3๏ธโƒฃ Set Up Environment Variables

Create a .env file in frontend and backend folders and add the following:

# for backend

NODE_ENV='development'

APPLICATION_PORT=4000
APPLICATION_URL='http://localhost:${APPLICATION_PORT}'
GRAPHQL_PREFIX='/graphql'
ALLOWED_ORIGIN='http://localhost:3000'

COOKIES_SECRET='secret'
SESSION_SECRET='secret'
SESSION_NAME='session'
SESSION_DOMAIN='localhost'
SESSION_MAX_AGE='30d'
SESSION_HTTP_ONLY=true
SESSION_SECURE=false
SESSION_FOLDER='sessions:'

POSTGRES_USER='root'
POSTGRES_PASSWORD='123456'
POSTGRES_HOST='localhost'
POSTGRES_PORT='5433'
POSTGRES_DATABASE='*'
POSTGRES_URI='postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}'

REDIS_USER='default'
REDIS_PASSWORD='123456'
REDIS_HOST='localhost'
REDIS_PORT='6379'
REDIS_URI='redis://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}'

MAIL_HOST='*'
MAIL_PORT=*
MAIL_LOGIN='*t'
MAIL_PASSWORD='*'

S3_ENDPOINT='*'
S3_REGION='*'
S3_ACCESS_KEY_ID='*'
S3_SECRET_ACCESS_KEY='*'
S3_BUCKET_NAME='*'

LIVEKIT_API_URL='*'
LIVEKIT_API_KEY='*'
LIVEKIT_API_SECRET='*'

TELEGRAM_BOT_TOKEN='*'

STRIPE_SECRET_KEY='*'
STRIPE_WEBHOOK_SECRET=''

# for frontend

NEXT_PUBLIC_APP_URL='http://localhost:3000'

NEXT_PUBLIC_SERVER_URL='http://localhost:4000/graphql'
NEXT_PUBLIC_WEBSOCKET_URL='ws://localhost:4000/graphql'
NEXT_PUBLIC_MEDIA_URL='*'

NEXT_PUBLIC_LIVEKIT_WS_URL=''

4๏ธโƒฃ Start the Services

Start the databases using Docker:

$ docker-compose up -d

5๏ธโƒฃ Run the Development Server

# for backend
$ yarn run start:dev

# for frontend
$ bun run dev

๐Ÿ“š Documentation


๐Ÿ“„ License

This project is licensed under the MIT License. ๐Ÿ“


โœจ Demo

Check out the live demo here: Twitch Clone Demo ๐ŸŽฅ