# saurov565/medicine-shop-management architecture

> Architecture diagram of the GitHub repository saurov565/medicine-shop-management, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saurov565/medicine-shop-management
- Repository: https://github.com/saurov565/medicine-shop-management

## Overview

1. This is a Java Swing desktop application for a medicine shop/pharmacy. The architecture is centered around a GUI shell with feature-specific panels, backed by service classes and simple domain objects.

2. The entry path is likely `Main.java` → `MainFrame.java`. `Main` starts the application, and `MainFrame` acts as the main window/container that hosts the rest of the UI.

3. The UI layer is split into three main functional panels:
   - `InventoryPanel.java` for stock and medicine management
   - `SalesPanel.java` for billing/sales workflows
   - `ReportsPanel.java` for analytics and summaries  
   These panels are the primary interaction points for the user.

4. Business logic is separated from the UI into service classes:
   - `InventoryService.java`
   - `SalesService.java`
   - `ReportService.java`  
   The panels likely call into these services rather than manipulating data directly, which keeps the GUI thin and the rules centralized.

5. The domain model is small and explicit:
   - `Medicine.java` represents inventory items and their properties such as stock and expiry-related data
   - `Sale.java` represents a completed or in-progress sale
   - `SaleItem.java` represents line items within a sale  
   This suggests sales are modeled as a parent transaction with itemized details.

6. The main data flow is user-driven: a user works in a panel, the panel invokes a service, the service updates or reads domain objects, and the UI reflects the result. For example, inventory edits flow through `InventoryPanel` → `InventoryService` → `Medicine`.

7. Sales appear to be a separate workflow from inventory, but connected to it. A sale likely consumes medicine stock through `SalesService`, which then updates inventory state and produces sale records for reporting.

8. Reporting is its own subsystem rather than just a UI table. `ReportService` likely aggregates data from inventory and sales to produce business summaries, such as stock status, sales totals, or expiry alerts.

9. The application boundary is a single-process desktop app: there is no sign of a web server, REST API, or external backend in the file list. That means the UI and business logic run in the same JVM and communicate by direct method calls.

10. There is no explicit persistence layer in the listed files. If data is saved, it is likely handled inside the service classes or via simple local storage not shown here; the repository structure itself emphasizes UI, services, and models rather than database infrastructure.

11. For an architecture diagram, the most important layers are:
   - Presentation: `MainFrame`, the three panels
   - Application/Business: `InventoryService`, `SalesService`, `ReportService`
   - Domain: `Medicine`, `Sale`, `SaleItem`
   - Startup: `Main`  
   Cross-cutting concern: stock/expiry management and reporting derived from the same shared domain objects.

12. The cleanest interpretation is a layered Swing CRUD-and-transaction app: a main window hosts feature panels, panels delegate to services, services manage medicine and sale entities, and reports are computed from those same underlying records.

