# Architecture

```text
Browser (Vue / CSRF / independent area cookies)
    -> Laravel web controllers -> PostgreSQL

Scheduler (30-second due scan)
    -> monitor_runs lease (unique monitor_id)
    -> Redis monitoring queue
    -> CheckMonitor worker
    -> TargetPolicy / HTTP cURL / TCP socket / ICMP process
    -> RecordCheck transaction
       -> check_results (every attempt; run_id + attempt unique)
       -> delayed retry or final monitor state
       -> incidents + incident_events
    -> metrics queries

Administrator ZIP upload
    -> signature + SHA-256 + path/size validation
    -> Redis updates queue
    -> staged release verification
    -> maintenance flag + exclusive deployment lock
    -> database dump + recovery journal
    -> migration + verification
    -> atomic current symlink
    -> worker/scheduler restart
```

Browser requests and monitoring work hold shared filesystem deployment locks. Deployment holds the exclusive lock. The maintenance flag closes new work before waiting for existing work. The lock is released even on exceptions. A process crash after database changes leaves the flag/journal for operator recovery.

Monitor run records coordinate dispatch and recording. Duplicate deliveries may issue the same safe network probe concurrently, but the result transaction locks the run and only accepts its current attempt. Deleting/pausing/editing a monitor invalidates outstanding runs. Expired runs are replaced after 15 minutes; results from old run IDs are ignored.

Monitoring network failures are data, not queue exceptions: they record a result and use the monitor's retry policy. Infrastructure/database exceptions use Laravel queue retries and ultimately failed_jobs. An incident starts at the first failed attempt and is detected after retry confirmation. A single fast successful run after a failure can remain down until its recovery threshold is met.

Application timestamps and PostgreSQL sessions use UTC. The browser displays local time. Metrics clip to monitor creation and first observation. A result contributes until the next observation, end of the range, or the gap cap (2 intervals + retry/timeout budget). Beyond that is unknown. Paused periods naturally expire into unknown; explicit per-pause SLA accounting is deferred.

The model streams history for metrics rather than loading every Eloquent result at once. Exact P95 still retains successful latency integers and queries raw data, so year-long/high-volume workloads need future rollups and sizing work.

Sensitive database credentials are encrypted in storage/app/installed.json with Laravel APP_KEY. The shared environment carries the trusted update public key, initial connection defaults and Redis settings. Signing private keys never belong on the web server. Logs, backups, packages and session files remain outside public/.

The supplied deployment uses file sessions/cache on a shared volume and Redis queues. Do not substitute a database session/cache driver before installation. Octane, multiple deployment hosts, remote filesystems with unreliable flock, queue failover and multi-region quorum are not supported in v1.
