Skip to content

stusseligmini/maya

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Maya AI - Content Optimization System

AI-powered content creation and social media management platform with mobile PWA support

Deploy to Render

πŸ“– Overview

Maya AI is an advanced AI-powered content optimization system designed for social media creators and businesses. It combines machine learning, automated content generation, and multi-platform publishing capabilities with a modern Progressive Web App (PWA) interface.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   API Gateway   β”‚    β”‚  Load Balancer  β”‚    β”‚     Nginx       β”‚
β”‚   (FastAPI)     β”‚    β”‚     (Nginx)     β”‚    β”‚   (Reverse      β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚    Proxy)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β–Ό                       β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Content        β”‚    β”‚   AI Models     β”‚    β”‚   Social        β”‚
β”‚  Processor      β”‚    β”‚   Integration   β”‚    β”‚   Platforms     β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β–Ό                       β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Database      β”‚    β”‚     Redis       β”‚    β”‚   Monitoring    β”‚
β”‚  (PostgreSQL)   β”‚    β”‚   (Cache &      β”‚    β”‚  (Prometheus/   β”‚
β”‚                 β”‚    β”‚   Queue)        β”‚    β”‚   Grafana)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core Components

1. API Layer (maya.api)

  • FastAPI-based REST API
  • JWT authentication and authorization
  • Rate limiting and security middleware
  • Comprehensive error handling

2. Content Processing (maya.content)

  • Platform-specific content optimization
  • Content validation and formatting
  • Hashtag and mention processing
  • Multi-platform content adaptation

3. AI Integration (maya.ai)

  • OpenAI GPT models for content generation and analysis
  • HuggingFace transformers for sentiment analysis
  • Configurable model selection and fallbacks
  • Content enhancement recommendations

4. Social Platform Integration (maya.social)

  • Twitter/X API integration
  • Instagram Business API integration
  • Scheduling and publishing workflow
  • Content unpublishing and management

5. Workflow Automation (maya.api.integrations)

  • n8n workflow integration for automation
  • Custom n8n nodes and triggers
  • Webhook endpoints for external system integration
  • Task submission API for background processing

6. Security (maya.security)

  • JWT token management
  • Password hashing and validation
  • Input sanitization and validation
  • Rate limiting and security headers

7. Monitoring (maya.monitoring)

  • Prometheus metrics collection
  • Health checks and alerting
  • Performance tracking
  • Structured logging with Sentry integration

βš™οΈ Configuration

Maya uses Pydantic Settings for configuration management with support for environment variables and configuration files.

Database Settings

DATABASE_URL=postgresql://user:password@host:port/database
DB_POOL_SIZE=10
DB_MAX_OVERFLOW=20

AI Model Configuration

OPENAI_API_KEY=sk-...
HUGGINGFACE_TOKEN=hf_...
MODEL_CACHE_DIR=./models/cache

Security Configuration

SECRET_KEY=your-secret-key-32-chars-minimum
JWT_ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
ALLOWED_HOSTS=["*"]  # Restrict in production

πŸ“š API Documentation

πŸš€ Maya AI - Content Optimization System

AI-powered content creation and social media management platform with mobile PWA support

Deploy to Render

πŸ“– Overview

Maya AI is an advanced AI-powered content optimization system designed for social media creators and businesses. It combines machine learning, automated content generation, and multi-platform publishing capabilities with a modern Progressive Web App (PWA) interface.

🌟 Key Features

πŸ€– AI-Powered Content Creation

  • Image Generation: Integration with Fooocus and AI models for high-quality visuals
  • Smart Caption Generation: OpenAI GPT-powered captions optimized for each platform
  • Content Enhancement: Automatic image optimization and text refinement
  • Hashtag Intelligence: AI-generated relevant hashtags for maximum reach

πŸ“± Progressive Web App (PWA)

  • Mobile Installation: Install as native app on iOS/Android devices
  • Offline Support: Content creation works without internet connection
  • Touch Optimized: Mobile-first responsive design
  • Push Notifications: Real-time content status updates
  • Cross-Platform: Works on desktop, tablet, and mobile

οΏ½ Multi-Platform Publishing

  • Instagram: Photos, Stories, Reels with optimal timing
  • TikTok: Short-form videos with trending hashtags
  • Twitter: Text and media posts with character optimization
  • Fanvue: Creator-focused content distribution
  • Snapchat: Engaging stories and snaps

πŸ” Content Moderation & Safety

  • AI Safety Scoring: Automatic content appropriateness detection
  • NSFW Detection: Advanced filtering for inappropriate content
  • Telegram Review: Human oversight through bot integration
  • Quality Assurance: Automated image and text quality checks

