1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
//! # Kaccy Protocol
//!
//! Complete platform for fractional Bitcoin transactions with reputation-backed personal tokens.
//!
//! ## Overview
//!
//! Kaccy is a next-generation value distribution protocol where professionals can tokenize
//! their expertise using Bitcoin and Lightning Network. Token holders gain access to creators'
//! services and future outputs, backed by a robust reputation system.
//!
//! ## Key Features
//!
//! - **Personal Tokens (FOT)**: Issue "Future Output Tokens" representing access to your services
//! - **Bonding Curve Pricing**: Automatic price discovery with always-available liquidity
//! - **Bitcoin Native**: All transactions in BTC, with Lightning Network for instant micropayments
//! - **Reputation System**: SBT-based reputation tracking with commitment verification
//! - **AI Integration**: Quality evaluation and fraud detection powered by AI
//!
//! ## Crates
//!
//! This meta-crate re-exports all Kaccy sub-crates for convenient access:
//!
//! - [`kaccy_core`] - Core business logic (tokens, orders, matching)
//! - [`kaccy_db`] - Database layer (PostgreSQL, Redis, caching)
//! - [`kaccy_bitcoin`] - Bitcoin Core & Lightning integration
//! - [`kaccy_reputation`] - Reputation scoring & SBT
//! - [`kaccy_ai`] - AI evaluation services
//! - [`kaccy_api`] - REST/WebSocket API (Axum)
//!
//! ## Quick Start
//!
//! ```rust,ignore
//! use kaccy::prelude::*;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Setup database
//! let pool = kaccy_db::create_pool(&std::env::var("DATABASE_URL")?).await?;
//!
//! // Initialize services
//! let user_repo = kaccy_db::UserRepository::new(pool.clone());
//! let token_repo = kaccy_db::TokenRepository::new(pool.clone());
//!
//! // Connect to Bitcoin
//! let bitcoin_client = kaccy_bitcoin::BitcoinClient::new(
//! "http://localhost:8332",
//! "rpcuser",
//! "rpcpassword",
//! kaccy_bitcoin::BitcoinNetwork::Mainnet,
//! )?;
//!
//! // Create reputation engine
//! let reputation = kaccy_reputation::ReputationEngine::new(pool.clone());
//!
//! Ok(())
//! }
//! ```
//!
//! ## Usage by Module
//!
//! ### Core Business Logic
//!
//! ```rust,ignore
//! use kaccy::kaccy_core::pricing::{BondingCurve, LinearBondingCurve};
//! use rust_decimal_macros::dec;
//!
//! let curve = LinearBondingCurve::new(dec!(0.0001), dec!(0.00001));
//! let cost = curve.buy_price(dec!(0), dec!(10));
//! ```
//!
//! ### Database Operations
//!
//! ```rust,no_run
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! use kaccy::kaccy_db::{create_pool, UserRepository};
//!
//! let pool = create_pool("postgresql://...").await?;
//! let user_repo = UserRepository::new(pool);
//! let user = user_repo.find_by_email("user@example.com").await?;
//! # Ok(())
//! # }
//! ```
//!
//! ### Bitcoin Integration
//!
//! ```rust,ignore
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! use kaccy::kaccy_bitcoin::{BitcoinClient, BitcoinNetwork, HdWallet, HdWalletConfig};
//!
//! let client = BitcoinClient::new("http://localhost:8332", "user", "pass", BitcoinNetwork::Mainnet)?;
//! let config = HdWalletConfig { xpub: std::env::var("WALLET_XPUB")?, ..Default::default() };
//! let wallet = HdWallet::new(config)?;
//! # Ok(())
//! # }
//! ```
//!
//! ### Reputation System
//!
//! ```rust,ignore
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! use kaccy::kaccy_reputation::{ReputationEngine, ReputationEventType};
//! # let pool: sqlx::PgPool = todo!();
//! # let user_id = uuid::Uuid::new_v4();
//!
//! let engine = ReputationEngine::new(pool);
//! let score = engine.get_score(user_id).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ### AI Services
//!
//! ```rust,no_run
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! use kaccy::kaccy_ai::{AiEvaluator, EvaluatorConfig};
//! use kaccy::kaccy_ai::llm::{LlmClient, OpenAiClient};
//!
//! let openai = OpenAiClient::with_default_model("api-key");
//! let llm_client = LlmClient::new(Box::new(openai));
//! let evaluator = AiEvaluator::with_config(llm_client, EvaluatorConfig::default());
//! # Ok(())
//! # }
//! ```
//!
//! ## Documentation
//!
//! See individual crate documentation for detailed API references:
//!
//! - [kaccy-core docs](https://docs.rs/kaccy-core)
//! - [kaccy-db docs](https://docs.rs/kaccy-db)
//! - [kaccy-bitcoin docs](https://docs.rs/kaccy-bitcoin)
//! - [kaccy-reputation docs](https://docs.rs/kaccy-reputation)
//! - [kaccy-ai docs](https://docs.rs/kaccy-ai)
//! - [kaccy-api docs](https://docs.rs/kaccy-api)
//!
//! ## License
//!
//! Proprietary - All rights reserved
// Re-export all sub-crates
pub use kaccy_ai;
pub use kaccy_api;
pub use kaccy_bitcoin;
pub use kaccy_core;
pub use kaccy_db;
pub use kaccy_reputation;