Proje: OkulUp API · Hub: OkulUp API — Architecture

OkulUp API — Observer ve Event Sistemi

Observers (AppServiceProvider’da kayıtlı)

ObserverModelNe Yapar
AnnouncementObserverAnnouncementCache temizle
MessageObserverMessageSendMessageNotificationJob + NewMessageEvent broadcast
EventObserverEventCache temizle
AttendanceObserverAttendanceattendances:school:{id}:page:{n} cache temizle
PaymentObserverPaymentCache temizle + veli Notification oluştur + Push gönder

PaymentObserver Özel

payment.created → öğrencinin ebeveynlerine hem DB notification hem push notification gönderir.
Bu pattern hem Notification::create() hem PushNotificationService::sendToUsers() kullanır — NotificationService::create() yerine.

Laravel Policies

app/Policies/ altında 13 policy var. Eloquent Policy sistemi kullanılır.

PolicyÖnemli Not
AssignmentPolicymanage() metodu — teacher sadece kendi ödevini manage edebilir
UserPolicyview() — öğretmen kendi sınıfındaki öğrenciyi görebilir
DiğerleriBenzer role-based pattern

AssignmentController::publish()$this->authorize('manage', $assignment) kullanır.

Broadcast Events (Laravel Reverb)

EventNe ZamanChannel
NewMessageEventMesaj oluşturuluncaConversation channel
MessageReadEventMesaj okunduğunda-
TypingEventTyping endpoint çağrıldığında-
NewNotificationEventBildirim oluştuğunda-
UserOnlineEventKullanıcı aktif-

Rate Limiters (AppServiceProvider)

AliasLimit
login5/dk per IP
register3/dk per IP
api60/dk per user/IP
upload10/dk per user/IP
message30/dk per user/IP
forgot-password3/dk per IP
school-search20/dk per user/IP

Slow Query Logging

Local + staging ortamda 100ms’den uzun sorgular Log::warning ile loglanır.

Model::shouldBeStrict()

AppServiceProvider::register()Model::shouldBeStrict() aktif.
Lazy loading, fillable violations, accessing non-existent attributes → exception fırlatır.