This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine
What I Built
PHANTOM TALES is an immersive, gothic horror storytelling engine and interactive branching gamebook inspired by classical horror literature (Mary Shelley, Edgar Allan Poe, Shirley Jackson, and H.P. Lovecraft).
The theme "Ghost in the Machine" challenges us to consider what happens when autonomous models generate mystery, dread, and atmospheric folklore. Most AI creative writing tools produce sterile, generic chat responses without mood, pacing, or consequence.
I built PHANTOM TALES to turn the machine itself into a haunted storyteller. It features:
Summon Nightmare: An atmospheric conjuration altar where readers craft gothic tales with specific dread intensities, archetypes, and settings (from Victorian asylums to sunken crypts).
Daily Nightmare: An automated fresh short horror story awakened every 24 hours.
Interactive Branching Chambers: Decision-driven gamebook experiences where each chapter presents 3 high-stakes moral choices that spawn distinct branches and alternate climaxes.
Illustrated Gothic Reader: A distraction-free, 820px centered reading sanctum with candlelight mode, serif typography, reading progress tracking, and contextual inline 16:9 illustrations placed between key paragraphs.
Grimoire Familiar (AI Assistant): A collapsible companion that provides chapter summaries, character scrutiny, hidden clues, and symbol deconstructions without spoiling upcoming twists.
Procedural Soundscapes: 9 ambient audio synthesisers (howling wind, creaking timbers, distant footsteps, sub-bass drones) generated entirely in-browser via the Web Audio API with zero autoplay.
Demo
Youtube: https://youtu.be/C-Z9PpEO8XM
Code
- Backend: FastAPI (Python 3.11+), SQLAlchemy Async + SQLite (aiosqlite), Pydantic v2.
- Frontend: React 19, TypeScript, Vite, Tailwind CSS v4, Framer Motion, Lucide Icons.
- Test Suite: 29 automated pytest suites covering providers, cascade deletions, and API endpoints.
How I Built It
- Dual AI Engine: Open-Weight Gemma 4
At the heart of PHANTOM TALES is Google's open-weight model family, Gemma 4:
Hosted Cloud Mode: Powered by gemma-4-26b-a4b-it through the Google GenAI SDK for high-speed cloud generation.
Local Offline Inference: Powered by local Ollama running gemma4 on http://localhost:11434.
A backend environment switch (USE_ONLINE_MODEL=true|false) seamlessly changes the inference pipeline across both providers without altering a single prompt, story model, or branching state.
- Contextual Scene Illustration Engine
Gemma 4 does not generate pixels—it acts as a visual art director. When a story is inscribed:
Gemma establishes a structured Visual Bible specifying protagonist appearance, historical era, color palettes (e.g., bruised violet, oxidized copper, amber lantern glow), and lighting style (chiaroscuro).
It analyzes the narrative paragraphs and extracts key moments, returning structured JSON with paragraph anchor indices, scene titles, captions, and detailed 16:9 cinematic prompts.
The image provider runs independently: if an image generator (like Google Imagen) is configured, it renders the scene; otherwise, it deterministically maps the tone to high-definition bundled gothic horror artwork.
Why Does Open Innovation Matter?
Why Does Open Innovation Matter?
Open innovation is essential for creative and genre-specific AI applications:
Local Privacy & Censorship Resistance: Traditional closed chat APIs frequently over-censor gothic and suspenseful creative writing because they conflate atmospheric fiction with harmful content. Open-weight models like Gemma 4, running locally on Ollama, give authors complete creative sovereignty without their personal manuscripts leaving their machine.
Deterministic, Inspectable Architecture: Closed APIs are opaque black boxes subject to silent prompt rewrites and breaking version shifts. With open weights and local inference, the narrative rules, temperature controls, and system instructions remain reproducible forever.
Hardware Accessibility: Open models allow students, solo creators, and indie developers to build rich, branching games on consumer hardware without prohibitive per-token fees or subscriptions.
My Agent Session
Built with Google Antigravity pair programming and DevRelay:
The Spirit of It
The moment PHANTOM TALES truly came alive was during the implementation of the Interactive Chambers.
While testing a chapter set in an abandoned limestone quarry, Gemma 4 generated a choice: “Examine the scratches inside the iron lid, or extinguish your lantern and listen.” Selecting the latter caused the procedural Web Audio engine to fade out into complete silence followed by low, rhythmic subterranean taps. Reading the generated continuation in the candlelight reader created genuine chills. It proved that pairing open AI with deliberate sensory art direction can turn code into atmosphere.
Prize Categories
Ghost in the Machine (Grand Prize)
Open Innovation Track (Gemma & Ollama)
Top comments (0)