feat: full clean architecture refactor — domain → application → infrastructure → presentation
- Restructure from Modular MVC to Clean Architecture with 4 strict layers - Domain: entities (anime/komik/proxy), Repository traits, typed errors - Application: use case classes with proper error propagation - Infrastructure: repository impls, parsers, Redis cache, HTTP/scraping, browser - Presentation: Axum handlers, DTOs, AppState, router, AppError+IntoResponse - Migrate all parsers (otakudesu, alqanime, komik) to native infra implementations - Replace once_cell::sync::Lazy/OnceCell with std::sync::LazyLock/OnceLock - Remove 150+ old files in modules/ and shared/ directories - Remove once_cell from Cargo.toml dependencies - Fix test/debug binaries to use new import paths - Zero new clippy warnings Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
80c96eaa42
commit
776fa828d8
@@ -0,0 +1,19 @@
|
||||
//! Repository trait for image cache (original → CDN mapping).
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
/// Repository for managing cached image URL mappings.
|
||||
#[async_trait]
|
||||
pub trait ImageCacheRepository: Send + Sync {
|
||||
async fn get_from_redis(&self, key: &str) -> Option<String>;
|
||||
async fn set_in_redis(&self, key: &str, value: &str, ttl: u64) -> Result<(), String>;
|
||||
async fn get_from_db(&self, original_url: &str) -> Result<Option<String>, String>;
|
||||
async fn save_to_db(&self, original_url: &str, cdn_url: &str) -> Result<(), String>;
|
||||
async fn find_original_from_cdn(&self, cdn_url: &str) -> Result<Option<String>, String>;
|
||||
async fn delete_from_db(&self, original_url: &str) -> Result<(), String>;
|
||||
async fn delete_from_redis(&self, key: &str) -> Result<(), String>;
|
||||
async fn get_lock(&self, key: &str) -> bool;
|
||||
async fn set_lock(&self, key: &str, ttl: u64) -> Result<(), String>;
|
||||
async fn release_lock(&self, key: &str) -> Result<(), String>;
|
||||
async fn invalidate_api_caches(&self, patterns: Vec<&str>) -> Result<(), String>;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
pub mod image_cache;
|
||||
pub mod scraping;
|
||||
|
||||
pub use image_cache::ImageCacheRepository;
|
||||
pub use scraping::ScrapingRepository;
|
||||
@@ -0,0 +1,12 @@
|
||||
//! Repository trait for scraping HTML from remote sources.
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::domain::error::ScrapingError;
|
||||
|
||||
/// Trait for repositories that fetch and scrape HTML content.
|
||||
#[async_trait]
|
||||
pub trait ScrapingRepository: Send + Sync {
|
||||
/// Fetch raw HTML from a URL.
|
||||
async fn fetch_html(&self, url: &str) -> Result<String, ScrapingError>;
|
||||
}
|
||||
Reference in New Issue
Block a user