إنتقل إلى المحتوى الرئيسي

📖 Technical Overview

This section is for developers who want to understand Monitron SaaS's internals, extend it, or contribute.


🏗️ Tech Stack

ComponentTechnology
FrameworkLaravel 12
Admin PanelFilament 3 (TALL Stack)
PHP Version8.2+
FrontendLivewire 3 + Alpine.js + Tailwind CSS
DatabaseMySQL 8+, PostgreSQL 13+, or SQLite
QueueLaravel Queue (database, Redis, or SQS)
SchedulerLaravel Console Scheduler

📁 Directory Structure

app/
├── Console/Commands/ # Artisan commands (AI reports, predictions)
├── DTOs/ # Data Transfer Objects
│ └── MonitorCheckResult.php # Check result DTO
├── Enums/ # PHP 8.1 enums
│ ├── CheckInterval.php # 10s to 1h intervals
│ ├── IncidentSeverity.php # Info, Warning, Critical, Emergency
│ ├── IncidentStatus.php # Investigating → Resolved
│ ├── MonitorStatus.php # Up, Down, Degraded, Paused, Pending, Maintenance
│ ├── MonitorType.php # 24 monitor types
│ └── NotificationChannel.php # 19 channels
├── Filament/ # Filament admin panel
│ ├── Pages/ # Settings, AI Settings, AI Assistant
│ ├── Resources/ # Monitor, Incident, Contact, StatusPage, NotificationLog
│ └── Widgets/ # Dashboard widgets
├── Http/
│ ├── Controllers/
│ │ ├── Api/V1/ # Heartbeat + Agent API controllers
│ │ ├── Install/ # Installation wizard
│ │ └── StatusPage/ # Public status pages
│ └── Middleware/ # Installation guard middleware
├── Jobs/ # Queue jobs
│ ├── ProcessMonitorCheck.php # Core check processor
│ └── SendAlertNotifications.php # Notification dispatcher
├── Models/ # 20 Eloquent models
├── Monitors/ # Monitor handler implementations
│ ├── Contracts/MonitorHandler.php # Handler interface
│ ├── HttpMonitor.php
│ ├── PingMonitor.php
│ ├── TcpMonitor.php
│ └── ... (8 handlers)
├── Providers/ # Service providers
│ └── MonitorServiceProvider.php # Registers all services
└── Services/ # Business logic
├── AI/ # 11 AI services
├── MonitorRegistry.php # Handler registry
└── NotificationDispatcher.php # 19 channel implementations

🔧 Key Design Patterns

1. Handler Pattern (Monitors)

Each monitor type has a handler implementing MonitorHandler:

interface MonitorHandler {
public function check(Monitor $monitor): MonitorCheckResult;
public function type(): MonitorType;
}

The MonitorRegistry maps type strings to handler classes.

2. Service Pattern (Notifications)

NotificationDispatcher contains methods for each of the 19 channels, dispatched via the SendAlertNotifications job.

3. Provider-Agnostic AI

AiService abstracts four AI providers behind a single chat() / json() interface. Feature services (RootCauseAnalyzer, etc.) use AiService without knowing which provider is configured.

4. Multi-Tenancy via team_id

All resource models are scoped by team_id. Filament resources filter by the current user's team.


🔄 Check Processing Flow

Scheduler (every 10s)


For each active monitor → shouldCheck()?

Yes → ProcessMonitorCheck::dispatch()

▼ (Queue Worker)
MonitorRegistry::resolve(type)


Handler::check(monitor) → MonitorCheckResult


Store check, update monitor status


Status transition? (UP→DOWN or DOWN→UP)


Create/resolve Incident → SendAlertNotifications::dispatch()


NotificationDispatcher → each channel