Skip to content

Repository files navigation

GhostWriter AI

Let your ghost write your post

GhostWriter AI FastAPI Python Status Ollama

An intelligent social media automation system that transforms news articles into engaging social media content using cutting-edge AI services.

πŸš€ Overview

GhostWriter AI is a comprehensive automation system that:

  • Automatically processes news articles from any source
  • Generates optimized social media content using local Ollama AI
  • Orchestrates multiple AI services for content analysis and generation
  • Provides seamless integration with Telegram for team notifications

Let your ghost write your post - while you focus on strategy, GhostWriter handles the content creation.

πŸ—οΈ Architecture

Core Components

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Content       β”‚    β”‚   FastAPI       β”‚    β”‚   Telegram      β”‚
β”‚   Monitor       │───▢│   Orchestrator  │───▢│   Bot           β”‚
β”‚   (Google Apps) β”‚    β”‚   (Backend)     β”‚    β”‚   Notifications β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β–Ό         β–Ό         β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Ollama  β”‚β”‚ FastVLM  β”‚β”‚ Content  β”‚
              β”‚ LLM      β”‚β”‚ Vision   β”‚β”‚Generator β”‚
              β”‚ Service  β”‚β”‚ Service  β”‚β”‚ Service  β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Team Roles

  • Lead Developer: FastAPI Backend Orchestrator
  • AI Engineer: Ollama/LLM Integration Specialist
  • Vision Engineer: FastVLM Vision Processing Service
  • DevOps Engineer: Deployment & Integration Management

✨ Features

πŸ€– AI-Powered Content Generation

  • Article Relevance Analysis: Automatically filters relevant news using local Ollama
  • Image Processing: AI-powered image ranking and caption generation
  • Content Optimization: Smart content generation for different social platforms

πŸ”§ Service Orchestration

  • Dynamic Service Switching: Mock/Real AI service toggling
  • Robust Error Handling: Graceful fallbacks and timeout management
  • Health Monitoring: Real-time service status and integration monitoring

πŸ” Enterprise Security

  • API Key Authentication: Secure access control
  • Environment-based Configuration: Secure credential management
  • Rate Limiting: API abuse prevention

πŸ“± Team Integration

  • Telegram Notifications: Real-time alerts via custom bot
  • Approval Workflow: Human-in-the-loop content review
  • Multi-platform Distribution: Ready for Facebook, Instagram, Twitter

πŸš€ Quick Start

Prerequisites

  • Python 3.9+
  • Ollama running locally (127.0.0.1:11434)
  • Telegram bot credentials

Installation

  1. Clone the repository

    git clone https://github.com/Lucian-Adrian/ghostwriter.git
    cd ghostwriter
  2. Create virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    cd backend_server
    pip install -r requirements.txt
  4. Configure environment

    cp .env.example .env
    # Edit .env with your credentials
  5. Start the server

    uvicorn app.main:app --host 0.0.0.0 --port 8003 --reload

Environment Variables

# API Security
API_KEY=your_secure_api_key
AGENTS_API_KEY=your_agents_api_key

# Service URLs
FASTVLM_API_URL=http://localhost:8001
GEMMA9B_API_URL=http://127.0.0.1:11434

# Telegram Bot
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id
TELEGRAM_BOT_USERNAME=@YourBot

# Development
DEBUG=True

πŸ“š API Documentation

Core Endpoints

Process Article

POST /api/v1/process-article
Content-Type: application/json
X-API-Key: your_api_key

{
  "article_url": "https://fmf.md/article-url",
  "source": "fmf_monitor"
}

Health Check

GET /health

Service Management

POST /api/v1/config/switch-to-real-services
POST /api/v1/config/switch-to-mock-services
GET /api/v1/config/test-ollama-connection

Full API Reference

πŸ§ͺ Testing

Run Integration Tests

cd backend_server
python test_complete_integration.py

Health Check

curl http://localhost:8003/health

πŸ“Š System Status