πŸ”„ Automated Workflow

  • Background Processing: Celery-powered async task processing
  • Smart Queue Management: Priority-based content processing
  • Real-time Analytics: Performance tracking and insights
  • Auto-posting: Scheduled content distribution
  • n8n Integration: Custom nodes for workflow automation

πŸ’¬ Telegram Integration

  • Review Workflow: Human review via Telegram bot
  • One-click Approval: Approve/reject content instantly
  • Content Editing: Edit captions and regenerate content
  • Status Notifications: Real-time updates and alerts

πŸš€ Quick Start

🌐 Deploy to Render (Recommended)

One-Click Deploy: Deploy to Render

Manual Setup:

git clone https://github.com/stusseligmini/maya.git
cd maya
# Follow RENDER_DEPLOYMENT_GUIDE.md for complete setup

πŸ“± Install Mobile PWA

After deployment, install Maya AI as a mobile app:

iPhone (iOS):

  1. Open Safari β†’ https://your-app.onrender.com/app
  2. Tap Share (░↑) β†’ "Add to Home Screen"
  3. Maya AI installs as native iOS app! 🍎

Android:

  1. Open Chrome β†’ https://your-app.onrender.com/app
  2. Tap "Add to Home screen" banner
  3. Maya AI installs as Android app! πŸ€–

πŸ”§ Local Development

# Clone repository
git clone https://github.com/stusseligmini/maya.git
cd maya

# Install dependencies
pip install -r requirements.txt

# Start development server
python main.py

# Access application
# Web: http://localhost:8000
# Mobile PWA: http://localhost:8000/app
# API Docs: http://localhost:8000/docs

πŸ—οΈ Architecture

Microservices Design

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Maya API      β”‚    β”‚   AI Service    β”‚    β”‚  Worker Service β”‚
β”‚   (FastAPI)     │◄──►│   (Fooocus)     │◄──►│   (Celery)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β–Ό                       β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   PostgreSQL    β”‚    β”‚     Redis       β”‚    β”‚  Telegram Bot   β”‚
β”‚   (Database)    β”‚    β”‚   (Cache/Queue) β”‚    β”‚   (Review)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Directory Structure

πŸ“ maya/
β”œβ”€β”€ πŸ“ docker/                     # Container configuration
β”‚   β”œβ”€β”€ Dockerfile                 # Main app container
β”‚   β”œβ”€β”€ docker-compose.yml         # Service orchestration
β”‚   └── services/                  # Individual service containers
β”‚       β”œβ”€β”€ ai-service/            # Fooocus & ML models
β”‚       β”œβ”€β”€ db-service/            # Database configuration
β”‚       └── worker-service/        # Background job processing
β”œβ”€β”€ πŸ“ config/                     # Environment & settings
β”‚   β”œβ”€β”€ settings.py               # Application configuration
β”‚   β”œβ”€β”€ secrets.py                # API keys & secrets
β”‚   β”œβ”€β”€ dev.env                   # Development environment
β”‚   └── prod.env                  # Production environment
β”œβ”€β”€ πŸ“ database/                   # Database layer
β”‚   β”œβ”€β”€ models.py                 # SQLAlchemy ORM models
β”‚   β”œβ”€β”€ connection.py             # Database connectivity
β”‚   └── migrations/               # Database schema changes
β”œβ”€β”€ πŸ“ api/                        # API endpoints
β”‚   β”œβ”€β”€ routes.py                 # Main API routes
β”‚   β”œβ”€β”€ auth.py                   # Authentication logic
β”‚   └── clients/                  # External API clients
β”‚       β”œβ”€β”€ openai_client.py      # OpenAI integration
β”‚       β”œβ”€β”€ huggingface_client.py # Hugging Face models
β”‚       └── runway_client.py      # Video generation
β”œβ”€β”€ πŸ“ queue/                      # Background processing
β”‚   β”œβ”€β”€ worker.py                 # Celery worker setup
β”‚   β”œβ”€β”€ tasks.py                  # Background tasks
β”‚   └── scheduler.py              # Scheduled jobs
β”œβ”€β”€ πŸ“ telegram/                   # Telegram integration
β”‚   β”œβ”€β”€ bot_image_review.py       # Image review bot
β”‚   β”œβ”€β”€ bot_video_review.py       # Video review bot
β”‚   └── callbacks/                # Bot callback handlers
β”œβ”€β”€ πŸ“ moderation/                 # Content safety
β”‚   β”œβ”€β”€ image_moderation.py       # Image content checks
β”‚   β”œβ”€β”€ emotion_analysis.py       # Text sentiment analysis
β”‚   └── platform_filter.py       # Platform-specific rules
β”œβ”€β”€ πŸ“ processing/                 # Content manipulation
β”‚   β”œβ”€β”€ caption_generator.py      # AI caption creation
β”‚   β”œβ”€β”€ video_editor.py           # Video processing
β”‚   β”œβ”€β”€ image_optimizer.py        # Image optimization
β”‚   └── scheduler.py              # Publishing scheduler
β”œβ”€β”€ πŸ“ publishing/                 # Platform publishing
β”‚   β”œβ”€β”€ instagram_api.py          # Instagram integration
β”‚   β”œβ”€β”€ tiktok_api.py             # TikTok integration
β”‚   β”œβ”€β”€ twitter_api.py            # Twitter integration
β”‚   β”œβ”€β”€ fanvue_upload.py          # Fanvue integration
β”‚   └── snapchat_upload.py        # Snapchat integration
β”œβ”€β”€ πŸ“ storage/                    # File management
β”‚   β”œβ”€β”€ proton_upload.py          # Proton Drive backup
β”‚   β”œβ”€β”€ backup_system.py          # Automated backups
β”‚   └── privacy_guard.py          # Data protection
β”œβ”€β”€ πŸ“ monitoring/                 # System monitoring
β”‚   β”œβ”€β”€ health_checks.py          # Service health monitoring
β”‚   β”œβ”€β”€ metrics.py                # Performance metrics
β”‚   └── alerts.py                 # Alert notifications
β”œβ”€β”€ πŸ“ input/                      # Content input directories
β”‚   β”œβ”€β”€ images_raw/               # AI-generated images
β”‚   β”œβ”€β”€ captions_raw/             # Generated captions
β”‚   └── videos_raw/               # Generated videos
β”œβ”€β”€ πŸ“ logs/                       # Application logs
β”œβ”€β”€ πŸ“ tests/                      # Test suite
β”œβ”€β”€ πŸ“„ main.py                     # Application entry point
β”œβ”€β”€ πŸ“„ requirements.txt            # Python dependencies
└── πŸ“„ README.md                   # This file

