Skip to main content

๐Ÿ“– 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