How spatie/laravel-medialibrary works
Core Components (Main Layer)
a. Media Management Layer
• It to the following sub-components:
• FileAdder System
• MediaCollection Manager
• Conversion Handler
• ResponsiveImage Generator
b. Storage Layer
• Multiple storage systems (represented as parallel components):
• Local Storage
• S3 Storage
• Custom Storage Adapters
Supporting Services (Secondary Layer)
a. Path Generation System
• DefaultPathGenerator
• CustomPathGenerator
• Connection to storage systems
b. URL Generation System
• DefaultUrlGenerator
• Custom URL Generators
• To the Media Management Layer
c. File Management Services
• FileNamer Service
• FileRemover Service
• Downloader Service
• To both Storage and Media Management layers
Processing Components
a. Conversion System
• Image Conversion Pipeline
• Custom Conversions
• Manipulation Queue
• To the following generators:
• Image Generator
• PDF Generator
• Video Generator
• SVG Generator
• AVIF Generator
• WebP Generator
b. Responsive Images System
• ResponsiveImageGenerator
• WidthCalculator
• TinyPlaceholderGenerator
• To the Conversion System
Integration Layer
a. Laravel Integration
• Eloquent Model Integration
• Relationship with HasMedia trait
• Migration/Database Connection
• To the Media Management Layer
b. Event System
• Media Events
• Conversion Events
• ResponsiveImage Events
Specific notations
• Use double lines for primary data flows
• Arrowheads to show direction of data/control flow
Important notes
• Async processes (like conversions)
• Points of extensibility
• Configuration injection points
Technical Details
• Database table relationship with media table
• File system abstraction layer
• Queue integration points
• Cache interaction points
• The modular nature of the system
• The separation of concerns between different components
• The extensibility points for custom implementations
• The flow of media files through the system
• The integration with Laravel's ecosystem
Keep the abstraction level high enough to be understandable but detailed enough to show the sophisticated architecture of the media handling system. Focus on showing how the different components interact to handle media uploads, conversions, and delivery while maintaining flexibility for different storage solutions and custom implementations.