A powerful document conversion application built with clean architecture principles and SOLID design patterns. Supports multiple conversion engines including Docling and MarkItDown for different use cases and requirements.
This application follows Clean Architecture principles with clear separation of concerns and dependency inversion. The structure is organized into distinct layers:
docling/
βββ main.py # Entry point with dependency injection
βββ models/ # Data models and domain entities
β βββ __init__.py
β βββ document_format.py # Enums, dataclasses for formats, jobs and converter types
βββ interfaces/ # Abstract interfaces (contracts)
β βββ __init__.py
β βββ interfaces.py # Abstract base classes and protocols
βββ services/ # Business logic and external integrations
β βββ __init__.py
β βββ conversion_service.py # Core conversion logic with multi-engine support
β βββ file_service.py # File operations service
βββ presenters/ # Application logic (MVP pattern)
β βββ __init__.py
β βββ converter_presenter.py # Presenter coordinating view and services
βββ views/ # User interface layer
βββ __init__.py
βββ converter_view.py # Tkinter GUI with converter selection
- Models: Only handle data structures and domain entities
- Services: Each service has one specific responsibility (file operations, conversion logic)
- Views: Only responsible for UI presentation
- Presenters: Only handle coordination between view and business logic
- Format Extensibility: New input/output formats can be added by extending enums
- Service Extensibility: New services can be added without modifying existing code
- UI Extensibility: New UI implementations can be created by implementing interfaces
- Service Interfaces: All service implementations can be substituted without breaking functionality
- Document Converter: Different converter implementations are interchangeable
- Focused Interfaces: Each interface serves a specific purpose
- UIEventHandler: Separated UI events from other responsibilities
- Service Interfaces: Each service interface is focused on its domain
- Abstract Dependencies: High-level modules depend on abstractions, not concrete implementations
- Dependency Injection: Dependencies are injected through constructors
- Interface-Based Design: All major components depend on interfaces
- View: Pure UI logic (
DocumentConverterView) - Presenter: Application logic and coordination (
DocumentConverterPresenter) - Model: Data structures and business entities (
document_format.py)
# main.py
docling_converter = DoclingDocumentConverter()
markitdown_converter = MarkItDownDocumentConverter()
file_service = FileService()
conversion_service = ConversionService(docling_converter, markitdown_converter, file_service)
presenter = DocumentConverterPresenter(conversion_service, file_service)- Different export formats implemented as strategies in
_export_document() - File type handling through format enums
- Docling: Advanced document converter with rich formatting support and comprehensive output options
- MarkItDown: Lightweight converter focused on markdown output, ideal for simple conversions
| Feature | Docling | MarkItDown |
|---|---|---|
| Best For | Complex documents with rich formatting | Simple text extraction and markdown conversion |
| Output Quality | High-fidelity with layout preservation | Clean, readable markdown |
| Performance | More resource intensive | Lightweight and fast |
| Output Formats | HTML, Markdown, JSON, Text, Doctags | Primarily Markdown (with HTML/Text export) |
| Use Cases | Professional document processing, archival | Quick content extraction, documentation |
- Documents: PDF, DOCX, XLSX, PPTX
- Text: Markdown, AsciiDoc, HTML, XHTML, CSV
- Images: PNG, JPEG, TIFF, BMP, WEBP
- Specialized: USPTO XML, JATS XML, Docling JSON
- HTML (with image embedding/referencing)
- Markdown
- JSON (lossless serialization)
- Text (plain text)
- Doctags
- β Multi-engine support: Choose between Docling and MarkItDown converters
- β Multi-file batch processing
- β Folder scanning with recursive file discovery
- β Progress tracking with real-time updates
- β Configurable output directory
- β Folder structure preservation
- β Duplicate file handling
- β Comprehensive error reporting
- β Clean, responsive GUI with converter selection
- Each component can be unit tested in isolation
- Dependencies can be easily mocked
- Clear boundaries between layers
- Changes in one layer don't affect others
- Easy to add new features or modify existing ones
- Clear code organization and responsibility separation
- New UI frameworks can be added (e.g., web interface, CLI)
- New conversion libraries can be integrated
- New file formats can be supported easily
- Services can be swapped without affecting the UI
- Different storage backends can be implemented
- Configuration and settings can be externalized
- Python 3.8 or higher
- pip (Python package installer)
- Clone or download the repository
- Install the required dependencies:
pip install -r requirements.txtIf you prefer to install packages individually:
pip install docling markitdownpython main.pyThe application will start with the GUI interface, allowing you to:
- Choose your conversion engine: Select between Docling (advanced) or MarkItDown (lightweight)
- Select files or folders for conversion
- Choose output format
- Configure output settings
- Start batch conversion with progress tracking
docling: Advanced document conversion librarymarkitdown: Lightweight document to markdown convertertkinter: GUI framework (built into Python)pathlib: Modern path handlingtyping: Type hints for better code quality
This architecture ensures the application is robust, maintainable, and easily extensible while following industry best practices and SOLID principles. The dual-converter approach provides flexibility for different use cases, from simple markdown conversion to complex document processing with rich formatting preservation.