# ek1gra/prescripto architecture

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

- Interactive diagram: https://gitdiagram.com/ek1gra/prescripto
- Repository: https://github.com/ek1gra/prescripto

## Overview

Prescripto is a doctor appointment booking and management application, with a patient-facing portal and separate admin/doctor panel. Patients browse doctors, book and manage appointments, update their profile, and pay; administrators manage doctors and appointments, while doctors manage their schedules and appointments. The backend exposes role-specific APIs and persists users, doctors, and appointments in MongoDB. The graph includes the central flows and documented panel capabilities; unsampled page implementations are represented by their exact tree paths, and connections are limited to source-index references or shown API calls.

Main entry points: [`backend/controllers/userController.js`](https://github.com/ek1gra/prescripto/blob/main/backend/controllers/userController.js) (Patient operations), [`frontend/src/App.jsx`](https://github.com/ek1gra/prescripto/blob/main/frontend/src/App.jsx) (Patient app routes), [`backend/controllers/adminController.js`](https://github.com/ek1gra/prescripto/blob/main/backend/controllers/adminController.js) (Admin operations), [`frontend/src/context/AppContext.jsx`](https://github.com/ek1gra/prescripto/blob/main/frontend/src/context/AppContext.jsx) (Patient API context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_patient["Patient portal"]
  node_patient_app["Patient app routes<br/>[App.jsx]"]
  node_browse["Doctor discovery<br/>[Doctors.jsx]"]
  node_booking["Appointment booking<br/>[Appointment.jsx]"]
  node_patient_manage["Profile and appointments<br/>[MyAppointments.jsx]"]
  node_payment_verify["Payment verification<br/>[Verify.jsx]"]
  node_patient_state["Patient API context<br/>[AppContext.jsx]"]
end

subgraph group_panels["Admin and doctor panels"]
  node_panel_app["Panel routes<br/>[App.jsx]"]
  node_admin_features["Admin management<br/>[AddDoctor.jsx]"]
  node_doctor_features["Doctor workspace<br/>[DoctorProfile.jsx]"]
  node_admin_state["Admin API context<br/>[AdminContext.jsx]"]
  node_doctor_state["Doctor API context<br/>[DoctorContext.jsx]"]
end

subgraph group_api["Backend API"]
  node_api_server["API server<br/>[server.js]"]
  node_user_routes["Patient routes<br/>[userRoute.js]"]
  node_admin_routes["Admin routes<br/>[adminRoute.js]"]
  node_doctor_routes["Doctor routes<br/>[doctorRoute.js]"]
  node_user_controller["Patient operations<br/>[userController.js]"]
  node_admin_controller["Admin operations<br/>[adminController.js]"]
  node_doctor_controller["Doctor operations"]
  node_auth["Role authentication<br/>[authAdmin.js]"]
end

subgraph group_domain["Scheduling domain"]
  node_doctor_model[("Doctor records<br/>[doctorModel.js]")]
  node_user_model[("Patient records<br/>[userModel.js]")]
  node_appointment_model[("Appointment records")]
end

subgraph group_integrations["External services"]
  node_mongodb[("MongoDB<br/>[mongodb.js]")]
  node_cloudinary["Cloudinary images<br/>[cloudinary.js]"]
  node_payments["Stripe and Razorpay"]
end

node_patient_actor(("Patient"))
node_panel_actor(("Admin or doctor"))

node_patient_actor -->|"uses"| node_patient_app
node_patient_app -->|"routes to"| node_browse
node_patient_app -->|"routes to"| node_booking
node_patient_app -->|"routes to"| node_patient_manage
node_patient_app -->|"routes to"| node_payment_verify
node_patient_state -->|"provides state"| node_patient_app
node_patient_state -->|"fetches doctors"| node_doctor_routes
node_patient_state -->|"loads profile"| node_user_routes
node_booking -->|"uses context"| node_patient_state
node_patient_manage -->|"uses context"| node_patient_state
node_panel_actor -->|"uses"| node_panel_app
node_panel_app -->|"routes to"| node_admin_features
node_panel_app -->|"routes to"| node_doctor_features
node_admin_state -->|"provides operations"| node_admin_features
node_doctor_state -->|"provides operations"| node_doctor_features
node_admin_state -->|"calls admin API"| node_admin_routes
node_admin_state -->|"changes availability"| node_doctor_routes
node_doctor_state -->|"calls doctor API"| node_doctor_routes
node_api_server -->|"mounts routes"| node_user_routes
node_api_server -->|"mounts routes"| node_admin_routes
node_api_server -->|"mounts routes"| node_doctor_routes
node_user_routes -->|"dispatches"| node_user_controller
node_admin_routes -->|"dispatches"| node_admin_controller
node_doctor_routes -->|"dispatches"| node_doctor_controller
node_admin_routes -->|"authenticates"| node_auth
node_user_controller -->|"reads and writes"| node_user_model
node_user_controller -->|"checks doctor slots"| node_doctor_model
node_user_controller -->|"books and updates"| node_appointment_model
node_admin_controller -->|"manages doctors"| node_doctor_model
node_admin_controller -->|"counts patients"| node_user_model
node_admin_controller -->|"manages appointments"| node_appointment_model
node_doctor_controller -->|"reads and updates"| node_doctor_model
node_doctor_controller -->|"manages appointments"| node_appointment_model
node_api_server -->|"connects"| node_mongodb
node_user_controller -->|"uploads profile image"| node_cloudinary
node_admin_controller -->|"uploads doctor image"| node_cloudinary
node_user_controller -->|"creates and verifies payments"| node_payments

click node_patient_app "https://github.com/ek1gra/prescripto/blob/main/frontend/src/App.jsx"
click node_browse "https://github.com/ek1gra/prescripto/blob/main/frontend/src/pages/Doctors.jsx"
click node_booking "https://github.com/ek1gra/prescripto/blob/main/frontend/src/pages/Appointment.jsx"
click node_patient_manage "https://github.com/ek1gra/prescripto/blob/main/frontend/src/pages/MyAppointments.jsx"
click node_payment_verify "https://github.com/ek1gra/prescripto/blob/main/frontend/src/pages/Verify.jsx"
click node_patient_state "https://github.com/ek1gra/prescripto/blob/main/frontend/src/context/AppContext.jsx"
click node_panel_app "https://github.com/ek1gra/prescripto/blob/main/admin/src/App.jsx"
click node_admin_features "https://github.com/ek1gra/prescripto/blob/main/admin/src/pages/Admin/AddDoctor.jsx"
click node_doctor_features "https://github.com/ek1gra/prescripto/blob/main/admin/src/pages/Doctor/DoctorProfile.jsx"
click node_admin_state "https://github.com/ek1gra/prescripto/blob/main/admin/src/context/AdminContext.jsx"
click node_doctor_state "https://github.com/ek1gra/prescripto/blob/main/admin/src/context/DoctorContext.jsx"
click node_api_server "https://github.com/ek1gra/prescripto/blob/main/backend/server.js"
click node_user_routes "https://github.com/ek1gra/prescripto/blob/main/backend/routes/userRoute.js"
click node_admin_routes "https://github.com/ek1gra/prescripto/blob/main/backend/routes/adminRoute.js"
click node_doctor_routes "https://github.com/ek1gra/prescripto/blob/main/backend/routes/doctorRoute.js"
click node_user_controller "https://github.com/ek1gra/prescripto/blob/main/backend/controllers/userController.js"
click node_admin_controller "https://github.com/ek1gra/prescripto/blob/main/backend/controllers/adminController.js"
click node_doctor_controller "https://github.com/ek1gra/prescripto/blob/main/backend/controllers/doctorController.js"
click node_auth "https://github.com/ek1gra/prescripto/blob/main/backend/middleware/authAdmin.js"
click node_doctor_model "https://github.com/ek1gra/prescripto/blob/main/backend/models/doctorModel.js"
click node_user_model "https://github.com/ek1gra/prescripto/blob/main/backend/models/userModel.js"
click node_appointment_model "https://github.com/ek1gra/prescripto/blob/main/backend/models/appointmentModel.js"
click node_mongodb "https://github.com/ek1gra/prescripto/blob/main/backend/config/mongodb.js"
click node_cloudinary "https://github.com/ek1gra/prescripto/blob/main/backend/config/cloudinary.js"

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_patient_app,node_browse,node_booking,node_patient_manage,node_payment_verify,node_patient_state toneBlue
class node_panel_app,node_admin_features,node_doctor_features,node_admin_state,node_doctor_state toneAmber
class node_api_server,node_user_routes,node_admin_routes,node_doctor_routes,node_user_controller,node_admin_controller,node_doctor_controller,node_auth toneMint
class node_doctor_model,node_user_model,node_appointment_model toneRose
class node_mongodb,node_cloudinary,node_payments,node_patient_actor,node_panel_actor toneIndigo
```

## Components

### Patient portal

- [Patient app routes](https://github.com/ek1gra/prescripto/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Doctor discovery](https://github.com/ek1gra/prescripto/blob/main/frontend/src/pages/Doctors.jsx): `frontend/src/pages/Doctors.jsx`
- [Appointment booking](https://github.com/ek1gra/prescripto/blob/main/frontend/src/pages/Appointment.jsx): `frontend/src/pages/Appointment.jsx`
- [Profile and appointments](https://github.com/ek1gra/prescripto/blob/main/frontend/src/pages/MyAppointments.jsx): `frontend/src/pages/MyAppointments.jsx`
- [Payment verification](https://github.com/ek1gra/prescripto/blob/main/frontend/src/pages/Verify.jsx): `frontend/src/pages/Verify.jsx`
- [Patient API context](https://github.com/ek1gra/prescripto/blob/main/frontend/src/context/AppContext.jsx): `frontend/src/context/AppContext.jsx`

### Admin and doctor panels

- [Panel routes](https://github.com/ek1gra/prescripto/blob/main/admin/src/App.jsx): `admin/src/App.jsx`
- [Admin management](https://github.com/ek1gra/prescripto/blob/main/admin/src/pages/Admin/AddDoctor.jsx): `admin/src/pages/Admin/AddDoctor.jsx`
- [Doctor workspace](https://github.com/ek1gra/prescripto/blob/main/admin/src/pages/Doctor/DoctorProfile.jsx): `admin/src/pages/Doctor/DoctorProfile.jsx`
- [Admin API context](https://github.com/ek1gra/prescripto/blob/main/admin/src/context/AdminContext.jsx): `admin/src/context/AdminContext.jsx`
- [Doctor API context](https://github.com/ek1gra/prescripto/blob/main/admin/src/context/DoctorContext.jsx): `admin/src/context/DoctorContext.jsx`

### Backend API

- [API server](https://github.com/ek1gra/prescripto/blob/main/backend/server.js): `backend/server.js`
- [Patient routes](https://github.com/ek1gra/prescripto/blob/main/backend/routes/userRoute.js): `backend/routes/userRoute.js`
- [Admin routes](https://github.com/ek1gra/prescripto/blob/main/backend/routes/adminRoute.js): `backend/routes/adminRoute.js`
- [Doctor routes](https://github.com/ek1gra/prescripto/blob/main/backend/routes/doctorRoute.js): `backend/routes/doctorRoute.js`
- [Patient operations](https://github.com/ek1gra/prescripto/blob/main/backend/controllers/userController.js): `backend/controllers/userController.js`
- [Admin operations](https://github.com/ek1gra/prescripto/blob/main/backend/controllers/adminController.js): `backend/controllers/adminController.js`
- [Doctor operations](https://github.com/ek1gra/prescripto/blob/main/backend/controllers/doctorController.js): `backend/controllers/doctorController.js`
- [Role authentication](https://github.com/ek1gra/prescripto/blob/main/backend/middleware/authAdmin.js): `backend/middleware/authAdmin.js`

### Scheduling domain

- [Doctor records](https://github.com/ek1gra/prescripto/blob/main/backend/models/doctorModel.js): `backend/models/doctorModel.js`
- [Patient records](https://github.com/ek1gra/prescripto/blob/main/backend/models/userModel.js): `backend/models/userModel.js`
- [Appointment records](https://github.com/ek1gra/prescripto/blob/main/backend/models/appointmentModel.js): `backend/models/appointmentModel.js`

### External services

- [MongoDB](https://github.com/ek1gra/prescripto/blob/main/backend/config/mongodb.js): `backend/config/mongodb.js`
- [Cloudinary images](https://github.com/ek1gra/prescripto/blob/main/backend/config/cloudinary.js): `backend/config/cloudinary.js`
- **Stripe and Razorpay**

### Other components

- **Patient**
- **Admin or doctor**

## Connections

- Patient → Patient app routes: uses (evidence: `frontend/src/App.jsx`)
- Patient app routes → Doctor discovery: routes to (evidence: `frontend/src/App.jsx`)
- Patient app routes → Appointment booking: routes to (evidence: `frontend/src/App.jsx`)
- Patient app routes → Profile and appointments: routes to (evidence: `frontend/src/App.jsx`)
- Patient app routes → Payment verification: routes to (evidence: `frontend/src/App.jsx`)
- Patient API context → Patient app routes: provides state (evidence: `frontend/src/main.jsx`)
- Patient API context → Doctor routes: fetches doctors (evidence: `frontend/src/context/AppContext.jsx`)
- Patient API context → Patient routes: loads profile (evidence: `frontend/src/context/AppContext.jsx`)
- Appointment booking → Patient API context: uses context (evidence: `frontend/src/pages/Appointment.jsx`)
- Profile and appointments → Patient API context: uses context (evidence: `frontend/src/pages/MyAppointments.jsx`)
- Admin or doctor → Panel routes: uses (evidence: `admin/src/App.jsx`)
- Panel routes → Admin management: routes to (evidence: `admin/src/App.jsx`)
- Panel routes → Doctor workspace: routes to (evidence: `admin/src/App.jsx`)
- Admin API context → Admin management: provides operations (evidence: `admin/src/pages/Admin/AddDoctor.jsx`)
- Doctor API context → Doctor workspace: provides operations (evidence: `admin/src/pages/Doctor/DoctorProfile.jsx`)
- Admin API context → Admin routes: calls admin API (evidence: `admin/src/context/AdminContext.jsx`)
- Admin API context → Doctor routes: changes availability (evidence: `admin/src/context/AdminContext.jsx`)
- Doctor API context → Doctor routes: calls doctor API (evidence: `admin/src/context/DoctorContext.jsx`)
- API server → Patient routes: mounts routes (evidence: `backend/server.js`)
- API server → Admin routes: mounts routes (evidence: `backend/server.js`)
- API server → Doctor routes: mounts routes (evidence: `backend/server.js`)
- Patient routes → Patient operations: dispatches (evidence: `backend/routes/userRoute.js`)
- Admin routes → Admin operations: dispatches (evidence: `backend/routes/adminRoute.js`)
- Doctor routes → Doctor operations: dispatches (evidence: `backend/routes/doctorRoute.js`)
- Admin routes → Role authentication: authenticates (evidence: `backend/routes/adminRoute.js`)
- Patient operations → Patient records: reads and writes (evidence: `backend/controllers/userController.js`)
- Patient operations → Doctor records: checks doctor slots (evidence: `backend/controllers/userController.js`)
- Patient operations → Appointment records: books and updates (evidence: `backend/controllers/userController.js`)
- Admin operations → Doctor records: manages doctors (evidence: `backend/controllers/adminController.js`)
- Admin operations → Patient records: counts patients (evidence: `backend/controllers/adminController.js`)
- Admin operations → Appointment records: manages appointments (evidence: `backend/controllers/adminController.js`)
- Doctor operations → Doctor records: reads and updates (evidence: `backend/controllers/doctorController.js`)
- Doctor operations → Appointment records: manages appointments (evidence: `backend/controllers/doctorController.js`)
- API server → MongoDB: connects (evidence: `backend/server.js`)
- Patient operations → Cloudinary images: uploads profile image (evidence: `backend/controllers/userController.js`)
- Admin operations → Cloudinary images: uploads doctor image (evidence: `backend/controllers/adminController.js`)
- Patient operations → Stripe and Razorpay: creates and verifies payments (evidence: `backend/controllers/userController.js`)
