How supabase/cli works
Core CLI Interface Layer
• Root Command Handler (cmd/root.go)
• Command Groups (organized in cmd/ directory)
• User Interface Components (internal/utils/console.go, internal/utils/tea.go)
Service Management Layer
• Project Management (internal/projects/)
• Database Operations (internal/db/)
• Functions Management (internal/functions/)
• Authentication & SSO (internal/sso/)
• Storage Management (internal/storage/)
Infrastructure Layer
• Docker Integration (internal/utils/docker.go)
• Database Connections (pkg/pgxv5/)
• API Clients (pkg/api/)
• Configuration Management (pkg/config/)
Development Tools
• Migration Management (internal/migration/)
• Testing Framework (internal/testing/)
• Code Generation (internal/gen/)
Use a top-down layered architecture approach
• [User Input Layer]
• ↓
• [Command Processing Layer]
• ↓
• [Service Management Layer]
• ↓
• [Infrastructure Layer]
External Integration Points
• Supabase Platform API
• Docker Engine
• PostgreSQL Database
• Local File System
• Cloud Storage
Key Interactions to Highlight:
Command Flow
• User Input → Command Parser → Service Manager → Infrastructure Layer → External Services
Configuration Management
• Config Files ↔ Config Manager ↔ Service Modules
Database Operations
• Migration Commands → Database Manager → PostgreSQL Client → Database Instance
Special Considerations:
Cross-Platform Support
• Platform-specific components (indicated by _darwin.go, _linux.go, _windows.go files)
• Common interfaces for platform-agnostic operations
Plugin Architecture
• How different commands are organized as plugins
• Extension points for future functionality
Security Flow
• Authentication paths
• Token management
• Encryption handling
Components:
□ Command Handler
○ Service Module
◇ Infrastructure Component
△ External Service
Connections:
→ Direct Dependency
⟶ Optional Dependency
↔ Bidirectional Flow
🔵 Core CLI
🟢 Service Management
🟠 Infrastructure
🟣 Development Tools
⚫ External Services
Level of Detail:
• Keep high-level components visible at first glance
• Use expandable/collapsible sections for detailed subcomponents
• Version compatibility notes
• Annotations for critical paths and important workflows