adaptive_pipeline/
presentation.rs

1// /////////////////////////////////////////////////////////////////////////////
2// Adaptive Pipeline
3// Copyright (c) 2025 Michael Gardner, A Bit of Help, Inc.
4// SPDX-License-Identifier: BSD-3-Clause
5// See LICENSE file in the project root.
6// /////////////////////////////////////////////////////////////////////////////
7
8//! # Interface Layer
9//!
10//! The interface layer provides external interfaces for user interaction and
11//! system integration. This layer handles all incoming requests and translates
12//! them into application layer operations.
13//!
14//! ## Architecture
15//!
16//! The interface layer follows the Clean Architecture pattern and serves as
17//! the outermost layer that:
18//!
19//! - Receives external requests (CLI, HTTP, etc.)
20//! - Validates and sanitizes input
21//! - Translates requests to application commands
22//! - Formats and returns responses
23//! - Handles authentication and authorization
24//!
25//! ## Module Structure
26//!
27//! ```text
28//! interface/
29//! ├── api/         # REST API and web interfaces
30//! ├── cli/         # Command-line interface
31//! └── config/      # Configuration management
32//! ```
33//!
34//! ## Command-Line Interface (CLI)
35//!
36//! The CLI provides a user-friendly command-line interface for pipeline
37//! operations:
38//!
39//! **Features:**
40//! - Interactive and non-interactive modes
41//! - Progress indicators and status updates
42//! - Comprehensive help and documentation
43//! - Configuration file support
44//! - Error handling with user-friendly messages
45//!
46//! **Example Usage:**
47//! ```bash
48//! # Process a file with a specific pipeline
49//! pipeline process --input input.txt --output output.adapipe --pipeline secure-backup
50//!
51//! # List available pipelines
52//! pipeline list-pipelines
53//!
54//! # Restore a processed file
55//! pipeline restore --input output.adapipe --output restored.txt
56//!
57//! # Create a new pipeline configuration
58//! pipeline create-pipeline --name my-pipeline --config pipeline.toml
59//! ```
60//!
61//! **Implementation:**
62//!
63//!
64//!
65//! ## REST API
66//!
67//! The REST API provides programmatic access to pipeline functionality:
68//!
69//! **Endpoints:**
70//! - `POST /api/v1/pipelines/{id}/process` - Process a file
71//! - `GET /api/v1/pipelines` - List pipelines
72//! - `POST /api/v1/pipelines` - Create pipeline
73//! - `GET /api/v1/pipelines/{id}/status` - Get processing status
74//!
75//! **Example API Usage:**
76//! ```bash
77//! # Process a file via REST API
78//! curl -X POST http://localhost:8080/api/v1/pipelines/secure-backup/process \
79//!   -H "Content-Type: application/json" \
80//!   -d '{
81//!     "input_path": "/path/to/input.txt",
82//!     "output_path": "/path/to/output.adapipe"
83//!   }'
84//! ```
85//!
86//! **Implementation:**
87//!
88//!
89//! ## Configuration Management
90//!
91//! The configuration module handles system configuration from multiple sources:
92//!
93//! **Configuration Sources:**
94//! - Configuration files (TOML, YAML, JSON)
95//! - Environment variables
96//! - Command-line arguments
97//! - Default values
98//!
99//! **Configuration Structure:**
100//! ```toml
101//! # pipeline.toml
102//! [server]
103//! host = "0.0.0.0"
104//! port = 8080
105//!
106//! [database]
107//! url = "sqlite:///pipeline.db"
108//! max_connections = 10
109//!
110//! [security]
111//! default_level = "confidential"
112//! encryption_algorithm = "aes256gcm"
113//!
114//! [processing]
115//! default_chunk_size = "1MB"
116//! max_workers = 4
117//! ```
118//!
119//! **Implementation:**
120//!
121//!
122//! ## Input Validation
123//!
124//! The interface layer performs comprehensive input validation:
125//!
126//!
127//!
128//! ## Error Handling
129//!
130//! The interface layer translates domain errors into user-friendly messages:
131//!
132//!
133//!
134//! ## Authentication and Authorization
135//!
136//! The interface layer handles security concerns:
137//!
138//!
139//!
140//! ## Testing Strategy
141//!
142//! Interface layer components are tested with:
143//!
144//! - **Unit Tests**: Test individual handlers and validators
145//! - **Integration Tests**: Test complete request/response flows
146//! - **End-to-End Tests**: Test user workflows through actual interfaces
147//!
148//! ```rust
149//! #[cfg(test)]
150//! mod tests {
151//!     use super::*;
152//!     use axum_test::StringestServer;
153//!
154//!     #[test]
155//!     fn test_process_file_endpoint() {
156//!         // Arrange: Set up test server
157//!         let app = create_test_app()?;
158//!         let server = StringestServer::new(app)?;
159//!
160//!         // Act: Make API request
161//!         let response = server
162//!             .post("/api/v1/pipelines/test/process")
163//!             .json(&ProcessRequest {
164//!                 input_path: "test.txt".to_string(),
165//!                 output_path: "test.adapipe".to_string(),
166//!             })?;
167//!
168//!         // Assert: Verify response
169//!         response.assert_status_ok();
170//!         let result: ProcessResponse = response.json();
171//!         assert!(result.success);
172//!         println!("API endpoint test passed");
173//!     }
174//! }
175//! ```
176
177//! # Interface Layer
178//!
179//! The interface layer provides external interfaces for interacting with the
180//! pipeline processing system. It includes API endpoints, CLI commands, and
181//! configuration management that allow users and external systems to access the
182//! application.
183//!
184//! ## Overview
185//!
186//! The interface layer provides:
187//!
188//! - **API Endpoints**: HTTP/REST API for programmatic access
189//! - **CLI Interface**: Command-line interface for interactive use
190//! - **Configuration**: System configuration and settings management
191//! - **Input Validation**: Validates and sanitizes external input
192//! - **Response Formatting**: Formats responses for different interfaces
193//!
194//! ## Components
195//!
196//! ### API
197//! RESTful HTTP API for external system integration:
198//! - Pipeline management endpoints
199//! - File processing operations
200//! - Status and monitoring endpoints
201//!
202//! ### CLI
203//! Command-line interface for direct user interaction:
204//! - Interactive commands
205//! - Batch processing support
206//! - Configuration management
207//!
208//! ### Configuration
209//! System configuration and settings:
210//! - Application settings
211//! - Pipeline configurations
212//! - Environment-specific settings
213
214pub mod adapters;