# wustho/baca architecture

> Architecture diagram of the GitHub repository wustho/baca, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wustho/baca
- Repository: https://github.com/wustho/baca

## Overview

##### Component Relationships

**User Input → UI Layer → Core App Layer ↔ E-book Processing Layer**
- ↕
- Utilities Layer

##### Detailed Component Breakdown

UI Layer:
- Windows management
- Content rendering
- Event handling
- Text justification system
- ANSI image display

Core Layer:
- Configuration management
- Reading position tracking
- Database interactions
- Search functionality

E-book Processing:
- Format-specific handlers (EPUB, MOBI, AZW)
- KindleUnpack integration
- Content extraction
- Image processing

Utilities:
- File system operations
- HTML parsing
- URL handling
- Temporary directory management
- Resource management

##### External Integrations

Connections to:
- System image viewers
- File system
- User configuration directory
- Terminal capabilities

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef ebook fill:#f1c40f,stroke:#f39c12,color:black
    classDef util fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef resource fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        UI[UI Components]:::ui
        Core[Core Components]:::core
        Ebook[E-book Processing]:::ebook
        Util[Utilities]:::util
        Ext[External Systems]:::external
        Res[Resources]:::resource
    end

    %% User Interface Layer
    subgraph UILayer[User Interface Layer]
        Windows[Windows Management]:::ui
        Contents[Content Rendering]:::ui
        Events[Event Handling]:::ui
        UIComponents[Components Module]:::ui
    end

    %% Core Application Layer
    subgraph CoreLayer[Core Application Layer]
        App[Main Application]:::core
        Config[Configuration Manager]:::core
        DB[Database Handler]:::core
        Models[Data Models]:::core
    end

    %% E-book Processing Layer
    subgraph EbookLayer[E-book Processing Layer]
        BaseHandler[Base E-book Handler]:::ebook
        EPUBHandler[EPUB Handler]:::ebook
        MOBIHandler[MOBI Handler]:::ebook
        AZWHandler[AZW Handler]:::ebook
        KindleUnpack[KindleUnpack Integration]:::ebook
    end

    %% Utilities Layer
    subgraph UtilLayer[Utilities Layer]
        HTMLParser[HTML Parser]:::util
        Systems[System Interactions]:::util
        Resources[Resource Management]:::util
        URLs[URL Handler]:::util
        TempDir[Temp Directory Manager]:::util
        UserDir[User Directory Manager]:::util
        CLI[CLI Utilities]:::util
    end

    %% External Systems
    subgraph ExternalSystems[External Systems]
        ImageViewer[System Image Viewer]:::external
        FileSystem[File System]:::external
        Terminal[Terminal]:::external
    end

    %% Resources
    subgraph ResourceFiles[Resources]
        ConfigTemplate[Config Template]:::resource
        StyleCSS[UI Styling]:::resource
    end

    %% Relationships
    UIComponents --> Windows & Contents & Events
    Windows & Contents & Events --> App
    App --> Config
    App --> DB
    App --> Models
    App --> BaseHandler
    BaseHandler --> EPUBHandler & MOBIHandler & AZWHandler
    MOBIHandler & AZWHandler --> KindleUnpack
    App --> HTMLParser & Systems & Resources & URLs & TempDir & UserDir & CLI
    Systems --> ImageViewer
    Systems --> FileSystem
    Config --> ConfigTemplate
    Contents --> StyleCSS
    Terminal --> UIComponents

    %% Click events
    click UIComponents "https://github.com/wustho/baca/tree/main/src/baca/components/"
    click Windows "https://github.com/wustho/baca/blob/main/src/baca/components/windows.py"
    click Contents "https://github.com/wustho/baca/blob/main/src/baca/components/contents.py"
    click Events "https://github.com/wustho/baca/blob/main/src/baca/components/events.py"
    click App "https://github.com/wustho/baca/blob/main/src/baca/app.py"
    click Config "https://github.com/wustho/baca/blob/main/src/baca/config.py"
    click DB "https://github.com/wustho/baca/blob/main/src/baca/db.py"
    click Models "https://github.com/wustho/baca/blob/main/src/baca/models.py"
    click BaseHandler "https://github.com/wustho/baca/blob/main/src/baca/ebooks/base.py"
    click EPUBHandler "https://github.com/wustho/baca/blob/main/src/baca/ebooks/epub.py"
    click MOBIHandler "https://github.com/wustho/baca/blob/main/src/baca/ebooks/mobi.py"
    click AZWHandler "https://github.com/wustho/baca/blob/main/src/baca/ebooks/azw.py"
    click KindleUnpack "https://github.com/wustho/baca/tree/main/src/baca/tools/KindleUnpack/"
    click HTMLParser "https://github.com/wustho/baca/blob/main/src/baca/utils/html_parser.py"
    click Systems "https://github.com/wustho/baca/blob/main/src/baca/utils/systems.py"
    click Resources "https://github.com/wustho/baca/blob/main/src/baca/utils/app_resources.py"
    click URLs "https://github.com/wustho/baca/blob/main/src/baca/utils/urls.py"
    click TempDir "https://github.com/wustho/baca/blob/main/src/baca/utils/tempdir.py"
    click UserDir "https://github.com/wustho/baca/blob/main/src/baca/utils/user_appdirs.py"
    click CLI "https://github.com/wustho/baca/blob/main/src/baca/utils/cli.py"
    click ConfigTemplate "https://github.com/wustho/baca/blob/main/src/baca/resources/config.ini"
    click StyleCSS "https://github.com/wustho/baca/blob/main/src/baca/resources/style.css"
```
