2.4 KiB
2.4 KiB
System Patterns
Architecture Overview
The application follows a client-server architecture with containerized deployment and secure authentication:
Authentication System
- JSON file-based user management
- Secure password hashing with bcrypt
- Session-based authentication using Flask-Login
- Protected API routes with login_required decorator
- Remember me functionality for persistent sessions
Frontend (React)
- Single Page Application (SPA) architecture
- Authentication state management
- Protected route handling
- Component-based structure:
- Login: User authentication interface
- FileUpload: Handles file input and processing
- FileList: Manages processed files
- ModelSelector: AI model selection
- Configurations: System settings and prompts
- ProgressBar: Real-time processing feedback
- Notifications: User feedback system
- TxtToPdf: Document conversion utility
Backend (Flask)
- RESTful API architecture
- Modular design with separate concerns:
- app.py: Main application and route handlers
- models.py: Data models and AI model management
- utils.py: Processing utilities and helpers
Key Technical Decisions
Background Processing
- Asynchronous job processing using threading
- Job tracking system with unique IDs
- Real-time progress updates via polling
File Management
- Secure file handling with unique naming
- Separate upload and output directories
- Support for multiple file formats
AI Integration
- Modular AI model system
- Support for multiple AI providers:
- OpenAI
- Gemini
- Mistral
- Configurable prompts system
OCR Processing
- Multiple processing modes:
- Pure OCR (Tesseract)
- Hybrid (OCR + AI)
- Full AI OCR
- Page-by-page processing for large documents
Translation System
- Language management system
- Page-by-page translation
- Progress tracking per page
Configuration Management
- JSON-based configuration storage
- Import/export functionality
- Runtime model and prompt updates
Error Handling
- Comprehensive error catching
- User-friendly error messages
- Job cancellation support
Security Patterns
- Secure file uploads with sanitization
- CORS configuration with credentials support
- Environment-based configuration
- Password hashing and verification
- Session management and protection
- API route protection
- Authentication state persistence
- Secure cookie handling