# yhhton/biigler architecture

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

- Interactive diagram: https://gitdiagram.com/yhhton/biigler
- Repository: https://github.com/yhhton/biigler

## Overview

##### Project type and purpose
- This is an R package (“biigler”) that serves as a client-side wrapper for the BIIGLE 2.0 RESTful API.
- Its primary purpose is to automate and simplify repetitive BIIGLE GUI operations (fetching volumes, images, label trees, posting/deleting labels or annotations, and generating reports) entirely from R.

##### File structure
- Top-level files:
- DESCRIPTION, NAMESPACE – standard R package metadata and export configuration
- biigler.Rproj – RStudio project file
- README.md, LICENSE* – documentation and licensing
- Directories:
- R/ – contains all functional R scripts grouped by operation (data retrieval, posting/deleting, labeling assistant, summary/visualization)
- man/ – generated Rd files documenting each exported function
- data/ – example datasets (ex_annotation.rda, ex_label.rda) for testing summary/visualization functions
- No separate “frontend” or “backend” folders; the package itself is both client and orchestrator.

##### Extract additional insights from README
- Key functional groups:
- API client functions (getBIIGLE, getVolID, getVolImg, getTree, postLabs, volPostNDelete, etc.)
- Labeling assistant (labelingAssistant)
- Reporting & visualization (ana_sumVol)
- Authentication utility (genAuth)
- Dependencies: R ≥4.1.2, BIIGLE 2.0 API v3.14.2, plus typical HTTP/JSON libraries (e.g., httr, jsonlite).

a. Main components to include:
- R Package (biigler)
– Authentication module (genAuth)
– API Client module (all get*/post* functions)
– Labeling Assistant module
– Reporting & Visualization module
– Example Data (ex_annotation, ex_label)
- External BIIGLE 2.0 RESTful API (hosted at user-configurable URL)
- User’s R session / script / RStudio IDE
- (Optional) Downstream chart output (e.g., ggplot bar charts)
b. Relationships and interactions:
1. User invokes functions in biigler from RStudio
2. Authentication module generates auth header
3. API Client module issues HTTP GET/POST requests to BIIGLE API
4. BIIGLE API responds with JSON data or status
5. Received JSON is parsed into R objects (data frames, lists)
6. Labeling Assistant or Reporting modules transform data or send batch requests
7. Visualization modules render bar charts or export CSV reports
c. Architectural patterns and design principles:
- Modular separation by responsibility (auth, data retrieval, data posting, reporting)
- Single responsibility functions, each documented in man/
- Data encapsulation: example data stored in data/ for testing
- Reuse of standard R package conventions (DESCRIPTION, NAMESPACE)
d. Key technologies and libraries:
- R (core language)
- httr / jsonlite (HTTP client and JSON parsing)
- csv / data.frame (data exchange format)
- ggplot2 or base plotting (assumed for bar charts in ana_sumVol)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "User & IDE"
        User["User (R Session/Script)"]
    end

    subgraph "biigler R Package"
        subgraph "Package Metadata"
            Desc["DESCRIPTION"]
            NS["NAMESPACE"]
            Readme["README.md"]
        end

        Auth["Authentication Module\ngenAuth"]
        subgraph "API Client Module"
            GetClient["Core GET Client\ngetBIIGLE"]
            BatchClient["Batch Post/Delete\nvolPostNDelete"]
        end
        LabelAssist["Labeling Assistant Module\nlabelingAssistant"]
        Report["Reporting & Visualization Module\nana_sumVol"]
        subgraph "Example Data"
            Annotation["ex_annotation"]
            LabelData["ex_label"]
        end
    end

    API["BIIGLE 2.0 RESTful API\n(JSON over HTTP)"]
    Output["Chart/CSV Output"]

    User --> Auth
    User --> GetClient
    Auth --> GetClient
    GetClient -->|"HTTP GET/POST"| API
    BatchClient -->|"HTTP POST/DELETE"| API
    API -->|"JSON Response"| GetClient
    API --> BatchClient
    GetClient --> LabelAssist
    GetClient --> Report
    Annotation --> Report
    LabelData --> Report
    Report --> Output

    click Desc "https://github.com/yhhton/biigler/tree/main/./DESCRIPTION"
    click NS "https://github.com/yhhton/biigler/tree/main/./NAMESPACE"
    click Readme "https://github.com/yhhton/biigler/blob/main/./README.md"
    click Auth "https://github.com/yhhton/biigler/blob/main/man/genAuth.Rd"
    click GetClient "https://github.com/yhhton/biigler/blob/main/R/getBIIGLE.R"
    click BatchClient "https://github.com/yhhton/biigler/blob/main/R/volPostNDelete.R"
    click LabelAssist "https://github.com/yhhton/biigler/blob/main/R/labelingAssistant.R"
    click Report "https://github.com/yhhton/biigler/blob/main/R/analysis.R"
    click Annotation "https://github.com/yhhton/biigler/blob/main/data/ex_annotation.rda"
    click LabelData "https://github.com/yhhton/biigler/blob/main/data/ex_label.rda"

    class Desc,NS,Readme,Auth,GetClient,BatchClient,LabelAssist,Report internal
    class API external
    class Annotation,LabelData datastore
    class Output output

    classDef internal fill:#E8F8F5,stroke:#1A5276,color:#1B2631
    classDef external fill:#FEF5E7,stroke:#873600,color:#6E2C00
    classDef datastore fill:#FDEDEC,stroke:#943126,color:#78281F
    classDef output fill:#E8EAF6,stroke:#283747,color:#1B2631
```
