# nikhil0718-tech/rxguardian architecture

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

- Interactive diagram: https://gitdiagram.com/nikhil0718-tech/rxguardian
- Repository: https://github.com/nikhil0718-tech/rxguardian

## Overview

RxGuardian is a medication-management product for patients, doctors, and guardians. Its main workflow is prescription creation, patient reminder tracking and medicine verification, with missed doses escalating to guardian alerts; role-based dashboards expose adherence and status. A separate AI engine provides medicine-image OCR and prediction, while assistant and RAG modules support medicine queries. The excerpts show app routing, prescription persistence, reminder verification, and alert logic. Some frontend-to-backend and AI integration details are not evidenced in the sampled source, so those links are omitted or marked unverified.

Main entry points: [`frontend/src/App.jsx`](https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/App.jsx) (Web route dispatcher), [`backend/app/main.py`](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/routes/reminder_routes.py`](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/routes/reminder_routes.py) (Reminder and verification routes), [`frontend/src/api/api.js`](https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/api/api.js) (HTTP API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Role-based web app"]
  node_webapp["Web route dispatcher<br/>[App.jsx]"]
  node_registration["Registration<br/>[Register.jsx]"]
  node_authclient["Auth API client<br/>[authService.js]"]
  node_patientdash["Patient dashboard"]
  node_upload["Medicine upload<br/>[UploadMedicine.jsx]"]
  node_doctorprescribe["Prescription creation"]
  node_guardiandash["Guardian dashboard"]
  node_http["HTTP API client<br/>[api.js]"]
end

subgraph group_api["Backend API"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_authroutes["Authentication routes<br/>[auth_routes.py]"]
  node_database[("SQL database session<br/>[database.py]")]
end

subgraph group_care["Medication care"]
  node_prescriptionroutes["Prescription routes"]
  node_reminderroutes["Reminder and verification routes<br/>[reminder_routes.py]"]
  node_reminderengine["Reminder scheduling"]
  node_adherence["Adherence calculation"]
  node_alertroutes["Guardian alert routes"]
  node_alertengine["Guardian alert generation"]
  node_remindermodel[("Reminder records<br/>[reminder_model.py]")]
  node_prescriptionmodel[("Prescription records")]
  node_alertmodel[("Guardian alert records")]
end

subgraph group_intelligence["AI and assistance"]
  node_ocr["Medicine image OCR<br/>[easyocr_engine.py]"]
  node_predictor["Medicine prediction<br/>[predictor.py]"]
  node_verifyengine["Prescription verification"]
  node_assistant["Assistant and RAG<br/>[rag_service.py]"]
end

node_users(("Patients, doctors, guardians"))

node_users -->|"use roles"| node_webapp
node_webapp -->|"routes to"| node_registration
node_webapp -->|"routes to"| node_patientdash
node_webapp -->|"routes to"| node_upload
node_webapp -->|"routes to"| node_doctorprescribe
node_webapp -->|"routes to"| node_guardiandash
node_registration -->|"calls"| node_authclient
node_authclient -->|"sends requests"| node_http
node_doctorprescribe -->|"uses"| node_http
node_patientdash -->|"uses"| node_http
node_guardiandash -->|"uses"| node_http
node_http -.->|"calls API"| node_backend
node_backend -->|"mounts routes"| node_authroutes
node_backend -->|"mounts routes"| node_prescriptionroutes
node_backend -->|"mounts routes"| node_reminderroutes
node_backend -->|"mounts routes"| node_alertroutes
node_prescriptionroutes -->|"creates records"| node_prescriptionmodel
node_prescriptionroutes -->|"creates reminders"| node_remindermodel
node_reminderroutes -->|"reads and updates"| node_remindermodel
node_reminderroutes -->|"updates alerts"| node_alertmodel
node_reminderroutes -->|"invokes"| node_alertengine
node_alertengine -->|"creates alerts"| node_alertmodel
node_alertengine -->|"checks reminder"| node_remindermodel
node_adherence -->|"reads status"| node_remindermodel
node_backend -->|"starts scheduler"| node_reminderengine
node_prescriptionroutes -->|"gets session"| node_database
node_reminderroutes -->|"gets session"| node_database
node_prescriptionmodel -->|"uses ORM base"| node_database
node_remindermodel -->|"uses ORM base"| node_database
node_alertmodel -->|"uses ORM base"| node_database
node_reminderroutes -.->|"verification integration"| node_verifyengine
node_verifyengine -->|"uses OCR"| node_ocr
node_verifyengine -->|"uses prediction"| node_predictor
node_assistant -.->|"answers queries"| node_users

click node_webapp "https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/App.jsx"
click node_registration "https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/pages/Auth/Register.jsx"
click node_authclient "https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/services/authService.js"
click node_patientdash "https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/pages/Patient/PatientDashboard.jsx"
click node_upload "https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/pages/Patient/UploadMedicine.jsx"
click node_doctorprescribe "https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/pages/Doctor/CreatePrescription.jsx"
click node_guardiandash "https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/pages/Guardian/GuardianDashboard.jsx"
click node_http "https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/api/api.js"
click node_backend "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/main.py"
click node_authroutes "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/routes/auth_routes.py"
click node_prescriptionroutes "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/routes/prescription_routes.py"
click node_reminderroutes "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/routes/reminder_routes.py"
click node_reminderengine "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/utils/reminder_scheduler.py"
click node_adherence "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/utils/adherence_engine.py"
click node_alertroutes "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/routes/guardian_alert_routes.py"
click node_alertengine "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/utils/guardian_alert_engine.py"
click node_remindermodel "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/models/reminder_model.py"
click node_prescriptionmodel "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/models/prescription_model.py"
click node_alertmodel "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/models/guardian_alert_model.py"
click node_database "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/config/database.py"
click node_ocr "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/ai_engine/ocr/easyocr_engine.py"
click node_predictor "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/ai_engine/inference/predictor.py"
click node_verifyengine "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/ai_engine/inference/verification_engine.py"
click node_assistant "https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/rag/rag_service.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_webapp,node_registration,node_authclient,node_patientdash,node_upload,node_doctorprescribe,node_guardiandash,node_http toneBlue
class node_backend,node_authroutes,node_database toneAmber
class node_prescriptionroutes,node_reminderroutes,node_reminderengine,node_adherence,node_alertroutes,node_alertengine,node_remindermodel,node_prescriptionmodel,node_alertmodel toneMint
class node_ocr,node_predictor,node_verifyengine,node_assistant toneRose
class node_users toneIndigo
```

## Components

### Role-based web app

- [Web route dispatcher](https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Registration](https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/pages/Auth/Register.jsx): `frontend/src/pages/Auth/Register.jsx`
- [Auth API client](https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/services/authService.js): `frontend/src/services/authService.js`
- [Patient dashboard](https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/pages/Patient/PatientDashboard.jsx): `frontend/src/pages/Patient/PatientDashboard.jsx`
- [Medicine upload](https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/pages/Patient/UploadMedicine.jsx): `frontend/src/pages/Patient/UploadMedicine.jsx`
- [Prescription creation](https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/pages/Doctor/CreatePrescription.jsx): `frontend/src/pages/Doctor/CreatePrescription.jsx`
- [Guardian dashboard](https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/pages/Guardian/GuardianDashboard.jsx): `frontend/src/pages/Guardian/GuardianDashboard.jsx`
- [HTTP API client](https://github.com/nikhil0718-tech/rxguardian/blob/main/frontend/src/api/api.js): `frontend/src/api/api.js`

### Backend API

- [FastAPI application](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication routes](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/routes/auth_routes.py): `backend/app/routes/auth_routes.py`
- [SQL database session](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/config/database.py): `backend/app/config/database.py`

### Medication care

- [Prescription routes](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/routes/prescription_routes.py): `backend/app/routes/prescription_routes.py`
- [Reminder and verification routes](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/routes/reminder_routes.py): `backend/app/routes/reminder_routes.py`
- [Reminder scheduling](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/utils/reminder_scheduler.py): `backend/app/utils/reminder_scheduler.py`
- [Adherence calculation](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/utils/adherence_engine.py): `backend/app/utils/adherence_engine.py`
- [Guardian alert routes](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/routes/guardian_alert_routes.py): `backend/app/routes/guardian_alert_routes.py`
- [Guardian alert generation](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/utils/guardian_alert_engine.py): `backend/app/utils/guardian_alert_engine.py`
- [Reminder records](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/models/reminder_model.py): `backend/app/models/reminder_model.py`
- [Prescription records](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/models/prescription_model.py): `backend/app/models/prescription_model.py`
- [Guardian alert records](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/models/guardian_alert_model.py): `backend/app/models/guardian_alert_model.py`

### AI and assistance

- [Medicine image OCR](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/ai_engine/ocr/easyocr_engine.py): `backend/ai_engine/ocr/easyocr_engine.py`
- [Medicine prediction](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/ai_engine/inference/predictor.py): `backend/ai_engine/inference/predictor.py`
- [Prescription verification](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/ai_engine/inference/verification_engine.py): `backend/ai_engine/inference/verification_engine.py`
- [Assistant and RAG](https://github.com/nikhil0718-tech/rxguardian/blob/main/backend/app/rag/rag_service.py): `backend/app/rag/rag_service.py`

### Other components

- **Patients, doctors, guardians**

## Connections

- Patients, doctors, guardians → Web route dispatcher: use roles (evidence: `frontend/src/App.jsx`)
- Web route dispatcher → Registration: routes to (evidence: `frontend/src/App.jsx`)
- Web route dispatcher → Patient dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Web route dispatcher → Medicine upload: routes to (evidence: `frontend/src/App.jsx`)
- Web route dispatcher → Prescription creation: routes to (evidence: `frontend/src/App.jsx`)
- Web route dispatcher → Guardian dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Registration → Auth API client: calls (evidence: `frontend/src/pages/Auth/Register.jsx`)
- Auth API client → HTTP API client: sends requests (evidence: `frontend/src/services/authService.js`)
- Prescription creation → HTTP API client: uses (evidence: `frontend/src/pages/Doctor/CreatePrescription.jsx`)
- Patient dashboard → HTTP API client: uses (evidence: `frontend/src/pages/Patient/PatientDashboard.jsx`)
- Guardian dashboard → HTTP API client: uses (evidence: `frontend/src/pages/Guardian/GuardianDashboard.jsx`)
- HTTP API client → FastAPI application: calls API
- FastAPI application → Authentication routes: mounts routes (evidence: `backend/app/main.py`)
- FastAPI application → Prescription routes: mounts routes (evidence: `backend/app/main.py`)
- FastAPI application → Reminder and verification routes: mounts routes (evidence: `backend/app/main.py`)
- FastAPI application → Guardian alert routes: mounts routes (evidence: `backend/app/main.py`)
- Prescription routes → Prescription records: creates records (evidence: `backend/app/routes/prescription_routes.py`)
- Prescription routes → Reminder records: creates reminders (evidence: `backend/app/routes/prescription_routes.py`)
- Reminder and verification routes → Reminder records: reads and updates (evidence: `backend/app/routes/reminder_routes.py`)
- Reminder and verification routes → Guardian alert records: updates alerts (evidence: `backend/app/routes/reminder_routes.py`)
- Reminder and verification routes → Guardian alert generation: invokes (evidence: `backend/app/routes/reminder_routes.py`)
- Guardian alert generation → Guardian alert records: creates alerts (evidence: `backend/app/utils/guardian_alert_engine.py`)
- Guardian alert generation → Reminder records: checks reminder (evidence: `backend/app/utils/guardian_alert_engine.py`)
- Adherence calculation → Reminder records: reads status (evidence: `backend/app/utils/adherence_engine.py`)
- FastAPI application → Reminder scheduling: starts scheduler (evidence: `backend/app/main.py`)
- Prescription routes → SQL database session: gets session (evidence: `backend/app/routes/prescription_routes.py`)
- Reminder and verification routes → SQL database session: gets session (evidence: `backend/app/routes/reminder_routes.py`)
- Prescription records → SQL database session: uses ORM base (evidence: `backend/app/models/prescription_model.py`)
- Reminder records → SQL database session: uses ORM base (evidence: `backend/app/models/reminder_model.py`)
- Guardian alert records → SQL database session: uses ORM base (evidence: `backend/app/models/guardian_alert_model.py`)
- Reminder and verification routes → Prescription verification: verification integration
- Prescription verification → Medicine image OCR: uses OCR (evidence: `backend/ai_engine/inference/verification_engine.py`)
- Prescription verification → Medicine prediction: uses prediction (evidence: `backend/ai_engine/inference/verification_engine.py`)
- Assistant and RAG → Patients, doctors, guardians: answers queries
