๐Ÿ—๏ธ

01-Platform-Strategy

๐Ÿ”’

Repolished. Production infrastructure is locked in B0 โ€” Production Infrastructure (CentOS + LiteSpeed + Laravel + MySQL). Where this page disagrees with B0, B0 wins. Earlier wording calling the product "iPhone-first" or naming PostgreSQL/Nginx as default is superseded.

๐Ÿ—๏ธ

Web-first, mobile-supported. Decisions here are binding for the rest of the spec. The Laravel Control Center is the primary operator surface; the iPhone app is a fully-featured remote with full parity over the same API.

1. Build order

  1. Production infrastructure (B0) โ€” CentOS-compatible Linux + LiteSpeed + lsphp 8.3 + MySQL/MariaDB + Redis + Supervisor + Let's Encrypt.
  1. Backend API + admin shell (Laravel 11, B1) โ€” projects, runs, events, files, snapshots, RAG, providers, Git, docs auto-update, server params, API tokens, Filament admin.
  1. Web Control Center (Livewire 3 + Reverb, B5) โ€” live console, diff viewer, plan/approve, RAG inspector. Part of v1.
  1. iPhone client (SwiftUI, B6) โ€” driven entirely by the same API; full parity with the Control Center.

Android is not in v1.

2. Backend stack

LayerChoiceReason
FrameworkLaravel 11 (or latest stable)Mature HTTP/queue/auth, Sanctum, Horizon.
AuthLaravel Sanctum (personal access tokens)Native fit for mobile + API tokens.
Web serverLiteSpeed Web Server 6.x (OpenLiteSpeed or Enterprise) + lsphp 8.3 via LSAPILocked in B0. Nginx/Apache/PHP-FPM are not supported in prod.
Operating systemCentOS-compatible Linux (AlmaLinux 9 / Rocky 9)SELinux enforcing; RPM packaging.
Primary DBMySQL 8.0 or MariaDB 11.4+Default. JSON columns, utf8mb4, InnoDB.
Vector storeMySQL JSON column (default) โ†’ app-layer cosine similarityDriver-aware. Opt-in upgrade to PostgreSQL 16 + pgvector when a project exceeds ~50k chunks.
Cache / queue / pubsubRedis 7Queues, locks, SSE fan-out.
JobsLaravel HorizonLong-running agent jobs, observable.
Object storageS3-compatibleSnapshot archives, downloadable logs.
AI: chatOpenAI API โ€ข Anthropic APIProvider-agnostic interface.
AI: embeddingsOpenAI text-embedding-3-large (configurable)Strong recall on code/docs.
Claude CodeLocal adapter via CLI / SDKWrapped in ClaudeCodeAgentService.
GitServer-side git binary via GitServiceSandboxed working dirs.
Process execsymfony/process with allowlistTimeouts + signal handling.
StreamingSSE (primary) + WebSocket optionalSimpler, mobile-friendly.
TestingPHPUnit + Pest + HTTP feature testsRequired for every service.

Vector storage โ€” default and upgrade path

RAG storage is abstracted behind RagContextService and the rag_chunks migration is driver-aware:

  • Default (MySQL/MariaDB): embedding is a JSON column. Cosine similarity is computed in the app layer (FastVector / PHP). Works to ~50k chunks per project.
  • Upgrade path (PostgreSQL 16 + pgvector): flip DB_CONNECTION=pgsql and run php artisan agent:reindex --all. The same migration creates embedding vector(3072) and an ivfflat index.
  • Future: MariaDB 11.7+ vector indexes when GA in the host distro.

No Qdrant/Milvus/Weaviate sidecar in v1.

3. iPhone stack

LayerChoice
UISwiftUI (iOS 17+)
ArchitectureMVVM + @Observable view models + Swift Concurrency (async/await)
NetworkingURLSession โ€ข a typed APIClient
Live eventsURLSession SSE reader (line-by-line)
AuthToken in Keychain
StorageSwiftData / Core Data for local caches
Diff viewerCustom UnifiedDiffView (text first; syntax later)
NotificationsAPNs for run-state changes (optional, v1.1)

4. Environments

EnvPurposeWeb serverDBNotes
localDevphp artisan serve or LSWS in DockerMySQL 8 in DockerRAG ON, real OpenAI key optional, mock provider available.
stagingPre-prodLiteSpeed + lsphp 8.3 on CentOS-compatibleMySQL 8 / MariaDB 11.4+Real keys, throttled, public push disabled.
productionProdLiteSpeed + lsphp 8.3 on CentOS-compatible (AlmaLinux 9 / Rocky 9)MySQL 8 / MariaDB 11.4+ (managed or self-hosted)Snapshots to local disk + optional S3 mirror; Horizon + Reverb supervised by Supervisor. SSL via Let's Encrypt.

5. Process supervision

  • php artisan horizon runs the agent queues: agents-default, agents-long, rag-index, docs.
  • Long agent runs use the agents-long queue with a long timeout and a Horizon supervisor configured for it.
  • One agent per project workspace at a time, enforced by a Redis lock workspace:lock:{project_id} with a TTL.

6. Configuration / secrets

  • All credentials come from server params (see 08 โ€” Server Params & Configuration).
  • Nothing is hardcoded.
  • .env holds only bootstrap values (DB connection, Redis URL, app key).
  • Tokens and API keys live in the agent_settings table (encrypted) and are surfaced through config/agent_workspace.php via a custom config repository.

7. Folder layout target

See section 6 of the master Spec Pack page. Production on-disk layout (/var/www/agent-workspace/{current,releases,shared,logs}/...) is defined in B0 ยง3.

8. Coding standards

  • PSR-12 + Laravel Pint.
  • All services constructor-injected. No facades inside services; facades only in controllers/jobs.
  • Strict types declared at the top of every PHP file.
  • Every public service method has a Pest test.
  • No business logic in controllers.
  • Every migration is reversible.