How exposedev/expose works
Main Components
• Client (Laravel Zero CLI)
– CLI entry point (bin/expose)
– Client.Command layer (app/Commands/*)
– app/Client (control connection orchestration)
– HTTP client (app/Http/HttpClient) for API calls
– ProxyManager (app/ProxyManager) managing open tunnels
– Logger hooks & plugins (app/Logger/… and app/Logger/Plugins)
• Server Application (Laravel‐style)
– HTTP Server (app/Http/App.php & Controllers)
– WebSocket endpoint (app/WebSockets/Socket.php) for tunneling
– Routing, middleware, resources (app/Http/Controllers, app/Http/Modifiers)
– Request/Response logging subsystem (app/Logger, app/RequestLog, app/ResponseLog)
– Plugin framework (app/Logger/Plugins for billing, GitHub, Stripe, etc.)
– Service Providers & configuration (app/Providers/AppServiceProvider)
• Persistence & Infrastructure
– Relational Database (MySQL/PostgreSQL) for logs, tokens, config
– Docker (Dockerfile, docker-compose.yml) for containerized hosting
– .env / config/expose.php for environment configuration
• Web Dashboard (Vue SPA)
– Static assets served from public/build/internal-dashboard
– API calls against the Server’s HTTP endpoints to list tunnels, logs, settings
• External Services
– Billing gateways (Stripe, Paddle) via plugin interfaces
– GitHub (for plugin usage data)
Relationships & Data Flows
• CLI → (HTTPS/API) → Server.Auth endpoints (authenticate/store token)
• CLI → (TCP/WebSocket) → Server tunnel endpoint (persistent control channel)
• Public Internet → Server (reverse proxy) → Tunnel → CLI → Local service
• Server HTTP API ↔ Database (store/retrieve logs, tokens, tunnel metadata)
• Server Web Dashboard → Server HTTP API → Database/Logger → returns data to UI
• Logger plugins → External billing platforms/APIs (Stripe, GitHub, Paddle)
Architectural Patterns & Design Principles
• Separation of Concerns:
– CLI client is distinct from server; communicates only via API & tunnel socket
– Server splits HTTP API, WebSocket proxy, logging, and plugin subsystems
• Plugin Architecture:
– Logger/Plugins implement a common interface (BasePlugin)
– PluginManager loads & invokes plugins without hard dependencies
• MVC‐style layering on server:
– Controllers (app/Http/Controllers) → Services/Models (app/RequestLog, app/ResponseLog) → Database
• Dependency Injection & Service Providers (Laravel Zero conventions)
Capturing Essential Details
• Persistent connections: CLI ↔ WebSocket proxy
• Stateless interactions: CLI ↔ HTTP API
• Configuration & bootstrap:
– bootstrap/app.php → sets up service providers & dependency injection
– config/expose.php → core tunneling options
• Lifecycle of a share request:
1) CLI invokes ShareCommand → HTTP POST /api/share → server creates tunnel entry
2) CLI opens WebSocket to /socket → server accepts & binds subdomain
3) Public client HTTP request → reverse proxy → WebSocket → CLI → local dev server