Domain Fintech

by actionbook5c40d3ad7851No license1.5K starsListed Oct 8, 2026Updated Oct 8, 2026Repository updated 6 weeks ago

Use when building fintech apps. Keywords: fintech, trading, decimal, currency, financial, money, transaction, ledger, payment, exchange rate, precision, rounding, accounting, 金融, 交易系统, 货币, 支付

AI-generated overview

Guidance for building fintech software in Rust, covering decimal money types, audit trails and transaction consistency.

What it does
This skill supplies domain constraints and design guidance for fintech applications, mainly in Rust. It maps financial rules such as precision, auditability and consistency to design implications, recommends crates like rust_decimal, chrono and uuid, and shows patterns such as currency newtypes, event sourcing, audit logs and double-entry ledgers. It also includes a sample Amount type and a list of common mistakes like using f64 for money.
When to use it
Use it when designing or reviewing fintech software where money handling, transaction integrity or audit requirements matter. It fits work on payments, ledgers, trading or accounting features that need precise decimal arithmetic and immutable records.
Requirements
No scripts or tooling are required; it is instructions only. Applying the guidance assumes a Rust project and the referenced crates such as rust_decimal, chrono, uuid, serde and validator.

FinTech Domain

Layer 3: Domain Constraints

Domain Constraints → Design Implications

Domain RuleDesign ConstraintRust Implication
Audit trailImmutable recordsArc<T>, no mutation
PrecisionNo floating pointrust_decimal
ConsistencyTransaction boundariesClear ownership
ComplianceComplete loggingStructured tracing
ReproducibilityDeterministic executionNo race conditions

Critical Constraints

Financial Precision

RULE: Never use f64 for moneyWHY: Floating point loses precisionRUST: Use rust_decimal::Decimal

Audit Requirements

RULE: All transactions must be immutable and traceableWHY: Regulatory compliance, dispute resolutionRUST: Arc<T> for sharing, event sourcing pattern

Consistency

RULE: Money can't disappear or appearWHY: Double-entry accounting principlesRUST: Transaction types with validated totals

Trace Down ↓

From constraints to design (Layer 2):

"Need immutable transaction records"    ↓ m09-domain: Model as Value Objects    ↓ m01-ownership: Use Arc for shared immutable data
"Need precise decimal math"    ↓ m05-type-driven: Newtype for Currency/Amount    ↓ rust_decimal: Use Decimal type
"Need transaction boundaries"    ↓ m12-lifecycle: RAII for transaction scope    ↓ m09-domain: Aggregate boundaries

Key Crates

PurposeCrate
Decimal mathrust_decimal
Date/timechrono, time
UUIDuuid
Serializationserde
Validationvalidator

Design Patterns

PatternPurposeImplementation
Currency newtypeType safetystruct Amount(Decimal);
TransactionAtomic operationsEvent sourcing
Audit logTraceabilityStructured logging with trace IDs
LedgerDouble-entryDebit/credit balance

Code Pattern: Currency Type

rust
use rust_decimal::Decimal;
#[derive(Clone, Debug, PartialEq)]pub struct Amount {    value: Decimal,    currency: Currency,}
impl Amount {    pub fn new(value: Decimal, currency: Currency) -> Self {        Self { value, currency }    }
    pub fn add(&self, other: &Amount) -> Result<Amount, CurrencyMismatch> {        if self.currency != other.currency {            return Err(CurrencyMismatch);        }        Ok(Amount::new(self.value + other.value, self.currency))    }}

Common Mistakes

MistakeDomain ViolationFix
Using f64Precision lossrust_decimal
Mutable transactionAudit trail brokenImmutable + events
String for amountNo validationValidated newtype
Silent overflowMoney disappearsChecked arithmetic

Trace to Layer 1

ConstraintLayer 2 PatternLayer 1 Implementation
Immutable recordsEvent sourcingArc<T>, Clone
Transaction scopeAggregateOwned children
PrecisionValue Objectrust_decimal newtype
Thread-safe sharingShared immutableArc (not Rc)

Related Skills

WhenSee
Value Object designm09-domain
Ownership for immutablem01-ownership
Arc for sharingm02-resource
Error handlingm13-domain-error

Source and attribution

Source:actionbook/rust-skillsinskills/domain-fintechat commit5c40d3a

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal