01Run locally
Prerequisites: Python 3.10+ and, for video assembly and YouTube look frames, ffmpeg (brew install ffmpeg on macOS, sudo apt install ffmpeg on Debian/Ubuntu).
git clone git@github.com:santoshimz/screenwriting-tool.git
cd screenwriting-tool
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt
cp .env.example .env # then edit .env — it is gitignored
python server.py
Open http://127.0.0.1:8765/.
| URL | What it is |
|---|---|
/ | Project library |
/edit?p=<project-id> | Screenplay editor |
/prepro?p=<project-id> | Storyboard wizard |
/feedback?p=<project-id> | Human still review & repair brief export |
/landing | Homepage for filmmakers & agent builders |
/guides/ARCHITECTURE.html | Architecture, code map & deploy guides |
/docs | FastAPI's interactive API explorer |
Which keys do you need? The writing tool needs none (and SCRIPTBOX_OFFLINE=1 walks the entire storyboard pipeline without spending credits). For live AI storyboards:
| Feature | Needs |
|---|---|
| Image generation, verification, story analysis, semantic planner, wardrobe analysis, look description | OPENAI_API_KEY (with image credits) |
| Fallback image provider | XAI_API_KEY (optional); Pollinations works without a key |
| Cast "Find images" | GOOGLE_CSE_API_KEY + GOOGLE_CSE_CX |
| Character voices (clone, design, TTS, voice changer) | ELEVENLABS_API_KEY (optional) |
| Motion clips (Seedance 2.5) | ARK_API_KEY (optional) |
| Make video / YouTube look frames | ffmpeg on PATH |
Other local commands
.venv/bin/python -m unittest discover -s tests # 379 tests, no network
./scripts/restart_storyboard_ui.sh # restart the server on :8765
Data lives in ./drafts/ by default. Set SCRIPTBOX_DATA_DIR to keep it elsewhere.
Story pack. Rules that only apply to one screenplay are generated locally for each project on upload and recompute. Optional hand overrides can sit alongside them inside the project's local data folder and win over the generated rules. Both merge over the shared playbooks at runtime and are never committed.
02Run locally in Docker
This is the same image Railway builds.
docker build -t scriptbox .
docker run --rm -p 8080:8080 \
--env-file .env \
-v "$PWD/drafts:/data" \
scriptbox
Open http://localhost:8080/. The .env file is passed at runtime and is never copied into the image (.dockerignore excludes it).
03Deploy to Railway
The repo already contains everything Railway needs:
| File | Role |
|---|---|
Dockerfile | Python 3.12 slim + ffmpeg; runs one Uvicorn worker on $PORT |
railway.json | Forces the Dockerfile builder, healthcheck on /healthz, restart on failure |
.dockerignore | Keeps .env, drafts/, output/, PDFs and .git out of the image |
Security: every storyboard endpoint can spend your OpenAI credits and read your scripts. On Railway the server refuses to start unlessSCRIPTBOX_AUTH_PASSWORD(12+ characters) is set. The browser will then show a login prompt; the username defaults toscriptbox.
3.1 Dashboard (GitHub deploy)
- Push the repo to GitHub (see §4 first).
- On railway.com: New Project → Deploy from GitHub repo →
santoshimz/screenwriting-tool. Railway readsrailway.jsonand builds the Dockerfile. Open the service → Variables and add:
Variable Value SCRIPTBOX_AUTH_PASSWORDA long random password, e.g. output of openssl rand -base64 24OPENAI_API_KEYYour OpenAI key SCRIPTBOX_AUTH_USEROptional (default scriptbox)XAI_API_KEY,GOOGLE_CSE_API_KEY,GOOGLE_CSE_CXOptional Any OPENAI_*/PREPRO_*tuning variable from.env.exampleOptional Mark the key and password variables as sealed so their values can no longer be viewed in the dashboard or API.
- Add a volume so projects survive redeploys: right-click the service (or use the command palette) → Attach volume, mount path
/data. The image already setsSCRIPTBOX_DATA_DIR=/data. Without a volume, every redeploy wipes all projects and generated images. - Settings → Networking → Generate Domain. Railway injects
PORT; the app listens on it automatically. - Deploy. When the healthcheck on
/healthzpasses, open the domain and sign in.
Subsequent pushes to the connected branch redeploy automatically.
3.2 CLI
brew install railway # or: npm i -g @railway/cli
railway login
railway init # create a project (or `railway link` to an existing one)
railway variables --set "SCRIPTBOX_AUTH_PASSWORD=$(openssl rand -base64 24)"
railway variables --set "OPENAI_API_KEY=sk-..." # paste in your terminal, never into a file in the repo
railway up # build and deploy from the current folder
railway volume add --mount-path /data
railway domain # generate a public URL
railway logs
railway up uploads the working directory but skips gitignored files, so .env, drafts/ and output/ are not sent. .dockerignore is a second barrier.
3.3 Verify the deployment
curl -s https://<your-domain>/healthz # {"status":"ok"}
curl -s -o /dev/null -w "%{http_code}\n" https://<your-domain>/api/drafts # 401
curl -s -u scriptbox:<password> https://<your-domain>/api/drafts # {"drafts":[...]}
3.4 Hosting limits to know about
| Topic | Detail |
|---|---|
| Replicas | Keep one replica and one worker. Generation locks and search/YouTube sessions are in process memory. |
| Long requests | A beat generation (plan + image + verify + repair) is one synchronous request and can take minutes. Railway's proxy caps request duration (15 minutes at the time of writing); generate scene by scene rather than whole films in one click. |
| Cursor fallback | The cursor image fallback needs a local Cursor agent and does nothing on a server. Set PREPRO_IMAGE_FALLBACK_CHAIN=openai,grok,pollinations on Railway. |
| YouTube look capture | YouTube often blocks data-centre IPs. If it fails on Railway, upload look stills directly (Step 4 → upload). |
| Costs | Every paid call is written to the audit ledger in /data/<project>/assets/audit/. Check provider dashboards for failed-request billing. |
| Motion (video) | Motion jobs run in a background thread and resume after a redeploy, so they are not bound by the proxy's request limit. Clips cost roughly $0.30/s at 720p ($0.134/s at 480p); each job stops at PREPRO_MOTION_MAX_USD_PER_RUN. Generated clips and voice samples live on the /data volume and need space (a 5 s 720p clip is a few MB). The Docker image already includes ffmpeg. |
| Seedance moderation | ModelArk can refuse first frames that show real people. Register authorised portraits in the BytePlus console and enter their asset IDs per character (Cast step) to enable the reference-mode fallback. |
| Backups | Railway volumes support backups; enable them, or periodically download /data. |
| Story pack | Optional. The image ships only generic playbooks. To use your private rules on Railway, put the JSON files in /data/_story_pack/ on the volume (for example through railway ssh); never add them to the repo. |
| Codex board import | Reads only from output/ inside the container, which is empty in the image; it is a local-only feature. |
04Keeping credentials out of GitHub
What protects you
| Layer | Protection |
|---|---|
| Code | No key is hardcoded. Every provider reads its key from the environment at call time (os.environ). Receipts and audit events never store keys. |
.gitignore | Ignores keys (.env, every .env.* except .env.example, *.pem, *.key, credential JSON), user data (drafts/, data/, output/, static/fixtures/), screenplay files (*.pdf, *.fdx, *.fountain, *.celtx, *.highland, *.doc(x), *.rtf), all images, video and audio (voice samples are biometric data) except docs/readme-assets/, and the local-only deprecated/ folder. |
scripts/check_secrets.sh | Run automatically by scripts/push.sh before committing. Fails if staged changes include any of the file types above (even when force-added), a key-shaped string (sk-…, sk_…, xai-…, AKIA…, AIza…, private keys) or the literal value of any *KEY*/*SECRET*/*TOKEN*/*PASSWORD* variable from your local .env. |
.dockerignore | Keeps .env and private data out of container images. |
| Story pack | Screenplay names and rules live in the gitignored drafts/_story_pack/; the guard also blocks staged lines containing its private_terms. |
| Railway | Secrets live in (sealed) service variables, not in the repo. |
Before every push
git check-ignore -v .env # must print a .gitignore rule
git add -A
./scripts/check_secrets.sh # must exit silently (local-only, gitignored)
git status # eyeball the file list
Or simply use ./scripts/push.sh "message", which does the check for you and unstages everything if it fails.
To make the check run on every git commit in your clone (optional, local only):
ln -s ../../scripts/check_secrets.sh .git/hooks/pre-commit
Also enable GitHub → Settings → Code security → Secret scanning → Push protection on the repository for a server-side safety net.
If a key ever reaches GitHub
Deleting the file is not enough — the key stays in history and forks. Revoke the key immediately in the provider dashboard (OpenAI: API keys → Revoke), create a new one, update .env and Railway, and then clean history if needed.
05Configuration reference
All variables are optional unless noted. See .env.example for the full list.
| Variable | Default | Purpose |
|---|---|---|
SCRIPTBOX_AUTH_PASSWORD | — | Enables the login gate; required when hosted |
SCRIPTBOX_AUTH_USER | scriptbox | Login username |
SCRIPTBOX_REQUIRE_AUTH | off | Force the gate outside Railway |
SCRIPTBOX_DATA_DIR | ./drafts (/data in Docker) | Where all project data lives |
SCRIPTBOX_STORY_PACK_DIR | <data dir>/_story_pack | Private screenplay-specific playbook overrides |
SCRIPTBOX_CORS_ORIGINS | — | Comma-separated cross-origin allow-list |
HOST / PORT | 127.0.0.1 / 8765 | python server.py bind address |
SCRIPTBOX_RELOAD | 1 | Auto-reload for python server.py |
OPENAI_API_KEY | — | OpenAI images, chat, vision |
OPENAI_IMAGE_MODEL | gpt-image-2.5-sunburst | Image model |
OPENAI_VERIFY_MODEL | gpt-4o-mini | Vision verifier (also default for look/summary models) |
OPENAI_STORYBOARD_PLANNER_MODEL | gpt-5.6-terra | Semantic planner model |
PREPRO_LLM_STORYBOARD_PLANNER | auto | 0 for deterministic-only planning |
PREPRO_DEFAULT_IMAGE_PROVIDER | auto | auto, openai, grok, pollinations, cursor |
PREPRO_IMAGE_FALLBACK_CHAIN | openai,grok,pollinations,cursor | Provider order for auto |
PREPRO_MAX_IMAGE_REFS | 5 | Reference images per request (max 10) |
PREPRO_MAX_AUTOMATIC_ATTEMPTS | 2 | Image attempts per beat including repair (max 5) |
PREPRO_LOOK_REFS_AS_IMAGES | off | Also send movie-look stills as image inputs |
XAI_API_KEY | — | Grok Imagine fallback |
GOOGLE_CSE_API_KEY, GOOGLE_CSE_CX | — | Cast likeness search |
ELEVENLABS_API_KEY | — | Character voices: clone, design, text-to-speech, voice changer |
ELEVENLABS_TTS_MODEL / ELEVENLABS_STS_MODEL | eleven_v3 / eleven_multilingual_sts_v2 | Speech and voice-changer models |
ELEVENLABS_USD_PER_1K_CHARS | estimate | Your plan's rate; makes voice costs exact in the ledger |
ARK_API_KEY | — | Seedance 2.5 on BytePlus ModelArk (motion clips) |
ARK_BASE_URL / SEEDANCE_MODEL | ap-southeast / dreamina-seedance-2-5-260628 | ModelArk region and model |
SEEDANCE_USD_PER_M_TOKENS | 10.70 | Rate applied to returned tokens |
PREPRO_MOTION_MAX_USD_PER_RUN | 25 | Hard spend cap per motion job |
PREPRO_MOTION_POLL_S / PREPRO_MOTION_TIMEOUT_S | 5 / 1800 | Video task polling interval and timeout |
OPENAI_CLEAN_PLATE_MODEL | image model | Masked edit that removes the subtitle band before motion |
SCRIPTBOX_OFFLINE | off | 1 for a credit-free dry run: local placeholder stills, no model or third-party calls |
SCRIPTBOX_EXECUTION_DUMPS | off | 1 dumps every storyboard stage to execution_dumps/ (local debugging only; never on a hosted server) |