跳到正文
DEV Community· Abdul Rehman Ahmad·· 3 小時前AI 評分42

SchemaGhost:以 Qwen3 和人工把關讓舊應用程式重獲新生

SchemaGhost: bringing legacy apps back to life with Qwen3 and a human in charge

AI 導讀

SchemaGhost 是一款開源工具,協助開發者在 API 回應結構變更後,為舊應用程式建立相容層,毋須重寫整個應用程式。它結合確定性啟發式方法與透過 Ollama 本機執行的 Qwen3 0.6B,建議新舊 JSON 欄位的對應方式。開發者可審核及核准建議、驗證映射,並生成 C# 配接器和其他相容檔案。

正文

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

👻 What I Built

SchemaGhost is an open-source tool that helps legacy applications survive API changes without requiring developers to rewrite the entire application.

Imagine a company has an old application that depends on an API. Everything works until the API provider changes its response structure.

Previously, the application expected:

{
  "user_id": 1024,
  "name": "Ali",
  "email": "ali@example.com",
  "is_active": true,
  "balance": 250.75
}

But the updated API now returns:

{
  "account": {
    "id": 1024,
    "status": "active"
  },
  "full_name": "Ali",
  "contact": {
    "email_address": "ali@example.com"
  },
  "isActive": "true",
  "wallet": {
    "balance": 250.75
  }
}

The information is mostly still there, but field names, nesting, and data types have changed.

The old application no longer understands the response.

For developers maintaining legacy systems, this can mean hours of investigating undocumented code, manually identifying changed fields, and writing compatibility logic.

That's the problem I wanted SchemaGhost to solve.

Instead of rewriting the old application, SchemaGhost helps developers build a compatibility layer between the old and new API structures.

⚙️ How SchemaGhost Works

  1. Compare: Paste the legacy JSON and the updated API response.
  2. Suggest: SchemaGhost identifies possible field mappings using deterministic heuristics and Qwen3.
  3. Review: The developer approves or rejects each suggested mapping.
  4. Verify: The application checks whether the approved mappings and transformations are valid.
  5. Generate: Download mapping.json, CompatibilityAdapter.cs, and the adapted JSON output.

The generated C# adapter can then serve as a starting point for integrating the changed API with an existing application.

👻 Why Ghost in the Machine?

I interpreted Ghost in the Machine as bringing forgotten software back to life.

Many organizations still depend on applications built years ago. Their original developers may have moved on, documentation may be incomplete, and changing the code can be risky.

These applications are like ghosts: still present, still important, but often overlooked.

SchemaGhost is my attempt to help them keep working.

Rather than replacing an old system, it gives developers a way to translate the new API response into something the existing application understands.

🎥 Demo

Watch SchemaGhost in action:

▶️ Watch the Demo on YouTube

The video demonstrates the complete workflow:

  • Comparing legacy and modern JSON structures.
  • Generating suggestions using heuristics and the locally running Qwen3 model.
  • Reviewing and approving mappings.
  • Rejecting an incorrect AI suggestion.
  • Verifying the approved mappings.
  • Generating and downloading the compatibility files.

One important moment in the demo is when Qwen3 proposes a mapping that shouldn't be accepted automatically.

The developer can leave it unapproved.

That was intentional: I wanted to demonstrate that AI suggestions are useful, but they shouldn't be trusted blindly.

💻 Code

⭐ View the Complete SchemaGhost Source Code on GitHub

SchemaGhost is available under the MIT license.

The repository includes the core library, command-line interface, ASP.NET Core API, Angular frontend, sample JSON data, documentation, and automated tests.

You can clone it, run it locally, explore the implementation, report issues, or contribute improvements.

🛠️ How I Built It

I built SchemaGhost around a simple principle:

Let AI suggest possible mappings, but keep validation, approval, and code generation under developer control.

Technology Stack

Component Technology Purpose
Frontend Angular JSON comparison and mapping review interface
Backend ASP.NET Core 10 API endpoints and application workflow
Core engine C# / .NET 10 JSON analysis, mapping validation, and adapter generation
AI model Qwen3 0.6B Semantic field-mapping suggestions
Model runtime Ollama Local AI inference
Testing xUnit Automated core and API tests
Version control Git and GitHub Open-source collaboration

1. Understanding the JSON Structures

The first challenge was understanding how fields in two different JSON structures relate to each other.

SchemaGhost analyzes JSON paths, including nested fields such as:

Legacy: user_id
Modern: account.id

Legacy: name
Modern: full_name

Legacy: email
Modern: contact.email_address

Legacy: balance
Modern: wallet.balance

Some mappings are relatively straightforward.

Others require understanding the meaning of a field rather than simply comparing names.

That's where Qwen3 comes in.

2. Integrating Open-Source AI

I used Qwen3, an open-weight language model from Alibaba's Qwen team, running locally through Ollama.

The default model is:

qwen3:0.6b

