# ivanbrillo/bioconnect architecture

> Architecture diagram of the GitHub repository ivanbrillo/bioconnect, 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/ivanbrillo/bioconnect
- Repository: https://github.com/ivanbrillo/bioconnect

## Overview

##### Project Type & Purpose
- BioConnect is a back-end API service built in Java using Maven and following the Spring Boot framework.
- Its purpose appears to be the management and processing of biomedical-related data (drug documents, protein documents, graphs related to diseases and drugs, etc.) with built-in REST endpoints, authentication using JWT, and integration of various biomedical datasets.
- The presence of a Swagger folder and accompanying documentation suggests the API is well-documented and intended for client consumption (possibly by front-end UIs or third-party consumers).

##### Analyzing the File Structure
- The top-level “BioConnect” directory contains a standard Maven project structure:
- The “src/main/java” tree houses multiple packages such as controllers, services, repositories, configurations, security (JWT), DTOs, models, and exception handlers.
- The controllers are organized by resource type (for example, DrugDoc, ProteinDoc, various Graph controllers) supporting a layered MVC or more generally a layered service architecture.
- The services and repositories indicate clear separation of concerns (i.e., controllers delegate to services; services access the persistence layer via repositories).
- The “config” package holds database, security, and OpenAPI documentation configurations.
- The “JWT” package implements token filtering and token provisioning, crucial for security.
- Additional folders (dataset, Swagger, doc) indicate that the project integrates or demonstrates usage with various biomedical data sources and provides external API documentation via Swagger UI.

a. Main Components:
- Client / API Consumer: Represents front-end applications or external systems that interact with the API.
- API Gateway / REST Controllers: Modules like AdminController, AuthController, Document controllers (DrugDocController, ProteinDocController), Graph controllers (DiseaseGraphController, DrugGraphController, ProteinGraphController), etc.
- Business Logic / Service Layer: Includes services such as DrugDocService, ProteinDocService, DiseaseGraphService, etc., that contain the application’s core business logic.
- Data Persistence / Repository Layer: Repositories interacting with the underlying databases (document-oriented or possibly relational) as configured by DatabaseConfig.
- Security Layer: JWTTokenFilter, JWTTokenProvider along with SecurityConfig and MongoUserDetailsService handling authentication and authorization.
- External Interfaces: Swagger documentation (SwaggerUI), and integration with external datasets (as observed in the “dataset” folder) that might be used for initial data seeding or ongoing data processing.
- Configuration Components: Configuration classes for database connections (DatabaseConfig), OpenAPI (OpenApiConfig), and security.

b. Relationships and Interactions:
- Clients initiate API calls that pass through a security layer (JWTTokenFilter via Spring Security) before reaching the Controllers.
- Controllers handle the REST endpoints and forward requests to the Service layer.
- The Service layer processes business logic and interacts with the Repository layer to perform CRUD operations.
- Repositories link to the underlying database(s) as defined by DatabaseConfig.
- Some services may also make use of utility methods (GraphUtils) or specialized components (DatabaseOperationExecutor) for batch operations or complex queries.
- The Swagger UI acts as the interactive API documentation interface, enabling clients to explore and test endpoints.
- Additionally, the project includes scripts and datasets that show an integration pipeline for data ingestion (though these might be run separately, they influence the overall data handling strategy).

c. Architectural Patterns & Design Principles:
- The structure follows a layered architecture (Controller → Service → Repository) which is common to Spring Boot applications.
- It utilizes configuration-based dependency injection and aspect-oriented programming evident from the global exception handling and security configuration.
- JWT-based stateless authentication is implemented as a core security mechanism.
- Data transfer objects (DTOs) are used to decouple the domain models from external representations.
- There’s an emphasis on modularity (separate packages for documents, graphs, and user management) which promotes extensibility.

d. Relevant Technologies & Frameworks:
- Java with Spring Boot (via Maven): Core framework for application development.
- Spring Security & JWT: For authentication and stateless security management.
- Maven: For project build and dependency management.
- Swagger / OpenAPI: For API documentation and exploration.
- Data Access: Likely using Spring Data repositories (and Mongo DB integration suggested by “MongoUserDetailsService”) and perhaps a graph database based on the “GraphDB” dataset folder.
- Standard Java libraries and utility packages for processing and batch operations.

