DEV Community

Cover image for πŸ‘» WRAITH: Resurrecting Lost Memories with Local Gemma 4 β€” The Ghost in the Machine
PRUTHVI RAJ G
PRUTHVI RAJ G

Posted on AI-assisted

πŸ‘» WRAITH: Resurrecting Lost Memories with Local Gemma 4 β€” The Ghost in the Machine

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission πŸ‘»πŸŒΌ

This is my submission for the Hacktoberfest Open-Source AI Challenge β€” Week 4: Ghost in the Machine.

What if an old diary could tell its story again? What if forgotten letters could preserve not only the facts they contain, but also the emotions and mysteries hidden between their lines?

Meet WRAITH β€” a local-first AI memory archive that transforms historical letters, diary entries, and personal recollections into atmospheric gothic stories while keeping factual information separate from creative interpretation.

πŸ”— GitHub Repository: https://github.com/PruthviRajG25/Hacktoberfest-Week4

Every Memory Leaves a Shadow.


πŸ•―οΈ What I Built

WRAITH is a privacy-focused archival and storytelling application powered by Google DeepMind's Gemma 4, running locally through Ollama.

It explores an interesting question: can AI help us preserve the emotional depth of personal memories without losing sight of the original facts?

WRAITH approaches this through two complementary layers:

  • The Verified Ledger: Extracts explicitly mentioned people, dates, events, and other details from the source text.
  • The Haunted Chronicle: Uses the mood, imagery, and emotional themes of the original text to create an atmospheric gothic ghost story.

The goal is to make historical preservation more engaging while clearly distinguishing information found in the source from AI-generated fiction.

🎯 The Problem

Personal diaries, handwritten letters, and family archives can hold irreplaceable memories. However, preserving and exploring them with modern AI introduces several challenges.

  1. Privacy concerns: Uploading intimate family records to cloud-based AI services may expose sensitive information to third-party systems.
  2. Historical accuracy: Generative AI can invent details or mix fictional elements with real events.
  3. Accessibility: Some AI solutions depend on cloud services, paid APIs, or hardware that may not be available to everyone.

WRAITH explores a local-first alternative that prioritizes privacy, separates facts from fiction, and makes archival storytelling accessible through a web interface.

πŸ‘» How WRAITH Interprets β€œGhost in the Machine”

Rather than treating the ghost as a literal supernatural presence, I approached the theme metaphorically.

What if the machine became a medium through which forgotten memories could speak again?

A diary entry becomes the starting point. The AI identifies the details present in the original text and then creates a fictional narrative inspired by its atmosphere.

The result is an experience that combines archival organization with creative storytellingβ€”without presenting invented supernatural events as historical facts.


πŸš€ Demo

WRAITH Interface Preview

πŸ•―οΈ Interactive Presentation

WRAITH also includes a standalone interactive experience in poster.html.

It features:

  • Atmospheric soundscape: Procedurally generated ambient audio using the Web Audio API.
  • Interactive ghost lantern: A cursor-based flashlight effect that reveals hidden visual details.
  • Interactive sΓ©ance simulator: A typewriter-style presentation that illustrates the AI analysis experience.
  • Print-ready presentation: A dedicated layout for sharing the project during demonstrations and judging.

These elements bring the project's theme to life beyond its core AI functionality.

⚑ Run WRAITH Locally

You will need Node.js, npm, and Ollama installed.

1. Download the model

ollama pull gemma4:e2b
Enter fullscreen mode Exit fullscreen mode

2. Clone the repository

git clone https://github.com/PruthviRajG25/Hacktoberfest-Week4.git
cd Hacktoberfest-Week4
Enter fullscreen mode Exit fullscreen mode

3. Install dependencies

npm run install:all
Enter fullscreen mode Exit fullscreen mode

4. Start the application

npm run dev
Enter fullscreen mode Exit fullscreen mode

Open http://localhost:3000 in your browser, assuming the application is configured to use that port.

You can also open poster.html to explore the standalone presentation.

Note: Model availability, hardware requirements, and startup commands depend on the installed Ollama version and the repository configuration. Check the README if you encounter any issues.


πŸ—οΈ Technical Architecture

WRAITH uses a lightweight web architecture that connects a browser-based interface to a locally running AI model.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           React + Vite             β”‚
β”‚       User Interface               β”‚
β”‚  Input Β· Results Β· Local Storage    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       Node.js + Express             β”‚
β”‚                                    β”‚
β”‚  Input Validation & Sanitization   β”‚
β”‚  API Routes & Structured Responses β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚            Ollama                  β”‚
β”‚       Local Model Runtime          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          Gemma 4                   β”‚
β”‚   Fact Extraction & Storytelling   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Enter fullscreen mode Exit fullscreen mode

