Commit Graph

29 Commits

Author SHA1 Message Date
46b51034bf feat: Send Threads posts to Telegram for easy copy-paste
When generating manual Threads posts, now sends each post directly
to Telegram with:
- Content wrapped in backticks (easy to copy)
- Quality score and category info
- Direct link to open Threads
- Character count

This enables a workflow where posts are generated automatically
and the user just needs to copy from Telegram and paste in Threads.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 23:11:21 +00:00
29520a00f6 feat: Add publish and mark-published endpoints with validation
- Add /api/posts/{id}/publish endpoint for API-based publishing
- Add /api/posts/{id}/mark-published endpoint for manual workflow
- Add content length validation before publishing
- Update modal with "Ya lo publiqué" and "Publicar (API)" buttons
- Fix retry_count handling for None values

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 23:01:28 +00:00
855e765417 feat: Add post detail modal with copy functionality
- Click on any post to open a detailed view modal
- Shows platform-specific content with tabs (X, Threads, etc.)
- Copy button for each platform's content
- Shows quality score and breakdown
- Quick actions: Publish, Delete from modal
- Useful for manually copying Threads posts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 22:57:03 +00:00
1239c4af2c feat: Add daily Threads content generation for manual publishing
- Add generate_threads_manual_posts() task that creates 2 posts daily
- Posts are saved with status 'draft' for manual copy/paste to Threads
- Uses tip_tech template with rotating categories (productividad, ia, etc.)
- Scheduled to run daily at 7:00 AM (Tijuana timezone)
- Posts appear in dashboard for easy access

This is a workaround while waiting for Threads API approval.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 22:54:07 +00:00
67263e7ed9 feat: Add get_post_metrics to all publishers for analytics
- Add abstract get_post_metrics() method to BasePublisher
- Implement get_post_metrics() in XPublisher using Twitter API v2
  - Returns: likes, comments, shares, retweets, quotes, impressions
- Implement get_post_metrics() in ThreadsPublisher using Meta Graph API
- Implement get_post_metrics() in FacebookPublisher with insights
- Implement get_post_metrics() in InstagramPublisher with insights

This enables the fetch_post_metrics task to collect engagement data
from all platforms, populating the analytics dashboard.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 22:12:54 +00:00
9008c5d945 feat: Auto-adapt content to platform limits when creating posts
- Add adapt_with_ai() method to PlatformAdapter that uses DeepSeek
  to condense content when it exceeds platform character limits
- Add adapt_for_all_platforms_smart() for batch adaptation
- Modify create_post endpoint to auto-generate content_x, content_threads,
  content_instagram, content_facebook with adapted versions
- Modify update_post to re-adapt content when main content changes
- If content fits within limit, use as-is (no AI call)
- If content exceeds limit, AI condenses while preserving message
- Fallback to rule-based truncation if DeepSeek API unavailable

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 21:20:04 +00:00
cf1e06bb11 docs: Add session context document for continuity
Complete project state documentation including:
- System architecture and services
- Implemented features (content engine, threads, interactions, reports)
- Scheduled tasks and database schema
- Useful commands and pending items

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 09:00:19 +00:00
b6823651e0 feat: Add follower tracking to interactions
- Add get_followers() method to X publisher
- Track new followers as "follow" interaction type
- Update daily reports to show followers separately
- Store follower name, username, bio, and profile image

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:07:28 +00:00
f5c6554fc3 feat: Add daily Telegram reports (morning and afternoon)
- Morning report (8:00 AM): scheduled posts for today + new interactions
- Afternoon report (6:00 PM): published count + pending interactions
- Reports are sent via Telegram with formatted summaries

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 10:10:31 +00:00
5f04aa0cce fix: Resolve duplicate interaction detection and add usernames
- Add processed_ids set to prevent duplicate inserts when a tweet is
  both a mention and a comment (same external_id)
- Enhance get_mentions() to fetch usernames via user expansions
- Update fetch_interactions to prefer username over numeric author_id

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 10:04:58 +00:00
f4f0a2d230 feat: Add recent published section and filter self-interactions
- Add "Publicaciones Recientes" section to dashboard showing published posts
- Filter out self-generated interactions in X API (thread auto-replies)
- Improve username resolution for X interactions using user expansions
- Pass recent_published data to dashboard template

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 23:29:02 +00:00
7427e818a5 feat: Add February 2026 content calendar and thread publishing support
- Generate 24 posts for February: 12 tips, 4 threads, 8 promotional
- Schedule automatic publication at optimal times
- Update publish_to_platform to handle hilo_educativo as threads
- Parse JSON thread posts and publish using publish_thread()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 22:55:06 +00:00
9e857961f9 feat: Add proper thread handling in content generation
- Detect threads by template name and skip platform truncation
- Parse thread content into individual posts with numbering
- Add thread_posts array to API response with post details
- Evaluate quality on first post (hook) for threads
- Add is_thread and thread_posts fields to GenerateV2Response

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 21:23:18 +00:00
e32885afc5 fix: Fix YAML syntax errors and validator prompt formatting
- Fix YAML files with unquoted strings containing quotes
- Export singleton instances in ai/__init__.py
- Fix validator scoring prompt to use replace() instead of format()
  to avoid conflicts with JSON curly braces

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 21:13:58 +00:00
11b0ba46fa feat: Add Content Generation Engine v2 with quality scoring
Major improvements to AI content generation:

