Skip to main content

datasynth_banking/personas/
mod.rs

1//! Behavioral persona blueprints module.
2//!
3//! This module defines behavioral patterns for different customer types:
4//! - Retail personas (student, early career, mid-career, etc.)
5//! - Business personas (SME, mid-market, enterprise, etc.)
6//! - Trust personas (family trust, charitable foundation, etc.)
7
8mod business;
9mod retail;
10mod trust;
11
12// Re-export specific functions with qualified names
13pub use business::get_profile as get_business_profile_impl;
14pub use retail::get_profile as get_retail_profile_impl;
15pub use trust::get_profile as get_trust_profile_impl;
16
17use datasynth_core::models::banking::{BusinessPersona, RetailPersona, TrustPersona};
18
19/// Transaction behavior profile.
20#[derive(Debug, Clone)]
21pub struct TransactionBehavior {
22    /// Average transactions per month
23    pub monthly_tx_count: u32,
24    /// Standard deviation of monthly count
25    pub monthly_tx_std: f64,
26    /// Average transaction amount
27    pub avg_amount: f64,
28    /// Amount standard deviation
29    pub amount_std: f64,
30    /// Minimum transaction amount
31    pub min_amount: f64,
32    /// Maximum transaction amount
33    pub max_amount: f64,
34    /// Percentage of transactions that are cash
35    pub cash_percentage: f64,
36    /// Percentage of transactions that are international
37    pub international_percentage: f64,
38    /// Typical transaction hours (start, end)
39    pub active_hours: (u8, u8),
40    /// Weekend activity multiplier
41    pub weekend_multiplier: f64,
42}
43
44impl Default for TransactionBehavior {
45    fn default() -> Self {
46        Self {
47            monthly_tx_count: 30,
48            monthly_tx_std: 10.0,
49            avg_amount: 150.0,
50            amount_std: 100.0,
51            min_amount: 5.0,
52            max_amount: 5000.0,
53            cash_percentage: 0.1,
54            international_percentage: 0.01,
55            active_hours: (8, 22),
56            weekend_multiplier: 1.0,
57        }
58    }
59}
60
61/// Spending category distribution.
62#[derive(Debug, Clone)]
63pub struct SpendingProfile {
64    /// Groceries percentage
65    pub groceries: f64,
66    /// Dining/restaurants percentage
67    pub dining: f64,
68    /// Entertainment percentage
69    pub entertainment: f64,
70    /// Shopping/retail percentage
71    pub shopping: f64,
72    /// Transportation percentage
73    pub transportation: f64,
74    /// Utilities percentage
75    pub utilities: f64,
76    /// Healthcare percentage
77    pub healthcare: f64,
78    /// Travel percentage
79    pub travel: f64,
80    /// Other/misc percentage
81    pub other: f64,
82}
83
84impl Default for SpendingProfile {
85    fn default() -> Self {
86        Self {
87            groceries: 0.20,
88            dining: 0.12,
89            entertainment: 0.08,
90            shopping: 0.15,
91            transportation: 0.10,
92            utilities: 0.15,
93            healthcare: 0.05,
94            travel: 0.05,
95            other: 0.10,
96        }
97    }
98}
99
100/// Income profile for retail customers.
101#[derive(Debug, Clone)]
102pub struct IncomeProfile {
103    /// Primary income source
104    pub source: IncomeSource,
105    /// Monthly income amount
106    pub monthly_amount: f64,
107    /// Income frequency
108    pub frequency: IncomeFrequency,
109    /// Day of month for income (if applicable)
110    pub income_day: Option<u8>,
111    /// Has multiple income streams
112    pub has_secondary: bool,
113}
114
115/// Income source types.
116#[derive(Debug, Clone, Copy, PartialEq, Eq)]
117pub enum IncomeSource {
118    Salary,
119    HourlyWage,
120    SelfEmployment,
121    Pension,
122    SocialSecurity,
123    Investment,
124    Rental,
125    Gig,
126    ParentalSupport,
127    Other,
128}
129
130/// Income frequency.
131#[derive(Debug, Clone, Copy, PartialEq, Eq)]
132pub enum IncomeFrequency {
133    Weekly,
134    BiWeekly,
135    SemiMonthly,
136    Monthly,
137    Irregular,
138}
139
140/// Full persona profile combining all aspects.
141#[derive(Debug, Clone)]
142pub struct PersonaProfile {
143    /// Transaction behavior
144    pub transaction_behavior: TransactionBehavior,
145    /// Spending categories
146    pub spending_profile: SpendingProfile,
147    /// Income profile (for retail)
148    pub income_profile: Option<IncomeProfile>,
149    /// Risk appetite (0.0 = very conservative, 1.0 = very aggressive)
150    pub risk_appetite: f64,
151    /// Saving rate (percentage of income saved)
152    pub saving_rate: f64,
153    /// Likelihood to use credit
154    pub credit_usage: f64,
155}
156
157/// Get persona profile for a retail persona.
158pub fn get_retail_profile(persona: RetailPersona) -> PersonaProfile {
159    retail::get_profile(persona)
160}
161
162/// Get persona profile for a business persona.
163pub fn get_business_profile(persona: BusinessPersona) -> PersonaProfile {
164    business::get_profile(persona)
165}
166
167/// Get persona profile for a trust persona.
168pub fn get_trust_profile(persona: TrustPersona) -> PersonaProfile {
169    trust::get_profile(persona)
170}