adding search engine

This commit is contained in:
DioCrafts
2025-03-27 01:13:34 +01:00
parent dacc3ecc4c
commit 7affff379d
24 changed files with 1531 additions and 66 deletions
+39 -26
View File
@@ -6,31 +6,29 @@ use axum::Router;
use tower_http::trace::TraceLayer;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
/**
* OxiCloud - Cloud Storage Platform
*
* OxiCloud is a NextCloud-like file storage system built in Rust with a focus on
* performance, security, and clean architecture. The system provides:
*
* - File and folder management with rich metadata
* - User authentication and authorization
* - File trash system with automatic cleanup
* - Efficient handling of large files through parallel processing
* - Compression capabilities for bandwidth optimization
* - RESTful API and web interface
*
* The architecture follows the Clean/Hexagonal Architecture pattern with:
*
* - Domain Layer: Core business entities and repository interfaces (domain/*)
* - Application Layer: Use cases and service orchestration (application/*)
* - Infrastructure Layer: Technical implementations of repositories (infrastructure/*)
* - Interface Layer: API endpoints and web controllers (interfaces/*)
*
* Dependencies are managed through dependency inversion, with high-level modules
* defining interfaces (ports) that low-level modules implement (adapters).
*
* @author OxiCloud Development Team
*/
/// OxiCloud - Cloud Storage Platform
///
/// OxiCloud is a NextCloud-like file storage system built in Rust with a focus on
/// performance, security, and clean architecture. The system provides:
///
/// - File and folder management with rich metadata
/// - User authentication and authorization
/// - File trash system with automatic cleanup
/// - Efficient handling of large files through parallel processing
/// - Compression capabilities for bandwidth optimization
/// - RESTful API and web interface
///
/// The architecture follows the Clean/Hexagonal Architecture pattern with:
///
/// - Domain Layer: Core business entities and repository interfaces (domain/*)
/// - Application Layer: Use cases and service orchestration (application/*)
/// - Infrastructure Layer: Technical implementations of repositories (infrastructure/*)
/// - Interface Layer: API endpoints and web controllers (interfaces/*)
///
/// Dependencies are managed through dependency inversion, with high-level modules
/// defining interfaces (ports) that low-level modules implement (adapters).
///
/// @author OxiCloud Development Team
/// Common utilities, configuration, and error handling
mod common;
@@ -580,6 +578,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}),
};
// Create the search service
let search_service: Option<Arc<dyn application::ports::inbound::SearchUseCase>> = {
// Create the search service with caching
let search_service = Arc::new(application::services::search_service::SearchService::new(
file_repository.clone(),
folder_repository.clone(),
300, // Cache TTL in seconds (5 minutes)
1000, // Maximum cache entries
));
tracing::info!("Search service initialized with caching (TTL: 300s, max entries: 1000)");
Some(search_service)
};
let application_services = common::di::ApplicationServices {
folder_service: folder_service.clone(),
file_service: file_service.clone(),
@@ -589,6 +601,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
file_use_case_factory: Arc::new(application::services::file_use_case_factory::AppFileUseCaseFactory::default_stub()),
i18n_service: i18n_service.clone(),
trash_service: trash_service.clone(),
search_service: search_service.clone(),
};
// Create the AppState without Arc first
@@ -613,7 +626,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let app_state = Arc::new(app_state);
// Build application router
let api_routes = create_api_routes(folder_service, file_service, Some(i18n_service), trash_service);
let api_routes = create_api_routes(folder_service, file_service, Some(i18n_service), trash_service, search_service);
let web_routes = create_web_routes();
// Build the app router