> ## Documentation Index
> Fetch the complete documentation index at: https://developers.drpn.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Backend engine overview

> The runtime architecture behind Darpan reconciliation.

Darpan's UI is the control surface. The backend is the engine that makes each run durable, scoped, repeatable, and reviewable.

The backend implementation is the [`drpn-ai/darpan`](https://github.com/drpn-ai/darpan) Moqui component. It is mounted inside a Moqui framework checkout at `<moqui-framework>/runtime/component/darpan`.

## Engine model

| Layer | Responsibility |
| - | - |
| Moqui | JSON-RPC transport, service contracts, entity persistence, security, session context, and XML-first orchestration. |
| Spark | Dataset normalization and comparison for files or records that exceed browser-memory workflows. |
| Drools/KIE | RuleSet compilation and execution for configurable matching, classification, and exception logic. |
| Generated outputs | Persistent result metadata and files that let users reopen, audit, and delete run evidence. |

This split keeps browser workflows thin. The UI asks for a run; the backend validates access, prepares data, compares records, applies rules, and writes output.

## Current shape

* Moqui component descriptor: `component.xml`
* Public service surface: `facade.*` Moqui JSON-RPC services through `/rpc/json`
* Operator surface: `admin.*` services, restricted to super admins and called by the Darpan admin app. They are not part of the public API.
* GraphQL: the images include a GraphQL component (`moqui-gql`). It is not a supported public API yet.
* Service contracts: XML service definitions under `service/**`
* Data model: Moqui entity definitions under `entity/**`
* Processing helpers: Groovy code under `src/main/groovy/**`
* Reconciliation engine: Spark-backed compare services with RuleSet and legacy mapping paths
* Rule engine: Drools/KIE services for compiling and executing reconciliation rules
* Output handling: generated-output descriptors plus tenant-scoped files
* One-time upgrade work: a migration registry and supervisor (see [Data migrations](https://developers.drpn.ai/backend/migrations.md))

## What the backend owns

* User, company, tenant, and permission checks before reads or writes.
* Durable records for schemas, saved runs, RuleSets, compare scopes, connections, and output descriptors.
* Source staging from uploads, text payloads, or configured systems.
* Spark-backed base diff computation.
* Drools-backed RuleSet execution.
* JSON-RPC responses shaped for the UI.

## UI contract

The UI treats facade services as the contract. Browser code does not recreate reconciliation rules, tenant filtering, output paths, or service-side validation.

This section traces product workflows into backend services, entities, processing helpers, and validation commands.

> **[Component layout](https://developers.drpn.ai/backend/component-layout.md)**
>
> Moqui component structure, dependencies, and implementation directories.

> **[Service layer](https://developers.drpn.ai/backend/service-layer.md)**
>
> Facade services, core services, and backend service orchestration.

> **[Reconciliation engine](https://developers.drpn.ai/backend/reconciliation-engine.md)**
>
> A run from source staging through Spark, RuleSets, and generated output.

> **[Rules and schemas](https://developers.drpn.ai/backend/rules-and-schemas.md)**
>
> RuleSet, Rule, compare-scope entities, and JSON schema model.

> **[Data access and tenancy](https://developers.drpn.ai/backend/data-access-and-tenancy.md)**
>
> Active tenant scope, permission membership, and generated-output isolation.

> **[Data migrations](https://developers.drpn.ai/backend/migrations.md)**
>
> Registry, prerequisites, ledger, and supervisor for one-time data migrations.

> **[Operations and validation](https://developers.drpn.ai/backend/operations-and-validation.md)**
>
> Test pools, Gradle commands, runtime baseline, and backend review checklist.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.