# illichtz/biblianote architecture

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

- Interactive diagram: https://gitdiagram.com/illichtz/biblianote
- Repository: https://github.com/illichtz/biblianote

## Overview

##### Main Components
- Android UI Layer: This includes the MainActivity that hosts various Fragments. Notice fragments for different functions:
- BookFragment, BooksFragment, ChaptersFragment, VerseFragment (for Bible reading/navigation)
- NoteFragment, NoteBookFragment (for note taking and organization)
- SettingsFragment (for configuration/preferences)
- Data/Local Storage Layer:
- A database module (e.g., the database package with Biblia.kt and Adapters.kt) responsible for managing notes and Bible study data.
- Local assets that store multiple Bible versions (found in app/src/main/assets) which the application loads for offline use.
- Export/Utility Functionality:
- A CSV export functionality for notes, as mentioned in the README.
- Testing Components:
- Instrumented tests and unit tests (seen in the androidTest and test directories) ensuring functionality across the UI and underlying layers.

##### Relationships and Interactions
- The MainActivity acts as a container, coordinating between various fragments, each representing a functional module (Bible reading, note taking, settings).
- Fragments load Bible content from the local assets (which contain different Bible translations) and interact with the database layer to save and retrieve user notes.
- The database module mediates data persistence to ensure offline operation.
- The CSV export feature interacts with the database to read out stored notes and generate an export file.
- Navigation flows (using the provided navigation XML files) define the transitions between various screens such as books, notes, and settings.

##### Architectural Patterns and Design Principles
- The application follows a modular component-based structure, likely using an MVVM or MVP pattern common in Android apps (even if not explicit, the separation into Fragments and a dedicated data layer indicates such separation).
- Offline-first design: Local assets and databases are critical to maintain operation without network connectivity.
- Separation of concerns: UI components, business logic, database interactions, and utility functions (like CSV export) are distinct, making the app easier to maintain and test.
- Use of navigation graphs (XML files in res/navigation) indicates a clear flow structure for user interactions.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        MA["MainActivity"]:::ui
        subgraph "Bible Reading Fragments"
            BF["BookFragment"]:::ui
            BFS["BooksFragment"]:::ui
            CF["ChaptersFragment"]:::ui
            VF["VerseFragment"]:::ui
        end
        subgraph "Note Taking Components"
            NF["NoteFragment"]:::ui
            NBF["Notebook Fragment"]:::ui
        end
        SF["SettingsFragment"]:::ui
    end

    %% Data/Local Storage Layer
    subgraph "Data/Local Storage"
        subgraph "Local Database"
            BIB["Biblia.kt"]:::data
            ADP["Adapters.kt"]:::data
        end
        LA["Local Assets"]:::data
    end

    %% Utility Components
    subgraph "Utility Components"
        CSV["CSV Export Utility"]:::export
    end

    %% Testing Components
    subgraph "Testing Components"
        IT["Instrumented Tests"]:::testing
        UT["Unit Tests"]:::testing
    end

    %% Connections from MainActivity to UI Fragments
    MA -->|"loads"| BF
    MA -->|"loads"| BFS
    MA -->|"loads"| CF
    MA -->|"loads"| VF
    MA -->|"manages"| NF
    MA -->|"manages"| NBF
    MA -->|"accesses"| SF

    %% Connection from Local Assets to Bible Reading Fragments
    LA -->|"supplies Bible versions to"| BF
    LA -->|"supplies Bible versions to"| BFS
    LA -->|"supplies Bible versions to"| CF
    LA -->|"supplies Bible versions to"| VF

    %% Data interactions for Note Taking
    NF -->|"saves/retrieves notes"| BIB
    NBF -->|"saves/retrieves notes"| ADP

    %% CSV Export reads data from the Database
    BIB -->|"exports data to"| CSV
    ADP -->|"exports data to"| CSV

    %% Testing connections
    IT -->|"tests UI and DB"| MA
    UT -->|"tests UI and DB"| MA

    %% Styles
    classDef ui fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef data fill:#FFE082,stroke:#FB8C00,stroke-width:2px;
    classDef export fill:#C5E1A5,stroke:#558B2F,stroke-width:2px;
    classDef testing fill:#F8BBD0,stroke:#C2185B,stroke-width:2px;

    %% Click Events
    click MA "https://github.com/illichtz/biblianote/blob/master/app/src/main/java/com/a101apps/biblianote/MainActivity.kt"
    click BF "https://github.com/illichtz/biblianote/blob/master/app/src/main/java/com/a101apps/biblianote/BookFragment.kt"
    click BFS "https://github.com/illichtz/biblianote/blob/master/app/src/main/java/com/a101apps/biblianote/biblia/BooksFragment.kt"
    click CF "https://github.com/illichtz/biblianote/blob/master/app/src/main/java/com/a101apps/biblianote/biblia/ChaptersFragment.kt"
    click VF "https://github.com/illichtz/biblianote/blob/master/app/src/main/java/com/a101apps/biblianote/biblia/VerseFragment.kt"
    click NF "https://github.com/illichtz/biblianote/blob/master/app/src/main/java/com/a101apps/biblianote/NoteFragment.kt"
    click NBF "https://github.com/illichtz/biblianote/blob/master/app/src/main/java/com/a101apps/biblianote/notebook/NoteBookFragment.kt"
    click SF "https://github.com/illichtz/biblianote/blob/master/app/src/main/java/com/a101apps/biblianote/SettingsFragment.kt"
    click BIB "https://github.com/illichtz/biblianote/blob/master/app/src/main/java/com/a101apps/biblianote/database/Biblia.kt"
    click ADP "https://github.com/illichtz/biblianote/blob/master/app/src/main/java/com/a101apps/biblianote/database/Adapters.kt"
    click LA "https://github.com/illichtz/biblianote/tree/master/app/src/main/assets"
    click IT "https://github.com/illichtz/biblianote/blob/master/app/src/androidTest/java/com/a101apps/biblianote/ExampleInstrumentedTest.kt"
    click UT "https://github.com/illichtz/biblianote/blob/master/app/src/test/java/com/a101apps/biblianote/ExampleUnitTest.kt"
```
