# hansamuh/histopedia architecture

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

- Interactive diagram: https://gitdiagram.com/hansamuh/histopedia
- Repository: https://github.com/hansamuh/histopedia

## Overview

##### Project Type Analysis
This is a Java-based application that follows object-oriented principles and implements several design patterns (Factory Pattern and Singleton Pattern). It's a standalone application with a clear separation of concerns in its architecture.

##### Main Components

A. Core Layers (Top to Bottom):
- [User Interface Layer (Menus)]
- ↓
- [Business Logic Layer (Models & Factories)]
- ↓
- [Data Layer (Database Singleton)]

##### User Interface Components
- AuthenticationMenu
- LibrarianMenu
- PatronMenu
- Base Menu

##### Model Components
- User (Base Class)
├── Librarian
└── Patron
- Book (Base Class)
├── BiographyBook
├── MilitaryHistoryBook
└── RevolutionBook
- BorrowingRecord

##### Factory Components
- UserFactory
├── LibrarianFactory
└── PatronFactory
- BookFactory
├── BiographyBookFactory
├── MilitaryHistoryBookFactory
└── RevolutionBookFactory
- BorrowingRecordFactory

##### Data Management
- Database (Singleton)

##### Database singleton connections

**┌─────────────────────────────────────────────┐**
- User Interface                 │
- ┌─────────┐  ┌────────────┐ ┌──────────┐  │
- Auth   │  │ Librarian  │ │  Patron  │  │
- Menu   │  │   Menu     │ │   Menu   │  │
- ┘  └────────────┘ └──────────┘  │
- ┬─────────────────────────┘
- ↓
**┌─────────────────────────────────────────────┐**
- Business Logic Layer              │
- ┌─────────┐    ┌─────────┐   ┌──────────┐  │
- Models  │←→  │Factories│   │ Business │  │
- ┘    └─────────┘   │  Logic   │  │
- ┘  │
- ┬─────────────────────────┘
- ↓
**┌─────────────────────────────────────────────┐**
- Data Layer                      │
- ┌──────────────┐                  │
- Database   │                  │
- Singleton   │                  │
- ┘                  │
- ┘

##### Additional Details

- Notes about the Factory Pattern implementation
- Singleton Pattern for the database
- Inheritance hierarchy for Books and Users
- Relationship between BorrowingRecord and other entities

## Diagram (Mermaid)

```mermaid
graph TD
    %% Styles
    classDef menu fill:#e1f5fe,stroke:#01579b
    classDef controller fill:#fff3e0,stroke:#e65100
    classDef model fill:#e8f5e9,stroke:#1b5e20
    classDef factory fill:#fce4ec,stroke:#880e4f
    classDef database fill:#ede7f6,stroke:#4527a0
    classDef record fill:#fff8e1,stroke:#ff6f00

    %% Presentation Layer
    subgraph Presentation["Presentation Layer"]
        AuthMenu["Authentication Menu"]:::menu
        LibMenu["Librarian Menu"]:::menu
        PatMenu["Patron Menu"]:::menu
    end

    %% Controller Layer
    subgraph Controllers["Controller Layer"]
        BookCtrl["Book Controller"]:::controller
        UserCtrl["User Controller"]:::controller
        BorrowCtrl["Borrowing Controller"]:::controller
    end

    %% Model Layer
    subgraph Models["Model Layer"]
        %% User Hierarchy
        User["User"]:::model
        Librarian["Librarian"]:::model
        Patron["Patron"]:::model
        
        %% Book Hierarchy
        Book["Book"]:::model
        Biography["Biography Book"]:::model
        Military["Military History Book"]:::model
        Revolution["Revolution Book"]:::model
        
        %% Records
        BorrowRecord["Borrowing Record"]:::record
    end

    %% Factory Layer
    subgraph Factories["Factory Layer"]
        %% User Factories
        UFactory["User Factory"]:::factory
        LFactory["Librarian Factory"]:::factory
        PFactory["Patron Factory"]:::factory
        
        %% Book Factories
        BFactory["Book Factory"]:::factory
        BioFactory["Biography Factory"]:::factory
        MilFactory["Military History Factory"]:::factory
        RevFactory["Revolution Factory"]:::factory
        
        %% Record Factory
        BRFactory["Borrowing Record Factory"]:::factory
    end

    %% Database Layer
    subgraph Database["Database Layer"]
        DB[(Database)]:::database
    end

    %% Layer Connections Only
    Presentation --> Controllers
    Controllers --> Models
    Models --> Factories
    Factories --> Database

    %% Click Events
    click AuthMenu "https://github.com/HansaMuh/Histopedia/blob/main/src/menus/AuthenticationMenu.java"
    click LibMenu "https://github.com/HansaMuh/Histopedia/blob/main/src/menus/LibrarianMenu.java"
    click PatMenu "https://github.com/HansaMuh/Histopedia/blob/main/src/menus/PatronMenu.java"
    click BookCtrl "https://github.com/HansaMuh/Histopedia/blob/main/src/controllers/BookController.java"
    click UserCtrl "https://github.com/HansaMuh/Histopedia/blob/main/src/controllers/UserController.java"
    click BorrowCtrl "https://github.com/HansaMuh/Histopedia/blob/main/src/controllers/BorrowingRecordController.java"
    click User "https://github.com/HansaMuh/Histopedia/blob/main/src/models/User.java"
    click Librarian "https://github.com/HansaMuh/Histopedia/blob/main/src/models/Librarian.java"
    click Patron "https://github.com/HansaMuh/Histopedia/blob/main/src/models/Patron.java"
    click Book "https://github.com/HansaMuh/Histopedia/blob/main/src/models/Book.java"
    click Biography "https://github.com/HansaMuh/Histopedia/blob/main/src/models/BiographyBook.java"
    click Military "https://github.com/HansaMuh/Histopedia/blob/main/src/models/MilitaryHistoryBook.java"
    click Revolution "https://github.com/HansaMuh/Histopedia/blob/main/src/models/RevolutionBook.java"
    click BorrowRecord "https://github.com/HansaMuh/Histopedia/blob/main/src/models/BorrowingRecord.java"
    click UFactory "https://github.com/HansaMuh/Histopedia/blob/main/src/factories/UserFactory.java"
    click LFactory "https://github.com/HansaMuh/Histopedia/blob/main/src/factories/LibrarianFactory.java"
    click PFactory "https://github.com/HansaMuh/Histopedia/blob/main/src/factories/PatronFactory.java"
    click BFactory "https://github.com/HansaMuh/Histopedia/blob/main/src/factories/BookFactory.java"
    click BioFactory "https://github.com/HansaMuh/Histopedia/blob/main/src/factories/BiographyBookFactory.java"
    click MilFactory "https://github.com/HansaMuh/Histopedia/blob/main/src/factories/MilitaryHistoryBookFactory.java"
    click RevFactory "https://github.com/HansaMuh/Histopedia/blob/main/src/factories/RevolutionBookFactory.java"
    click BRFactory "https://github.com/HansaMuh/Histopedia/blob/main/src/factories/BorrowingRecordFactory.java"
    click DB "https://github.com/HansaMuh/Histopedia/blob/main/src/singleton/Database.java"
```