Main entry points: [`MainFrame.java`](https://github.com/saurov565/medicine-shop-management/blob/main/MainFrame.java) (Main Frame), [`SalesService.java`](https://github.com/saurov565/medicine-shop-management/blob/main/SalesService.java) (SalesSvc), [`ReportService.java`](https://github.com/saurov565/medicine-shop-management/blob/main/ReportService.java) (ReportSvc), [`Medicine.java`](https://github.com/saurov565/medicine-shop-management/blob/main/Medicine.java) (Medicine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup"]
  node_main(("Main<br/>entrypoint<br/>[Main.java]"))
end

subgraph group_ui["UI"]
  node_mainframe["Main Frame<br/>window<br/>[MainFrame.java]"]
  node_inventory_panel["Inventory<br/>panel"]
  node_sales_panel["Sales<br/>panel<br/>[SalesPanel.java]"]
  node_reports_panel["Reports<br/>panel<br/>[ReportsPanel.java]"]
end

subgraph group_services["Services"]
  node_inventory_service["InventorySvc"]
  node_sales_service["SalesSvc<br/>[SalesService.java]"]
  node_report_service["ReportSvc<br/>[ReportService.java]"]
end

subgraph group_domain["Domain"]
  node_medicine["Medicine<br/>entity<br/>[Medicine.java]"]
  node_sale["Sale<br/>entity<br/>[Sale.java]"]
  node_sale_item["Sale Item<br/>entity<br/>[SaleItem.java]"]
end

node_main -->|"launches"| node_mainframe
node_mainframe -->|"hosts"| node_inventory_panel
node_mainframe -->|"hosts"| node_sales_panel
node_mainframe -->|"hosts"| node_reports_panel
node_inventory_panel -->|"uses"| node_inventory_service
node_sales_panel -->|"uses"| node_sales_service
node_reports_panel -->|"uses"| node_report_service
node_inventory_service -->|"manages"| node_medicine
node_sales_service -->|"creates"| node_sale
node_sales_service -->|"adds"| node_sale_item
node_sales_service -->|"updates stock"| node_medicine
node_report_service -->|"reads"| node_medicine
node_report_service -->|"reads"| node_sale
node_report_service -->|"reads"| node_sale_item

click node_main "https://github.com/saurov565/medicine-shop-management/blob/main/Main.java"
click node_mainframe "https://github.com/saurov565/medicine-shop-management/blob/main/MainFrame.java"
click node_inventory_panel "https://github.com/saurov565/medicine-shop-management/blob/main/InventoryPanel.java"
click node_sales_panel "https://github.com/saurov565/medicine-shop-management/blob/main/SalesPanel.java"
click node_reports_panel "https://github.com/saurov565/medicine-shop-management/blob/main/ReportsPanel.java"
click node_inventory_service "https://github.com/saurov565/medicine-shop-management/blob/main/InventoryService.java"
click node_sales_service "https://github.com/saurov565/medicine-shop-management/blob/main/SalesService.java"
click node_report_service "https://github.com/saurov565/medicine-shop-management/blob/main/ReportService.java"
click node_medicine "https://github.com/saurov565/medicine-shop-management/blob/main/Medicine.java"
click node_sale "https://github.com/saurov565/medicine-shop-management/blob/main/Sale.java"
click node_sale_item "https://github.com/saurov565/medicine-shop-management/blob/main/SaleItem.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main toneBlue
class node_mainframe,node_inventory_panel,node_sales_panel,node_reports_panel toneAmber
class node_inventory_service,node_sales_service,node_report_service toneMint
class node_medicine,node_sale,node_sale_item toneRose
```

## Components

### Startup

Application entrypoint and bootstrap.

- [Main](https://github.com/saurov565/medicine-shop-management/blob/main/Main.java): entrypoint · Starts the desktop application. · `Main.java`

### UI

Swing window and feature panels.

- [Main Frame](https://github.com/saurov565/medicine-shop-management/blob/main/MainFrame.java): window · Primary Swing shell that hosts feature panels. · `MainFrame.java`
- [Inventory](https://github.com/saurov565/medicine-shop-management/blob/main/InventoryPanel.java): panel · Medicine and stock management UI. · `InventoryPanel.java`
- [Sales](https://github.com/saurov565/medicine-shop-management/blob/main/SalesPanel.java): panel · Billing and transaction UI. · `SalesPanel.java`
- [Reports](https://github.com/saurov565/medicine-shop-management/blob/main/ReportsPanel.java): panel · Analytics and summary UI. · `ReportsPanel.java`

### Services

Business logic and workflow coordination.

- [InventorySvc](https://github.com/saurov565/medicine-shop-management/blob/main/InventoryService.java): service · Coordinates stock updates and medicine operations. · `InventoryService.java`
- [SalesSvc](https://github.com/saurov565/medicine-shop-management/blob/main/SalesService.java): service · Handles sales workflow and stock consumption. · `SalesService.java`
- [ReportSvc](https://github.com/saurov565/medicine-shop-management/blob/main/ReportService.java): service · Builds summaries from inventory and sales data. · `ReportService.java`

### Domain

Core medicine and sales entities.

- [Medicine](https://github.com/saurov565/medicine-shop-management/blob/main/Medicine.java): entity · Inventory item and stock record. · `Medicine.java`
- [Sale](https://github.com/saurov565/medicine-shop-management/blob/main/Sale.java): entity · Sale transaction header. · `Sale.java`
- [Sale Item](https://github.com/saurov565/medicine-shop-management/blob/main/SaleItem.java): entity · Line item within a sale. · `SaleItem.java`

## Connections

- Main → Main Frame: launches · Application startup creates the main window.
- Main Frame → Inventory: hosts · Main window embeds the inventory workspace.
- Main Frame → Sales: hosts · Main window embeds the sales workspace.
- Main Frame → Reports: hosts · Main window embeds the reporting workspace.
- Inventory → InventorySvc: uses · Inventory UI delegates stock operations to business logic.
- Sales → SalesSvc: uses · Sales UI delegates billing workflow to business logic.
- Reports → ReportSvc: uses · Reports UI requests aggregated summaries.
- InventorySvc → Medicine: manages · Inventory service reads and updates medicine records.
- SalesSvc → Sale: creates · Sales service builds and finalizes sale transactions.
- SalesSvc → Sale Item: adds · Sales service composes sales from itemized lines.
- SalesSvc → Medicine: updates stock · Completing sales reduces inventory quantities.
- ReportSvc → Medicine: reads · Reports aggregate stock-related data from medicine records.
- ReportSvc → Sale: reads · Reports aggregate sales totals and history.
- ReportSvc → Sale Item: reads · Reports can derive detail metrics from line items.
