# shabarish2311/webmedicalmanagement architecture

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

- Interactive diagram: https://gitdiagram.com/shabarish2311/webmedicalmanagement
- Repository: https://github.com/shabarish2311/webmedicalmanagement

## Overview

##### Project Type and Purpose
- This is a full-stack web application: a pharmacy management system (“Web Medical Management System”) built with Java Servlets/JSP on the server side, a MySQL relational database, and HTML/CSS/Javascript on the client side.
- Purpose: Manage medicine inventory, pharmacists, billing, and generate sales/inventory reports with dynamic charts.

##### File Structure Analysis
- Top level:
- src/main/java – Java packages:
– DBUtility (DBConnection.java)
– dao (DAO interfaces for Bill, BillItem, Medicine, Sales, User)
– daoImpl (concrete implementations of the DAOs)
– model (POJOs: Bill, BillItem, Medicine, Sale, User)
– servlets (controller layer: AddMedicineServlet, LoginServlet, GenerateBillServlet, etc.)
– test (Main.java)
- src/main/webapp – JSP views, static assets (CSS, JS), WEB-INF (web.xml, libraries).
- build/classes – compiled classes mirror src structure.
- Key external libraries under WEB-INF/lib: MySQL Connector, iText (PDF generation), JFreeChart (charts), supporting libs.

##### README Insights
- Tech Stack reaffirmed (Java, JSP, Servlets, MySQL, HTML, CSS).
- Normalized MySQL schema for medicines, users, sales, bills.
- Dynamic analytics: top-selling medicines, trends, pharmacist contributions.

a. Main Components
1. Client Browser – JSP pages, CSS, JS
2. Web Server / Servlet Container – Java Servlets handle HTTP requests
3. Controller Layer – Servlets mapped in web.xml
4. Service/DAO Layer – DAO interfaces + implementations for persistence
5. Model Layer – Business entities (Medicine, User, Sale, Bill, BillItem)
6. Database – MySQL storing normalized tables
7. Reporting Engine – JFreeChart for chart generation; iText for PDF export
b. Relationships & Data Flow
- User interacts with JSP → submits form to a Servlet
- Servlet invokes DAO → Model objects → DB
- DAO returns model instances → Servlet forwards to JSP for view
- Reporting Servlets fetch data, hand off to JFreeChart/iText libraries → generate charts/PDF → return to client
c. Architectural Patterns & Principles
- MVC-style separation: JSP (View), Servlets (Controller), DAOs/Models (Model)
- Layered architecture: Presentation → Controller → Service/DAO → Data source
- Dependency inversion: DAOs referenced via interfaces (BillDAO, MedicineDAO, etc.)
- Single responsibility: Each servlet handles one use case (login, generate bill, update stock).
d. Key Technologies & Frameworks
- Java Servlets/JSP – request handling and view rendering
- MySQL – data persistence
- JDBC via DAO layer – data access
- JFreeChart – dynamic charting
- iText – PDF generation
- JavaScript/CSS – client-side interactivity and styling

##### Detail
- Schema grouping: Medicines, Users, Sales, Bills tables under the DB.
- DBConnection utility as the entry point for all JDBC connections.
- Don’t overcrowd: group similar components but list all five DAO pairs and model classes.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Client Browser" 
        JSP["JSP Pages"]:::frontend
        CSS["CSS Styles"]:::frontend
        JS["JS Scripts"]:::frontend
    end

    subgraph "Web Server (Tomcat)"
        subgraph "Presentation Layer"
            JSP
            CSS
            JS
        end
        subgraph "Controller Layer"
            ServletsPkg["Servlets Package"]:::controller
        end
    end

    subgraph "Service/DAO Layer"
        subgraph "DAO Interfaces"
            DAOPkg["DAO Interfaces"]:::persistence
        end
        subgraph "DAO Implementations"
            DAOImplPkg["DAO Implementations"]:::persistence
        end
    end

    subgraph "Model Layer"
        ModelPkg["Model Classes"]:::model
    end

    DBUtil["DBConnection Utility"]:::utility

    Database["MySQL Database"]:::database

    subgraph "External Libraries"
        JFreeChart["JFreeChart"]:::lib
        iText["iText (iTextPDF)"]:::lib
        MySQLConnector["MySQL Connector"]:::lib
    end

    JS -->|loads page| JSP
    JSP -->|submit form| ServletsPkg
    ServletsPkg -->|uses| DAOPkg
    DAOPkg -->|implemented by| DAOImplPkg
    DAOImplPkg -->|uses| DBUtil
    DBUtil -->|connects to| Database
    ServletsPkg -->|forwards to| JSP
    ServletsPkg -->|generate charts| JFreeChart
    ServletsPkg -->|export PDF| iText
    DAOImplPkg -->|JDBC queries| Database

    click JSP "https://github.com/shabarish2311/webmedicalmanagement/tree/main/WebMedicalManagement/webmedicalmanagement/src/main/webapp"
    click CSS "https://github.com/shabarish2311/webmedicalmanagement/tree/main/WebMedicalManagement/webmedicalmanagement/src/main/webapp"
    click JS "https://github.com/shabarish2311/webmedicalmanagement/tree/main/WebMedicalManagement/webmedicalmanagement/src/main/webapp"
    click ServletsPkg "https://github.com/shabarish2311/webmedicalmanagement/tree/main/WebMedicalManagement/webmedicalmanagement/src/main/java/servlets"
    click DAOPkg "https://github.com/shabarish2311/webmedicalmanagement/tree/main/WebMedicalManagement/webmedicalmanagement/src/main/java/dao"
    click DAOImplPkg "https://github.com/shabarish2311/webmedicalmanagement/tree/main/WebMedicalManagement/webmedicalmanagement/src/main/java/daoImpl"
    click ModelPkg "https://github.com/shabarish2311/webmedicalmanagement/tree/main/WebMedicalManagement/webmedicalmanagement/src/main/java/model"
    click DBUtil "https://github.com/shabarish2311/webmedicalmanagement/blob/main/WebMedicalManagement/webmedicalmanagement/src/main/java/DBUtility/DBConnection.java"
    click Database "https://github.com/shabarish2311/webmedicalmanagement/blob/main/WebMedicalManagement/webmedicalmanagement/src/main/webapp/WEB-INF/lib/mysql-connector-j-8.0.33.jar"
    click JFreeChart "https://github.com/shabarish2311/webmedicalmanagement/blob/main/WebMedicalManagement/webmedicalmanagement/src/main/webapp/WEB-INF/lib/jfreechart-1.5.3.jar"
    click iText "https://github.com/shabarish2311/webmedicalmanagement/blob/main/WebMedicalManagement/webmedicalmanagement/src/main/webapp/WEB-INF/lib/itextpdf-5.1.0.jar"

    classDef frontend fill:#D0E7FF,stroke:#036,stroke-width:1px
    classDef controller fill:#D6F5D6,stroke:#070,stroke-width:1px
    classDef persistence fill:#FFF0B3,stroke:#B35F00,stroke-width:1px
    classDef model fill:#FFE0E0,stroke:#A00,stroke-width:1px
    classDef database fill:#FFCCCC,stroke:#900,stroke-width:1px
    classDef lib fill:#FFF2CC,stroke:#996600,stroke-width:1px,stroke-dasharray: 5 5
    classDef utility fill:#EDEDED,stroke:#666,stroke-width:1px,stroke-dasharray: 2 2
```