Core Components

  • βœ… Backend Orchestrator: FastAPI server operational
  • βœ… Telegram Integration: Bot notifications configured
  • βœ… Ollama LLM Service: Local AI processing ready
  • 🟑 Vision Service: FastVLM integration ready for setup
  • 🟑 Content Monitor: Google Apps Script ready for deployment

Service Endpoints

  • Backend Orchestrator: http://localhost:8003
  • Ollama LLM: http://127.0.0.1:11434
  • Artiom's FastVLM: http://localhost:8001 (configurable)
  • Telegram Bot: @OfficialGhostWriterBot

πŸ› οΈ Development

Project Structure

ghostwriter/
β”œβ”€β”€ README.md                    # Main documentation
β”œβ”€β”€ CONTRIBUTING.md              # Development guidelines
β”œβ”€β”€ .gitignore                   # Git ignore rules
β”œβ”€β”€ backend_server/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py              # FastAPI application
β”‚   β”‚   β”œβ”€β”€ telegram_handler.py  # Telegram integration
β”‚   β”‚   β”œβ”€β”€ services/            # AI service integrations
β”‚   β”‚   β”‚   β”œβ”€β”€ language_service.py # Ollama LLM integration
β”‚   β”‚   β”‚   └── vision_service.py   # FastVLM integration
β”‚   β”‚   └── tools/               # Utility functions
β”‚   β”‚       β”œβ”€β”€ scraper_tool.py  # Web scraping
β”‚   β”‚       └── image_editor_tool.py # Image processing
β”‚   β”œβ”€β”€ requirements.txt         # Python dependencies
β”‚   β”œβ”€β”€ .env.example            # Environment template
β”‚   β”œβ”€β”€ run_simple.py           # Simple server startup
β”‚   β”œβ”€β”€ start.bat / start.sh    # Platform-specific startup
β”‚   └── processed_images/       # Image cache directory
└── docs/
    β”œβ”€β”€ API.md                  # API documentation
    β”œβ”€β”€ ARCHITECTURE.md         # Technical architecture
    β”œβ”€β”€ DEPLOYMENT.md           # Deployment guide
    β”œβ”€β”€ examples.md             # Content examples
    β”œβ”€β”€ google-apps-script.md   # GAS integration
    └── monitor.gs              # Google Apps Script

Adding New Services

  1. Create service module in app/services/
  2. Implement service interface
  3. Add configuration to .env
  4. Update orchestrator in main.py
  5. Write comprehensive tests

Contributing

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open Pull Request

πŸ”§ Configuration

Service Switching

Switch between mock and real services:

# Switch to real services
curl -X POST http://localhost:8003/api/v1/config/switch-to-real-services \
  -H "X-API-Key: your_api_key"

# Switch to mock services  
curl -X POST http://localhost:8003/api/v1/config/switch-to-mock-services \
  -H "X-API-Key: your_api_key"

Health Monitoring

# Check all services
curl http://localhost:8003/health

# Test Ollama connection
curl -X GET http://localhost:8003/api/v1/config/test-ollama-connection \
  -H "X-API-Key: your_api_key"

πŸ“ž Support

Documentation

  • πŸ› Bug Reports: Create GitHub issue with reproduction steps
  • πŸ’‘ Feature Requests: Open GitHub discussion
  • πŸ“– Documentation: Check the docs/ folder for detailed guides

πŸ“„ License

This project is open source software for AI-powered social media automation.

🎯 Roadmap

Phase 1: Core System

  • Backend orchestrator
  • Telegram bot integration
  • Ollama LLM integration
  • Vision service integration
  • Content monitoring setup

Phase 2: Production Ready

  • Google Apps Script integration
  • Production server deployment
  • Performance monitoring
  • Advanced error handling

Phase 3: Advanced Features

  • Multi-platform social media posting
  • Content analytics dashboard
  • A/B testing for optimization
  • Automated content scheduling

GhostWriter AI - Let your ghost write your post

Built with ❀️ for intelligent content automation

About

GhostWriter: AI Agent for automated social media news posting.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages