# eightman999/narou_db_view architecture

> Architecture diagram of the GitHub repository eightman999/narou_db_view, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eightman999/narou_db_view
- Repository: https://github.com/eightman999/narou_db_view

## Overview

##### Main Components
- Core Application (app/):
- Core functions in app/core such as database_manager.py, novel_manager.py, checker.py, update_manager.py, and the settings modules.
- The main entry point (app/main.py) ties these together.
- User Interface (app/ui/):
- UI components in app/ui/components (novel_list, episode_list, command_prompt, settings_panel, update_panel) are used for displaying and interacting with the data.
- Database Layer (app/database/):
- The database handler (db_handler.py) and its associated files (the ‘db_files’ folder that contains the actual database files) represent the persistence layer.
- Tools and Utilities:
- Tools in app/tools for data cleanup (duplicates_remover, episode_cleanup_script) and episode fetching are for maintenance and extra functionalities.
- Utilities in app/utils, including the exporters (such as txt_exporter) and logger_manager, support cross-component operations.
- Initialization/Setup (init/):
- The init directory provides data injection, formatting, and initial configuration scripts to prime the application.
- Configuration:
- Settings files (app/settings.ini, app/core/settings.ini, config.py) hold the configuration data for various parts of the app.

##### Relationships and Interactions
- The UI layer interacts with the Core layer which implements business logic. The UI components send commands to the core components to initiate data loads, updates, or configuration changes.
- The Core layer communicates with the Database layer via objects like database_manager and db_handler that encapsulate data storage operations.
- The Tools and Utilities provide auxiliary features such as cleaning up data and exporting, which may be triggered either from the UI (if exposed as actions/components) or via separate scripts.
- Initialization scripts (in init/) run at setup or migration time to prepare the database and seed data.
- Configuration files influence each of these layers ensuring that settings and parameters are consistent throughout.

##### Architectural Patterns and Design Principles
- The Project follows a modular design, where functionalities are decoupled into separate directories (e.g., core vs. ui, and database vs. tools).
- There is an implicit MVC-like pattern:
- The UI (view) is separated from the business logic (model/controller in core).
- Database abstractions further isolate persistence concerns.
- Separation of concerns is maintained by keeping utility functionalities in independent modules (tools, utils, init).