## New Components (app/services/ai/)
- PromptLibrary: YAML-based prompt templates with inheritance
- ContextEngine: Anti-repetition and best performers tracking
- ContentGeneratorV2: Enhanced generation with dynamic parameters
- PlatformAdapter: Platform-specific content adaptation
- ContentValidator: AI-powered quality scoring (0-100)

## Prompt Library (app/prompts/)
- 3 personalities: default, educational, promotional
- 5 templates: tip_tech, product_post, service_post, thread, response
- 4 platform configs: x, threads, instagram, facebook
- Few-shot examples by category: ia, productividad, seguridad

## Database Changes
- New table: content_memory (tracks generated content)
- New columns in posts: quality_score, score_breakdown, generation_attempts

## New API Endpoints (/api/v2/generate/)
- POST /generate - Generation with quality check
- POST /generate/batch - Batch generation
- POST /quality/evaluate - Evaluate content quality
- GET /templates, /personalities, /platforms - List configs

## Celery Tasks
- update_engagement_scores (every 6h)
- cleanup_old_memory (monthly)
- refresh_best_posts_yaml (weekly)

## Tests
- Comprehensive tests for all AI engine components

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:55:28 +00:00
f458f809ca fix: Add scipy dependency and fix config for Docker deployment
- Add scipy==1.11.4 for A/B testing statistical analysis
- Add SMTP config fields and extra="ignore" to Settings
- Remove obsolete 'version' attribute from docker-compose.yml

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 03:29:38 +00:00
e2882ce72b docs: Add comprehensive documentation for all new features
- FEATURES_OVERVIEW.md: Complete summary of all system features
- ANALYTICS.md: Analytics and reporting system documentation
- ODOO_INTEGRATION.md: Odoo ERP integration guide
- AB_TESTING.md: A/B testing system documentation
- CONTENT_RECYCLING.md: Content recycling system docs
- THREAD_SERIES.md: Thread series and scheduled posts
- IMAGE_TEMPLATES.md: Visual template system documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 03:17:23 +00:00
ecc2ca73ea feat: Add Analytics, Odoo Integration, A/B Testing, and Content features
Phase 1 - Analytics y Reportes:
- PostMetrics and AnalyticsReport models for tracking engagement
- Analytics service with dashboard stats, top posts, optimal times
- 8 API endpoints at /api/analytics/*
- Interactive dashboard with Chart.js charts
- Celery tasks for metrics fetch (15min) and weekly reports

Phase 2 - Integración Odoo:
- Lead and OdooSyncLog models for CRM integration
- Odoo fields added to Product and Service models
- XML-RPC service for bidirectional sync
- Lead management API at /api/leads/*
- Leads dashboard template
- Celery tasks for product/service sync and lead export

Phase 3 - A/B Testing y Recycling:
- ABTest, ABTestVariant, RecycledPost models
- Statistical winner analysis using chi-square test
- Content recycling with engagement-based scoring
- APIs at /api/ab-tests/* and /api/recycling/*
- Automated test evaluation and content recycling tasks

Phase 4 - Thread Series y Templates:
- ThreadSeries and ThreadPost models for multi-post threads
- AI-powered thread generation
- Enhanced ImageTemplate with HTML template support
- APIs at /api/threads/* and /api/templates/*
- Thread scheduling with reply chain support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 03:10:42 +00:00
03b5f9f2e2 feat: Add missing products and services dashboard templates
- Add products.html with full CRUD, filtering, stats, and AI post generation
- Add services.html with full CRUD, filtering, stats, and AI post generation
- Both templates follow existing design patterns (Tailwind CSS, dark theme)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 02:30:19 +00:00
fad24bf284 chore: Remove nginx from docker-compose files
Simplified setup for local network access - access FastAPI directly on port 8000

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 02:24:22 +00:00
a683baaca4 feat: Add local network configuration (no SSL)
- Add nginx.local.conf for HTTP-only access via local IP
- Add docker-compose.local.yml for local network deployment
- Simpler setup without SSL certificate requirements

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 02:16:02 +00:00
85bda6abcf feat(phase-6): Complete testing and deployment setup
Testing:
- Add pytest configuration (pytest.ini)
- Add test fixtures (tests/conftest.py)
- Add ContentGenerator tests (13 tests)
- Add ContentScheduler tests (16 tests)
- Add PublisherManager tests (16 tests)
- All 45 tests passing

Production Docker:
- Add docker-compose.prod.yml with healthchecks, resource limits
- Add Dockerfile.prod with multi-stage build, non-root user
- Add nginx.prod.conf with SSL, rate limiting, security headers
- Add .env.prod.example template

Maintenance Scripts:
- Add backup.sh for database and media backups
- Add restore.sh for database restoration
- Add cleanup.sh for log rotation and Docker cleanup
- Add healthcheck.sh with Telegram alerts

Documentation:
- Add DEPLOY.md with complete deployment guide

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 02:12:34 +00:00
354270be98 feat(phase-5): Complete dashboard UI templates
- Add posts.html: Post management with filtering by status/platform/type,
  stats display, pagination, edit modal, and actions (approve, reject,
  publish now, schedule, edit, delete)
- Add calendar.html: Visual calendar with month/week views, drag-and-drop
  rescheduling, platform filtering with color-coded status
- Add interactions.html: Interactions management with filtering, detail
  panel for responding, AI response suggestions, lead marking
- Add settings.html: API connection status, DeepSeek config, Telegram
  notifications setup, system info, and quick actions
- Update dashboard.py with settings route

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 02:03:28 +00:00
edc0e5577b feat(phase-4): Complete scheduling and automation system
- Add Celery worker with 5 scheduled tasks (Beat)
- Create ContentScheduler for optimal posting times
- Add calendar endpoints for scheduled posts management
- Implement Telegram notification service
- Add notification API with setup guide

Celery Beat Schedule:
- check_scheduled_posts: Every minute
- generate_daily_content: Daily at 6 AM
- sync_interactions: Every 15 minutes
- send_daily_summary: Daily at 9 PM
- cleanup_old_data: Weekly on Sundays

New endpoints:
- GET /api/calendar/posts/scheduled - List scheduled posts
- GET /api/calendar/posts/view - Calendar view
- GET /api/calendar/posts/slots - Available time slots
- POST /api/calendar/posts/{id}/schedule - Schedule post
- POST /api/calendar/posts/{id}/publish-now - Publish immediately
- GET /api/notifications/status - Check notification config
- POST /api/notifications/test - Send test notification
- GET /api/notifications/setup-guide - Configuration guide

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 01:56:10 +00:00
964e38564a feat(phase-3): Complete AI content generation system
- Add /api/generate endpoints for AI content generation
- Integrate DeepSeek AI into dashboard compose page
- Add content templates for tips, products, services, engagement
- Implement batch generation for weekly/monthly calendars
- Add cost estimation endpoint

New endpoints:
- POST /api/generate/tip - Generate tech tips
- POST /api/generate/product - Generate product posts
- POST /api/generate/service - Generate service posts
- POST /api/generate/thread - Generate educational threads
- POST /api/generate/response - Generate response suggestions
- POST /api/generate/adapt - Adapt content to platform
- POST /api/generate/improve - Improve existing content
- POST /api/generate/batch - Batch generate for calendar
- GET /api/generate/batch/estimate - Estimate batch costs
- GET /api/generate/status - Check AI connection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 01:49:49 +00:00
3caf2a67fb feat(phase-2): Complete social media API integration
- Add ImageUploadService for public URL generation (Meta APIs)
- Create PublisherManager for unified multi-platform publishing
- Add /api/publish endpoints (single, multiple, thread, test)
- Add compose page in dashboard for creating posts
- Add connection test script (scripts/test_connections.py)
- Update navigation with compose link and logout

New endpoints:
- POST /api/publish/single - Publish to one platform
- POST /api/publish/multiple - Publish to multiple platforms
- POST /api/publish/thread - Publish thread (X/Threads)
- GET /api/publish/test - Test all API connections
- GET /api/publish/platforms - List available platforms

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 01:43:22 +00:00
cda224f852 docs: Add DeepSeek API cost estimate analysis
- Detailed token usage per content type
- Monthly/annual cost projections
- Comparison with alternative APIs
- Optimization recommendations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 01:33:14 +00:00
541a8484a7 feat(phase-1): Complete foundation setup
- Add User model and authentication system with JWT cookies
- Implement login/logout routes and protected dashboard
- Add Alembic database migration configuration
- Add create_admin.py script for initial user setup
- Make ContentGenerator and ImageGenerator lazy-initialized
- Add comprehensive API keys setup documentation
- Fix startup errors when services unavailable

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 01:30:15 +00:00
049d2133f9 Implementación inicial del sistema de automatización de redes sociales
- Estructura completa del proyecto con FastAPI
- Modelos de base de datos (productos, servicios, posts, calendario, interacciones)
- Publishers para X, Threads, Instagram, Facebook
- Generador de contenido con DeepSeek API
- Worker de Celery con tareas programadas
- Dashboard básico con templates HTML
- Docker Compose para despliegue
- Documentación completa

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 01:11:44 +00:00