# Bibliotheca Architecture Overview

This document links together the module overviews and describes how a book flows
through the system.

## High-level flow

1. **Import** (`BookImport`, `Sha256`)
   - Compute SHA-256 id for each selected file.
   - Extract metadata and cover (EPUB via libzip/tinyxml2, PDF via poppler).
2. **Persistence** (`DatabaseManager`)
   - Ensure the SQLite schema exists.
   - Insert/update/remove records using prepared statements.
3. **Model** (`BookList`)
   - Load books from the database into memory.
   - Expose CRUD helpers with signal emission.
   - Provide thread-safe enqueue helpers for background imports.
4. **Presentation** (`BookShelf`, `BookTile`)
   - Mirror the model into a `Gio::ListStore`.
   - Render a grid of tiles, expose activation, and filter results.
5. **Application shell** (`BibliothecaWindow`)
   - Build the UI chrome (header, search bar, stack pages).
   - React to imports, search queries, and user activation.

## Module documentation

- [BookImport](bookimport.md)
- [DatabaseManager](database_manager.md)
- [BookList](booklist.md)
- [BookShelf](bookshelf.md)
- [BookTile](booktile.md)
- [BibliothecaWindow](bibliotheca_window.md)
- [SHA-256 helper](sha256.md)
- [Entry point](main.md)

## External dependencies

- **GTK 4 / gtkmm**: UI toolkit for widgets, signals, and layout.
- **SQLite3**: persistence layer for book metadata.
- **poppler-glib**: PDF metadata/covers.
- **libzip + tinyxml2**: EPUB metadata extraction.
- **OpenSSL (libcrypto)**: SHA-256 hashing.

## Future work

- Add ADRs (`docs/decisions/`) for larger architectural choices.
- Document additional subsystems as they appear (e.g., reader view, tagging).
- Add screenshots or diagrams for quick onboarding.
