# rubailly/openmrs-module-pharmacymanagement architecture

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

- Interactive diagram: https://gitdiagram.com/rubailly/openmrs-module-pharmacymanagement
- Repository: https://github.com/rubailly/openmrs-module-pharmacymanagement

## Overview

- An API module (located under the “api” directory) that encapsulates the business logic, data models (e.g., DrugOrder, Pharmacy, Inventory classes), service implementations, and data access objects.
- A Web module (located under the “omod” directory) that provides the user interface elements, such as controllers and JSP-based views, and extends OpenMRS UI components (for instance, via portlets and HTML extensions).

In addition, the repository contains a .github folder with multiple GitHub Actions workflows to handle CI tasks (verify pull requests, deploy snapshots, and perform releases), which is an essential part of the project’s deployment pipeline.

##### Component Identification
– Domain models (e.g., DrugAndSolde, DrugOrderPrescription, etc.)
– Data access layer (DAO classes and Hibernate ORM configurations)
– Service layer (business logic with classes like DrugOrderServiceImpl)
- OMODULE (OMOD): Represent the “omod” module. This encompasses:
– The presentation and UI layer (JSP files, controllers such as DrugOrderView, PharmacyViewController, etc.)
– View extensions for the OpenMRS UI (the “extension” and “view/extn” packages)
- Database: Although not explicitly defined in a “db” folder, the presence of Hibernate mapping files (e.g., CmdDrug.hbm.xml) and DAO classes indicates underlying relational database interactions.
- External Dependencies: Include Maven as the build and dependency management tool and denote potential integration with the OpenMRS Maven repositories (for SNAPSHOT and release deployments).

##### Relationships and Interconnections
- Directional flows between the UI layer (omod) and the API layer: UI controllers in omod will invoke services defined in the API to process data (such as drug orders, consumption, and inventory).
- That the API layer interacts with the Database using DAOs and Hibernate mappings.
- That the CI/CD pipeline sits “outside” the running system, triggering builds, tests, and deployments whenever code is committed.

##### Architectural Patterns and Principles
- The code structure follows a layered architecture – splitting data models, business logic, and presentation.
- There is a clear separation of concerns between the API (back-end services) and the OMOD (head-end user interface).
- Use of Maven and GitHub Actions contributes to a continuous integration/deployment workflow.
- Dependency directions such as “omod” depending on “api” for core functionalities and “api” relying on persistence (Hibernate) to communicate with the database.

##### Relevant Technologies
- Java and Maven for application development and build management.
- GitHub Actions for CI/CD operations.
- OpenMRS framework as the host platform.
- Hibernate (ORM) for database mapping.
- Standard Java EE web technologies (servlets/JSP) for the UI layer.

##### Detailed Elements to Capture
- OMODULE (OMOD): Include the web layers (JSP pages, web controllers, and portlets) that interact with end-users.
- Database & External Repositories: Always include these as external systems that the API interacts with.

## Diagram (Mermaid)

```mermaid
flowchart TD
    CI["CI/CD Pipeline (GitHub Actions)"]:::cicd
    EXT["External Dependencies (Maven & OpenMRS)"]:::external
    OMOD["OMOD Module (Presentation/UI)"]:::omod
    API["API Module (Business Logic & Data Access)"]:::api
    DB["Database (Relational DB & Hibernate)"]:::db

    CI -->|"TriggersBuild(mvnVerify,deploy,release)"| EXT
    EXT -->|"BuildsAndDeploysModules"| OMOD
    EXT -->|"BuildsAndDeploysModules"| API
    OMOD -->|"InvokesAPIServices"| API
    API -->|"PerformsCRUD(DAO/Hibernate)"| DB

    click CI "https://github.com/rubailly/openmrs-module-pharmacymanagement/tree/master/.github/workflows"
    click API "https://github.com/rubailly/openmrs-module-pharmacymanagement/tree/master/api"
    click OMOD "https://github.com/rubailly/openmrs-module-pharmacymanagement/tree/master/omod"
    click DB "https://github.com/rubailly/openmrs-module-pharmacymanagement/blob/master/omod/src/main/resources/CmdDrug.hbm.xml"

    classDef cicd fill:#FFCCCC,stroke:#990000,stroke-width:2px;
    classDef external fill:#FFFFCC,stroke:#999900,stroke-width:2px;
    classDef omod fill:#CCFFCC,stroke:#006600,stroke-width:2px;
    classDef api fill:#CCE5FF,stroke:#003366,stroke-width:2px;
    classDef db fill:#FFDAB9,stroke:#FF8C00,stroke-width:2px;
```
