# saadinnovates/pharmacy-management-system architecture

> Architecture diagram of the GitHub repository saadinnovates/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/saadinnovates/pharmacy-management-system
- Repository: https://github.com/saadinnovates/pharmacy-management-system

## Overview

##### Main Components
- User Interface (UI) Layer:
- Multiple GUI components as seen (login_gui.py, main_gui.py, medicines_gui.py, inventory_gui.py, prescriptions_gui.py, suppliers_gui.py, predictor_ui.py, users_gui.py).
- A separate theme.py file suggests configurable visual styling.
- Business Logic Layer:
- Core functionalities separated into distinct modules (medicines.py, inventory.py, prescriptions.py, suppliers.py, predictor.py, users.py, register.py).
- Data Access Layer:
- The database.py file handles connections and interactions with the MySQL database.
- Application Entry Point:
- main.py and main_gui.py likely act as the startup scripts that orchestrate the UI and logic components.

##### Relationships and Interactions
- The UI components (Tkinter-based GUIs) interact directly with the business logic modules. For example, medicines_gui.py calls functions in medicines.py for operations such as adding, updating, or deleting medicine records.
- The business logic modules process requests, apply business rules, and then interact with the database module (database.py) to perform CRUD operations on MySQL.
- User authentication and session management are handled by modules such as login_gui.py and register.py.
- The predictor functionality (predictor.py & predictor_ui.py) is specialized to check medicine effectiveness for a given disease, likely integrating domain-specific logic.
- Separate management of inventory, prescriptions, and suppliers suggests modular design where each module encapsulates its specific domain logic.

##### Architectural Patterns and Design Principles
- MVC-Like Structure: Although this isn’t a web application, the separation between views (GUI files), controllers/model (business logic files), and data access (database.py) implies a form of Model-View-Controller (MVC) pattern.
- Separation of Concerns: The project clearly separates the GUI-related elements from the core business functions and data persistence.
- Modular Design: Each major function has its own pair (module and corresponding GUI) making it easier to extend or modify individual parts without affecting the entire system.

##### Relevant Technologies and Frameworks
- Tkinter for Desktop GUIs.
- MySQL for data storage.
- Python as the primary programming language.

##### Final Reminders
- Component (e.g., medicines, inventory) is clearly labeled.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Entry Point
    MainEntry("Main Entry"):::entry

    %% User Interface Layer
    subgraph "User Interface Layer"
        UI1("Login GUI"):::ui
        UI2("Main GUI"):::ui
        UI3("Medicines GUI"):::ui
        UI4("Inventory GUI"):::ui
        UI5("Prescriptions GUI"):::ui
        UI6("Suppliers GUI"):::ui
        UI7("Predictor UI"):::ui
        UI8("Users GUI"):::ui
        UI9("Theme"):::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        BL1("Medicines"):::bl
        BL2("Inventory"):::bl
        BL3("Prescriptions"):::bl
        BL4("Suppliers"):::bl
        BL5("Predictor"):::bl
        BL6("Users"):::bl
        BL7("Registration"):::bl
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DAL1("Database"):::dal
    end

    %% Connections from Application Entry to UI
    MainEntry -->|"launches"| UI2

    %% Connections from UI Layer to Business Logic Layer
    UI1 -->|"AuthenticationRequest"| BL6
    UI3 -->|"ManageMedicines"| BL1
    UI4 -->|"InventoryActions"| BL2
    UI5 -->|"PrescriptionHandling"| BL3
    UI6 -->|"SupplierActions"| BL4
    UI7 -->|"PredictEffectiveness"| BL5
    UI8 -->|"UserManagement"| BL6

    %% Connections from Business Logic Layer to Data Access Layer
    BL1 -->|"CRUDOperations"| DAL1
    BL2 -->|"CRUDOperations"| DAL1
    BL3 -->|"CRUDOperations"| DAL1
    BL4 -->|"CRUDOperations"| DAL1
    BL5 -->|"QueryData"| DAL1
    BL6 -->|"UserData"| DAL1
    BL7 -->|"CreateUser"| DAL1

    %% Styles
    classDef ui fill:#8ecae6,stroke:#219ebc,stroke-width:2px;
    classDef bl fill:#90be6d,stroke:#43aa8b,stroke-width:2px;
    classDef dal fill:#ffd166,stroke:#f4a261,stroke-width:2px;
    classDef entry fill:#f28482,stroke:#e76f51,stroke-width:2px;

    %% Click Events for UI Layer
    click UI1 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/login_gui.py"
    click UI2 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/main_gui.py"
    click UI3 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/medicines_gui.py"
    click UI4 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/inventory_gui.py"
    click UI5 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/prescriptions_gui.py"
    click UI6 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/suppliers_gui.py"
    click UI7 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/predictor_ui.py"
    click UI8 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/users_gui.py"
    click UI9 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/theme.py"

    %% Click Events for Business Logic Layer
    click BL1 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/medicines.py"
    click BL2 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/inventory.py"
    click BL3 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/prescriptions.py"
    click BL4 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/suppliers.py"
    click BL5 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/predictor.py"
    click BL6 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/users.py"
    click BL7 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/register.py"

    %% Click Event for Data Access Layer
    click DAL1 "https://github.com/saadinnovates/pharmacy-management-system/blob/main/database.py"

    %% Click Event for Application Entry
    click MainEntry "https://github.com/saadinnovates/pharmacy-management-system/blob/main/main.py"
```