πŸš€ Quick Start

Prerequisites

  • Docker & Docker Compose
  • Python 3.11+
  • PostgreSQL
  • Redis

1. Clone Repository

git clone <repository-url>
cd maya

2. Environment Setup

# Copy environment file
cp config/dev.env .env

# Edit configuration
nano .env

3. Docker Setup

# Start all services
cd docker
docker-compose up -d

# Check service status
docker-compose ps

4. Initialize Database

# Run database migrations
docker-compose exec maya-api python init_db.py

5. Access Services

πŸ“Š Content Processing Flow

graph TD
    A[Upload Content] --> B[Queue Processing]
    B --> C[Content Moderation]
    C --> D{Safe Content?}
    D -->|Yes| E[AI Analysis]
    D -->|No| F[Reject & Log]
    E --> G[Caption Generation]
    G --> H[Platform Optimization]
    H --> I[Telegram Review]
    I --> J{Approved?}
    J -->|Yes| K[Schedule Publishing]
    J -->|No| L[Edit/Regenerate]
    K --> M[Publish to Platforms]
    M --> N[Monitor Performance]
    L --> G
Loading

πŸ”§ Configuration

Environment Variables

# Core Settings
ENVIRONMENT=development
DEBUG=True
DATABASE_URL=postgresql://maya:maya_secret@postgres:5432/maya_db
REDIS_URL=redis://redis:6379/0

# AI Services
OPENAI_API_KEY=your-openai-key
HUGGINGFACE_API_KEY=your-huggingface-key
FOOOCUS_API_URL=http://ai-service:8080

# Social Media APIs
INSTAGRAM_ACCESS_TOKEN=your-instagram-token
TIKTOK_ACCESS_TOKEN=your-tiktok-token
TWITTER_API_KEY=your-twitter-key

# Telegram Bot
TELEGRAM_BOT_TOKEN=your-telegram-bot-token
TELEGRAM_CHAT_ID=your-telegram-chat-id

# Security
JWT_SECRET_KEY=your-secret-key
ENCRYPTION_KEY=your-encryption-key

Platform API Setup

Instagram

  1. Create Facebook Developer Account
  2. Create Instagram Business Account
  3. Generate access token via Graph API
  4. Add token to environment variables

TikTok

  1. Register for TikTok for Developers
  2. Create application and get credentials
  3. Implement OAuth flow for user tokens

