# ibreez/cr_app_backend architecture

> Architecture diagram of the GitHub repository ibreez/cr_app_backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ibreez/cr_app_backend
- Repository: https://github.com/ibreez/cr_app_backend

## Overview

This is a Maldives-focused accounting and tax-compliance web application. Users authenticate, manage outlets and bills, review uploaded records, and view financial summaries; backend routes expose those workflows and run tax and GST operations. The broader runtime also covers accounting, regulatory rules, reconciliation, explainability, compliance, and filing. The README describes a generic AI Studio app rather than these capabilities, so the map relies on the supplied source index and excerpts; unsampled subsystem links are omitted where their callers are not shown.

Main entry points: [`src/services/orchestrator/taxEngineOrchestrator.ts`](https://github.com/ibreez/cr_app_backend/blob/main/src/services/orchestrator/taxEngineOrchestrator.ts) (Tax orchestrator), [`src/App.tsx`](https://github.com/ibreez/cr_app_backend/blob/main/src/App.tsx) (Web application), [`server.ts`](https://github.com/ibreez/cr_app_backend/blob/main/server.ts) (HTTP routes), [`src/regulatory/resolvers/ruleResolver.ts`](https://github.com/ibreez/cr_app_backend/blob/main/src/regulatory/resolvers/ruleResolver.ts) (Regulatory rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_app["Web application<br/>[App.tsx]"]
  node_billreview["Bill review"]
  node_taxreview["Tax review"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
end

subgraph group_api["Application API"]
  node_server["HTTP routes<br/>[server.ts]"]
  node_store[("Application store<br/>[appStore.ts]")]
  node_db[("Prisma client<br/>[client.ts]")]
end

subgraph group_finance["Accounting and tax"]
  node_orchestrator["Tax orchestrator"]
  node_accounting["Accounting and P&amp;L<br/>[pnlService.ts]"]
  node_classification["Transaction classification"]
  node_tax["Tax computation"]
  node_adjustments["Tax adjustments"]
  node_gst["GST computation"]
end

subgraph group_compliance["Compliance and filing"]
  node_rules["Regulatory rules<br/>[ruleResolver.ts]"]
  node_reconciliation["Tax reconciliation"]
  node_explainability["Tax explainability"]
  node_filing["Filing controls"]
  node_regression["Regulatory regression"]
end

node_user(("Business user"))

node_user -->|"uses"| node_app
node_app -->|"requests data"| node_server
node_app -->|"opens review"| node_billreview
node_app -->|"opens review"| node_taxreview
node_app -->|"renders"| node_dashboard
node_server -->|"refreshes records"| node_store
node_server -->|"converts bills"| node_gst
node_server -.->|"invokes engine"| node_orchestrator
node_orchestrator -->|"classifies transactions"| node_classification
node_orchestrator -->|"gets P&amp;L"| node_accounting
node_orchestrator -->|"computes tax"| node_tax
node_orchestrator -->|"processes adjustments"| node_adjustments
node_orchestrator -->|"computes GST"| node_gst
node_orchestrator -->|"reconciles results"| node_reconciliation
node_tax -->|"resolves rates"| node_rules
node_gst -->|"resolves rates"| node_rules
node_explainability -->|"resolves rules"| node_rules
node_reconciliation -->|"reads adjustments"| node_adjustments
node_regression -->|"resolves rules"| node_rules
node_filing -.->|"prepares filing"| node_orchestrator
node_accounting -->|"uses database"| node_db
node_classification -->|"uses database"| node_db

click node_app "https://github.com/ibreez/cr_app_backend/blob/main/src/App.tsx"
click node_billreview "https://github.com/ibreez/cr_app_backend/blob/main/src/components/BillReviewModal.tsx"
click node_taxreview "https://github.com/ibreez/cr_app_backend/blob/main/src/components/TaxReviewDashboard.tsx"
click node_dashboard "https://github.com/ibreez/cr_app_backend/blob/main/src/components/Dashboard.tsx"
click node_server "https://github.com/ibreez/cr_app_backend/blob/main/server.ts"
click node_store "https://github.com/ibreez/cr_app_backend/blob/main/src/db/appStore.ts"
click node_db "https://github.com/ibreez/cr_app_backend/blob/main/src/db/client.ts"
click node_orchestrator "https://github.com/ibreez/cr_app_backend/blob/main/src/services/orchestrator/taxEngineOrchestrator.ts"
click node_accounting "https://github.com/ibreez/cr_app_backend/blob/main/src/services/accounting/pnlService.ts"
click node_classification "https://github.com/ibreez/cr_app_backend/blob/main/src/services/classification/canonicalClassificationEngine.ts"
click node_tax "https://github.com/ibreez/cr_app_backend/blob/main/src/services/tax/entityTaxService.ts"
click node_adjustments "https://github.com/ibreez/cr_app_backend/blob/main/src/services/tax/taxAdjustmentService.ts"
click node_gst "https://github.com/ibreez/cr_app_backend/blob/main/src/services/gst/gstEngineService.ts"
click node_rules "https://github.com/ibreez/cr_app_backend/blob/main/src/regulatory/resolvers/ruleResolver.ts"
click node_reconciliation "https://github.com/ibreez/cr_app_backend/blob/main/src/services/reconciliation/reconciliationEngine.ts"
click node_explainability "https://github.com/ibreez/cr_app_backend/blob/main/src/services/explainability/taxExplainabilityEngine.ts"
click node_filing "https://github.com/ibreez/cr_app_backend/blob/main/src/services/filing/preFilingControlEngine.ts"
click node_regression "https://github.com/ibreez/cr_app_backend/blob/main/src/regulatory/regression/regulatoryRegressionEngine.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_billreview,node_taxreview,node_dashboard,node_user toneBlue
class node_server,node_store,node_db toneAmber
class node_orchestrator,node_accounting,node_classification,node_tax,node_adjustments,node_gst toneMint
class node_rules,node_reconciliation,node_explainability,node_filing,node_regression toneRose
```

## Components

### User interface

- [Web application](https://github.com/ibreez/cr_app_backend/blob/main/src/App.tsx): `src/App.tsx`
- [Bill review](https://github.com/ibreez/cr_app_backend/blob/main/src/components/BillReviewModal.tsx): `src/components/BillReviewModal.tsx`
- [Tax review](https://github.com/ibreez/cr_app_backend/blob/main/src/components/TaxReviewDashboard.tsx): `src/components/TaxReviewDashboard.tsx`
- [Dashboard](https://github.com/ibreez/cr_app_backend/blob/main/src/components/Dashboard.tsx): `src/components/Dashboard.tsx`

### Application API

- [HTTP routes](https://github.com/ibreez/cr_app_backend/blob/main/server.ts): `server.ts`
- [Application store](https://github.com/ibreez/cr_app_backend/blob/main/src/db/appStore.ts): `src/db/appStore.ts`
- [Prisma client](https://github.com/ibreez/cr_app_backend/blob/main/src/db/client.ts): `src/db/client.ts`

### Accounting and tax

- [Tax orchestrator](https://github.com/ibreez/cr_app_backend/blob/main/src/services/orchestrator/taxEngineOrchestrator.ts): `src/services/orchestrator/taxEngineOrchestrator.ts`
- [Accounting and P&L](https://github.com/ibreez/cr_app_backend/blob/main/src/services/accounting/pnlService.ts): `src/services/accounting/pnlService.ts`
- [Transaction classification](https://github.com/ibreez/cr_app_backend/blob/main/src/services/classification/canonicalClassificationEngine.ts): `src/services/classification/canonicalClassificationEngine.ts`
- [Tax computation](https://github.com/ibreez/cr_app_backend/blob/main/src/services/tax/entityTaxService.ts): `src/services/tax/entityTaxService.ts`
- [Tax adjustments](https://github.com/ibreez/cr_app_backend/blob/main/src/services/tax/taxAdjustmentService.ts): `src/services/tax/taxAdjustmentService.ts`
- [GST computation](https://github.com/ibreez/cr_app_backend/blob/main/src/services/gst/gstEngineService.ts): `src/services/gst/gstEngineService.ts`

### Compliance and filing

- [Regulatory rules](https://github.com/ibreez/cr_app_backend/blob/main/src/regulatory/resolvers/ruleResolver.ts): `src/regulatory/resolvers/ruleResolver.ts`
- [Tax reconciliation](https://github.com/ibreez/cr_app_backend/blob/main/src/services/reconciliation/reconciliationEngine.ts): `src/services/reconciliation/reconciliationEngine.ts`
- [Tax explainability](https://github.com/ibreez/cr_app_backend/blob/main/src/services/explainability/taxExplainabilityEngine.ts): `src/services/explainability/taxExplainabilityEngine.ts`
- [Filing controls](https://github.com/ibreez/cr_app_backend/blob/main/src/services/filing/preFilingControlEngine.ts): `src/services/filing/preFilingControlEngine.ts`
- [Regulatory regression](https://github.com/ibreez/cr_app_backend/blob/main/src/regulatory/regression/regulatoryRegressionEngine.ts): `src/regulatory/regression/regulatoryRegressionEngine.ts`

### Other components

- **Business user**

## Connections

- Business user → Web application: uses
- Web application → HTTP routes: requests data (evidence: `src/App.tsx`)
- Web application → Bill review: opens review (evidence: `src/App.tsx`)
- Web application → Tax review: opens review (evidence: `src/App.tsx`)
- Web application → Dashboard: renders (evidence: `src/App.tsx`)
- HTTP routes → Application store: refreshes records (evidence: `server.ts`)
- HTTP routes → GST computation: converts bills (evidence: `server.ts`)
- HTTP routes → Tax orchestrator: invokes engine
- Tax orchestrator → Transaction classification: classifies transactions (evidence: `src/services/orchestrator/taxEngineOrchestrator.ts`)
- Tax orchestrator → Accounting and P&L: gets P&L (evidence: `src/services/orchestrator/taxEngineOrchestrator.ts`)
- Tax orchestrator → Tax computation: computes tax (evidence: `src/services/orchestrator/taxEngineOrchestrator.ts`)
- Tax orchestrator → Tax adjustments: processes adjustments (evidence: `src/services/orchestrator/taxEngineOrchestrator.ts`)
- Tax orchestrator → GST computation: computes GST (evidence: `src/services/orchestrator/taxEngineOrchestrator.ts`)
- Tax orchestrator → Tax reconciliation: reconciles results (evidence: `src/services/orchestrator/taxEngineOrchestrator.ts`)
- Tax computation → Regulatory rules: resolves rates (evidence: `src/services/tax/entityTaxService.ts`)
- GST computation → Regulatory rules: resolves rates (evidence: `src/services/gst/gstEngineService.ts`)
- Tax explainability → Regulatory rules: resolves rules (evidence: `src/services/explainability/taxExplainabilityEngine.ts`)
- Tax reconciliation → Tax adjustments: reads adjustments (evidence: `src/services/reconciliation/reconciliationEngine.ts`)
- Regulatory regression → Regulatory rules: resolves rules (evidence: `src/regulatory/regression/regulatoryRegressionEngine.ts`)
- Filing controls → Tax orchestrator: prepares filing
- Accounting and P&L → Prisma client: uses database (evidence: `src/services/accounting/pnlService.ts`)
- Transaction classification → Prisma client: uses database (evidence: `src/services/classification/canonicalClassificationEngine.ts`)
