BuddyScript is a modern, scalable social media web application built with Laravel 12 and React 18. It features a real-time feel, threaded comments, and a high-performance feed capable of handling millions of posts.
- Infinite Scrolling Feed: Seamlessly scroll through thousands of posts using cursor-based pagination and Intersection Observer.
- Optimized Performance:
- Redis Counters: Likes and Membership checks are handled in Redis (O(1)) to prevent database strain.
- Counter Caches: Post likes and comment counts are stored directly on the table, eliminating N+1 query bottlenecks.
- Shallow Eager Loading: Efficient data retrieval that only fetches what is necessary for the current view.
- Threaded Comments: Support for parent comments and nested replies with independent pagination.
- Post Management: Create, edit, and delete posts with custom privacy settings (Public/Private).
- Authentication: Secure JWT-based API authentication.
- Robust Authorization: Fine-grained Policies (Post, Comment, User) ensuring users can only manage their own content.
- Backend: PHP 8.2+, Laravel 12
- Frontend: React 18, Vite, TypeScript, Vanilla CSS
- Database: MySQL (optimized with indices and counter caches)
- Cache/NoSQL: Redis (used for likes tracking and fast membership checks)
- Auth: JWT (JSON Web Token)
-
Clone the repository:
git clone <repository-url> cd buddy-project
-
Backend Setup:
composer install cp .env.example .env php artisan key:generate php artisan jwt:secret
-
Database & Redis:
- Configure your
.envwith your MySQL and Redis credentials. - Run migrations:
php artisan migrate
- Configure your
-
Frontend Setup:
npm install
-
Running the Application:
- In terminal 1 (Vite):
npm run dev
- In terminal 2 (Laravel):
php artisan serve
- In terminal 1 (Vite):
We have included a specialized DemoSeeder designed to test the system at scale (10,000+ posts).
To seed the database with demo users, posts, and comments:
php artisan db:seed --class=DemoSeederNote: This will preserve the user nayakemily50@gmail.com if it exists.
The project follows strict Laravel Authorization patterns:
- PostPolicy: Determines who can view (based on privacy), update, or delete a post.
- CommentPolicy: Ensures only authors or post owners can manage comments.
- UserPolicy: Restricts profile updates and account deletions to the account owner.
- N+1 Fixes: Reduced typical feed page from ~35 queries down to 2-3 queries.
- Redis Membership: Used for checking if a user liked a post, preventing millions of
SELECT EXISTSqueries on the DB. - Cursor Pagination: Uses
last_idinstead ofOFFSET, preventing performance degradation as the database grows to millions of rows.
This project is open-sourced software licensed under the MIT license.