Epic Saga Builder is a collaborative storytelling platform where players and AI work together to create immersive fantasy adventures. The platform combines human creativity with AI-powered narration to create unique, dynamic stories that evolve based on player actions.
You can visit and give the project a try here: (https://eventfy.com)
- Collaborative Storytelling: Multiple players can join stories and shape the narrative together
- AI-Powered Narration: Advanced language models provide dynamic responses to player actions
- Rich Character Creation: Create detailed characters with unique backgrounds and abilities
- Real-time Updates: See story developments as they happen
- Responsive Design: Works seamlessly on desktop and mobile devices
Epic Saga Builder follows a modern web application architecture with these key components:
-
Frontend Layer
- React-based SPA with TypeScript
- Real-time updates using Supabase Realtime
- Responsive UI with Tailwind CSS
- Client-side routing with React Router
-
Backend Services
- Supabase for database and authentication
- LLM service (GPT4All locally or a SaaS LLM like OpenAI, DeepSeek etc in production)
- Real-time messaging system
-
Data Storage
- PostgreSQL database (managed by Supabase)
- Row Level Security for data protection
- Real-time subscriptions for live updates
graph TD
A[Web Client] --> B[React Frontend]
B --> C[Supabase Client]
B --> D[LLM Client]
C --> E[Supabase Backend]
D --> F[LLM Service]
E --> G[PostgreSQL]
E --> H[Auth Service]
E --> I[Realtime Service]
- User actions trigger state changes in React components
- Data mutations are sent to Supabase
- Real-time subscriptions notify all connected clients
- LLM service processes story actions and generates narrations
- Updates are broadcasted to all story participants
src/App.tsx- Main application component and routing setupsrc/contexts/AuthContext.tsx- Authentication context providersrc/lib/supabase.ts- Supabase client configuration
src/lib/session-manager.ts- Manages story sessions and player actionssrc/lib/story-service.ts- Story-related database operationssrc/lib/character-service.ts- Character management operations
src/lib/llm.ts- LLM service integrationsrc/lib/llm-factory.ts- Factory for LLM service creationsrc/lib/llm-prompts.ts- System prompts and templatessrc/lib/mock-llm.ts- Mock LLM for development
src/components/StoryConsole.tsx- Main story interaction interfacesrc/components/StoryMessage.tsx- Message display componentsrc/components/CharacterList.tsx- Character roster displaysrc/components/AuthModal.tsx- Authentication interface
The database structure is defined in migration files under supabase/migrations/:
- Users table: Player accounts and profiles
- Stories table: Story metadata and settings
- Characters table: Character data and relationships
- Story Messages table: Story progression and interactions
- Node.js 18+ and npm
- GPT4All with a LLM model (tested with "Llama 3.2 3B Instruct") or a SaaS LLM like Open AI, DeepSeek, Google AI etc
- Supabase account (free tier works fine)
- Git (optional, for version control)
- Download GPT4All from https://gpt4all.io
- Install and run GPT4All
- Download the "Llama 3.2 3B Instruct" model
- Enable "Local API Server" in settings and set port to 4891
# Clone repository
git clone https://github.com/pburglin/EpicSagaBuilder
cd EpicSagaBuilder
# Install dependencies
npm install
# Copy environment file
cp .env.example .envEdit .env file:
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
# Set VITE_USE_MOCK_LLM to false to integrate with a LLM API
VITE_USE_MOCK_LLM=true
VITE_LLM_API_ENDPOINT=http://localhost:4891/v1/chat/completions
VITE_LLM_MAX_TOKENS=128
VITE_LLM_MODEL_NAME="Llama 3.2 3B Instruct"
VITE_LLM_MAX_HISTORY=10
VITE_LLM_SYSTEM_PROMPT="You are a skilled RPG game master..."- Create a new Supabase project
- Click "Connect to Supabase" button in the app
- Run migrations from
supabase/migrationsfolder
npm run devVisit http://localhost:5173 to see the app running.
- Account with a cloud platform like Netlify or AWS (tested with Netlify free tier)
- Domain name (optional, but recommended)
Next steps assume AWS. It is easier to set it up with Netlify.
- Create an S3 bucket for static hosting
- Configure CloudFront distribution
- Setup Route53 if using custom domain
- Create account with a SaaS LLM like OpenAI API, DeekSeek, Google AI etc
- Generate API key
- Update environment variables:
VITE_LLM_API_ENDPOINT=https://api.openai.com/v1/chat/completions
VITE_LLM_API_KEY=your_openai_api_key
VITE_LLM_MODEL_NAME=gpt-3.5-turbo# Build project
npm run build
# Deploy to S3
aws s3 sync dist/ s3://your-bucket-name
# Invalidate CloudFront cache
aws cloudfront create-invalidation --distribution-id YOUR_DIST_ID --paths "/*"- Create new Supabase project for production
- Update environment variables with production credentials
- Run migrations on production database
For local development with GPT4All, you'll need to temporarily disable CORS in your browser:
- Open Safari / Settings / Advanced, check "Show features for web developers"
- Open Develop / Developer Settings, under Security check "Disable cross-origin restrictions"
- Open Safari / Settings for localhost, uncheck "Enable content blockers"
- Create a shortcut with target:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir="%LOCALAPPDATA%\Google\Chrome\User Data\Testing Profile"
- Type
about:configin address bar - Set
security.fileuri.strict_origin_policytofalse
For production deployment:
- Use a SaaS LLM like OpenAI's API instead of a local LLM
- Implement proper authentication for API calls
- Setup rate limiting and usage monitoring
- Configure proper CORS headers in your API gateway
- Node.js 18+
- GPT4All with a LLM model (tested with "Llama 3.2 3B Instruct")
- Supabase (free tier)
- Modern web browser
- OpenAI API account
- AWS services:
- S3
- CloudFront
- Route53 (optional)
- ACM for SSL (optional)
- Supabase (production tier recommended)
For issues and feature requests, please create an issue in the GitHub repository (https://github.com/pburglin/EpicSagaBuilder).
This project is licensed under the GNU AFFERO GENERAL PUBLIC LICENSE - see the LICENSE file for details.


