# santosh5358/pharmacy-management architecture

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

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

## Overview

##### Overall Architecture
- The system is divided into a Frontend (React.js) and a Backend (Express.js) that communicates with a MongoDB database.
- Additionally, there is a Netlify directory for serverless functions – these likely provide an alternative deployment strategy for backend endpoints or additional utilities.

##### Main Components
a. Frontend Component:
- User Interface (React components such as Header, Footer, Login, Register, Dashboard, etc.)
- Routing (React Router)
- HTTP Client (Axios for calling backend API endpoints)
- That the “ForntEnd” folder contains both the development (src) and the built assets (build).

b. Backend Component:
- Server Script (server.js)
- Data Models (Inside Backend/models: Contact.js, Item.js, Order.js, User.js) which indicate the domain objects.
- API layer for handling authentication, CRUD operations for medicines, and user profile management.

c. Database:
- MongoDB database that stores user details, medicine data, orders, and invoices.
- That the backend communicates with MongoDB (via MONGO_URI environment variable).

d. Netlify Serverless Functions:
- Functions with the Frontend (if used in that deployment context) or as an alternative microservice.

##### Relationships and Interactions
- From the Frontend component to the Backend component, indicating API calls for operations like authentication, medicine retrieval, order creation.
- From the Backend to the Database (MongoDB) to show data persistence.
- If the Netlify functions are in use, add a connection between the Frontend and these serverless components (or between Netlify functions and the Backend, if they serve as subsets of the main API).

##### Architectural Patterns and Design Principles
- Separation of concerns:
- The Frontend handles presentation and client-side logic.
- The Backend handles business logic, data validation, and interaction with MongoDB.
- That the project emphasizes role-based access (admin vs. regular users) and RESTful API design.
- Mention use of environment variables for configuration (JWT_SECRET, MONGO_URI, PORT), reinforcing good security practices.

##### Technologies, Frameworks, and Libraries
- Frontend: React.js, React Router, Axios.
- Backend: Express.js, Node.js.
- Database: MongoDB.
- Additional: Netlify for hosting/deploying serverless functions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (React.js)"
        FSource("Frontend Source"):::frontend
        FBuild("Frontend Build"):::frontend
        Header("Header"):::frontend
        Footer("Footer"):::frontend
        Login("Login"):::frontend
        Register("Register"):::frontend
        Dashboard("Dashboard"):::frontend
        Routing("Routing & HTTP Client"):::frontend
    end

    %% Backend Layer
    subgraph "Backend (Express.js)"
        Server("Server (Express.js)"):::backend
        ModelContact("Contact Model"):::backend
        ModelItem("Item Model"):::backend
        ModelOrder("Order Model"):::backend
        ModelUser("User Model"):::backend
    end

    %% Database Layer
    subgraph "Database"
        Mongo("MongoDB"):::database
    end

    %% Netlify Functions Layer
    subgraph "Netlify Functions"
        NetlifyEntry("Function Entry"):::netlify
        NetModelContact("Contact (Netlify)"):::netlify
        NetModelItem("Item (Netlify)"):::netlify
        NetModelOrder("Order (Netlify)"):::netlify
        NetModelUser("User (Netlify)"):::netlify
    end

    %% Relationships between Frontend and Backend
    Routing -->|"APIcalls"| Server
    FSource -->|"Serverless"| NetlifyEntry

    %% Server relationships with models
    Server -->|"uses"| ModelContact
    Server -->|"uses"| ModelItem
    Server -->|"uses"| ModelOrder
    Server -->|"uses"| ModelUser

    %% Netlify Function relationships with models
    NetlifyEntry -->|"uses"| NetModelContact
    NetlifyEntry -->|"uses"| NetModelItem
    NetlifyEntry -->|"uses"| NetModelOrder
    NetlifyEntry -->|"uses"| NetModelUser

    %% Backend to Database Communication
    Server -->|"DBcalls"| Mongo

    %% Click Events for Frontend directories and files
    click FSource "https://github.com/santosh5358/pharmacy-management/tree/main/ForntEnd/src"
    click FBuild "https://github.com/santosh5358/pharmacy-management/tree/main/ForntEnd/build"
    click Header "https://github.com/santosh5358/pharmacy-management/blob/main/ForntEnd/src/Header.js"
    click Footer "https://github.com/santosh5358/pharmacy-management/blob/main/ForntEnd/src/Footer.js"
    click Login "https://github.com/santosh5358/pharmacy-management/blob/main/ForntEnd/src/components/Login.js"
    click Register "https://github.com/santosh5358/pharmacy-management/blob/main/ForntEnd/src/components/Register.js"
    click Dashboard "https://github.com/santosh5358/pharmacy-management/blob/main/ForntEnd/src/components/Dashboard.js"
    click Routing "https://github.com/santosh5358/pharmacy-management/blob/main/ForntEnd/src/App.js"

    %% Click Events for Backend
    click Server "https://github.com/santosh5358/pharmacy-management/blob/main/Backend/server.js"
    click ModelContact "https://github.com/santosh5358/pharmacy-management/blob/main/Backend/models/Contact.js"
    click ModelItem "https://github.com/santosh5358/pharmacy-management/blob/main/Backend/models/Item.js"
    click ModelOrder "https://github.com/santosh5358/pharmacy-management/blob/main/Backend/models/Order.js"
    click ModelUser "https://github.com/santosh5358/pharmacy-management/blob/main/Backend/models/User.js"

    %% Click Events for Netlify Functions
    click NetlifyEntry "https://github.com/santosh5358/pharmacy-management/blob/main/netlify/functions/hello.js"
    click NetModelContact "https://github.com/santosh5358/pharmacy-management/blob/main/netlify/functions/models/Contact.js"
    click NetModelItem "https://github.com/santosh5358/pharmacy-management/blob/main/netlify/functions/models/Item.js"
    click NetModelOrder "https://github.com/santosh5358/pharmacy-management/blob/main/netlify/functions/models/Order.js"
    click NetModelUser "https://github.com/santosh5358/pharmacy-management/blob/main/netlify/functions/models/User.js"

    %% Styles
    classDef frontend fill:#e6f7ff,stroke:#1890ff,stroke-width:2px;
    classDef backend fill:#fff2e8,stroke:#ff7f0e,stroke-width:2px;
    classDef database fill:#f0fff0,stroke:#2ca02c,stroke-width:2px;
    classDef netlify fill:#f9f9c5,stroke:#d62728,stroke-width:2px;
```
