NewsRoom is a scalable RESTful API built with Laravel using advanced backend architecture concepts and clean code principles.
The project simulates a real-world newsroom/content management platform where users can create, manage, publish, and organize articles with a fully event-driven backend architecture.
The system demonstrates:
- Clean Architecture
- SOLID Principles
- Service Layer Pattern
- Event-Driven Design
- Queue Processing
- Notifications System
- API Versioning
- Authentication & Authorization
- Rate Limiting
- Validation & Security Best Practices
- Laravel 12
- PHP 8+
- MySQL
- Laravel Sanctum
- Queue System
- Notifications
- REST API
Implemented using Laravel Sanctum.
Features:
- Register
- Login
- Logout
- Protected API routes
- Token authentication
Full CRUD system for users.
Features:
- Create user
- Update user
- Delete user
- List users
- Role management
- Policy authorization د
Advanced article system with:
- Create article
- Update article
- Delete article
- Publish article
- Slug generation
- Pagination
- Tag support
- Reading time calculation
- Comments count
Complete CRUD implementation for article tags.
Features:
- Create tag
- Update tag
- Delete tag
- Slug support
- Validation rules
The API supports multiple versions.
Basic article structure.
Enhanced article response with:
- Reading time
- Comments count
- Optimized writer response
- Simplified tags structure
The project follows layered architecture:
Handle HTTP requests and responses.
Contain business logic.
Decouple implementations using dependency injection.
Handle validation and authorization.
Manage access control.
Transform API responses.
Single responsibility application actions.
Handle asynchronous system reactions.
Watch model lifecycle changes.
Send email/database notifications.
Execute background processing.
The application uses Laravel Events, Listeners, and Observers.
Examples:
Flow:
- Article status changes to published
- Observer detects update
- Event dispatched
- Listener triggered
- Notification queued
- User notified asynchronously
Implemented using Laravel Queues.
Features:
- Queueable notifications
- Background jobs
- Failed jobs handling
- Multiple queues
Queues:
- emails
- notifications
Example Job:
- SendWeeklyArticlesReportJob
Context-aware notification system.
Supported channels:
- Email notifications
- Database notifications
Implemented using:
- Notification classes
- Contextual binding
- Queueable notifications
Implemented security best practices:
- Form Request validation
- Policy authorization
- Forbidden content filtering
- Input sanitization
- API rate limiting
- Protected routes
Custom validation:
- CleanContentRule
API requests are protected using Laravel Rate Limiter.
Example:
- 60 requests/minute per user or IP
- Service Layer Pattern
- Strategy Pattern
- Observer Pattern
- Action Pattern
- Dependency Injection
- Event-Driven Architecture
- Contextual Binding
git clone <[repository-url](https://github.com/Ebla-a/NewsRoom)>composer installcp .env.example .envUpdate .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=newsroom
DB_USERNAME=root
DB_PASSWORD=php artisan key:generatephp artisan migrate --seedphp artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
php artisan migratephp artisan queue:table
php artisan queue:failed-table
php artisan migrateInside .env
QUEUE_CONNECTION=rdeisphp artisan queue:work --queue=emails,notifications,low| Method | Endpoint |
|---|---|
| POST | /api/register |
| POST | /api/login |
| POST | /api/logout |
| Method | Endpoint |
|---|---|
| GET | /api/v1/articles |
| POST | /api/v1/articles |
| GET | /api/v1/articles/{id} |
| PUT | /api/v1/articles/{id} |
| DELETE | /api/v1/articles/{id} |
| POST | /api/v1/articles/{id}/publish |
Developed using Laravel and modern backend engineering practices.