# marcelhassankassem-dev/carepharm architecture

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

- Interactive diagram: https://gitdiagram.com/marcelhassankassem-dev/carepharm
- Repository: https://github.com/marcelhassankassem-dev/carepharm

## Overview

CarePharm is a Django pharmacy application for staff and patients. Staff manage patient records, inventory, prescription dispensing, counter sales, safety decisions and reports; patients have accounts, and the owner manages staff. The graph separates domain services from their persistent records. Some views and reports are named in the source index but not excerpted, so their connections are included only where the index or README supports them; no external integrations are documented.

Main entry points: [`prescriptions/services.py`](https://github.com/marcelhassankassem-dev/carepharm/blob/main/prescriptions/services.py) (Prescription Workflow), [`safety/services.py`](https://github.com/marcelhassankassem-dev/carepharm/blob/main/safety/services.py) (Safety Checks), [`sales/services.py`](https://github.com/marcelhassankassem-dev/carepharm/blob/main/sales/services.py) (Sales), [`passport/services.py`](https://github.com/marcelhassankassem-dev/carepharm/blob/main/passport/services.py) (Patient Records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Accounts and Patients"]
  node_accounts["Accounts<br/>[views.py]"]
  node_account_services["Account Services<br/>[services.py]"]
  node_patient_records["Patient Records<br/>[services.py]"]
  node_patient_data[("Patient Data<br/>[models.py]")]
end

subgraph group_operations["Pharmacy Operations"]
  node_inventory["Inventory<br/>[services.py]"]
  node_inventory_data[("Medicine and Batches<br/>[models.py]")]
  node_sales["Sales<br/>[services.py]"]
  node_sales_data[("Sale Records<br/>[models.py]")]
end

subgraph group_care["Clinical Workflow"]
  node_prescriptions["Prescription Workflow<br/>[services.py]"]
  node_prescription_data[("Prescription Records<br/>[models.py]")]
  node_safety["Safety Checks<br/>[services.py]"]
  node_safety_data[("Safety Overrides<br/>[models.py]")]
end

subgraph group_insight["Reporting and Audit"]
  node_reports["Reports<br/>[services.py]"]
  node_audit["Activity and Notifications<br/>[services.py]"]
  node_audit_data[("Audit Records<br/>[models.py]")]
end

node_staff(("Staff"))
node_patients(("Patients"))

node_staff -->|"signs in"| node_accounts
node_patients -->|"signs in"| node_accounts
node_staff -->|"manages staff"| node_accounts
node_accounts -->|"uses"| node_account_services
node_patient_records -->|"creates patient login"| node_account_services
node_patient_records -->|"creates and queries"| node_patient_data
node_inventory -->|"queries and updates"| node_inventory_data
node_sales -->|"checks and takes stock"| node_inventory
node_sales -->|"records sales"| node_sales_data
node_sales -->|"logs sale"| node_audit
node_prescriptions -->|"manages status and items"| node_prescription_data
node_prescriptions -->|"takes or returns stock"| node_inventory
node_prescriptions -->|"records collection sale"| node_sales
node_prescriptions -->|"updates long-term medicines"| node_patient_records
node_safety -->|"checks allergies and medicines"| node_patient_records
node_safety -->|"adds prescription item"| node_prescriptions
node_safety -->|"stores overrides"| node_safety_data
node_safety -->|"logs decision"| node_audit
node_reports -->|"uses stock services"| node_inventory
node_reports -->|"uses prescription services"| node_prescriptions
node_audit -->|"creates and queries"| node_audit_data

click node_accounts "https://github.com/marcelhassankassem-dev/carepharm/blob/main/accounts/views.py"
click node_account_services "https://github.com/marcelhassankassem-dev/carepharm/blob/main/accounts/services.py"
click node_patient_records "https://github.com/marcelhassankassem-dev/carepharm/blob/main/passport/services.py"
click node_patient_data "https://github.com/marcelhassankassem-dev/carepharm/blob/main/passport/models.py"
click node_inventory "https://github.com/marcelhassankassem-dev/carepharm/blob/main/inventory/services.py"
click node_inventory_data "https://github.com/marcelhassankassem-dev/carepharm/blob/main/inventory/models.py"
click node_sales "https://github.com/marcelhassankassem-dev/carepharm/blob/main/sales/services.py"
click node_sales_data "https://github.com/marcelhassankassem-dev/carepharm/blob/main/sales/models.py"
click node_prescriptions "https://github.com/marcelhassankassem-dev/carepharm/blob/main/prescriptions/services.py"
click node_prescription_data "https://github.com/marcelhassankassem-dev/carepharm/blob/main/prescriptions/models.py"
click node_safety "https://github.com/marcelhassankassem-dev/carepharm/blob/main/safety/services.py"
click node_safety_data "https://github.com/marcelhassankassem-dev/carepharm/blob/main/safety/models.py"
click node_reports "https://github.com/marcelhassankassem-dev/carepharm/blob/main/reports/services.py"
click node_audit "https://github.com/marcelhassankassem-dev/carepharm/blob/main/core/services.py"
click node_audit_data "https://github.com/marcelhassankassem-dev/carepharm/blob/main/core/models.py"

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_accounts,node_account_services,node_patient_records,node_patient_data toneBlue
class node_inventory,node_inventory_data,node_sales,node_sales_data toneAmber
class node_prescriptions,node_prescription_data,node_safety,node_safety_data toneMint
class node_reports,node_audit,node_audit_data toneRose
class node_staff,node_patients toneIndigo
```

## Components

### Accounts and Patients

- [Accounts](https://github.com/marcelhassankassem-dev/carepharm/blob/main/accounts/views.py): `accounts/views.py`
- [Account Services](https://github.com/marcelhassankassem-dev/carepharm/blob/main/accounts/services.py): `accounts/services.py`
- [Patient Records](https://github.com/marcelhassankassem-dev/carepharm/blob/main/passport/services.py): `passport/services.py`
- [Patient Data](https://github.com/marcelhassankassem-dev/carepharm/blob/main/passport/models.py): `passport/models.py`

### Pharmacy Operations

- [Inventory](https://github.com/marcelhassankassem-dev/carepharm/blob/main/inventory/services.py): `inventory/services.py`
- [Medicine and Batches](https://github.com/marcelhassankassem-dev/carepharm/blob/main/inventory/models.py): `inventory/models.py`
- [Sales](https://github.com/marcelhassankassem-dev/carepharm/blob/main/sales/services.py): `sales/services.py`
- [Sale Records](https://github.com/marcelhassankassem-dev/carepharm/blob/main/sales/models.py): `sales/models.py`

### Clinical Workflow

- [Prescription Workflow](https://github.com/marcelhassankassem-dev/carepharm/blob/main/prescriptions/services.py): `prescriptions/services.py`
- [Prescription Records](https://github.com/marcelhassankassem-dev/carepharm/blob/main/prescriptions/models.py): `prescriptions/models.py`
- [Safety Checks](https://github.com/marcelhassankassem-dev/carepharm/blob/main/safety/services.py): `safety/services.py`
- [Safety Overrides](https://github.com/marcelhassankassem-dev/carepharm/blob/main/safety/models.py): `safety/models.py`

### Reporting and Audit

- [Reports](https://github.com/marcelhassankassem-dev/carepharm/blob/main/reports/services.py): `reports/services.py`
- [Activity and Notifications](https://github.com/marcelhassankassem-dev/carepharm/blob/main/core/services.py): `core/services.py`
- [Audit Records](https://github.com/marcelhassankassem-dev/carepharm/blob/main/core/models.py): `core/models.py`

### Other components

- **Staff**
- **Patients**

## Connections

- Staff → Accounts: signs in (evidence: `README.md`)
- Patients → Accounts: signs in (evidence: `README.md`)
- Staff → Accounts: manages staff (evidence: `README.md`)
- Accounts → Account Services: uses
- Patient Records → Account Services: creates patient login (evidence: `passport/services.py`)
- Patient Records → Patient Data: creates and queries (evidence: `passport/services.py`)
- Inventory → Medicine and Batches: queries and updates (evidence: `inventory/services.py`)
- Sales → Inventory: checks and takes stock (evidence: `sales/services.py`)
- Sales → Sale Records: records sales (evidence: `sales/services.py`)
- Sales → Activity and Notifications: logs sale (evidence: `sales/services.py`)
- Prescription Workflow → Prescription Records: manages status and items (evidence: `prescriptions/services.py`)
- Prescription Workflow → Inventory: takes or returns stock (evidence: `prescriptions/services.py`)
- Prescription Workflow → Sales: records collection sale (evidence: `prescriptions/services.py`)
- Prescription Workflow → Patient Records: updates long-term medicines (evidence: `prescriptions/services.py`)
- Safety Checks → Patient Records: checks allergies and medicines (evidence: `safety/services.py`)
- Safety Checks → Prescription Workflow: adds prescription item (evidence: `safety/services.py`)
- Safety Checks → Safety Overrides: stores overrides (evidence: `safety/services.py`)
- Safety Checks → Activity and Notifications: logs decision (evidence: `safety/services.py`)
- Reports → Inventory: uses stock services (evidence: `reports/services.py`)
- Reports → Prescription Workflow: uses prescription services (evidence: `reports/services.py`)
- Activity and Notifications → Audit Records: creates and queries (evidence: `core/services.py`)
