# surajkulriya/pharmacy-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/surajkulriya/pharmacy-management-system
- Repository: https://github.com/surajkulriya/pharmacy-management-system

## Overview

##### Project Overview
- This is a full-stack desktop application built primarily in Java using Swing for the GUI, along with a MySQL back end (accessed via JDBC). It supports pharmacy operations such as user login, drug management, purchase/sales handling, invoicing, reporting, and messaging.

##### File Structure
- Notice the separation between the source Java files (in the src/main directory) and GUI form files (with “.form” extensions). This indicates strong coupling between the UI layer and the underlying Java classes.
- The existence of separate directories for build, dist, and lib suggests that the application is modularized into components that deal with the GUI, business logic, and external libraries (e.g., AbsoluteLayout.jar, JTattoo, MySQL connector).
- The “nbproject” and “build.xml” files hint at NetBeans usage, so the build process and dependency management are also part of the overall system architecture.

##### Identifying the Main System Components
a. User Interface (Presentation Layer):
- Composed of Swing-based Java forms (e.g., Login.form, Pharmacy.form, Drug_List.form, etc.).
- This layer handles user input, display of reports/invoices, and navigation between modules.

b. Business Logic Layer:
- Implemented in the corresponding Java classes (e.g., Login.java, Drug.java, Sales_Bill.java).
- Handles the core operations like business rules, validations, processing of transactions (e.g., drug purchase, sales, user management, messaging).

c. Data Access Layer:
- Although not explicitly separated into a package, connection handling is present in classes like Connect.java.
- This layer is responsible for communicating with the MySQL database (using the mysql-connector-java provided in lib).

d. Database (Persistence Layer):
- The MySQL database, which is set up using the provided “pharmacy.sql” file.

##### Relationships and Interactions
- Users interact with the GUI, which in turn passes requests to the Business Logic Layer.
- The Business Logic Layer uses the Data Access Layer to perform CRUD (Create, Read, Update, Delete) operations on the Database.
- Additionally, consider including error paths and possibly periodic data refresh cycles (e.g., for stock updates, messaging modules).

##### Architectural Patterns and Design Principles
- The project appears to follow a multi-tiered architecture separating the presentation, business, and persistence concerns.
- MVC-style separation is evident since the Swing forms (UI) are separate from the business logic implementations.
- That the design ensures modularity so that any changes to the GUI or database access could be isolated without affecting other parts.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interface Layer
    subgraph "User Interface (Swing Forms)"
        UI_Login["Login Form"]:::UI
        UI_Pharmacy["Pharmacy Form"]:::UI
        UI_Drug["Drug List Form"]:::UI
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        BL_Login["Login Module (Login.java)"]:::Business
        BL_Drug["Drug Management Module (Drug.java)"]:::Business
        BL_Sales["Sales Module (Sales_Bill.java)"]:::Business
        BL_Company["Company Module (Company.java)"]:::Business
        BL_User["User Settings Module (User.java)"]:::Business
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DAL["Connection Manager (Connect.java)"]:::DAL
    end

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

    %% External Libraries
    subgraph "External Libraries"
        LIB_Abs["AbsoluteLayout"]:::Library
        LIB_JTattoo["JTattoo"]:::Library
        LIB_MySQL["MySQL Connector"]:::Library
        LIB_RS2XML["RS2XML"]:::Library
    end

    %% Build and Deployment
    subgraph "Build and Deployment"
        BUILD_XML["build.xml"]:::Build
        NBPROJ["nbproject"]:::Build
        DIST["Pharmacy.jar"]:::Build
    end

    %% UI to Business Logic connections
    UI_Login -->|"triggers"| BL_Login
    UI_Pharmacy -->|"navigates"| BL_Sales
    UI_Pharmacy -->|"configures"| BL_User
    UI_Pharmacy -->|"updates"| BL_Company
    UI_Drug -->|"manages"| BL_Drug

    %% Business Logic to Data Access connections
    BL_Login -->|"processes"| DAL
    BL_Drug -->|"processes"| DAL
    BL_Sales -->|"processes"| DAL
    BL_Company -->|"processes"| DAL
    BL_User -->|"processes"| DAL

    %% Data Access to Database connection
    DAL -->|"CRUD operations"| DB

    %% External Libraries integration connections
    LIB_Abs -->|"styles"| UI_Login
    LIB_JTattoo -->|"themes"| UI_Pharmacy
    LIB_MySQL -->|"connects"| DAL
    LIB_RS2XML -->|"formats"| DAL

    %% Build and Deployment flow
    NBPROJ -->|"builds"| BUILD_XML
    BUILD_XML -->|"packages"| DIST

    %% Click Events for UI
    click UI_Login "https://github.com/surajkulriya/pharmacy-management-system/blob/master/src/main/Login.form"
    click UI_Pharmacy "https://github.com/surajkulriya/pharmacy-management-system/blob/master/src/main/Pharmacy.form"
    click UI_Drug "https://github.com/surajkulriya/pharmacy-management-system/blob/master/src/main/Drug_List.form"

    %% Click Events for Business Logic
    click BL_Login "https://github.com/surajkulriya/pharmacy-management-system/blob/master/src/main/Login.java"
    click BL_Drug "https://github.com/surajkulriya/pharmacy-management-system/blob/master/src/main/Drug.java"
    click BL_Sales "https://github.com/surajkulriya/pharmacy-management-system/blob/master/src/main/Sales_Bill.java"
    click BL_Company "https://github.com/surajkulriya/pharmacy-management-system/blob/master/src/main/Company.java"
    click BL_User "https://github.com/surajkulriya/pharmacy-management-system/blob/master/src/main/User.java"

    %% Click Event for Data Access Layer
    click DAL "https://github.com/surajkulriya/pharmacy-management-system/blob/master/src/main/Connect.java"

    %% Click Event for Database
    click DB "https://github.com/surajkulriya/pharmacy-management-system/blob/master/pharmacy.sql"

    %% Click Events for External Libraries
    click LIB_Abs "https://github.com/surajkulriya/pharmacy-management-system/blob/master/lib/AbsoluteLayout.jar"
    click LIB_JTattoo "https://github.com/surajkulriya/pharmacy-management-system/blob/master/lib/JTattoo-1.6.11.jar"
    click LIB_MySQL "https://github.com/surajkulriya/pharmacy-management-system/blob/master/lib/mysql-connector-java-5.1.40-bin.jar"
    click LIB_RS2XML "https://github.com/surajkulriya/pharmacy-management-system/blob/master/lib/rs2xml.jar"

    %% Click Events for Build and Deployment
    click BUILD_XML "https://github.com/surajkulriya/pharmacy-management-system/blob/master/build.xml"
    click NBPROJ "https://github.com/surajkulriya/pharmacy-management-system/tree/master/nbproject"
    click DIST "https://github.com/surajkulriya/pharmacy-management-system/blob/master/dist/Pharmacy.jar"

    %% Styles
    classDef UI fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef Business fill:#A9DFBF,stroke:#1D8348,stroke-width:2px;
    classDef DAL fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef DB fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef Library fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
    classDef Build fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
```
