How ankushgitrepo/pharmacy-management-system works
Main Components
• Console UI / Main Application: Represented by the Main class and related command/menu handling.
• Drug Management Module: Components to add, update, delete, view drugs and list expired drugs (including the Drug class and associated audit/triggers indicated by the DBMS folder files).
• Customer Management Module: Handled by the Customer class and related functionalities – adding, updating, and deleting customer records.
• Cart and Order Processing: Modules for Cart (Cart and CartItem classes), Order, and OrderItems operations.
• Data Structures & Action Logging: Custom implementations like StackDSA for logging actions and LinkedListDSA for additional data handling.
• Database Handler: The DatabaseHandler class that manages connections and queries to the PostgreSQL database.
• Database and External Services: PostgreSQL database itself (and associated schema with Drugs, Customers, Cart, Orders, OrderItems, and Drugs_Audit tables) with integration via the postgresql-42.7.3.jar driver.
Relationships and Interactions
• The Main class initiates the application, directing control flows to the various management modules.
• For any operation (e.g., adding a drug or registering a customer), the respective module (Drug Management, Customer Management) validates input, processes business logic, and then calls the DatabaseHandler to execute SQL operations.
• The Cart Management module interacts with both Drug and Customer modules. It ensures that a customer's cart data is consistent with the inventory data.
• An action logging mechanism (the stack data structure) captures user commands or changes as they occur.
• The system relies on triggers in the database (log_drug_changes trigger) to audit drug data modifications.
• Data flows from the console UI to business logic, then to the database for persistence and back for confirmation/updates.
Architectural Patterns & Design Principles
• Separation of Concerns: The system divides responsibilities into distinct modules (UI, business logic, data access).
• Modular Design: Each module (Drug Management, Customer Management, Cart, and Orders) has its defined classes and interactions.
• Use of Custom Data Structures: Instead of standard collections, the application uses a Stack and LinkedList for specialized logging and data handling.
• Database Abstraction: All database interactions are centralized in the DatabaseHandler, ensuring maintainability and easier configuration.