Inspiration
A room is familiar until one detail feels wrong: a television that seems to be watching you, an empty chair that no longer feels empty, or a shadow that belongs to nobody. Most horror games take place in environments designed by someone else. I wanted to explore a different possibility: what if an ordinary photograph of your own room could become the setting for a ghost story?
That idea became The Ghost in the Machine, an interactive haunted-storytelling application built for Kiroween 2026. It combines computer vision, rules-based scene composition, narrative generation, and an atmospheric 3D interface. The central creative idea is simple: the objects in your surroundings should help determine the story, rather than merely provide a background image.
What it does
Upload a photograph of a room and the app analyzes it for supported furniture objects. Its CPU-based YOLO11n Vision Agent identifies sofas, chairs, televisions, beds, and tables. The Haunting Engine then associates detected objects with haunting effects and narrative interactions. A Narrative Agent produces a short eerie story about the room, while the Scene Composition Agent prepares an interactive scene and a QA Agent checks consistency between objects, effects, and story beats.
The result is a stylized Three.js haunted room that users can explore by orbiting and zooming, selecting objects to reveal portions of the story, and toggling atmospheric sound. The interface also supports keyboard interaction, reduced-motion preferences, and a text fallback when WebGL is unavailable.
The app distinguishes real detections from fallbacks. YOLO currently recognizes five furniture categories; it does not identify windows, mirrors, doors, lamps, paintings, or bookshelves from uploaded photographs. When none of the supported classes is found, the app explicitly reports a default-room fallback. Likewise, when no live LLM credential is configured, it uses a template narrative rather than claiming a model-generated story.
How I built it
The frontend uses Next.js, React, TypeScript, and Three.js. The backend uses Python, FastAPI, SQLAlchemy, Alembic, and PostgreSQL. The visual recognition system uses Ultralytics YOLO11n on CPU, with a deterministic fallback for unsupported environments. The interactive story pipeline follows five stages: Vision → Haunting Engine → Narrative → Scene Composition → QA.
I developed the application using Kiro Web to delegate repository implementation, request reviews, run tests, address security and deployment findings, and produce GitHub pull requests. I structured the repository with three specifications—Vision, Narrative, and Orchestration—each containing requirements, design, and implementation tasks. Three steering documents cover coding standards, the haunted design system, and agent behavior.
The project also includes three hook definitions (linting, pre-commit tests, and secret scanning), a local MCP asset server, a custom haunting-assets Power, and a declarative Crew workflow. The MCP server was exercised over stdio and the corresponding commands were tested independently. The hooks and Power have not been verified executing inside Kiro IDE, and the workflow is executed by a tested Python orchestrator rather than by Kiro Crew itself. These distinctions are documented in the repository instead of overstating the integration.
Testing included 92 backend tests plus 14 script tests, 43 frontend tests, Hypothesis property-based testing of Haunting Engine placement and vision bounding-box invariants, PostgreSQL migration/read-write tests, and container-level smoke tests under Podman. An earlier Playwright suite passed 10/10 checks using software WebGL; the final browser rerun could not start Chromium in the restricted environment. The repository records both successful and blocked checks.
Challenges
Making detection genuine. An initial stand-in detector produced seeded labels without reading the image. I replaced that production path with a tested YOLO11n CPU detector. The supported object vocabulary remains deliberately narrow, and the app labels fallback behavior rather than presenting invented detections as factual.
Controlling deployment size. The production backend image is approximately 1.74 GB and measured about 502 MB peak process memory in the test environment. That made deploying genuine object detection on a 512 MB free instance risky and required a separate deployment strategy.
Connecting storytelling to objects. The central challenge was keeping detected objects, haunting effects, story beats, and interactions consistent. A dedicated QA stage and property-based tests check invariants that ordinary example-based tests can miss.
Separating configuration from execution. Some Kiro-specific integrations were authored in the repository but not exercised in the Kiro IDE or Crew runtime. The project maintains explicit verification notes so judges can distinguish functioning pipelines, tested artifacts, and work that remains to be validated.
Accomplishments
- Built a complete Next.js/FastAPI application with an interactive haunted 3D scene and object-triggered story events.
- Executed real CPU-based YOLO11n detection on different room photographs and obtained image-dependent results.
- Implemented contextual haunting rules, narrative and scene generation, consistency checks, and explicit fallback behavior.
- Added Hypothesis property-based tests, along with backend, frontend, database, and container tests.
- Tracked specs, steering, hooks, MCP configuration, a custom Power, and the orchestration workflow in the public
.kirodirectory. - Documented what was tested and what still requires verification rather than presenting an untested deployment as complete.
What I learned
This project reinforced the value of structured agentic development: requirements and invariants must remain visible even when an agent can generate code quickly. Property-based tests are especially useful for validating object placement over combinations of room configurations. I also learned that a successful local build does not imply a successful hosted deployment—model memory, container size, proxy boundaries, licensing, and real-browser behavior all need separate checks.
Most importantly, building an AI experience requires visible provenance. Users should know whether an object came from actual image recognition, a default scene, a live language model, or a template.
What's next
The next steps are to establish and verify a public deployment, enable and test a live narrative model, expand object recognition beyond five furniture categories, improve the visual scene fidelity, verify additional browsers and mobile gestures, and exercise the repository's Kiro hooks, Power, and Crew workflow in their intended environments. The longer-term vision is a shareable personalized horror experience for parties, creators, and interactive storytelling.
Source code: https://github.com/AkankshaJagdish/the-ghost-in-the-machine
Built With
- alembic
- docker
- fastapi
- github
- hypothesis
- kiro
- kiro-web
- mcp
- next.js
- playwright
- podman
- postgresql
- python
- pytorch
- react
- sqlalchemy
- three.js
- typescript
- ultralytics
- vitest
- webgl
- yolo11n