allsource_core/lib.rs
1//! # AllSource Core - High-Performance Event Store
2//!
3//! A high-performance event sourcing platform built in Rust, following Clean Architecture principles.
4//!
5//! ## Architecture Overview
6//!
7//! The codebase follows a layered Clean Architecture:
8//!
9//! ```text
10//! ┌─────────────────────────────────────────────────────────────┐
11//! │ Infrastructure Layer │
12//! │ (HTTP handlers, WebSocket, persistence, security) │
13//! │ infrastructure::web, infrastructure::persistence, │
14//! │ infrastructure::security, infrastructure::repositories │
15//! ├─────────────────────────────────────────────────────────────┤
16//! │ Application Layer │
17//! │ (Use cases, services, DTOs) │
18//! │ application::use_cases, application::services, │
19//! │ application::dto │
20//! ├─────────────────────────────────────────────────────────────┤
21//! │ Domain Layer │
22//! │ (Entities, value objects, repository traits) │
23//! │ domain::entities, domain::value_objects, │
24//! │ domain::repositories │
25//! └─────────────────────────────────────────────────────────────┘
26//! ```
27//!
28//! ## Module Organization
29//!
30//! - **domain**: Core business entities, value objects, and repository traits
31//! - **application**: Use cases, services, and DTOs that orchestrate domain logic
32//! - **infrastructure**: Concrete implementations (web, persistence, security)
33//!
34//! ## Quick Start
35//!
36//! ```rust,ignore
37//! use allsource_core::{EventStore, Event, IngestEventRequest};
38//!
39//! let store = EventStore::new();
40//! let event = Event::from_strings(
41//! "user.created".to_string(),
42//! "user-123".to_string(),
43//! "default".to_string(),
44//! serde_json::json!({"name": "Alice"}),
45//! None,
46//! )?;
47//! store.ingest(event)?;
48//! ```
49
50// Suppress warnings for development
51#![allow(dead_code)]
52#![allow(unused_variables)]
53#![allow(deprecated)]
54#![allow(unused_must_use)]
55// Clippy configuration - allow common patterns in this codebase
56#![allow(clippy::too_many_arguments)]
57#![allow(clippy::type_complexity)]
58#![allow(clippy::module_inception)]
59#![allow(clippy::derivable_impls)]
60#![allow(clippy::empty_line_after_doc_comments)]
61#![allow(clippy::useless_vec)]
62#![allow(clippy::or_fun_call)]
63#![allow(clippy::only_used_in_recursion)]
64#![allow(clippy::assign_op_pattern)]
65
66// =============================================================================
67// Clean Architecture Layers
68// =============================================================================
69
70/// Layer 1: Domain Layer - Enterprise Business Rules
71///
72/// Contains pure business entities, value objects, and repository traits.
73/// This layer has ZERO external dependencies.
74pub mod domain;
75
76/// Layer 2: Application Layer - Application Business Rules
77///
78/// Contains use cases that orchestrate domain entities and services.
79/// Depends only on the domain layer.
80pub mod application;
81
82/// Layer 3: Infrastructure Layer - Interface Adapters
83///
84/// Contains concrete implementations of abstractions.
85/// Depends on domain and application layers.
86pub mod infrastructure;
87
88// =============================================================================
89// Shared Modules
90// =============================================================================
91
92/// Error types for the entire crate
93pub mod error;
94
95/// Main EventStore facade
96pub mod store;
97
98/// Advanced security module (anomaly detection, encryption, KMS)
99pub mod security;
100
101// =============================================================================
102// Public API - Commonly Used Types
103// =============================================================================
104
105// Domain layer exports
106pub use domain::entities;
107pub use domain::entities::Event;
108pub use domain::repositories;
109
110// Application layer exports
111pub use application::dto::{IngestEventRequest, QueryEventsRequest};
112pub use application::services::{
113 AnalyticsEngine, Pipeline, PipelineConfig, PipelineManager, ProjectionManager, ReplayManager,
114 SchemaRegistry, TenantManager,
115};
116
117// Infrastructure layer exports
118pub use infrastructure::persistence::{
119 CompactionConfig, CompactionManager, EventIndex, ParquetStorage, SnapshotConfig,
120 SnapshotManager, WALConfig, WriteAheadLog,
121};
122pub use infrastructure::security::{AuthManager, Permission, RateLimiter, Role};
123pub use infrastructure::web::{serve, WebSocketManager};
124
125// Error handling
126pub use error::{AllSourceError, Result};
127
128// =============================================================================
129// Backward-Compatible Aliases (for binaries and external users)
130// =============================================================================
131
132/// Auth module re-export for backward compatibility
133pub mod auth {
134 pub use crate::infrastructure::security::{AuthManager, Permission, Role};
135}
136
137/// Rate limiting module re-export
138pub mod rate_limit {
139 pub use crate::infrastructure::security::rate_limit::{RateLimitConfig, RateLimiter};
140}
141
142/// Tenant module re-export
143pub mod tenant {
144 pub use crate::application::services::tenant_service::{TenantManager, TenantQuotas};
145 pub use crate::domain::entities::Tenant;
146}
147
148/// Config module re-export
149pub mod config {
150 pub use crate::infrastructure::config::*;
151}
152
153/// Backup module re-export
154pub mod backup {
155 pub use crate::infrastructure::persistence::backup::*;
156}
157
158/// API v1 module re-export
159pub mod api_v1 {
160 pub use crate::infrastructure::web::api_v1::*;
161}
162
163// Main store facade
164pub use store::EventStore;
165
166// =============================================================================
167// Tests
168// =============================================================================
169
170#[cfg(test)]
171mod security_integration_tests;