Back to Projects

Experimental Sequence 05

Thirueadu
Ledger Documentation

This page mirrors `project_documentation` from the distributed-ledger project. It captures the complete runtime design: command bridge, service validation, immutable transaction ledger, people-debt workflows, data model, and UI evidence.

React 19TypeScriptTauri v2RustSQLiteReact QueryRecharts
Ledger CoreImmutable
Paise-precision model

Purpose and Scope

Multi-account money tracking for bank, cash, and wallet

Person-centric debt ledger using virtual asset/liability accounts

Transaction coverage for expense, income, transfer, debt, and settlement

Analytics dashboard for spending categories and payment modes

Computed balances from immutable transaction history

Local-first desktop execution with no cloud dependency

Layered Runtime Design

UI views capture input and render ledger/dashboard state.

Query hooks fetch and mutate data with cache invalidation boundaries.

Bridge layer (`src/db.ts`) converts rupees to paise and invokes Tauri commands.

Rust handlers route payloads into service-level business validation.

Repository layer executes parameterized SQL over SQLite.

Balances are derived from transaction rows, never directly stored in accounts.

Architecture Overview Diagram

Dedicated architecture rendering for Thirueadu flow: React UI, Tauri bridge, Rust service, and SQLite repository path.

Entity Relationship Diagram

Full relational mapping of accounts, transactions, categories, payment modes, and ledger links.

Transaction Interaction Path

Step 1

User submits a transaction in AddTransactionModal.

Step 2

Amount is converted to paise in frontend bridge helpers.

Step 3

Tauri invoke sends the payload to Rust command handlers.

Step 4

Service layer validates amount/account/type rules.

Step 5

Repository inserts immutable transaction rows.

Step 6

Query cache invalidates and UI recomputes account/people balances.

Frontend/Backend Core Files

Frontend

src/App.tsx

src/components/Dashboard.tsx

src/components/AddTransactionModal.tsx

src/components/PeopleView.tsx

src/components/AddAccountView.tsx

src/components/CategoriesView.tsx

src/components/PaymentModesView.tsx

src/hooks/useQuery.ts

src/db.ts

src/calculations.ts

Backend

src-tauri/src/handlers/mod.rs

src-tauri/src/service/mod.rs

src-tauri/src/repository/mod.rs

src-tauri/src/repository/database.rs

src-tauri/src/models/mod.rs

View State Machine

home

transactions

stats

accounts

people

person-ledger

add-account

add-transaction

categories

payment-modes

add-person

Data Model and Table Roles

accounts

Real and virtual accounts for money and people-ledger modeling

transactions

Immutable ledger rows in paise with source and destination references

categories

Expense/income category definitions

payment_modes

Payment channel entities (UPI/Cash/Card, etc.)

account_modes

Account-to-payment mode associations

account_categories

Account-to-category associations

audit_logs

Operation history and traceability

budgets

Reserved table for budgeting module extensions

People Ledger Modes

DEBT_GIVEN

DEBT_TAKEN

DEBT_SETTLED_RECEIVE

DEBT_SETTLED_PAY

Architecture Diagrams

Visual Walkthrough (01-12)

Security and Integrity Notes

Money is stored as integer paise to avoid floating-point drift.

SQLite foreign keys are enforced (`PRAGMA foreign_keys = ON`).

Balances are derived from ledger history; there is no direct balance mutation.

SQL operations use SQLx parameter binding for safer queries.

Audit log table supports post-operation traceability.