DEV Community

Cover image for CodeCrypt 👻: Bringing Forgotten Code Back to Life with Local AI | Hacktoberfest Week 4
Ch Umamaheshwar
Ch Umamaheshwar

Posted on

CodeCrypt 👻: Bringing Forgotten Code Back to Life with Local AI | Hacktoberfest Week 4

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission 👻🌼

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine

👻 CodeCrypt — Bringing Forgotten Code Back to Life with Local AI

What happens when you open an old codebase, look at a function you wrote months ago, and have absolutely no idea what it does?

What if you inherit a project filled with unfamiliar code, struggle to understand its logic, or discover potential issues buried inside hundreds of lines?

That is the problem I wanted to explore with CodeCrypt.

CodeCrypt is a locally running, AI-powered code analysis assistant built to help developers understand forgotten code, uncover potential issues, and breathe new life into existing programs.

Instead of relying on a closed, cloud-based AI API, CodeCrypt uses an open-weight AI model running locally through Ollama.

The idea behind the project is simple:

No code should remain a mystery forever.


🧠 What I Built

CodeCrypt is a web application that combines a simple developer-friendly interface with local AI inference.

It provides three main tools:

1. Explain Code — Understand the unknown

Ever found a piece of code that looks like another language?

Paste it into CodeCrypt, select the programming language, and let the AI explain it.

The explanation is designed to make unfamiliar code easier to understand, with beginner-friendly breakdowns, key concepts, and explanations of how the code works.

2. Scan for Issues — Uncover what's hiding

Sometimes code looks perfectly fine until something goes wrong.

The issue scanner analyses submitted code to identify potential bugs, risky patterns, and maintainability concerns.

It also provides suggested fixes and explanations to help developers understand what might need attention.

3. Restore Code — Give old code a fresh start

Code doesn't always age well.

The Restore feature helps developers explore improved, refactored, or modernized versions of existing code, along with explanations of the suggested changes.

The goal isn't simply to rewrite code, but to make it easier to maintain and understand.

Other features

Alongside the three main AI tools, CodeCrypt includes:

  • Programming language selector: Choose from supported languages or use automatic detection.
  • Built-in examples: Try the application without having to prepare your own code snippets.
  • Ollama connection status: Check whether the local AI service is available.
  • Copy functionality: Easily copy generated explanations and code suggestions.
  • Recent history: Keep track of recent analyses using browser local storage.
  • Responsive interface: A modern dashboard designed to work across different screen sizes.

🎬 Demo

CodeCrypt is designed to run locally on the developer's machine.

Rather than depending on a hosted AI service, the application communicates with a locally running Ollama instance.

The screenshots above demonstrate the application's interface and features.

The complete setup instructions are available in the GitHub repository.


💻 Source Code

GitHub Repository:

Maheshwar247/CodeCrypt

The repository includes the complete application source code, installation instructions, configuration examples, and automated tests.

Feel free to explore the code, try it locally, or build upon the idea!


⚙️ How I Built It

I wanted CodeCrypt to be practical, lightweight, and beginner-friendly to work on.

I chose a straightforward architecture using Python for the backend and standard web technologies for the frontend.

Technology Stack

Technology Purpose
Python Backend logic
Flask Web framework and API routes
HTML5 Application structure
CSS3 Styling and responsive interface
Vanilla JavaScript Frontend interactions
Ollama Local AI inference
Gemma 2 (2B) Open-weight AI model
Python unittest Automated testing

How the AI integration works

The most important part of CodeCrypt is its local AI integration.

The application uses Gemma 2 (2B) through Ollama.

Here's the basic workflow:

  1. The user enters a code snippet and selects an operation.
  2. The Flask backend receives the request.
  3. Based on the selected operation, the backend prepares a suitable prompt.
  4. The prompt and submitted code are sent to the locally running Ollama API.
  5. Gemma 2 processes the request and generates a response.
  6. Flask returns the result to the frontend, where it is displayed to the user.

In simple terms:

User → Flask Backend → Ollama → Gemma 2 → AI Response → User

One of my main goals was to make the AI the actual engine behind the application, rather than adding it as a decorative or secondary feature.

A little attention to safety

Since users may paste code from unfamiliar sources, I also included safeguards in the application.

  • Input validation and a maximum code length.
  • Submitted code is treated as untrusted input.
  • The application does not execute submitted or AI-generated code.
  • AI-generated suggestions are presented for review rather than treated as guaranteed-correct fixes.

I also included automated tests that use mocked Ollama responses to test application behaviour without requiring a running model for every test.


🌍 Why Does Open Innovation Matter?

For me, this is one of the most interesting parts of building CodeCrypt.

AI-powered developer tools are becoming increasingly common, but many rely on closed APIs, external services, and paid usage limits.

I wanted to explore a different approach.

Using Gemma 2 and Ollama made it possible to build an AI-powered application that runs locally without requiring a paid, cloud-hosted AI API.

That brought several advantages:

1. Accessibility

Developers can experiment with AI-powered tools without necessarily needing a paid API subscription.

2. Privacy and control

CodeCrypt sends prompts to a locally running Ollama service instead of a remote commercial AI API. This gives users more control over where their code is processed.

3. Customization

Because the model runs locally, developers can experiment with prompts and compatible models, and adapt the application to their needs.

4. Open collaboration

The project itself is open source. Other developers can inspect its implementation, learn from it, suggest improvements, and contribute new ideas.

I believe open innovation matters because it gives more people the opportunity to experiment, build, learn, and improve technology together.

CodeCrypt is a small example of what becomes possible when open-source models and accessible development tools come together.


🧩 Challenges I Faced

Building CodeCrypt wasn't just about connecting a frontend to an AI model.

Some of the things I had to consider were:

  • Designing three distinct AI operations without making the interface unnecessarily complicated.
  • Creating prompts that guide the model towards useful, structured responses.
  • Handling situations where Ollama is unavailable or the model doesn't respond.
  • Keeping the application lightweight while maintaining a polished interface.
  • Making sure the application handles potentially untrusted code safely.

Working through these challenges helped me understand how local AI inference can be integrated into an ordinary web application.


💭 The Spirit of It

The Ghost in the Machine theme made me think about something developers experience quite often.

Code gets forgotten.

Projects get abandoned. Documentation disappears. Developers move on. Sometimes, even the person who originally wrote a piece of code no longer remembers why it was written that way.

But forgotten doesn't have to mean useless.

I wanted CodeCrypt to be a small tool that helps developers revisit those forgotten pieces, understand what they do, identify what might be wrong, and discover ways to improve them.

There is something interesting about taking code that once felt like a mystery and finally understanding how it works.

That's the spirit behind CodeCrypt.

Bring forgotten code back to life. Uncover what's hiding in it. 👻


🚀 What's Next?

CodeCrypt is my contribution to exploring what can be built with open-source AI.

There is plenty of room for future improvements, including support for additional programming languages, more detailed analysis, and further refinements to the AI responses.

For now, I wanted to focus on building a working, approachable foundation that demonstrates how local AI can become a useful part of everyday development.

If you find the project interesting, feel free to explore the repository and share your thoughts!

Thanks for checking out CodeCrypt!

Hacktoberfest #OpenSourceAI #Ollama #Gemma #Python #Flask #LocalAI #CodeAnalysis

Top comments (0)