SchemaGhost provides the legacy and modern JSON structures to Qwen3 and asks it to identify possible relationships between their fields.

For each proposed mapping, the model can suggest a destination path, a transformation, a confidence score, and a short explanation.

For example:

Legacy field: user_id
Suggested modern field: account.id
Transformation: none

The advantage of a language model is that it can recognize semantic relationships that simple string matching might miss.

However, language models can also produce incorrect suggestions.

So I designed SchemaGhost to treat AI output as untrusted input.

3. Combining AI with Deterministic Heuristics

SchemaGhost doesn't depend entirely on Qwen3.

It also includes a heuristic matching system that can suggest mappings without using an AI model.

The two approaches complement each other:

  • Heuristics provide a predictable baseline.
  • Qwen3 helps identify possible semantic relationships.
  • Hybrid mode combines their suggestions while preserving developer review.

This also means SchemaGhost can still provide useful functionality when Ollama is unavailable.

4. Keeping a Human in Control

This was one of the most important parts of the project.

A model might suggest that:

is_active → account.status

But the legacy field expects a boolean, while the new field contains a status string such as "active".

Those values should not be treated as interchangeable without an appropriate, explicitly supported transformation.

During my demo, Qwen3 made this kind of suggestion, and I deliberately left it unapproved.

SchemaGhost includes safeguards such as checking proposed paths, restricting transformations, requiring approval, and verifying mappings before code generation.

The AI never gets the final decision.

5. Generating Compatibility Files

After reviewing and verifying the mappings, SchemaGhost generates downloadable artifacts.

These include:

  • mapping.json — a structured record of the approved mappings.
  • CompatibilityAdapter.cs — generated C# compatibility code.
  • adapted.json — an example response transformed into the legacy structure.

This turns the mapping process into something developers can inspect, test, and integrate into an existing codebase.

6. Testing the Application

I also wanted SchemaGhost to be more than a working interface.

I added automated tests for the core logic and API.

Before preparing this submission, I ran both test suites:

Test suite Result
Core tests 8 passed
API tests 19 passed
Total 27 passed, 0 failed

The Angular production build also completed successfully.

🚧 Challenges and Lessons Learned

Building SchemaGhost taught me several things.

AI confidence doesn't guarantee correctness. A model can produce a convincing explanation for a wrong mapping. Human review and deterministic validation are necessary.

Smaller models can still be useful. Qwen3 0.6B is not a large model, but it can contribute meaningful suggestions when given a narrow task.

Fallbacks matter. The heuristic engine allows SchemaGhost to remain useful without relying entirely on AI inference.

Generated code needs safeguards. Mapping inputs must be checked before they are used to produce source code.

Most importantly, I learned that adding AI to a project should make an existing workflow more useful, not make it harder to understand or trust.

🔮 Current Limitations and Future Plans

SchemaGhost is still an early-stage project.

It currently has limitations around complex arrays, unusual JSON field names, and advanced transformations.

Some improvements I would like to explore include:

  • Supporting mappings inside arrays of objects.
  • Adding more carefully validated transformations.
  • Testing against real-world API changes.
  • Comparing the performance of different Qwen3 model sizes.
  • Generating compatibility adapters for languages beyond C#.
  • Expanding automated frontend testing.

🌍 Why Does Open Innovation Matter?

For this project, open innovation made a real difference.

SchemaGhost deals with JSON responses that could represent customer records, financial information, or other sensitive application data.

Using an open-weight model means developers can run the AI locally rather than depending on a hosted service.

🔒 Privacy

With Qwen3 running through Ollama on a local machine, the JSON sent for inference does not need to leave that machine.

That gives developers more control over how their data is processed.

💡 Accessibility

A developer can experiment with SchemaGhost without purchasing AI API credits.

Running a local model still requires computing resources, but there is no per-request hosted inference charge.

🔄 Flexibility

Developers can choose different compatible models and improve the mapping workflow without depending on a single proprietary AI provider.

🤝 Community Collaboration

Because SchemaGhost is open source, other developers can inspect its implementation, test its limitations, suggest improvements, and contribute new features.

I believe open-source AI is especially valuable when it helps solve practical problems that developers and organizations already face.

The goal isn't to replace developers with AI. It's to give developers better tools.

👻 The Spirit of It

When we talk about building software, we usually focus on creating something new.

But sometimes, innovation is about helping something old survive.

There are applications that have been running for years, quietly supporting businesses and the people who depend on them.

They may not have modern interfaces or the latest technology, but they still matter.

I built SchemaGhost around that idea.

Instead of telling developers to throw away an old application, I wanted to give them a way to understand what changed and keep the application working.

For me, that's the spirit of Ghost in the Machine.

Not every ghost needs to be removed. Sometimes it just needs a translator.


Built for Hacktoberfest 2026 — Open-Source AI Challenge, Week 4.

💻 GitHub: SchemaGhost Repository

🎥 Demo: Watch SchemaGhost in Action

來源:DEV Community · dev.to