# iso8859/wfbiblio architecture

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

- Interactive diagram: https://gitdiagram.com/iso8859/wfbiblio
- Repository: https://github.com/iso8859/wfbiblio

## Overview

##### Project Type and Purpose
- This is a Windows desktop application (WinForms) for managing a library. Its purpose is to handle notices, exemplars, borrowers (lecteurs), loans (prêts), and even integration with external bibliographic services (via SRU queries to BNF, Papyrus, etc.).
- The README emphasizes simple, multi-post system usage with automatic notice retrieval, reader group management, and even future enhancements like CSV class imports or quick inventory modes.

##### File Structure
- Top-Level Files: Core C# source files such as Main.cs, Program.cs, Global.cs, various control files (ctrlAttente.cs, ctrlChoixLecteur.cs, etc.) and form files (frmAjouterNotice.cs, frmImport.cs, etc.) indicate a typical WinForms UI design.
- Directories:
- The SRU directory contains files (NoticeQuery.cs, QueryBuilder.cs, SRU.xml, etc.) that encapsulate the logic for constructing and handling SRU queries to external bibliographic services.
- The Properties directory holds application configuration, data sources, resources, and settings.
- Documentation and wiki directories provide further context (PDF manuals and demo videos), which reinforces the application's domain and usage.
- Other Files: Data.cs, ImportNoticeExemplaires.cs, Global.cs indicate business logic and helper services managing the library data.

##### Core Components
a. User Interface (UI) Layer:
- WinForms-based main form (Main/Form UI) and additional forms/controls (e.g., frmAjouterNotice, frmImport, ctrlCirculation, ctrlNotices, etc.) handling user interactions.

b. Business Logic Layer:
- Core application logic found in files like Global.cs, Data.cs, and specialised modules (e.g., Toolbox.cs) that manage internal states, business rules, and processes such as loan circulation, notice management, and reader handling.
- Event-handling code embedded in the WinForms controls also forms part of this layer.

c. SRU/External Integration Module:
- Encapsulated by the SRU directory which includes classes for building and processing SRU queries (NoticeQuery.cs, QueryBuilder.cs, etc.). This component interacts with external bibliographic services (e.g., BNF).

d. Data/Configuration Layer:
- Data source definitions in Properties/DataSources, configuration settings in app.config, and possibly the use of XML/JSON files (ExempleReponse.xml, ExempleReponse.json) for sample responses.

e. Additional Utilities/Helpers:
- Utility files like ImportNoticeExemplaires.cs indicate helper functionality for import and data manipulation.

##### Relationships and Interactions
- User interactions travel from the UI layer (forms and controls) to the business logic layer where operations such as searching, adding notices, or managing loans occur.
- The business logic layer interacts with the SRU module when external bibliographic data is needed, sending queries and processing responses.
- Data sources and configuration settings are used throughout, with the UI modulating data input and displaying output managed by backend logic.
- Triggers/events from the UI layer feeding into business logic.
- Request/response cycles between business logic and the SRU module.
- Dependency from business logic to data configurations and external files.

