Open-Source Game Manager in Practice: Organizing a Local Library and Adding AI Search

    This article explains how to build an open-source game manager that scans and deduplicates local files, enriches them with metadata from external databases, and adds AI-powered search, recommendations, and question answering. It covers the system architecture, metadata caching, retrieval-augmented generation, streaming responses, and handling network failures.

    Why Local Game Libraries Need Better Management Tools

    A player’s games are often scattered across multiple locations: disc images, digital platform installation folders, indie game archives, and ROM files used by older emulators. These files have no unified entry point, so finding a specific game may require searching through several directories. The default file browser can sort by filename, but it cannot tell users a game’s release year or genre, nor can it determine whether two files represent duplicate versions.

    Traditional game managers usually focus on two tasks: listing files and launching games quickly. They are much less capable when users want to organize a library by conditions, complete missing information, or receive recommendations based on games they have already played. How to remove duplicates from a local game library and how to connect an AI game assistant to external APIs are practical questions for both developers and players.

    I developed this manager with two goals. First, I wanted to use an engineering-oriented approach to consolidate, deduplicate, and enrich a game library. Second, I wanted to evaluate whether a large language model could provide useful interaction in a desktop application. This article describes the design decisions and problems encountered during development, with an emphasis on the underlying approach and trade-offs.

    Overall Architecture: Three Independent Modules

    The manager is divided into three modules based on responsibility. The modules communicate only through clearly defined data structures. If one module fails or needs to be replaced, the others do not need to be modified.

    1. Game Library Scanning and Identification

    This module traverses user-selected folders and locates executable and image files. It does not depend on the directory structures or shortcut formats of a particular distribution platform, because different channels organize their files in very different ways.

    Identification is based on characteristics of the files themselves, including executable version information, icons in resource sections, and partition structures within image files. These characteristics can provide estimates of a game’s type and platform, but the results are not always accurate. Some older games use unusual executable formats, while an archive may contain only an installer. Both situations can lead to incorrect identification. For this reason, the interface labels the result as an inference and allows the user to edit it manually.

    Scanning uses multiple threads, and the results are written to a local index cache. When the application starts again, it reads the cache and checks only whether files have changed. Scan time depends on the number of files in the library, the storage device—mechanical hard drives and solid-state drives behave differently—and the available memory. No systematic benchmark was conducted in a standardized environment, so this article does not provide specific performance figures.

    2. Metadata Scraping and Information Aggregation

    Many game files have names consisting only of English text or abbreviated romanization. Obtaining localized names, cover art, descriptions, and release years requires external databases.

    The metadata module uses a pluggable design. Its default sources are commonly used community game databases such as IGDB and TheGamesDB. The module first normalizes the game name by removing version numbers, regional markers in parentheses, and unnecessary symbols. It then uses fuzzy matching to find candidate entries. When the matching confidence is low, the interface asks the user to confirm the result instead of writing it directly to the library.

    To reduce duplicate requests, the module maintains a local cache keyed by the file hash. Metadata that has already been retrieved successfully is saved and does not need to be requested again. This also enables offline browsing, although newly added games cannot be enriched without a network connection.

    External database integrations also require several safeguards:

    • Services usually impose request-rate limits, so the application needs throttling.
    • Cached data should have an expiration policy because game information may be corrected later.
    • Different data sources use different field names, which requires a field-mapping table.
    • If one source is temporarily unavailable, the application should switch to the next source instead of interrupting the entire process.

    3. AI Assistant Integration Layer

    This is the most experimental part of the manager. The model is not deployed locally because end-user hardware varies widely, and it is difficult to provide consistent model size and inference speed across devices. The current implementation calls a cloud model through its API.

    All model calls pass through an independent adapter layer. The adapter standardizes request formats, prompt templates, and the tool-calling protocol. If the application needs to switch model providers, a new adapter implementation can be added without changing the business logic.

    The current AI features fall into three categories:

    • Natural-language search: A user can enter a request such as “Find a side-scrolling shooter released in 2015.” The system converts it into structured filters such as year, genre, and platform.
    • Game recommendations: Using locally recorded play time and user tags, the model generates a recommendation list and explains the reasons behind the recommendations.
    • Question answering: For walkthrough or configuration questions about a specific game, the model provides answers based on public information. Configuration advice may be outdated or inaccurate, so the interface reminds users to consult official sources.

    Technical Challenge 1: Showing the Model Only the Information It Needs

    A large language model has a limited context window, so it is not practical to include the details of an entire game library in every prompt. The manager uses a lightweight retrieval-augmented generation approach instead.

    For each game, the application creates a vector index from metadata such as its name, description, tags, and rating. When the user asks a question, the system first performs similarity search in the local vector store. It then selects several games most relevant to the query and inserts their information into the prompt.

    Three parameters are particularly important:

    1. The embedding model: This affects vector quality. The application can use a small local embedding model or call a cloud service.
    2. The similarity threshold: Results below the threshold are discarded to prevent irrelevant information from distracting the model.
    3. The empty-retrieval fallback: If no relevant result is found, the system falls back to keyword matching and tells the user that the result came from rules rather than the model.

    This approach can significantly shorten prompts, but the actual savings depend on the size of the library and the number of retrieved items. No fixed figure is provided here. Developers can measure the result with their own libraries by recording the token count of each request and calculating the average.

    Technical Challenge 2: Streaming Output and Network Failures

    AI conversations should display responses incrementally. Otherwise, users may have to wait a long time before seeing the first character. The module uses Server-Sent Events (SSE) to receive incremental model output and refreshes the conversation interface as new content arrives in an asynchronous event loop.

    Network failures are another concern. The module implements automatic retries, with the delay increasing exponentially after each failure—for example, one second, two seconds, and four seconds. When the number of consecutive failures reaches the configured limit, the module enters a circuit-breaker state and temporarily pauses cloud requests. The interface then informs the user that the AI service is currently unavailable.