How dart-lang/pub works
Main Components
a. Command Layer
• CommandRunner as the entry point
• Commands in lib/src/command/ (get, add, remove, upgrade, etc.)
• To the core services layer
b. Core Services Layer
• Package Management Services
• Source Handling (hosted, git, path, sdk)
• Version Solver
• System Cache Management
• Authentication Services
c. External Integrations
• Pub.dev API Integration
• Git Repository Integration
• Local File System
• Package Cache Storage
Architectural Patterns to Highlight
a. Command Pattern
• How each command (in lib/src/command/) implements a common interface
• Demonstrate the command routing through the CommandRunner
b. Source Strategy Pattern
• Different package sources (hosted, git, path, sdk)
• How they implement a common source interface
c. Solver Architecture
• Version solver component
• Package resolution logic
• Dependency graph management
Component Relationships
[Command Runner] → [Commands] → [Core Services] → [External Services]
• ↓
• [Source Handlers]
• ↓
• [Version Solver]
Implementation Details
• How commands are registered and routed
• Package source resolution flow
• Version solving process
• Cache management strategy
• Authentication flow
• File system interactions