Skip to content

NishalDev/twitch.tv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Twitch.tv Clone

A full-stack web application inspired by Twitch.tv, built with React.js and Node.js. This project features user authentication, real-time communication capabilities, and a modern responsive interface.

πŸš€ Features

  • User Authentication: Secure login and registration system
  • JWT Authentication: Token-based authentication with 8-hour expiration
  • Password Encryption: Secure password hashing with bcrypt
  • Input Validation: Client-side and server-side validation using Joi
  • Real-time Communication: Socket.io integration for live features
  • Responsive Design: Mobile-friendly interface
  • Toast Notifications: User feedback with react-hot-toast
  • Modern Routing: React Router DOM for seamless navigation

πŸ› οΈ Tech Stack

Frontend

  • React.js (v18.3.1) - UI Framework
  • React Router DOM (v6.26.0) - Navigation
  • Axios (v1.7.7) - HTTP Client
  • React Hot Toast (v2.4.1) - Notifications
  • CSS3 - Styling

Backend

  • Node.js - Runtime Environment
  • Express.js (v4.19.2) - Web Framework
  • MongoDB with Mongoose (v8.5.2) - Database
  • Socket.io (v4.7.5) - Real-time Communication
  • JWT (v9.0.2) - Authentication
  • bcrypt.js (v2.4.3) - Password Hashing
  • Joi (v17.13.3) - Input Validation
  • CORS (v2.8.5) - Cross-Origin Resource Sharing

πŸ“‹ Prerequisites

Before running this application, make sure you have the following installed:

  • Node.js (v14 or higher)
  • npm or yarn
  • MongoDB (local installation or MongoDB Atlas)

βš™οΈ Installation & Setup

1. Clone the repository

git clone https://github.com/NishalDev/twitch.tv.git
cd twitch.tv

2. Environment Configuration

Create a .env file in the server directory with the following variables:

# Server Configuration
PORT=5002
API_PORT=5002

# Database
MONGO_URI=mongodb://localhost:27017/twitchtv
# Or use MongoDB Atlas: mongodb+srv://<username>:<password>@cluster.mongodb.net/twitchtv

# JWT Configuration
TOKEN_KEY=your_super_secret_jwt_key_here

3. Install Dependencies

Backend Setup

cd twitch.tv/server
npm install

Frontend Setup

cd ../client
npm install

πŸš€ Running the Application

Development Mode

Start the Backend Server

cd server
npm start

The server will run on http://localhost:5002

Start the Frontend Application

cd client
npm start

The application will open at http://localhost:3000

Production Build

Build the Frontend

cd client
npm run build

πŸ“ Project Structure

twitch.tv/
β”œβ”€β”€ client/                 # React frontend application
β”‚   β”œβ”€β”€ public/            # Public assets
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ API/           # API configuration and calls
β”‚   β”‚   β”œβ”€β”€ AuthPage/      # Authentication components
β”‚   β”‚   β”œβ”€β”€ DashboardPage/ # Main dashboard
β”‚   β”‚   β”œβ”€β”€ shared/        # Shared utilities
β”‚   β”‚   β”‚   β”œβ”€β”€ hooks/     # Custom React hooks
β”‚   β”‚   β”‚   └── validators/ # Input validation functions
β”‚   β”‚   └── resources/     # Images and assets
β”‚   └── package.json
β”œβ”€β”€ server/                # Node.js backend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ controllers/   # Route controllers
β”‚   β”‚   β”‚   └── auth/      # Authentication controllers
β”‚   β”‚   β”œβ”€β”€ models/        # MongoDB models
β”‚   β”‚   └── routes/        # API routes
β”‚   β”œβ”€β”€ index.js          # Server entry point
β”‚   └── package.json
└── README.md

πŸ” API Endpoints

Authentication Routes

Register User

POST /api/auth/register
Content-Type: application/json

{
  "username": "string (3-12 characters)",
  "email": "valid-email@example.com",
  "password": "string (6-12 characters)"
}

Login User

POST /api/auth/login
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "userpassword"
}

Response:

{
  "userDetails": {
    "email": "user@example.com",
    "username": "username",
    "token": "jwt_token_here"
  }
}

πŸ—„οΈ Database Schema

User Model

{
  email: String (unique),
  username: String,
  password: String (hashed)
}

πŸ”’ Security Features

  • Password Hashing: All passwords are encrypted using bcrypt
  • JWT Tokens: Secure authentication with 8-hour expiration
  • Input Validation: Both client and server-side validation
  • CORS Protection: Configured for secure cross-origin requests
  • Email Validation: Regex-based email format validation

πŸ§ͺ Testing

# Run frontend tests
cd client
npm test

# Run backend tests (when implemented)
cd server
npm test

πŸš€ Deployment

Frontend Deployment

The React application can be deployed to platforms like:

  • Vercel
  • Netlify
  • GitHub Pages
  • AWS S3 + CloudFront

Backend Deployment

The Node.js server can be deployed to:

  • Heroku
  • Railway
  • AWS EC2
  • DigitalOcean
  • Vercel

Database Deployment

  • MongoDB Atlas (Recommended for production)
  • AWS DocumentDB
  • Self-hosted MongoDB

🀝 Contributing

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ Development Notes

Current Implementation Status

  • βœ… User Registration & Login
  • βœ… JWT Authentication
  • βœ… Input Validation
  • βœ… Basic Dashboard Structure
  • πŸ”„ Dashboard functionality (In Progress)
  • πŸ”„ Real-time features (Socket.io integrated but not implemented)
  • πŸ”„ Video streaming capabilities
  • πŸ”„ Chat system

Known Issues

  • Fix typo in postLogin.js: toLowercase() should be toLowerCase()
  • API base URL uses HTTPS but server runs on HTTP in development
  • Dashboard page needs implementation

πŸ“„ License

This project is licensed under the ISC License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

NishalDev

πŸ™ Acknowledgments

  • Inspired by Twitch.tv
  • Built with Create React App
  • Uses modern web development practices and technologies

πŸ“ž Support

If you have any questions or need help getting started, please open an issue in this repository.

About

A full-stack web application inspired by Twitch.tv, built with React.js and Node.js. This project features user authentication, real-time communication capabilities, and a modern responsive interface.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors