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.
- 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
| 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 |
| 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.
| 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) |
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 |
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 serveBROADCAST_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=6001MIT