Technology Stack

  • Frontend: React 18, Vite, custom CSS, responsive interface.
  • Backend: Node.js and Express for API handling, input sanitization, and response validation.
  • AI: Google DeepMind's Gemma 4 through Ollama for local inference.
  • Data storage: Browser localStorage for locally saved records.
  • Export: Markdown files with YAML frontmatter for use with tools such as Obsidian and Logseq.
  • Interactive experience: HTML, CSS, JavaScript, and the Web Audio API.

Why a Backend?

The Express backend is an important part of WRAITH, not just a connection layer.

It handles incoming requests, validates and sanitizes user input, communicates with the local model runtime, and returns structured responses to the frontend. This creates a clear separation between the user interface and AI processing.

Keeping this logic behind a backend also provides a foundation for adding stronger validation, error handling, testing, and more advanced archival features in the future.


🧠 How I Built It

1. Running an Open-Weight Model Locally

WRAITH uses Gemma 4 through Ollama rather than relying on a hosted AI API for its core inference workflow.

This design aims to keep personal archival text on the user's device during local processing, reducing the need to send sensitive content to an external AI provider.

Local execution also provides an opportunity to experiment with open-weight AI while learning how model runtimes integrate with a full-stack application.

2. Separating Facts from Fiction

One of the most important design decisions was to avoid mixing extracted historical details with generated storytelling.

The backend sends structured instructions to the model and requests a JSON response.

For example, the model is instructed to:

  • Extract only names, dates, and events explicitly supported by the input.
  • Return empty arrays when the source contains no relevant information.
  • Keep factual extraction separate from creative storytelling.
  • Generate a short gothic narrative inspired by the source text.
  • Return the results in a consistent JSON structure.

Here is a simplified example of the response format:

{
  "title": "The Forgotten Attic",
  "summary": "A mysterious memory preserved in an old diary.",
  "people": [],
  "dates": [],
  "facts": [],
  "story": "The house stood silent beneath the winter sky..."
}
Enter fullscreen mode Exit fullscreen mode

The example above illustrates the response structure, not a verified output from a specific test.

Structured output makes the results easier for the frontend to display and helps maintain a clear boundary between source-supported information and generated fiction. However, model outputs still require validation, and factual extraction is not guaranteed to be error-free.


🌍 Why Open Innovation Matters

For a project dealing with personal memories, privacy and accessibility are important design considerations.

πŸ” 1. Privacy by Design

Personal letters and diaries can contain deeply sensitive information. Running inference locally can reduce exposure to third-party AI services, provided the application is configured to keep processing and storage local.

WRAITH is designed around this principle: the user's memories should remain under their control.

πŸ’» 2. Accessible AI

Local inference offers an alternative to applications that depend entirely on paid cloud APIs.

The practical hardware requirements depend on the selected model, quantization, available memory, and system configuration, but the approach makes experimentation with open-weight AI possible without requiring a dedicated cloud inference service.

πŸ“š 3. Long-Term Preservation

A local-first architecture gives users more control over their archives. Markdown export also makes records easier to move between compatible applications and personal knowledge-management systems.

The aim is not to promise that software will work forever, but to make preserved information portable and less dependent on a single hosted service.


πŸ› οΈ My Development Process

Building WRAITH brought together several areas of full-stack development:

  • AI integration: Connecting a locally hosted model to a web application.
  • Prompt engineering: Designing instructions that separate source-based extraction from creative generation.
  • Backend development: Building API routes, validating input, and handling structured model responses.
  • Frontend development: Creating a responsive interface with a consistent gothic visual identity.
  • Creative interaction design: Using CSS animations, cursor effects, and procedural audio to reinforce the theme.
  • Developer experience: Organizing installation and startup commands to simplify local setup.

The biggest design challenge was balancing two very different goals: preserving the integrity of historical information and creating an engaging fictional experience.

Keeping those outputs separate became the foundation of the project.


πŸ•°οΈ The Experience: When a Memory Becomes a Story

Imagine opening an old diary and finding a fragment about a locked attic, a brass key, and a ticking pocket watch.

WRAITH's goal is to preserve the details that the text actually mentions while creating a separate fictional narrative inspired by its atmosphere.

The historical record remains the starting point. The story becomes an interpretationβ€”not a replacement for the original memory.

That distinction is what makes this project meaningful to me. AI does not need to rewrite the past to help us explore it. Sometimes, it can simply give forgotten words a new way to be experienced.

That is the ghost in the machine: not a ghost living inside the model, but the echoes of human memories brought to life through technology.


πŸ”— Explore WRAITH

I'd love to hear your thoughts!

If you could preserve one memory, letter, or story using AI, what would it be? πŸ•―οΈ

devchallenge #hf26challenge #webdev #opensource

Top comments (0)