Skip to content

Ma7moud1599/Twitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twitter Clone — Laravel

A real-time Twitter-like social platform built with Laravel. Supports tweets, likes, retweets, replies, quote tweets, media uploads, followers, notifications, and a live timeline — all streamed over WebSockets.

Features

  • Tweet Lifecycle — create, like, unlike, retweet, undo-retweet, reply, quote
  • Real-time Updates — WebSocket broadcasting via beyondcode/laravel-websockets + Pusher protocol; counters update live without page reload
  • Media Uploads — attach images/video to tweets using spatie/laravel-medialibrary
  • Followers & Timeline — follow users and get a personalized, paginated timeline
  • Notifications — in-app notifications for likes, retweets, replies, and new followers
  • Event-driven Architecture — all tweet mutations fire domain events consumed by listeners that update counts and fan out to connected clients
  • Laravel Telescope — built-in dev debugger for inspecting jobs, events, queries, and WebSocket messages

Tech Stack

Layer Technology
Framework Laravel
Auth Laravel Sanctum
WebSockets beyondcode/laravel-websockets + Pusher server
Media spatie/laravel-medialibrary
Debugging Laravel Telescope
HTTP Client Guzzle
Database MySQL

Domain Events

Event Triggered When
TweetWasCreated New tweet posted
TweetWasDeleted Tweet removed
TweetLikesWereUpdated Like or unlike
TweetRetweetsWereUpdated Retweet or undo
TweetRepliesWereUpdated Reply added

Events are listened to by jobs that update counters and broadcast channel notifications to connected clients.

Data Models

Model Description
User Account with followers/following
Tweet Core tweet with type (original/reply/quote/retweet)
TweetType Enum: original, reply, quote, retweet
Like User ↔ Tweet pivot
Follower User ↔ User follow relationship
TweetMedia Attached media files
Entity Extracted entities (mentions, hashtags, URLs)

API Endpoints

All routes require authentication (auth middleware).

Method Endpoint Description
GET /api/timeline Paginated home timeline
POST /api/tweets Post a tweet
POST /api/tweets/{tweet}/replies Reply to a tweet
POST /api/tweets/{tweet}/likes Like a tweet
DELETE /api/tweets/{tweet}/likes Unlike a tweet
POST /api/tweets/{tweet}/retweets Retweet
DELETE /api/tweets/{tweet}/retweets Undo retweet
POST /api/tweets/{tweet}/quotes Quote tweet
POST /api/media Upload media
GET /api/media/types Supported media types
GET /api/notifications User notifications

Installation

git clone https://github.com/Ma7moud1599/Twitter.git
cd Twitter

composer install
cp .env.example .env
php artisan key:generate

# Configure DB and Pusher/WebSocket credentials in .env
php artisan migrate

# Start WebSocket server
php artisan websockets:serve

php artisan serve

WebSocket Configuration (.env)

BROADCAST_DRIVER=pusher
PUSHER_APP_ID=your-app-id
PUSHER_APP_KEY=your-app-key
PUSHER_APP_SECRET=your-app-secret
PUSHER_HOST=127.0.0.1
PUSHER_PORT=6001

License

MIT

About

Real-time Twitter clone — tweets, likes, retweets, WebSockets, media uploads

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors