the-fork
README
The Fork — hero banner

The Fork

One decision split your life in half. This app lets you talk to the version of you who took the other path.

This README is brief where it should be, thorough where it must be. Read it like you're about to open a door you can't close — clearly, without hand-holding, with a map and a few emergency exits.


Quick orientation — what it is (and what it isn't)

Trigger warning: conversations can surface uncomfortable material. If you're in crisis, stop now and seek help.


Demo

The Fork app UI - chat interface screenshot 1
The Fork app UI - chat interface screenshot 2

How it works (high level)

  1. You provide a fork statement — a single defining decision and the path you didn't take.
  2. You pick intensity: mild, savage, or brutal.
  3. The frontend posts your session (sessionId + messages + forkStatement + intensity) to the backend.
  4. The backend composes a system prompt (the "Other You" persona + safety checks + style mirroring), calls the OpenRouter API, and returns a reply.
  5. Conversations are ephemeral — nothing is persisted for user experience. (Mongo exists in the template but is optional.)

Tech stack & requirements

Quick Start — local development (recommended)

Two short paths below. Copy .env.example → .env, add your OPENROUTER_API_KEY for chat to work.

A. Backend (local)

# from repo root
cd backend
# copy template and edit
cp .env.example .env
# edit .env -> set OPENROUTER_API_KEY and MONGO_URL/DB_NAME if you use mongo
# install Python deps
python -m pip install -r requirements.txt
# run tests
pytest
# run server
uvicorn server:app --reload
# Open the API at http://localhost:8000/api/
# Swagger UI: http://localhost:8000/api/docs

B. Frontend (local)

cd frontend
# copy template and edit
cp .env.example .env
# ensure REACT_APP_BACKEND_URL points to your backend (http://localhost:8000)
# install
yarn install
# run E2E tests
yarn test:e2e
# start dev server
yarn start
# App at http://localhost:3000

Quick Start — Docker Compose (one-command)

Docker Compose spins up mongo (optional), backend, and frontend dev server.

# from repo root
docker-compose up --build
# Frontend: http://localhost:3000
# Backend API: http://localhost:8000
# API docs: http://localhost:8000/api/docs

Stop and remove services:

docker-compose down
# To remove volumes (mongo data)
docker-compose down -v

View logs:

docker-compose logs -f backend
docker-compose logs -f frontend
docker-compose logs -f mongo

Backend — API & configuration (practical)

Core file: backend/server.py — the chat endpoint and safety logic live here.

Main endpoint:

Environment (backend/.env.example):

MONGO_URL="mongodb://localhost:27017"
DB_NAME="test_database"
CORS_ORIGINS="*"
OPENROUTER_API_KEY=your_openrouter_key_here # REQUIRED for chat to work
OPENROUTER_MODEL=openai/gpt-4o-mini # optional, defaults in code
SERVER_HOST="0.0.0.0"
SERVER_PORT=8000

Example curl (chat):

curl -X POST http://localhost:8000/api/chat \
-H "Content-Type: application/json" \
-d '{
"forkStatement": "I chose engineering instead of art.",
"intensity": "savage",
"messages": [
{"role": "user", "content": "Do you regret it?"}
],
"sessionId": "550e8400-e29b-41d4-a716-446655440000"
}'

Error cases:

Safety summary (what the server checks):

LLM integration:

Frontend — dev, build, test

Key scripts (frontend/package.json):

Environment (frontend/.env.example):

REACT_APP_BACKEND_URL=http://localhost:8000
WDS_SOCKET_PORT=443
ENABLE_HEALTH_CHECK=false

Development tips:

Docker notes & ports

Production considerations:

Testing & CI

CI:

Contributing — short, direct, practical

If you're about to change the voice, rewind and think twice. The persona is deliberate and documented in server.py. That said, we welcome improvements.

Workflow:

  1. Fork & clone
  2. Create a branch: git checkout -b feature/your-feature
  3. Run tests (backend & frontend)
  4. Add tests for new behavior
  5. Keep changes scoped; document changes in ENHANCEMENT_SUMMARY.md or docs
  6. Open a PR with a clear description of intent and design/ethics impacts

Code style:

Troubleshooting (common)

Backend won't start:

Frontend won't start:

Mongo connection:

CORS:

Safety & ethics (read this)

The app intentionally pushes hard at lived choices. The server implements:

If you plan to use this beyond private experiments, get an ethics review, add moderation, and be explicit about limitations to users.

Crisis resources (if you're reading and need them):

Where to look next (docs & files)

License & maintainers

If you came here to ask "what if?", do it honestly. The Fork won't make it gentle for you; it will make it real. If you're hacking on it, keep things safe, include tests, and respect the persona rules baked into server.py.

Open the door carefully.