Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Personalized Content Generator

A web application that generates content — blog posts, emails, social media posts, essays, and more — that sounds exactly like you wrote it. It creates a "digital twin" of your writing style by analyzing your existing writing samples using RAG (Retrieval-Augmented Generation) and style profiling via the Claude API.

No custom model training required. It uses your writing samples as few-shot context alongside a structured style profile to produce content indistinguishable from your own voice.

How It Works

  1. Upload your writing samples — past blog posts, emails, social media posts, essays, etc.
  2. Generate your style profile — Claude analyzes your writing to extract tone, vocabulary, sentence structure, quirks, and rhetorical patterns
  3. Generate content — Describe what you want to write; the app retrieves your most relevant writing samples and uses them as examples to generate content in your exact voice

Features

  • Upload files (.txt, .md, .pdf, .docx) or paste text directly
  • Automatic style profile extraction (tone, formality, vocabulary, sentence patterns, quirks)
  • RAG-powered generation: retrieves your writing samples relevant to the topic before generating
  • Regenerate or refine any piece of content
  • Rate generated content (1–5 stars)
  • Full generation history
  • Clean web UI — no Node.js required

Tech Stack

Layer Technology
Backend Python 3.11+ / FastAPI
Database SQLite (WAL mode) / SQLAlchemy async
Vector DB ChromaDB (embedded, local embeddings)
LLM Claude API (Sonnet for generation, Haiku for analysis)
Frontend Jinja2 + HTMX + Tailwind CSS (CDN)
File parsing pymupdf (PDF), python-docx (DOCX)

Setup

1. Clone and create a virtual environment

git clone <repo-url>
cd "Personalized Content Generator"
python3 -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate

2. Install dependencies

pip install -e ".[dev]"

3. Configure environment

cp .env.example .env

Edit .env and add your Anthropic API key:

ANTHROPIC_API_KEY=sk-ant-your-key-here

Get a key at console.anthropic.com.

4. Run the server

uvicorn app.main:app --reload

Open http://127.0.0.1:8000 in your browser.

Usage

Step 1 — Add writing samples

Go to Writing Samples and either:

  • Upload .txt, .md, .pdf, or .docx files (max 10MB each)
  • Paste text directly with a title

Add as many samples as you have — more samples = better style matching. Label each with the content type (blog, email, social, etc.).

Step 2 — Generate your style profile

Go to Dashboard and click Generate Profile. Claude will analyze your samples and extract a detailed style profile. This takes ~10–30 seconds. You can regenerate it anytime as you add more samples.

Step 3 — Generate content

Go to Generate and fill in:

  • Content type (blog, email, tweet, LinkedIn post, essay)
  • Topic
  • Target audience (optional)
  • Length (short / medium / long)
  • Any additional instructions

Click Generate. If the result isn't quite right, click Regenerate for a different version or use Refine to give specific feedback.

API

All functionality is available as a REST API:

Method Endpoint Description
POST /api/samples/upload Upload files
POST /api/samples/paste Submit pasted text
GET /api/samples List samples
DELETE /api/samples/{id} Delete a sample
GET /api/profile Get active style profile
POST /api/profile/generate Generate/regenerate profile
POST /api/generate Generate content
POST /api/generate/{id}/regenerate Regenerate
POST /api/generate/{id}/refine Refine with instructions
GET /api/history List generation history
POST /api/history/{id}/rate Rate (1–5)

Interactive API docs available at http://127.0.0.1:8000/docs.

Estimated API Costs

Operation Model Approx. Cost
Style analysis Claude Haiku 4.5 ~$0.01 per run
Generate (short) Claude Sonnet 4 ~$0.02
Generate (medium) Claude Sonnet 4 ~$0.03
Generate (long) Claude Sonnet 4 ~$0.05
Embeddings Local (MiniLM) Free

Light personal use (~50 generations/month): ~$1–3/month.

Privacy

  • Writing samples are sent to the Anthropic API for style analysis and generation
  • No data is stored by Anthropic beyond their standard API retention policy
  • All your data (samples, profile, history) is stored locally in data/
  • Your .env file (containing your API key) is gitignored

Project Structure

app/
├── main.py                  # FastAPI app, lifespan, startup reconciliation
├── config.py                # Settings via environment variables
├── api/                     # JSON REST API endpoints
├── pages/                   # HTML page routes
├── models/                  # SQLAlchemy ORM models + Pydantic schemas
├── services/
│   ├── file_parsers.py      # Safe file parsing with limits
│   ├── ingestion.py         # Text chunking for RAG
│   ├── vectorstore.py       # ChromaDB wrapper
│   ├── style_analyzer.py    # Style profile extraction
│   └── generator.py         # RAG + prompt assembly + generation
├── prompts/                 # Prompt templates for Claude
└── templates/               # Jinja2 HTML templates
data/                        # Runtime data (gitignored)
├── content_gen.db           # SQLite database
├── chroma/                  # ChromaDB vector store
└── uploads/                 # Temporary upload storage

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages