Integrate Cloudinary for cloud-based image and video storage

Implement Cloudinary integration for uploading, storing, and transforming media files, including a new settings section for user configuration and API endpoints for media management.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/p0c5kxJ
This commit is contained in:
michaelschal committed 2025-10-01 14:14:59 +00:00
1 parent 66e20a83e7
commit bee6f53f23
6 files changed
+363 -35

No files matched your search

+21 -9
View File
@@ -55,7 +55,7 @@ Preferred communication style: Simple, everyday language.
- `/api/pages/*` - Social page management
- `/api/posts/*` - Post and scheduling management
**File Upload**: Multer middleware for handling multipart/form-data with in-memory storage strategy
**File Upload**: Multer middleware for handling multipart/form-data with in-memory storage strategy, integrated with Cloudinary for cloud storage
**Background Processing**:
- Node-cron for scheduled task execution
@@ -65,7 +65,7 @@ Preferred communication style: Simple, everyday language.
**Session Management**: Stateless authentication with session cookies (connect-pg-simple for PostgreSQL session store)
**Key Architectural Patterns**:
- Service layer pattern (OpenRouterService, ImageProcessor, SchedulerService)
- Service layer pattern (OpenRouterService, CloudinaryService, SchedulerService)
- Storage abstraction layer for database operations
- Middleware-based request processing pipeline
- Separation of concerns between routes, services, and storage
@@ -80,8 +80,9 @@ Preferred communication style: Simple, everyday language.
Core Tables:
- `users` - User authentication and profiles
- `cloudinary_config` - Cloudinary configuration per user (cloud name, API key, API secret)
- `social_pages` - Connected Facebook/Instagram pages with access tokens
- `media` - Uploaded media files with platform-specific processed versions
- `media` - Uploaded media files with Cloudinary public IDs and transformation URLs
- `posts` - Post content with AI generation tracking and status
- `scheduled_posts` - Scheduled publication queue with page assignments
- `ai_generations` - History of AI-generated content
@@ -101,20 +102,21 @@ Core Tables:
### Media Processing Pipeline
**Image Processing Library**: Sharp for high-performance image manipulation
**Cloud Storage**: Cloudinary for image/video storage and transformation
**Format Optimization Strategy**:
- Facebook Feed: 1200x630px (landscape format)
- Instagram Feed: 1080x1080px (square format)
- Instagram Story: 1080x1920px (vertical format)
**Storage**: Local filesystem storage in `/uploads` directory with unique UUID-based filenames
**Storage**: Cloud-based storage via Cloudinary CDN with automatic transformations
**Processing Flow**:
1. Upload original file to memory buffer
2. Generate three optimized versions for different platforms
3. Store all versions with references in database
4. Serve via `/uploads` static route
1. Upload original file to memory buffer via Multer
2. Upload to Cloudinary with unique public_id
3. Cloudinary automatically generates transformation URLs for all platform formats
4. Store Cloudinary public_id and transformation URLs in database
5. Serve optimized images via Cloudinary CDN
## External Dependencies
@@ -126,6 +128,16 @@ Core Tables:
- Configuration: Requires `OPENROUTER_API_KEY` environment variable
- Temperature: 0.8 for creative variation
### Cloud Storage
**Cloudinary**:
- Purpose: Cloud-based image and video storage with automatic transformations
- Configuration: User-configurable via Settings page (cloud name, API key, API secret)
- Storage: Images stored in Cloudinary cloud with unique public IDs
- Transformations: Automatic generation of platform-specific formats (Facebook Feed, Instagram Feed, Instagram Story)
- CDN: Global content delivery network for fast image loading
- Status: Fully integrated for media uploads
### Social Media APIs
**Facebook Graph API**: