AI Interactive Fiction Generator: Storytelling with Tangible Consequences
This narrative engine uses OpenAI’s GPT models to generate dynamic, choice-driven stories. By selecting a genre and literary style, users trigger the system to construct original plots, characters, and branching endings in real time. The experience moves away from pre-written scripts and recycled tropes, ensuring every playthrough is unique.
Before the first scene begins, the backend generates a comprehensive story map. This structure is rendered in-browser via Mermaid.js, allowing you to visualize the branching paths and potential conclusions before making your first move. To deepen the immersion, every session also creates a fictional author and a book title specifically tailored to your chosen style.
How It Works
Dynamic Story Assembly The AI generates opening scenes, rising actions, and resolutions based on your selected mode—such as Eastern fantasy or Western arcana. Every request produces fresh prose through live inference rather than pulling from a static database.
Randomized Authorship When you start a game, the system assigns a plausible pen name and title. This turns a technical demo into a more cohesive experience, like picking a unique paperback off a shelf.
Visible Narrative Mapping After the initial call, the backend provides a JSON-based story structure. The frontend then converts this into a flowchart. You can see the narrative's potential destination, even if the path to get there remains a mystery.
Meaningful Branching Every choice you make forks the narrative. The AI tracks your previous decisions and steers the story toward one of the pre-defined endings on the map. This ensures the narrative structure remains coherent and your choices have real weight.
Adaptive Literary Styles The model receives specific style directives for every game. Whether it is Gothic horror or Wuxia, the prose adjusts its tone and vocabulary without requiring manual prompt tuning from the user.
Tech Stack
| Category | Technology |
|---|---|
| Backend | FastAPI (Python), SQLAlchemy & SQLModel (ORM), Redis (Caching & SSE queues) |
| Frontend | Vanilla JavaScript, Tailwind CSS, Mermaid.js (Diagrams) |
| AI | OpenAI GPT models |
| Deployment | Docker & Docker Compose |
Local Deployment
Ensure you have Docker and Docker Compose installed. Clone the repository and follow these steps:
cp .env.example .env (macOS/Linux) or copy .env.example .env (Windows)..env file.docker-compose up --build.npm run build in a separate terminal.http://localhost:1888.API Endpoints
| Method | Path | Description |
|---|---|---|
POST |
/api/v1/game |
Initializes a new session; returns the opening scene and story map. |
POST |
/api/v1/game/{game_id}/choice |
Submits a player decision and retrieves the subsequent scene. |
GET |
/api/v1/game/{game_id} |
Retrieves the current state of an ongoing game. |
DELETE |
/api/v1/game/{game_id} |
Terminates the current session. |
The Initialization Process
POST request to /api/v1/game.generate_initial_scene() function.game_id, scene text, and story map back to the frontend.
openAgent: Open Source Enterprise AI Platform With RAG and Agent Workflows
Fast RAG: Deploy a Private Hybrid Search RAG Stack Locally
Feiniao VPN: Free Trial, 4K Streaming & Unblock Netflix (2026 Guide)
LiveMCPBench: Benchmark AI Agents on Real-World MCP Tool Tasks
ntopng Network Traffic Monitor: Identify Bandwidth Consumption and Network Bottlenecks
NetBird Setup Guide: Building a WireGuard Mesh VPN
Zettlr Setup and Developer Guide (macOS, Windows, Linux)
QSV: Slice, Query, and Clean Massive CSV Files with High Performance
MusicFree: A Modular Open-Source Music Player for Android and HarmonyOS
Turn eBooks & PDFs into Audio with Abogen – Fast TTS Tool
PyVideoTrans: Open-Source Video Translation & Dubbing Tool
Shendeng VPN: Two Modes to Speed Up Games and Chinese Apps