Twitter

  1. Create Twitter Developer Account
  2. Generate API keys and tokens
  3. Configure OAuth 2.0 settings

πŸ€– API Usage

Upload Content

curl -X POST "http://localhost:8080/api/content/upload" 
  -H "Authorization: Bearer YOUR_TOKEN" 
  -F "file=@image.jpg" 
  -F "metadata={"title":"Test Image","content_type":"image","target_platforms":["instagram","twitter"]}"

Check Processing Status

curl "http://localhost:8080/api/queue/status" 
  -H "Authorization: Bearer YOUR_TOKEN"

Publish Content

curl -X POST "http://localhost:8080/api/content/123/publish" 
  -H "Authorization: Bearer YOUR_TOKEN" 
  -H "Content-Type: application/json" 
  -d '{"platforms":["instagram","twitter"],"schedule_time":"2024-01-01T14:00:00"}'

πŸ” Monitoring & Debugging

Health Checks

# System health
curl http://localhost:8080/health

# Service metrics
curl http://localhost:8080/metrics

Log Monitoring

# Application logs
docker-compose logs -f maya-api

# Worker logs
docker-compose logs -f worker-service

# Database logs
docker-compose logs -f postgres

Celery Monitoring

Visit http://localhost:5555 for real-time worker monitoring

πŸ§ͺ Testing

Run Tests

# Unit tests
docker-compose exec maya-api pytest tests/unit/

# Integration tests
docker-compose exec maya-api pytest tests/integration/

# End-to-end tests
docker-compose exec maya-api pytest tests/e2e/

Manual Testing

# Test content upload
python scripts/test_upload.py

# Test moderation
python scripts/test_moderation.py

# Test publishing
python scripts/test_publishing.py

πŸ”’ Security

Authentication

All API endpoints require JWT authentication except for health checks and token creation.

  • JWT token-based authentication
  • Role-based access control
  • API key management for external services

Data Protection

  • Encryption at rest and in transit
  • GDPR compliance features
  • Automatic data anonymization
  • Secure API key storage

Rate Limiting

  • Per-user request limits
  • Platform-specific rate limiting
  • Automatic backoff and retry logic

πŸ“ˆ Performance Optimization

Caching Strategy

  • Redis for session and API response caching
  • Image thumbnail caching
  • Model prediction caching

Database Optimization

  • Connection pooling
  • Query optimization
  • Automatic indexing
  • Read replicas for scaling

Processing Optimization

  • Async task processing
  • Batch content processing
  • Resource usage monitoring
  • Auto-scaling workers

🚨 Troubleshooting

Common Issues

Database Connection Issues

# Check database status
docker-compose ps postgres

# Reset database
docker-compose down
docker volume rm maya_postgres_data
docker-compose up -d postgres

Worker Not Processing Tasks

# Get access token
POST /auth/token
{
  "username": "demo",
  "password": "demo123"
}

# Use token in requests
Authorization: Bearer <token>

Content Processing

Check worker status

docker-compose logs worker-service

Restart workers

docker-compose restart worker-service

Check Redis connection

docker-compose exec redis redis-cli ping


#### API Authentication Errors
```bash
# Process content for optimization
POST /content/process
{
  "text": "Your content here",
  "content_type": "text",
  "target_platforms": ["twitter", "instagram"],
  "analyze_with_ai": true
}
# Verify JWT secret
echo $JWT_SECRET_KEY

# Check token generation
python scripts/generate_token.py

Support Channels

  • GitHub Issues: Technical problems and feature requests
  • Documentation: Detailed guides and API reference
  • Community Forum: Usage questions and best practices

🀝 Contributing

Development Setup

  1. Fork the repository
  2. Create feature branch
  3. Install development dependencies
  4. Run tests before committing
  5. Submit pull request

Code Standards

  • Follow PEP 8 Python style guide
  • Write comprehensive tests
  • Document all functions and classes
  • Use type hints consistently

πŸ“„ License

This project is licensed under the MIT License - see LICENSE file for details.

πŸ† Acknowledgments

  • Fooocus: AI image generation capabilities
  • OpenAI: GPT models for content generation
  • Hugging Face: ML model ecosystem
  • FastAPI: High-performance web framework
  • Celery: Distributed task processing
  • PostgreSQL: Robust database system

πŸš€ Ready to Optimize Your Content?

Maya AI transforms your content creation workflow with intelligent automation. Get started today and experience the future of social media management!

Need Help? Check our documentation or open an issue.

About

AI Content Optimization for Social Platforms

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages