# chahmed12/cpharma architecture

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

- Interactive diagram: https://gitdiagram.com/chahmed12/cpharma
- Repository: https://github.com/chahmed12/cpharma

## Overview

Cpharma is a telemedicine and pharmacy platform spanning professional onboarding, patient consultation, prescription signing and pharmacy dispensing, with consultation payments and real-time video. The user-facing workflow starts in the role-based web app; consultations use WebRTC with WebSocket signaling, and prescriptions are cryptographically verified at the pharmacy. The graph also includes authentication/OTP and financial processing as distinct capabilities. Relationships are limited to those stated in the README or visible in the supplied source index and excerpts; unsampled implementation details are not inferred.

Main entry points: [`frontend/src/App.tsx`](https://github.com/chahmed12/cpharma/blob/main/frontend/src/App.tsx) (Role-based app), [`backend/apps/accounts/views.py`](https://github.com/chahmed12/cpharma/blob/main/backend/apps/accounts/views.py) (Account API), [`backend/apps/consultations/views.py`](https://github.com/chahmed12/cpharma/blob/main/backend/apps/consultations/views.py) (Consultation API), [`backend/apps/prescriptions/views.py`](https://github.com/chahmed12/cpharma/blob/main/backend/apps/prescriptions/views.py) (Prescription API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["Role-based app<br/>[App.tsx]"]
  node_doctor_ui["Doctor dashboard"]
  node_auth_ui["Auth client<br/>[authService.ts]"]
end

subgraph group_identity["Identity and trust"]
  node_identity_api["Account API<br/>[views.py]"]
  node_otp["OTP service<br/>[otp_service.py]"]
  node_account_store[("Account records<br/>[models.py]")]
end

subgraph group_care["Care delivery"]
  node_consult_api["Consultation API<br/>[views.py]"]
  node_consult_store[("Consultation records<br/>[models.py]")]
  node_signaling["WebSocket signaling<br/>[consumers.py]"]
  node_webrtc["Video session<br/>[useWebRTC.ts]"]
  node_crypto["Prescription crypto<br/>[cryptoService.ts]"]
  node_prescription_api["Prescription API<br/>[views.py]"]
  node_prescription_store[("Prescription records<br/>[models.py]")]
  node_signature_view["Signature viewer"]
  node_patient_records[("Patient records<br/>[models.py]")]
end

subgraph group_commerce["Pharmacy and finance"]
  node_payment_api["Payment API<br/>[views.py]"]
  node_payment_store[("Payment records<br/>[models.py]")]
  node_payment_client["Payment client<br/>[paymentService.ts]"]
end

node_patient(("Patient"))
node_doctor(("Doctor"))
node_pharmacist(("Pharmacist"))

node_patient -->|"uses"| node_webapp
node_doctor -->|"uses"| node_webapp
node_pharmacist -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_doctor_ui
node_webapp -->|"routes to"| node_auth_ui
node_auth_ui -->|"sends auth requests"| node_identity_api
node_identity_api -.->|"uses OTP"| node_otp
node_identity_api -.->|"reads and writes"| node_account_store
node_webapp -.->|"routes consultation"| node_consult_api
node_consult_api -.->|"reads and writes"| node_consult_store
node_webapp -.->|"opens signaling"| node_signaling
node_signaling -.->|"signals session"| node_webrtc
node_doctor_ui -.->|"signs prescription"| node_crypto
node_pharmacist -.->|"verifies signature"| node_signature_view
node_signature_view -.->|"verifies cryptographically"| node_crypto
node_webapp -.->|"routes prescription"| node_prescription_api
node_prescription_api -.->|"reads and writes"| node_prescription_store
node_prescription_api -.->|"accesses patient data"| node_patient_records
node_payment_client -.->|"requests payment"| node_payment_api
node_payment_api -.->|"reads and writes"| node_payment_store
node_consult_api -.->|"settles consultation"| node_payment_api

click node_webapp "https://github.com/chahmed12/cpharma/blob/main/frontend/src/App.tsx"
click node_doctor_ui "https://github.com/chahmed12/cpharma/blob/main/frontend/src/pages/DoctorDashboard.tsx"
click node_auth_ui "https://github.com/chahmed12/cpharma/blob/main/frontend/src/services/authService.ts"
click node_identity_api "https://github.com/chahmed12/cpharma/blob/main/backend/apps/accounts/views.py"
click node_otp "https://github.com/chahmed12/cpharma/blob/main/backend/apps/accounts/services/otp_service.py"
click node_account_store "https://github.com/chahmed12/cpharma/blob/main/backend/apps/accounts/models.py"
click node_consult_api "https://github.com/chahmed12/cpharma/blob/main/backend/apps/consultations/views.py"
click node_consult_store "https://github.com/chahmed12/cpharma/blob/main/backend/apps/consultations/models.py"
click node_signaling "https://github.com/chahmed12/cpharma/blob/main/backend/apps/consultations/consumers.py"
click node_webrtc "https://github.com/chahmed12/cpharma/blob/main/frontend/src/hooks/useWebRTC.ts"
click node_crypto "https://github.com/chahmed12/cpharma/blob/main/frontend/src/services/cryptoService.ts"
click node_prescription_api "https://github.com/chahmed12/cpharma/blob/main/backend/apps/prescriptions/views.py"
click node_prescription_store "https://github.com/chahmed12/cpharma/blob/main/backend/apps/prescriptions/models.py"
click node_signature_view "https://github.com/chahmed12/cpharma/blob/main/frontend/src/components/prescription/SignatureViewer.tsx"
click node_patient_records "https://github.com/chahmed12/cpharma/blob/main/backend/apps/patients/models.py"
click node_payment_api "https://github.com/chahmed12/cpharma/blob/main/backend/apps/payments/views.py"
click node_payment_store "https://github.com/chahmed12/cpharma/blob/main/backend/apps/payments/models.py"
click node_payment_client "https://github.com/chahmed12/cpharma/blob/main/frontend/src/services/paymentService.ts"

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_webapp,node_doctor_ui,node_auth_ui toneBlue
class node_identity_api,node_otp,node_account_store toneAmber
class node_consult_api,node_consult_store,node_signaling,node_webrtc,node_crypto,node_prescription_api,node_prescription_store,node_signature_view,node_patient_records toneMint
class node_payment_api,node_payment_store,node_payment_client toneRose
class node_patient,node_doctor,node_pharmacist toneIndigo
```

## Components

### Web experience

- [Role-based app](https://github.com/chahmed12/cpharma/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Doctor dashboard](https://github.com/chahmed12/cpharma/blob/main/frontend/src/pages/DoctorDashboard.tsx): `frontend/src/pages/DoctorDashboard.tsx`
- [Auth client](https://github.com/chahmed12/cpharma/blob/main/frontend/src/services/authService.ts): `frontend/src/services/authService.ts`

### Identity and trust

- [Account API](https://github.com/chahmed12/cpharma/blob/main/backend/apps/accounts/views.py): `backend/apps/accounts/views.py`
- [OTP service](https://github.com/chahmed12/cpharma/blob/main/backend/apps/accounts/services/otp_service.py): `backend/apps/accounts/services/otp_service.py`
- [Account records](https://github.com/chahmed12/cpharma/blob/main/backend/apps/accounts/models.py): `backend/apps/accounts/models.py`

### Care delivery

- [Consultation API](https://github.com/chahmed12/cpharma/blob/main/backend/apps/consultations/views.py): `backend/apps/consultations/views.py`
- [Consultation records](https://github.com/chahmed12/cpharma/blob/main/backend/apps/consultations/models.py): `backend/apps/consultations/models.py`
- [WebSocket signaling](https://github.com/chahmed12/cpharma/blob/main/backend/apps/consultations/consumers.py): `backend/apps/consultations/consumers.py`
- [Video session](https://github.com/chahmed12/cpharma/blob/main/frontend/src/hooks/useWebRTC.ts): `frontend/src/hooks/useWebRTC.ts`
- [Prescription crypto](https://github.com/chahmed12/cpharma/blob/main/frontend/src/services/cryptoService.ts): `frontend/src/services/cryptoService.ts`
- [Prescription API](https://github.com/chahmed12/cpharma/blob/main/backend/apps/prescriptions/views.py): `backend/apps/prescriptions/views.py`
- [Prescription records](https://github.com/chahmed12/cpharma/blob/main/backend/apps/prescriptions/models.py): `backend/apps/prescriptions/models.py`
- [Signature viewer](https://github.com/chahmed12/cpharma/blob/main/frontend/src/components/prescription/SignatureViewer.tsx): `frontend/src/components/prescription/SignatureViewer.tsx`
- [Patient records](https://github.com/chahmed12/cpharma/blob/main/backend/apps/patients/models.py): `backend/apps/patients/models.py`

### Pharmacy and finance

- [Payment API](https://github.com/chahmed12/cpharma/blob/main/backend/apps/payments/views.py): `backend/apps/payments/views.py`
- [Payment records](https://github.com/chahmed12/cpharma/blob/main/backend/apps/payments/models.py): `backend/apps/payments/models.py`
- [Payment client](https://github.com/chahmed12/cpharma/blob/main/frontend/src/services/paymentService.ts): `frontend/src/services/paymentService.ts`

### Other components

- **Patient**
- **Doctor**
- **Pharmacist**

## Connections

- Patient → Role-based app: uses (evidence: `README.md`)
- Doctor → Role-based app: uses (evidence: `README.md`)
- Pharmacist → Role-based app: uses (evidence: `README.md`)
- Role-based app → Doctor dashboard: routes to (evidence: `frontend/src/App.tsx`)
- Role-based app → Auth client: routes to (evidence: `frontend/src/App.tsx`)
- Auth client → Account API: sends auth requests (evidence: `frontend/src/services/authService.ts`)
- Account API → OTP service: uses OTP
- Account API → Account records: reads and writes
- Role-based app → Consultation API: routes consultation
- Consultation API → Consultation records: reads and writes
- Role-based app → WebSocket signaling: opens signaling
- WebSocket signaling → Video session: signals session (evidence: `README.md`)
- Doctor dashboard → Prescription crypto: signs prescription (evidence: `README.md`)
- Pharmacist → Signature viewer: verifies signature (evidence: `README.md`)
- Signature viewer → Prescription crypto: verifies cryptographically (evidence: `README.md`)
- Role-based app → Prescription API: routes prescription
- Prescription API → Prescription records: reads and writes
- Prescription API → Patient records: accesses patient data
- Payment client → Payment API: requests payment
- Payment API → Payment records: reads and writes
- Consultation API → Payment API: settles consultation (evidence: `README.md`)
