Mercura: Architecture and Implementation of a Local-First, AI-Assisted Merchant Operating System for Small and Medium Enterprises
Subhaditya Singh
ABSTRACT
mall and medium merchants commonly rely on a fragmented mix of point solutions for inventory, order processing, payments, accounting, customer records, and analytics, which complicates data consistency and limits the availability of unified, data-grounded decision support. Cloud-hosted artificial-intelligence (AI) assistants can help address the analytics gap, but they typically require external API keys, network connectivity, and the transmission of proprietary business data to third-party services, which is unattractive for smaller merchants operating with limited budgets and privacy constraints. This paper presents Mercura, an implemented, single-process, local-first merchant operating system that integrates inventory management, order and transaction processing, a local payment sandbox, accounting (profit-and-loss, cash-flow, and balance-sheet computation), deterministic fraud risk scoring, customer intelligence, geographic analytics, and an AI Merchant Copilot within one React/TypeScript and Express/TypeScript codebase backed by a local SQLite database. The system's AI layer follows a provider-abstraction pattern: a deterministic, rule-based LocalAnalyticsAI engine is grounded in the merchant's real, locally persisted operational and financial data and serves as the default and guaranteed-available provider, while an optional local large language model (LLM), accessed through Ollama, can be substituted when available and is otherwise silently bypassed through an automatic fallback. This paper documents the system architecture, formalizes the accounting, inventory-status, and AI context-construction logic actually implemented in the codebase, and reports a functional evaluation consisting of the project's automated Vitest test suite (four test files, eight tests, all passing at time of writing) together with a structured code-level audit of the fraud, accounting, and payment-sandbox modules. The evaluation establishes functional feasibility and internal consistency of the implemented workflows rather than comparative superiority over commercial systems: no user study, production deployment, or benchmarked accuracy/ precision/recall figures were collected, and none are claimed. The paper explicitly distinguishes implemented functionality from simulated functionality — most notably, the payment layer is a local sandbox that never contacts a real payment network, and the fraud engine is a deterministic risk-scoring mechanism rather than a trained machine-learning classifier. The primary contribution is systems-architectural: a reproducible, engineering-level demonstration that a unified, privacy-preserving, offline-capable merchant operating system with data-grounded AI decision support can be built without a mandatory cloud AI dependency, together with an honest accounting of the approach's current limitations and the experimental work required to validate it further.

















