🐵 Social MONKEE Infrastructure Map

Complete System Architecture & Deployment Overview

Version 2.4 - Premium Stock Photo System | Updated: October 20, 2025

📊 System Overview

Full-Stack Architecture

Frontend
React + Vite
Backend API
Node.js + Express
PostgreSQL
Database
Google Gemini
Content Gen
Google Imagen
Image Gen
OpenAI DALL-E
Fallback
AWS S3
Image Storage
GHL API
Publishing

🌐 Frontend Servers

🚀
Primary Frontend (v2)
Production Application
Platform
Netlify
Status
Active Production
Purpose
Main user interface for content creation and social media management
Tech Stack
React 19 TypeScript Vite 6.2 Tailwind CSS
# Environment Variables
VITE_API_URL=https://postmonkeev2.onrender.com
🔄
Legacy Frontend
Deprecated - Redirects to v2
Platform
Netlify
Status
Deprecated
Purpose
Legacy URL for backwards compatibility

⚙️ Backend Servers

🖥️
Backend API Server
Node.js Express Server
Platform
Render.com
Service Type
Web Service (Professional Plan - $25/mo)
Status
Active Production
Purpose
REST API for content generation, GHL integration, image processing, and database operations
Main File
backend/server-social-monkee.js
Tech Stack
Node.js 18+ Express 4.19 PostgreSQL Sharp (Images)
⚠️ Security Note: All credentials stored as encrypted environment variables in Render dashboard. Never commit credentials to Git.

🗄️ Database Infrastructure

🐘
PostgreSQL Database
Primary Data Store
Platform
Render.com (Managed PostgreSQL)
Version
PostgreSQL 14+
Status
Active
Purpose
Store clients, GHL connections, social accounts, posts, brand documents, and embeddings
Extensions
pgvector SSL/TLS
Tables
clients, ghl_connections, social_accounts, social_posts, brand_uploads, embeddings
# Connection String
DATABASE_URL=postgresql://user:pass@host:5432/dbname
DATABASE_SSL=true

🤖 AI Service Providers

Google Gemini 2.5 Flash
Content Generation Engine
Provider
Google AI Studio
Purpose
Multi-platform social media content generation with platform-specific optimization
Platforms Supported
Facebook Instagram LinkedIn Twitter/X Google Business TikTok
# API Configuration
API_KEY=your_google_gemini_api_key_here
🎨
Google Imagen (Vertex AI)
Primary Image Generation
Provider
Google Cloud Vertex AI
Status
Configuring
Purpose
Premium stock photo quality image generation with automatic fallback to OpenAI
Image Formats
1:1 Square 4:5 Portrait 9:16 Story 16:9 Landscape 4:3 Google
# Google Cloud Configuration
GOOGLE_CLOUD_PROJECT_ID=your_project_id
GOOGLE_CLOUD_LOCATION=us-central1
GOOGLE_SERVICE_ACCOUNT_JSON={"type":"service_account"...}
🖼️
OpenAI DALL-E 3
Fallback Image Generation
Provider
OpenAI API
Status
Active
Purpose
Photorealistic image generation with stock photo quality. Also provides text embeddings for brand context.
Services Used
DALL-E 3 text-embedding-3-small
# OpenAI Configuration
OPENAI_API_KEY=sk-proj-...

☁️ Cloud Storage & CDN

📦
AWS S3 Bucket
Image Storage & Hosting
Provider
Amazon Web Services
Bucket Name
social-monkee-media
Region
us-east-1
Status
Active
Purpose
Public image hosting required by Go High Level API. Stores all generated social media images.
Configuration
Public read access, no ACL (uses bucket policies)
# AWS Credentials
AWS_ACCESS_KEY_ID=AKIAQAFBF54TOXY5UHPG
AWS_SECRET_ACCESS_KEY=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
AWS_S3_BUCKET=social-monkee-media
AWS_S3_REGION=us-east-1
⚠️ Security: These credentials are shown for documentation. In production, stored securely in Render environment variables.

🔌 External API Integrations

🚀
Go High Level (GHL)
Social Media Publishing Platform
Integration Type
OAuth 2.0 Private App
Status
Active Production
Purpose
Multi-platform social media publishing, account management, and OAuth authentication
API Endpoints
OAuth: https://marketplace.gohighlevel.com/oauth/chooselocation
API: https://services.leadconnectorhq.com
OAuth Scopes
socialplanner/account.readonly socialplanner/post.write
# GHL OAuth Configuration
GHL_CLIENT_ID=68d5cb1bc139dc9da89af57b-mg0biin6
GHL_CLIENT_SECRET=46287c3c-bf6b-4f90-8d1f-2bde59ba40af
GHL_REDIRECT_URI=https://postmonkeev2.onrender.com/api/social/callback
GHL_DEFAULT_USER_ID=optional_fallback_user_id

🔄 Version Control & CI/CD

🦊
GitLab Repository
Source Code Management
Platform
GitLab.com
Status
Active
Purpose
Version control, deployment triggers, and collaboration
Auto-Deploy
Enabled to Render.com on push to main branch
🔧
Deployment Pipeline
Automated CI/CD
Workflow
1. Push to GitLab → 2. Render Auto-Deploy → 3. npm install → 4. Start Server → 5. Health Check
Build Commands
# Backend (Render)
Build: npm install
Start: npm start (runs server-social-monkee.js)
# Frontend (Netlify)
Build: npm install && npm run build
Publish: dist/

🔒 Security & Credential Management

🛡️
Encryption & Security
Token & Data Protection
Token Encryption
AES-256-CBC with unique IVs
Database Security
SSL/TLS connections, parameterized queries, client isolation
CORS Configuration
Restricted to posts.monkee.ai and postmonkeev2.netlify.app
OAuth Security
CSRF protection via state parameter, PKCE flow
# Security Configuration
TOKEN_ENCRYPTION_KEY=32_character_encryption_key
FRONTEND_ORIGIN=https://posts.monkee.ai
NODE_ENV=production
🔑
Credential Storage Locations
Where Credentials Are Stored
Render Environment Variables
All backend API keys, database credentials, AWS keys, GHL OAuth secrets
Netlify Environment Variables
Frontend API URL (VITE_API_URL)
Database (Encrypted)
GHL OAuth tokens (AES-256-CBC encrypted)
⚠️ Never Stored in Git
All secrets, API keys, and credentials excluded via .gitignore

📈 System Status & Metrics

Feature Completion Status
Phase 1 (GHL Integration)
✅ COMPLETE
Phase 2.2 (Images)
✅ COMPLETE
Phase 2.3 (4-Post Campaigns)
✅ COMPLETE
Phase 2.4 (Premium Images)
✅ COMPLETE
Google Imagen Integration
⚙️ CONFIGURING
📊
Performance Metrics
API Response Time
< 200ms (standard endpoints)
Content Generation
15-30 seconds (multi-platform)
Image Generation
3-8 seconds (multi-format)
System Uptime
99.9%+ (Render + Netlify combined)

🚀 Quick Reference - Critical URLs