From e397d13711c7457d693eda2f039d554c1a4f0a70 Mon Sep 17 00:00:00 2001 From: Space-Banane Date: Fri, 26 Jun 2026 15:44:50 +0200 Subject: [PATCH] Add README Co-Authored-By: Claude Sonnet 4.6 --- README.md | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..77c1997 --- /dev/null +++ b/README.md @@ -0,0 +1,117 @@ +# prompt-gen + +A local web app for building and reusing prompt templates. Write a prompt once with `{{variable}}` placeholders, save it as a preset, then fill in the fields to generate new prompts on demand. + +![prompt-gen screenshot](https://via.placeholder.com/800x400?text=prompt-gen) + +## Features + +- **Presets** — save any number of named templates with descriptions +- **Live variable filling** — input fields are generated automatically from `{{variable_name}}` placeholders in your template +- **AI rewrite** — send the filled prompt to GPT for improvement with one click +- **Persistent storage** — everything saved to a local `settings.json`, no database + +## Quick start (Docker) + +```bash +docker compose up --build +``` + +Open [http://localhost:8000](http://localhost:8000). + +Data persists in a Docker named volume. To back it up: + +```bash +docker compose cp app:/app/data/settings.json ./settings.json +``` + +## Quick start (local dev) + +**Requirements:** Python 3.11+, Node 18+ + +```bash +# Install dependencies +pip install -r requirements.txt +cd frontend && npm install && npm run build && cd .. + +# Run +uvicorn backend.main:app --host 127.0.0.1 --port 8001 +``` + +Open [http://localhost:8001](http://localhost:8001). + +### Hot-reload dev mode + +```bash +# Terminal 1 — backend +uvicorn backend.main:app --port 8001 --reload + +# Terminal 2 — frontend +cd frontend && npm run dev +``` + +Frontend dev server runs on [http://localhost:5173](http://localhost:5173) and proxies `/api` to port 8001. + +## AI rewrite + +Click the ⚙ icon and enter your OpenAI API key. The key is stored in `settings.json` and never sent to the frontend. Once set, the **✦ Rewrite with AI** button becomes active in the prompt runner. + +The model defaults to `gpt-4.1`. Override it with the `OPENAI_MODEL` environment variable: + +```bash +OPENAI_MODEL=gpt-4o uvicorn backend.main:app --port 8001 +# or in docker-compose.yml under environment: +``` + +## Template syntax + +Use `{{variable_name}}` anywhere in your template. Variable names must start with a letter or underscore and contain only letters, numbers, and underscores. + +``` +Resolve {{issue_id}} in {{repo}}. Create the PR as {{author}}. +``` + +Duplicate variable names collapse to a single input field. Variables appear in the order they first appear in the template. + +## Configuration + +All settings are stored in `settings.json` at the project root (or at `$SETTINGS_PATH` when set). + +```json +{ + "openai_api_key": "sk-...", + "presets": [ + { + "id": "a1b2c3d4", + "name": "My template", + "description": "optional", + "template": "Resolve {{issue_id}} in {{repo}}.", + "variables": ["issue_id", "repo"], + "created_at": "2026-06-26T10:00:00Z", + "updated_at": "2026-06-26T10:00:00Z" + } + ] +} +``` + +## API + +The FastAPI backend exposes a simple REST API at `/api`. + +| Method | Path | Description | +|--------|------|-------------| +| `GET` | `/api/presets` | List all presets | +| `POST` | `/api/presets` | Create a preset | +| `PUT` | `/api/presets/{id}` | Update a preset | +| `DELETE` | `/api/presets/{id}` | Delete a preset | +| `GET` | `/api/settings` | Check if OpenAI key is set | +| `POST` | `/api/settings` | Save OpenAI API key | +| `POST` | `/api/rewrite` | Rewrite a prompt with AI | + +Interactive docs available at [http://localhost:8001/docs](http://localhost:8001/docs) when running locally. + +## Stack + +- **Frontend** — React 18, Tailwind CSS v3, Vite +- **Backend** — FastAPI, uvicorn +- **Storage** — `settings.json` (flat file, no database)