##### Architectural Patterns and Relevant Technologies
- Although a classic layered architecture is used (UI, Business Logic, Data/Integration), you might also note the partial MVC-like separation in the use of WinForms:
- Views: The WinForms and user controls.
- Controllers/Logic: Code-behind in each form and shared business logic in files like Global.cs.
- The SRU module acts as an adaptor/interface to external services, adhering to a service-oriented design.
- Reviews of the naming (e.g., "ctrl" for user controls and "frm" for forms) indicate a modular approach to each UI function.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        U1["Main Form"]:::ui
        U2["frmAjouterNotice"]:::ui
        U3["frmImport"]:::ui
        U4["frmLecteur"]:::ui
        U5["frmResultSearch"]:::ui
        U6["frmrExemplaire"]:::ui
        UC1["ctrlAttente"]:::ui
        UC2["ctrlChoixLecteur"]:::ui
        UC3["ctrlCirculation"]:::ui
        UC4["ctrlCorriger"]:::ui
        UC5["ctrlNotices"]:::ui
        UC6["ctrlPret"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        BL1["Global.cs"]:::logic
        BL2["Data.cs"]:::logic
        BL3["ImportNoticeExemplaires.cs"]:::logic
        BL4["Toolbox.cs"]:::logic
    end

    %% SRU Integration Module
    subgraph "SRU Integration Module"
        S1["NoticeQuery.cs"]:::sru
        S2["QueryBuilder.cs"]:::sru
        S3["EnumQuery.cs"]:::sru
        S4["NoticeCriteria.cs"]:::sru
        S5["SRU.xml"]:::sru
    end

    %% Data/Configuration Layer
    subgraph "Data/Configuration Layer"
        subgraph "Data Sources"
            DS1["Exemplaire.datasource"]:::data
            DS2["InfoLecteur.datasource"]:::data
            DS3["Lecteur.datasource"]:::data
            DS4["Notice.datasource"]:::data
        end
        subgraph "Application Settings"
            AS1["app.config"]:::data
            AS2["AssemblyInfo.cs"]:::data
            AS3["Resources.Designer.cs"]:::data
            AS4["Resources.resx"]:::data
            AS5["Settings.Designer.cs"]:::data
            AS6["Settings.settings"]:::data
        end
        subgraph "Sample Responses"
            SR1["ExempleReponse.json"]:::data
            SR2["ExempleReponse.xml"]:::data
        end
    end

    %% External Bibliographic Services
    subgraph "External Bibliographic Services"
        EB1["BNF SRU Service"]:::external
    end

    %% Connections from UI Layer to Business Logic
    U1 -->|"triggers"| BL1
    U2 -->|"triggers"| BL1
    U3 -->|"triggers"| BL1
    U4 -->|"triggers"| BL1
    U5 -->|"triggers"| BL1
    U6 -->|"triggers"| BL1
    UC1 -->|"triggers"| BL1
    UC2 -->|"triggers"| BL1
    UC3 -->|"triggers"| BL1
    UC4 -->|"triggers"| BL1
    UC5 -->|"triggers"| BL1
    UC6 -->|"triggers"| BL1

    %% Business Logic Interactions
    BL1 -->|"executes"| BL2
    BL2 -->|"calls"| BL3
    BL1 -->|"calls"| BL4

    %% Business Logic and Data/Configuration
    BL1 -->|"utilizes"| AS1
    BL2 -->|"utilizes"| DS1
    BL3 -->|"utilizes"| SR1

    %% Business Logic and SRU Integration
    BL1 -->|"queries"| S1
    BL1 -->|"queries"| S2
    S1 -- "response" --> BL1

    %% SRU Integration with External Services
    S1 -->|"sends"| EB1
    S2 -->|"sends"| EB1

    %% Click Events for UI Layer
    click U1 "https://github.com/iso8859/wfbiblio/blob/master/Main.cs"
    click U2 "https://github.com/iso8859/wfbiblio/blob/master/frmAjouterNotice.cs"
    click U3 "https://github.com/iso8859/wfbiblio/blob/master/frmImport.cs"
    click U4 "https://github.com/iso8859/wfbiblio/blob/master/frmLecteur.cs"
    click U5 "https://github.com/iso8859/wfbiblio/blob/master/frmResultSearch.cs"
    click U6 "https://github.com/iso8859/wfbiblio/blob/master/frmrExemplaire.cs"
    click UC1 "https://github.com/iso8859/wfbiblio/blob/master/ctrlAttente.cs"
    click UC2 "https://github.com/iso8859/wfbiblio/blob/master/ctrlChoixLecteur.cs"
    click UC3 "https://github.com/iso8859/wfbiblio/blob/master/ctrlCirculation.cs"
    click UC4 "https://github.com/iso8859/wfbiblio/blob/master/ctrlCorriger.cs"
    click UC5 "https://github.com/iso8859/wfbiblio/blob/master/ctrlNotices.cs"
    click UC6 "https://github.com/iso8859/wfbiblio/blob/master/ctrlPret.cs"

    %% Click Events for Business Logic Layer
    click BL1 "https://github.com/iso8859/wfbiblio/blob/master/Global.cs"
    click BL2 "https://github.com/iso8859/wfbiblio/blob/master/Data.cs"
    click BL3 "https://github.com/iso8859/wfbiblio/blob/master/ImportNoticeExemplaires.cs"
    click BL4 "https://github.com/iso8859/wfbiblio/blob/master/Toolbox.cs"

    %% Click Events for SRU Integration Module
    click S1 "https://github.com/iso8859/wfbiblio/blob/master/SRU/NoticeQuery.cs"
    click S2 "https://github.com/iso8859/wfbiblio/blob/master/SRU/QueryBuilder.cs"
    click S3 "https://github.com/iso8859/wfbiblio/blob/master/SRU/EnumQuery.cs"
    click S4 "https://github.com/iso8859/wfbiblio/blob/master/SRU/NoticeCriteria.cs"
    click S5 "https://github.com/iso8859/wfbiblio/blob/master/SRU/SRU.xml"

    %% Click Events for Data/Configuration Layer
    click DS1 "https://github.com/iso8859/wfbiblio/blob/master/Properties/DataSources/Exemplaire.datasource"
    click DS2 "https://github.com/iso8859/wfbiblio/blob/master/Properties/DataSources/InfoLecteur.datasource"
    click DS3 "https://github.com/iso8859/wfbiblio/blob/master/Properties/DataSources/Lecteur.datasource"
    click DS4 "https://github.com/iso8859/wfbiblio/blob/master/Properties/DataSources/Notice.datasource"
    click AS1 "https://github.com/iso8859/wfbiblio/blob/master/app.config"
    click AS2 "https://github.com/iso8859/wfbiblio/blob/master/Properties/AssemblyInfo.cs"
    click AS3 "https://github.com/iso8859/wfbiblio/blob/master/Properties/Resources.Designer.cs"
    click AS4 "https://github.com/iso8859/wfbiblio/blob/master/Properties/Resources.resx"
    click AS5 "https://github.com/iso8859/wfbiblio/blob/master/Properties/Settings.Designer.cs"
    click AS6 "https://github.com/iso8859/wfbiblio/blob/master/Properties/Settings.settings"
    click SR1 "https://github.com/iso8859/wfbiblio/blob/master/ExempleReponse.json"
    click SR2 "https://github.com/iso8859/wfbiblio/blob/master/ExempleReponse.xml"

    %% Styling Classes
    classDef ui fill:#AED6F1,stroke:#2874A6,stroke-width:2px;
    classDef logic fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef sru fill:#ABEBC6,stroke:#2E8B57,stroke-width:2px;
    classDef data fill:#F5B7B1,stroke:#CB4335,stroke-width:2px;
    classDef external fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
```
