SBScriptBox docs

Operations guide

Running and deploying ScriptBox

For the person who installs ScriptBox. Filmmakers use the browser after this is running; the filmmaker guide is on the homepage. This page is how to run it on your machine, in Docker, and on Railway — and how the repo keeps API keys, screenplays, and private story rules out of GitHub.

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/.

URLWhat 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
/landingHomepage for filmmakers & agent builders
/guides/ARCHITECTURE.htmlArchitecture, code map & deploy guides
/docsFastAPI'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:

FeatureNeeds
Image generation, verification, story analysis, semantic planner, wardrobe analysis, look descriptionOPENAI_API_KEY (with image credits)
Fallback image providerXAI_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 framesffmpeg 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:

FileRole
DockerfilePython 3.12 slim + ffmpeg; runs one Uvicorn worker on $PORT
railway.jsonForces the Dockerfile builder, healthcheck on /healthz, restart on failure
.dockerignoreKeeps .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 unless SCRIPTBOX_AUTH_PASSWORD (12+ characters) is set. The browser will then show a login prompt; the username defaults to scriptbox.

3.1 Dashboard (GitHub deploy)

  1. Push the repo to GitHub (see §4 first).
  2. On railway.com: New Project → Deploy from GitHub repo → santoshimz/screenwriting-tool. Railway reads railway.json and builds the Dockerfile.
  3. Open the service → Variables and add:

    VariableValue
    SCRIPTBOX_AUTH_PASSWORDA long random password, e.g. output of openssl rand -base64 24
    OPENAI_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.

  1. Add a volume so projects survive redeploys: right-click the service (or use the command palette) → Attach volume, mount path /data. The image already sets SCRIPTBOX_DATA_DIR=/data. Without a volume, every redeploy wipes all projects and generated images.
  2. Settings → Networking → Generate Domain. Railway injects PORT; the app listens on it automatically.
  3. Deploy. When the healthcheck on /healthz passes, 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

TopicDetail
ReplicasKeep one replica and one worker. Generation locks and search/YouTube sessions are in process memory.
Long requestsA 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 fallbackThe 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 captureYouTube often blocks data-centre IPs. If it fails on Railway, upload look stills directly (Step 4 → upload).
CostsEvery 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 moderationModelArk 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.
BackupsRailway volumes support backups; enable them, or periodically download /data.
Story packOptional. 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 importReads 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

LayerProtection
CodeNo key is hardcoded. Every provider reads its key from the environment at call time (os.environ). Receipts and audit events never store keys.
.gitignoreIgnores 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.shRun 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.
.dockerignoreKeeps .env and private data out of container images.
Story packScreenplay names and rules live in the gitignored drafts/_story_pack/; the guard also blocks staged lines containing its private_terms.
RailwaySecrets 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.

VariableDefaultPurpose
SCRIPTBOX_AUTH_PASSWORD—Enables the login gate; required when hosted
SCRIPTBOX_AUTH_USERscriptboxLogin username
SCRIPTBOX_REQUIRE_AUTHoffForce the gate outside Railway
SCRIPTBOX_DATA_DIR./drafts (/data in Docker)Where all project data lives
SCRIPTBOX_STORY_PACK_DIR<data dir>/_story_packPrivate screenplay-specific playbook overrides
SCRIPTBOX_CORS_ORIGINS—Comma-separated cross-origin allow-list
HOST / PORT127.0.0.1 / 8765python server.py bind address
SCRIPTBOX_RELOAD1Auto-reload for python server.py
OPENAI_API_KEY—OpenAI images, chat, vision
OPENAI_IMAGE_MODELgpt-image-2.5-sunburstImage model
OPENAI_VERIFY_MODELgpt-4o-miniVision verifier (also default for look/summary models)
OPENAI_STORYBOARD_PLANNER_MODELgpt-5.6-terraSemantic planner model
PREPRO_LLM_STORYBOARD_PLANNERauto0 for deterministic-only planning
PREPRO_DEFAULT_IMAGE_PROVIDERautoauto, openai, grok, pollinations, cursor
PREPRO_IMAGE_FALLBACK_CHAINopenai,grok,pollinations,cursorProvider order for auto
PREPRO_MAX_IMAGE_REFS5Reference images per request (max 10)
PREPRO_MAX_AUTOMATIC_ATTEMPTS2Image attempts per beat including repair (max 5)
PREPRO_LOOK_REFS_AS_IMAGESoffAlso 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_MODELeleven_v3 / eleven_multilingual_sts_v2Speech and voice-changer models
ELEVENLABS_USD_PER_1K_CHARSestimateYour 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_MODELap-southeast / dreamina-seedance-2-5-260628ModelArk region and model
SEEDANCE_USD_PER_M_TOKENS10.70Rate applied to returned tokens
PREPRO_MOTION_MAX_USD_PER_RUN25Hard spend cap per motion job
PREPRO_MOTION_POLL_S / PREPRO_MOTION_TIMEOUT_S5 / 1800Video task polling interval and timeout
OPENAI_CLEAN_PLATE_MODELimage modelMasked edit that removes the subtitle band before motion
SCRIPTBOX_OFFLINEoff1 for a credit-free dry run: local placeholder stills, no model or third-party calls
SCRIPTBOX_EXECUTION_DUMPSoff1 dumps every storyboard stage to execution_dumps/ (local debugging only; never on a hosted server)