# Automated Content Generation Pipeline

Hands-off social/marketing content system for a Linux + cPanel environment.

**What it does each scheduled run**

1. Pulls Italian IT / software / hardware trends from public RSS feeds  
2. Loads your example creator profiles + ERP documentation  
3. Uses **Claude (Anthropic)** to invent on-brand ideas and copy  
4. Renders **images**, **carousels**, and **short videos** locally (Pillow + ffmpeg)  
5. Uploads the batch folder to **Google Drive**  
6. Notifies the team on **Telegram**

## Why Python (not PHP)

PHP would run fine on cPanel, but this stack is intentionally lean and media-heavy:

| Concern | Python advantage on cPanel |
|---|---|
| Claude / Drive official clients | Mature first-party / Google client libraries |
| Images + carousels | Pillow (no Imagick extension fights) |
| Short video | Thin wrapper over system `ffmpeg` (already common on VPS/cPanel) |
| Cron deployment | Identical model: `crontab` → CLI script |

It runs as a **cron CLI process** — no web server, no Node, no Zapier/n8n cloud. Same operational model your team expects from PHP cron jobs.

## External services (minimized)

| Service | Role |
|---|---|
| **Anthropic Claude** | Ideation + copy + visual/slide/video scripts |
| **Google Drive API** | Storage of finished batches |
| **Telegram Bot API** | Completion alerts |
| Public RSS | Italian IT news (no key) |

**No** Buffer/Hootsuite, Midjourney, Zapier, or cloud workflow SaaS.  
Visuals are **template-rendered from Claude’s copy** (branded slides), not a separate image-generation SaaS. That keeps cost and vendors down while staying on-brand. (Optional AI image APIs can be plugged in later if you want photographic assets.)

## How Claude is used

### Ideation
Claude receives three context blocks every run:

- Creator profile notes (`data/profiles/`) — style benchmark  
- ERP docs (`data/erp/`) — proprietary product truth  
- Fresh Italian IT news headlines/summaries — topical fuel  

It returns a JSON batch of ideas with `format` = `image` | `carousel` | `video`, plus captions, hashtags, slide copy, and short video beats.

### Asset generation (where applicable)
Claude does **not** paint pixels. It writes:

- Hook / body for single-image posts  
- Per-slide title + body for carousels  
- On-screen text + voiceover lines for shorts  

Local code turns that into PNG / MP4 with your brand colors (`BRAND_*` env vars).

## Quick start

```bash
cd /path/to/content_generation
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
# edit .env — at minimum ANTHROPIC_API_KEY

# Smoke-test rendering (no API keys):
python bin/run_pipeline.py --demo

# Full run but skip Drive + Telegram:
# (needs ANTHROPIC_API_KEY)
python bin/run_pipeline.py --dry-run

# Production run:
python bin/run_pipeline.py
```

Outputs land in `storage/runs/batch_YYYYMMDD_HHMMSS/`.

## Simple Web Launcher

If you prefer clicking a button instead of terminal commands:

```bash
cd /path/to/content_generation
source venv/bin/activate
python3 bin/web_ui.py
```

Open `http://127.0.0.1:8088` and use **Start Run**.

## Documentation

- [Architecture walkthrough](docs/ARCHITECTURE.md)  
- [Setup & maintenance](docs/SETUP.md)  

## Project layout

```
bin/run_pipeline.py      # CLI entry
cron/run.sh              # cPanel cron wrapper
src/pipeline.py          # orchestration
src/services/            # Claude, news, knowledge, ideation
src/generators/          # Pillow + ffmpeg assets
src/storage/drive.py     # Google Drive upload
src/notify/telegram.py   # Telegram alerts
data/profiles/           # creator style refs (you edit)
data/erp/                # ERP docs (you edit)
storage/runs/            # local batch output
```
