A modern, full-stack screenplay writing application with real-time collaboration, AI assistance, and comprehensive breakdown tools.
Trelby Core is a comprehensive screenplay writing platform consisting of:
- Backend API: FastAPI-based REST API server for screenplay operations
- Frontend: Next.js React application with advanced editing capabilities
- AI Integration: Multi-provider LLM support for screenplay generation and translation
- Breakdown Tools: Advanced screenplay breakdown and production planning
- Modern web-based screenplay editor with proper industry formatting
- Real-time auto-save and version control
- User authentication and script management
- Multi-format export (PDF, Fountain, Final Draft FDX, HTML)
- AI-Powered Translation: Multi-language screenplay translation
- Screenplay Breakdown: Automatic and manual element extraction for production planning
- Scene Navigation: Smart scene detection and quick navigation
- Character Management: Comprehensive character tracking and metadata
- Import Support: PDF, FDX, and plain text import capabilities
- Comprehensive breakdown reports with filtering
- Production summary generation
- Element categorization and highlighting
- Export capabilities for production teams
trelby-core/
βββ src/ # Backend API server (FastAPI)
β βββ app/ # Application logic
β βββ requirements.txt # Python dependencies
β βββ dockerfile # Container configuration
βββ sc_app/ # Frontend (Next.js + React)
β βββ components/ # React components
β βββ lib/ # Utilities and helpers
β βββ services/ # API services
β βββ store/ # State management (Zustand)
β βββ package.json # Node.js dependencies
βββ README.md # This file
- Python 3.8+ with pip
- Node.js 16+ with npm/yarn/bun
- PostgreSQL 13+
- Docker (optional, for containerized deployment)
git clone https://github.com/yourusername/trelby-core.git
cd trelby-corecd src
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure environment variables
cp .env.example .env
# Edit .env with your configuration (see Environment Variables section)
# Initialize the database
python -m app.db.init_db
# Start the development server
uvicorn app.main:app --reloadThe API will be available at http://localhost:8000 with documentation at http://localhost:8000/api/docs
cd sc_app
# Install dependencies
npm install
# or: bun install / yarn install
# Configure environment variables
cp .env.local.example .env.local
# Edit .env.local with your configuration
# Start development server
npm run devThe frontend will be available at http://localhost:3000
Create a .env file in the src/ directory:
# Security
SECRET_KEY=your-secret-key-here-change-this-in-production
# Database Configuration
DB_NAME=trelby
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=localhost
DB_PORT=5432
# CORS Origins (comma-separated URLs)
BACKEND_CORS_ORIGINS=http://localhost:3000,http://localhost:3001,https://your-domain.com
# AI Service API Keys (Optional)
OPENAI_API_KEY=your-openai-key
ANTHROPIC_API_KEY=your-anthropic-key
GEMINI_API_KEY=your-gemini-key
GROQ_API_KEY=your-groq-key
# Babel LLM Service Configuration
BABEL_LLM_ENABLED=true
BABEL_LLM_API_URL=http://localhost:8001
BABEL_LLM_TIMEOUT=30
BABEL_LLM_MAX_RETRIES=3Create a .env.local file in the sc_app/ directory:
# Backend API URL
NEXT_PUBLIC_API_URL=http://localhost:8000
# Environment
NODE_ENV=development# Using OpenSSL
openssl rand -hex 32
# Using Python
python -c "import secrets; print(secrets.token_hex(32))"For production, update BACKEND_CORS_ORIGINS to include only your frontend domains:
BACKEND_CORS_ORIGINS=https://your-frontend-domain.com,https://your-admin-domain.com# Build and run with Docker Compose
docker-compose up --build
# Or build individual containers
docker build -t trelby-backend ./src
docker build -t trelby-frontend ./sc_appcd src
# Install dependencies
pip install -r requirements.txt
# Set production environment variables
export SECRET_KEY="your-production-secret-key"
export DB_HOST="your-production-db-host"
# ... other production variables
# Run with Gunicorn
gunicorn app.main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000cd sc_app
# Install dependencies
npm install
# Set production environment variables
export NEXT_PUBLIC_API_URL="https://your-api-domain.com"
# Build for production
npm run build
# Start production server
npm start# Backend tests
cd src
pytest
# Frontend tests
cd sc_app
npm testThis project uses:
- ESLint & Prettier for frontend code formatting
- Black & isort for backend code formatting
- TypeScript for type safety
- Proper logging instead of console statements in production
- Backend: FastAPI with auto-reload for development
- Frontend: Next.js with hot reloading
- Database: PostgreSQL with SQLAlchemy ORM
- State Management: Zustand for client-side state
- Styling: Tailwind CSS with custom components
Once the backend is running, visit:
- Interactive Docs:
http://localhost:8000/api/docs - ReDoc:
http://localhost:8000/api/redoc - OpenAPI JSON:
http://localhost:8000/api/openapi.json
- OpenAI (GPT-4, GPT-3.5)
- Anthropic (Claude)
- Google (Gemini)
- Groq (Open-source models)
- Custom BabelLLM (Self-hosted)
- UI element translation
- Full screenplay translation
- Batch processing with progress tracking
- Error handling and retry mechanisms
- Database Connection: Ensure PostgreSQL is running and credentials are correct
- CORS Errors: Update
BACKEND_CORS_ORIGINSto include your frontend URL - Import Issues: Check file format support and file size limits
- AI Features: Verify API keys are set correctly
- Database: Use connection pooling for production
- Frontend: Enable caching for static assets
- Logging: Use appropriate log levels for production
- Memory: Monitor memory usage with large screenplays
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow existing code style and conventions
- Add tests for new features
- Update documentation as needed
- Use proper TypeScript types
- Implement proper error handling
This project is licensed under the MIT License - see the LICENSE file for details.
- Built on the foundation of the original Trelby screenplay editor
- Uses industry-standard screenplay formatting conventions
- Inspired by modern web development best practices
For questions, issues, or contributions:
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Available in the
/docsdirectory
Trelby Core - Professional screenplay writing for the modern age. π¬β¨