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
56// =============================================================================
57// Clean Architecture Layers
58// =============================================================================
59
60/// Layer 1: Domain Layer - Enterprise Business Rules
61///
62/// Contains pure business entities, value objects, and repository traits.
63/// This layer has ZERO external dependencies.
64pub mod domain;
65
66/// Layer 2: Application Layer - Application Business Rules
67///
68/// Contains use cases that orchestrate domain entities and services.
69/// Depends only on the domain layer.
70pub mod application;
71
72/// Layer 3: Infrastructure Layer - Interface Adapters
73///
74/// Contains concrete implementations of abstractions.
75/// Depends on domain and application layers.
76pub mod infrastructure;
77
78// =============================================================================
79// Shared Modules
80// =============================================================================
81
82/// Error types for the entire crate
83pub mod error;
84
85/// Main EventStore facade
86pub mod store;
87
88/// Advanced security module (anomaly detection, encryption, KMS)
89pub mod security;
90
91// =============================================================================
92// Public API - Commonly Used Types
93// =============================================================================
94
95// Domain layer exports
96pub use domain::entities;
97pub use domain::entities::Event;
98pub use domain::repositories;
99
100// Application layer exports
101pub use application::dto::{IngestEventRequest, QueryEventsRequest};
102pub use application::services::{
103 AnalyticsEngine, Pipeline, PipelineConfig, PipelineManager, ProjectionManager, ReplayManager,
104 SchemaRegistry, TenantManager,
105};
106
107// Infrastructure layer exports
108pub use infrastructure::persistence::{
109 CompactionConfig, CompactionManager, EventIndex, ParquetStorage, SnapshotConfig,
110 SnapshotManager, WALConfig, WriteAheadLog,
111};
112pub use infrastructure::security::{AuthManager, Permission, RateLimiter, Role};
113pub use infrastructure::web::{serve, WebSocketManager};
114
115// Error handling
116pub use error::{AllSourceError, Result};
117
118// =============================================================================
119// Backward-Compatible Aliases (for binaries and external users)
120// =============================================================================
121
122/// Auth module re-export for backward compatibility
123pub mod auth {
124 pub use crate::infrastructure::security::{AuthManager, Permission, Role};
125}
126
127/// Rate limiting module re-export
128pub mod rate_limit {
129 pub use crate::infrastructure::security::rate_limit::{RateLimitConfig, RateLimiter};
130}
131
132/// Tenant module re-export
133pub mod tenant {
134 pub use crate::application::services::tenant_service::{TenantManager, TenantQuotas};
135 pub use crate::domain::entities::Tenant;
136}
137
138/// Config module re-export
139pub mod config {
140 pub use crate::infrastructure::config::*;
141}
142
143/// Backup module re-export
144pub mod backup {
145 pub use crate::infrastructure::persistence::backup::*;
146}
147
148/// API v1 module re-export
149pub mod api_v1 {
150 pub use crate::infrastructure::web::api_v1::*;
151}
152
153// Main store facade
154pub use store::EventStore;
155
156// =============================================================================
157// Tests
158// =============================================================================
159
160#[cfg(test)]
161mod security_integration_tests;