Code Structure
Cheolsu Proxy is structured as a Rust-based monorepo with a Tauri desktop application.
Overall Structure
Workspace Structure
Root Cargo.toml
External Crates
proxy_v2_models is not a workspace member but is a separate crate that other workspace members reference as a dependency.
Key Modules
- har.rs: HAR 1.2 format conversion module (
build_har(),build_har_json()) - request.rs / response.rs: HTTP request/response models
- data_type.rs: Data type classification
- file_storage.rs: Body file storage management
Backend Structure
1. proxyapi_v2/ (Main Proxy Engine)
2. certificate_authority/ (CA Management)
Module Structure
Key Features
- Dynamic Certificate Generation: Automatic certificate generation per domain
- PKCS12 Support: PKCS12 certificate generation for native-tls
- Cross-platform: Support for macOS, Windows
3. proxy/ (Proxy Core)
Builder Pattern
Internal Logic
Frontend Structure (desktop/)
FSD (Feature-Sliced Design) Architecture
Layer Responsibilities
1. app/ (Application Layer)
- App.tsx: Root component, routing setup
- layouts/: Common layout components
- providers/: React Context providers
2. pages/ (Page Layer)
- network-dashboard/: Main network monitoring page
- sessions/: Session management page
3. widgets/ (Widget Layer)
- network-table/: Network request table
- network-header/: Network header information
- host-path-tree/: Host-based path tree
4. features/ (Feature Layer)
- network-table/: Table-related features (filtering, sorting, etc.)
- transaction-details/: Transaction detail view
- har-export/: Export transactions in HAR 1.2 format
- websocket-test/: WebSocket test functionality
5. entities/ (Entity Layer)
- proxy/: Proxy-related data models
- session/: Session-related data models
- transaction/: Transaction-related data models
6. shared/ (Shared Layer)
- api/: Backend API client
- ui/: Reusable UI components
- lib/: Utility functions
- stores/: Zustand state management
- assets/: Static assets
Tauri Backend (desktop/src-tauri/)
Tauri Configuration
Data Flow
1. Proxy Request Processing
2. Frontend Data Flow
State Management
Zustand Store Structure
API Communication
Tauri Invoke API
Test Structure
Rust Tests
Frontend Tests
Build and Deployment
Development Build
Production Build
Performance Optimization
Backend Optimization
- Asynchronous Processing: Using tokio runtime
- Memory Pooling: Object pool pattern implementation
- Streaming: Large data streaming processing
Frontend Optimization
- Virtualization: Large list virtualization
- Memoization: React.memo, useMemo usage
- Code Splitting: Dynamic import usage
Security Considerations
Backend Security
- Certificate Management: Secure CA certificate generation
- Memory Security: Safe memory management
- Input Validation: All input data validation
Frontend Security
- XSS Prevention: Input data escaping
- CSRF Prevention: Token-based authentication
- Content Security Policy: CSP header settings
Extensibility
Plugin System (Future)
API Extension
- REST API addition
- GraphQL support
- gRPC support
Understanding this structure will help you effectively navigate and contribute to the Cheolsu Proxy codebase.