##### Specific Elements
- A “Client” block representing external users and other client systems.
- A “Security Layer” block (with JWTTokenFilter and SecurityConfig) positioned between the client and the core API.
- A “Controller Layer” block that lists the different controllers (AuthController, AdminController, Document Controllers, Graph Controllers, etc.).
- A “Service Layer” block that contains various business service components.
- A “Repository/Database” block showing interactions with databases (document databases, graph databases) as configured in DatabaseConfig.
- A “Configuration/Utility” block for components like OpenApiConfig, DatabaseOperationExecutor, and utility classes.
- A side component or note indicating the external datasets and scripts used for data ingestion and preparation.
- A Swagger UI block for API documentation/interaction, potentially connected back to the Client block.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client and External Interfaces
    subgraph "Client & External Interfaces"
        Client("Client / API Consumer"):::client
        Swagger("Swagger UI"):::external
    end

    %% Security Layer
    subgraph "Security Layer"
        JWT("JWT Token Provider & Filter"):::security
        SecCfg("SecurityConfig"):::security
    end

    %% Controller Layer
    subgraph "Controller Layer"
        Controller("REST Controllers"):::controller
    end

    %% Service Layer
    subgraph "Service Layer"
        Service("Business Services"):::service
    end

    %% Repository/Database Layer
    subgraph "Repository/Database Layer"
        Repo("Data Repositories"):::repository
    end

    %% Configuration & Utility
    subgraph "Configuration & Utility"
        Config("Configuration Components"):::config
    end

    %% External Data Integration
    DataIntegration("Data Integration / External Datasets"):::data

    %% Flow Connections
    Client -->|"initiates"| JWT
    JWT -->|"secures"| SecCfg
    SecCfg -->|"forwards to"| Controller
    Controller -->|"delegates"| Service
    Service -->|"queries/stores"| Repo

    %% Additional Connections
    Client ---|"explores"| Swagger
    Swagger -->|"calls"| Controller
    Config ---|"configures"| JWT
    Config ---|"configures"| Controller
    Config ---|"configures"| Service
    DataIntegration ---|"feeds data"| Repo

    %% Click Events
    click Controller "https://github.com/ivanbrillo/bioconnect/tree/main/BioConnect/src/main/java/org/unipi/bioconnect/controller"
    click Service "https://github.com/ivanbrillo/bioconnect/tree/main/BioConnect/src/main/java/org/unipi/bioconnect/service"
    click Repo "https://github.com/ivanbrillo/bioconnect/tree/main/BioConnect/src/main/java/org/unipi/bioconnect/repository"
    click JWT "https://github.com/ivanbrillo/bioconnect/tree/main/BioConnect/src/main/java/org/unipi/bioconnect/jwt"
    click SecCfg "https://github.com/ivanbrillo/bioconnect/blob/main/BioConnect/src/main/java/org/unipi/bioconnect/config/SecurityConfig.java"
    click Config "https://github.com/ivanbrillo/bioconnect/tree/main/BioConnect/src/main/java/org/unipi/bioconnect/config"
    click Swagger "https://github.com/ivanbrillo/bioconnect/tree/main/Swagger"
    click DataIntegration "https://github.com/ivanbrillo/bioconnect/tree/main/dataset"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef security fill:#FFFF99,stroke:#333,stroke-width:2px;
    classDef controller fill:#F5A623,stroke:#333,stroke-width:2px;
    classDef service fill:#A9DFBF,stroke:#333,stroke-width:2px;
    classDef repository fill:#CED4DA,stroke:#333,stroke-width:2px;
    classDef config fill:#B3CDE0,stroke:#333,stroke-width:2px;
    classDef external fill:#D6A4A4,stroke:#333,stroke-width:2px;
    classDef data fill:#E2E2E2,stroke:#333,stroke-width:2px;
```
