# lvttn/pharmacy-mangment-system architecture

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

- Interactive diagram: https://gitdiagram.com/lvttn/pharmacy-mangment-system
- Repository: https://github.com/lvttn/pharmacy-mangment-system

## Overview

##### Main System Components

The system is a full-stack application with these primary components:

a) Frontend (Angular):
- Authentication Module
- Main Dashboard
- Multiple Feature Windows (Inventory, POS, Sales, etc.)
- Admin Configuration
- Charts and Reports

b) Backend (Node.js):
- REST API Server
- Authentication Middleware
- Database Models
- Route Handlers

##### Key Architectural Elements

a) Client Layer:
- Main Angular modules:
- Auth Module (Login/Signup)
- Main Window Module
- Configuration Module
- Shared Components (Header, Sidemenu)

b) Server Layer:
- Express.js Server
- Authentication Middleware
- API Routes
- Model Definitions

c) Database Layer:
- MongoDB Collections for:
- Users (Pharmacy Staff, Doctors)
- Inventory
- Sales
- Doctor Orders
- Suppliers

##### Component Relationships

- Client-Server Communication via REST APIs
- Authentication Flow
- Data Flow for Key Features:
- Point of Sale Operations
- Inventory Management
- Doctor Order Processing
- Sales Reporting

##### Specific Implementation Details

Specialized components:
- Email Service for Supplier Notifications
- Chart Generation System
- Order Processing Pipeline
- Stock Management System

##### Additional Elements

Include:
- Security boundaries
- Authentication checkpoints
- External service integrations
- Caching mechanisms
- Error handling flow

- The modular nature of the frontend
- The RESTful architecture
- The role-based access control
- The separation of concerns between components
- The data flow for critical operations like POS and inventory management

This system design should reflect the complex nature of the pharmacy management system while keeping it clear and understandable for the development team.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Auth["Authentication Module"]
        Dashboard["Main Dashboard"]
        Inventory["Inventory Management"]
        POS["Point of Sale System"]
        DoctorOrders["Doctor Orders System"]
        Sales["Sales Reports & Analytics"]
        Admin["Admin Configuration"]
        Supplier["Supplier Management"]
        Stock["Stock Management"]
    end

    subgraph Server
        Express["Express Server"]
        AuthMW["Auth Middleware"]
        Routes["API Routes"]
        EmailSvc["Email Service"]
    end

    subgraph Database
        MongoDB[(MongoDB)]
        Users[("Users Collection")]
        InventoryDB[("Inventory Collection")]
        SalesDB[("Sales Collection")]
        DoctorOrdersDB[("Doctor Orders Collection")]
        SupplierDB[("Suppliers Collection")]
    end

    %% Client Layer Connections
    Auth --> Express
    Dashboard --> Express
    Inventory --> Express
    POS --> Express
    DoctorOrders --> Express
    Sales --> Express
    Admin --> Express
    Supplier --> Express
    Stock --> Express

    %% Server Layer Connections
    Express --> AuthMW
    AuthMW --> Routes
    Routes --> EmailSvc
    Routes --> MongoDB

    %% Database Connections
    MongoDB --> Users
    MongoDB --> InventoryDB
    MongoDB --> SalesDB
    MongoDB --> DoctorOrdersDB
    MongoDB --> SupplierDB

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef service fill:#9b59b6,stroke:#8e44ad,color:white

    class Auth,Dashboard,Inventory,POS,DoctorOrders,Sales,Admin,Supplier,Stock frontend
    class Express,Routes backend
    class AuthMW security
    class MongoDB,Users,InventoryDB,SalesDB,DoctorOrdersDB,SupplierDB database
    class EmailSvc service

    %% Click Events
    click Auth "https://github.com/LVTTN/Pharmacy-Mangment-System/tree/master/src/app/auth/"
    click AuthMW "https://github.com/LVTTN/Pharmacy-Mangment-System/blob/master/backend/middleware/check-auth.js"
    click Dashboard "https://github.com/LVTTN/Pharmacy-Mangment-System/blob/master/src/app/mainwindow/mainwindow.component.ts"
    click Inventory "https://github.com/LVTTN/Pharmacy-Mangment-System/tree/master/src/app/mainwindow/a-inventory-window/"
    click POS "https://github.com/LVTTN/Pharmacy-Mangment-System/tree/master/src/app/mainwindow/a-pointofsale-window/"
    click DoctorOrders "https://github.com/LVTTN/Pharmacy-Mangment-System/tree/master/src/app/mainwindow/a-doctor-order-window/"
    click Sales "https://github.com/LVTTN/Pharmacy-Mangment-System/tree/master/src/app/mainwindow/a-sales-window/"
    click Admin "https://github.com/LVTTN/Pharmacy-Mangment-System/tree/master/src/app/mainwindow/x-configuration-settings-admin/"
    click Supplier "https://github.com/LVTTN/Pharmacy-Mangment-System/tree/master/src/app/mainwindow/a-suppliers-window/"
    click Stock "https://github.com/LVTTN/Pharmacy-Mangment-System/tree/master/src/app/mainwindow/a-exp-outofstock-window/"
    click Express "https://github.com/LVTTN/Pharmacy-Mangment-System/blob/master/backend/app.js"
    click EmailSvc "https://github.com/LVTTN/Pharmacy-Mangment-System/blob/master/src/app/mainwindow/a-doctor-order-window/new-doctor-order-window/email-Interaction.service.ts"
```