##### Final Assembly
- The Core layer central to all business logic.
- The Database layer as the storage backend.
- Tools/Utilities a separate module connected to the Core.
- Initialization/scripting as a preparatory step feeding data/configuration into the system.
- Double-check that all key components (especially those highlighted in the README such as novel management and data cleanup) are represented.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface (app/ui)"
        UI["Components"]:::ui
        UI_cmd["command_prompt.py"]:::ui
        UI_episode["episode_list.py"]:::ui
        UI_novel["novel_list.py"]:::ui
        UI_settings["settings_panel.py"]:::ui
        UI_update["update_panel.py"]:::ui
    end

    %% Core Functionality Layer
    subgraph "Core Functionality (app/core)"
        CoreMain["main.py"]:::core
        Core_db_manager["database_manager.py"]:::core
        Core_novel_manager["novel_manager.py"]:::core
        Core_checker["checker.py"]:::core
        Core_update_manager["update_manager.py"]:::core
        Core_settings_manager["settings_manager.py"]:::core
    end

    %% Database Layer
    subgraph "Database Layer (app/database)"
        DB_handler["db_handler.py"]:::db
        DB_files["db_files (novel_status.db-shm & novel_status.db-wal)"]:::db
    end

    %% Tools & Utilities Layer
    subgraph "Tools & Utilities"
        Tools_cleanup["Data Cleanup Tools"]:::tools
        Tools_duplicate["duplicates_remover.py"]:::tools
        Tools_episode_cleanup["episode_cleanup_script.py"]:::tools
        Tools_episode_fetcher["episode_fetcher.py"]:::tools
        Utils_exporter["txt_exporter.py"]:::utils
        Utils_logger["logger_manager.py"]:::utils
    end

    %% Initialization/Setup Layer
    subgraph "Initialization/Setup (init)"
        Init_data_inject["data_inject.py"]:::init
        Init_db_columns["db_columns.py"]:::init
        Init_first_formatter["first_formatter.py"]:::init
        Init_first_last_read["first_last_read.py"]:::init
        Init_salvager["ohanashi_salvager.py"]:::init
    end

    %% Configuration Files
    subgraph "Configuration"
        Config1["app/settings.ini"]:::config
        Config2["app/core/settings.ini"]:::config
        Config3["config.py"]:::config
    end

    %% Relationships
    UI -->|"UIAction"| CoreMain
    UI -->|"UIAction"| Core_db_manager
    UI -->|"UIAction"| Core_novel_manager
    UI -->|"UIAction"| Core_checker
    UI -->|"UIAction"| Core_update_manager
    UI -->|"UIAction"| Core_settings_manager

    CoreMain -->|"DataQuery"| DB_handler
    Core_db_manager -->|"DataAccess"| DB_handler

    CoreMain -->|"InvokeCleanup"| Tools_cleanup
    CoreMain -->|"Export/Log"| Utils_exporter
    CoreMain -->|"Export/Log"| Utils_logger

    Tools_cleanup -->|"RunCleaner"| Tools_duplicate
    Tools_cleanup -->|"RunCleaner"| Tools_episode_cleanup
    Tools_cleanup -->|"FetchEpisodes"| Tools_episode_fetcher

    Init_data_inject -->|"SeedData"| DB_handler
    Init_data_inject -->|"ConfigureCore"| CoreMain

    Config1 -->|"LoadConfig"| CoreMain
    Config1 -->|"LoadConfig"| UI
    Config1 -->|"LoadConfig"| DB_handler
    Config2 -->|"LoadConfig"| CoreMain
    Config3 -->|"GlobalConfig"| CoreMain

    %% Styling
    classDef ui fill:#ffe6f7,stroke:#333,stroke-width:1px;
    classDef core fill:#e6f7ff,stroke:#333,stroke-width:1px;
    classDef db fill:#fff3cc,stroke:#333,stroke-width:1px;
    classDef tools fill:#e6ffe6,stroke:#333,stroke-width:1px;
    classDef utils fill:#ffe6e6,stroke:#333,stroke-width:1px;
    classDef init fill:#e6ffff,stroke:#333,stroke-width:1px;
    classDef config fill:#f2f2f2,stroke:#333,stroke-width:1px;

    %% Click Events for Core Application
    click Core_db_manager "https://github.com/eightman999/narou_db_view/blob/master/app/core/database_manager.py"
    click Core_novel_manager "https://github.com/eightman999/narou_db_view/blob/master/app/core/novel_manager.py"
    click Core_checker "https://github.com/eightman999/narou_db_view/blob/master/app/core/checker.py"
    click Core_update_manager "https://github.com/eightman999/narou_db_view/blob/master/app/core/update_manager.py"
    click Core_settings_manager "https://github.com/eightman999/narou_db_view/blob/master/app/core/settings_manager.py"
    click CoreMain "https://github.com/eightman999/narou_db_view/blob/master/app/main.py"

    %% Click Events for User Interface
    click UI_cmd "https://github.com/eightman999/narou_db_view/blob/master/app/ui/components/command_prompt.py"
    click UI_episode "https://github.com/eightman999/narou_db_view/blob/master/app/ui/components/episode_list.py"
    click UI_novel "https://github.com/eightman999/narou_db_view/blob/master/app/ui/components/novel_list.py"
    click UI_settings "https://github.com/eightman999/narou_db_view/blob/master/app/ui/components/settings_panel.py"
    click UI_update "https://github.com/eightman999/narou_db_view/blob/master/app/ui/components/update_panel.py"

    %% Click Events for Database Layer
    click DB_handler "https://github.com/eightman999/narou_db_view/blob/master/app/database/db_handler.py"
    click DB_files "https://github.com/eightman999/narou_db_view/tree/master/app/database/db_files"

    %% Click Events for Tools & Utilities
    click Tools_duplicate "https://github.com/eightman999/narou_db_view/blob/master/app/tools/data_cleanup/duplicates_remover.py"
    click Tools_episode_cleanup "https://github.com/eightman999/narou_db_view/blob/master/app/tools/data_cleanup/episode_cleanup_script.py"
    click Tools_episode_fetcher "https://github.com/eightman999/narou_db_view/blob/master/app/tools/episode_fetcher.py"
    click Utils_exporter "https://github.com/eightman999/narou_db_view/blob/master/app/utils/exporters/txt_exporter.py"
    click Utils_logger "https://github.com/eightman999/narou_db_view/blob/master/app/utils/logger_manager.py"

    %% Click Events for Initialization/Setup
    click Init_data_inject "https://github.com/eightman999/narou_db_view/blob/master/init/data_inject.py"
    click Init_db_columns "https://github.com/eightman999/narou_db_view/blob/master/init/db_columns.py"
    click Init_first_formatter "https://github.com/eightman999/narou_db_view/blob/master/init/first_formatter.py"
    click Init_first_last_read "https://github.com/eightman999/narou_db_view/blob/master/init/first_last_read.py"
    click Init_salvager "https://github.com/eightman999/narou_db_view/blob/master/init/ohanashi_salvager.py"

    %% Click Events for Configuration
    click Config1 "https://github.com/eightman999/narou_db_view/blob/master/app/settings.ini"
    click Config2 "https://github.com/eightman999/narou_db_view/blob/master/app/core/settings.ini"
    click Config3 "https://github.com/eightman999/narou_db_view/blob/master/config.py"
```
