# tinashe2023/shalom-medical-center architecture

> Architecture diagram of the GitHub repository tinashe2023/shalom-medical-center, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tinashe2023/shalom-medical-center
- Repository: https://github.com/tinashe2023/shalom-medical-center

## Overview

Shalom Medical Center is a role-based healthcare appointment and records system. Patients register, verify accounts, find doctors, book appointments, and access histories and prescriptions; doctors manage schedules, appointments, records, and prescriptions; administrators oversee users, appointments, departments, and analytics. The React application selects role-specific dashboards and communicates with an Express API backed by PostgreSQL. The README documents email notifications and a local, database-aware AI assistant. Sampled source confirms app routing, server dispatch, authentication/database access, appointment UI API use, and AI database/model integration; other feature wiring is represented only where documented.

Main entry points: [`src/backend/server.js`](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/server.js) (Express server), [`src/backend/db.js`](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/db.js) (PostgreSQL), [`src/lib/api.ts`](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/lib/api.ts) (API client), [`src/App.tsx`](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/App.tsx) (Role-based app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Role-based app<br/>[App.tsx]"]
  node_patientui["Patient dashboard"]
  node_booking["Appointment booking<br/>[PatientBooking.tsx]"]
  node_history["Patient history"]
  node_doctorui["Doctor dashboard"]
  node_schedule["Doctor schedule<br/>[DoctorSchedule.tsx]"]
  node_prescriptions["Prescription workflow"]
  node_adminui["Admin dashboard<br/>[AdminDashboard.tsx]"]
  node_apptmanager["Appointment oversight"]
  node_assistantui["AI chat<br/>[AIAssistant.tsx]"]
  node_clientapi["API client<br/>[api.ts]"]
end

subgraph group_api["API and workflows"]
  node_server["Express server<br/>[server.js]"]
  node_auth["Authentication<br/>[auth.js]"]
  node_appointments["Appointment routes<br/>[appointments.js]"]
  node_patients["Patient routes<br/>[patients.js]"]
  node_doctors["Doctor routes<br/>[doctors.js]"]
  node_records["Medical record routes<br/>[medical-records.js]"]
  node_stats["Analytics routes<br/>[stats.js]"]
  node_users["User routes<br/>[users.js]"]
  node_ai_route["AI routes<br/>[ai.js]"]
end

subgraph group_state["Records and services"]
  node_database[("PostgreSQL<br/>[db.js]")]
  node_ai_service["AI context service<br/>[ai-service.js]"]
  node_email["Email service<br/>[email-service.js]"]
end

subgraph group_integrations["External services"]
  node_smtp["SMTP email"]
  node_lmstudio["LMStudio"]
end

node_patient(("Patient"))
node_doctor(("Doctor"))
node_admin(("Administrator"))

node_patient -->|"uses"| node_app
node_doctor -->|"uses"| node_app
node_admin -->|"uses"| node_app
node_app -->|"routes by role"| node_patientui
node_app -->|"routes by role"| node_doctorui
node_app -->|"routes by role"| node_adminui
node_patientui -->|"offers booking"| node_booking
node_patientui -->|"shows records"| node_history
node_doctorui -->|"manages availability"| node_schedule
node_doctorui -->|"manages care"| node_prescriptions
node_adminui -->|"manages appointments"| node_apptmanager
node_booking -->|"requests appointments"| node_clientapi
node_apptmanager -->|"deletes appointments"| node_clientapi
node_history -->|"requests records"| node_clientapi
node_schedule -->|"requests schedules"| node_clientapi
node_prescriptions -->|"submits prescriptions"| node_clientapi
node_assistantui -->|"sends questions"| node_clientapi
node_clientapi -->|"sends API requests"| node_server
node_server -->|"dispatches auth"| node_auth
node_server -->|"dispatches appointments"| node_appointments
node_server -->|"dispatches patients"| node_patients
node_server -->|"dispatches doctors"| node_doctors
node_server -->|"dispatches records"| node_records
node_server -->|"dispatches analytics"| node_stats
node_server -->|"dispatches users"| node_users
node_server -->|"dispatches AI"| node_ai_route
node_auth -->|"reads and writes"| node_database
node_appointments -->|"reads and writes"| node_database
node_patients -->|"reads and writes"| node_database
node_doctors -->|"reads and writes"| node_database
node_records -->|"reads and writes"| node_database
node_stats -->|"queries statistics"| node_database
node_users -->|"reads and writes"| node_database
node_ai_route -->|"invokes assistant"| node_ai_service
node_ai_service -->|"queries context"| node_database
node_ai_service -.->|"sends prompts"| node_lmstudio
node_email -->|"sends notifications"| node_smtp
node_auth -.->|"sends account mail"| node_email
node_appointments -.->|"sends appointment mail"| node_email
node_records -.->|"sends prescriptions"| node_email

click node_app "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/App.tsx"
click node_patientui "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/PatientDashboard.tsx"
click node_booking "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/PatientBooking.tsx"
click node_history "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/PatientMedicalHistory.tsx"
click node_doctorui "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/DoctorDashboard.tsx"
click node_schedule "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/DoctorSchedule.tsx"
click node_prescriptions "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/DoctorPatientHistory.tsx"
click node_adminui "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/AdminDashboard.tsx"
click node_apptmanager "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/AppointmentManager.tsx"
click node_assistantui "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/AIAssistant.tsx"
click node_clientapi "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/lib/api.ts"
click node_server "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/server.js"
click node_auth "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/auth.js"
click node_appointments "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/appointments.js"
click node_patients "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/patients.js"
click node_doctors "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/doctors.js"
click node_records "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/medical-records.js"
click node_stats "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/stats.js"
click node_users "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/users.js"
click node_ai_route "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/ai.js"
click node_database "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/db.js"
click node_ai_service "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/ai-service.js"
click node_email "https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/email-service.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_app,node_patientui,node_booking,node_history,node_doctorui,node_schedule,node_prescriptions,node_adminui,node_apptmanager,node_assistantui,node_clientapi toneBlue
class node_server,node_auth,node_appointments,node_patients,node_doctors,node_records,node_stats,node_users,node_ai_route toneAmber
class node_database,node_ai_service,node_email toneMint
class node_smtp,node_lmstudio toneRose
class node_patient,node_doctor,node_admin toneIndigo
```

## Components

### Web application

- [Role-based app](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/App.tsx): `src/App.tsx`
- [Patient dashboard](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/PatientDashboard.tsx): `src/components/PatientDashboard.tsx`
- [Appointment booking](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/PatientBooking.tsx): `src/components/PatientBooking.tsx`
- [Patient history](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/PatientMedicalHistory.tsx): `src/components/PatientMedicalHistory.tsx`
- [Doctor dashboard](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/DoctorDashboard.tsx): `src/components/DoctorDashboard.tsx`
- [Doctor schedule](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/DoctorSchedule.tsx): `src/components/DoctorSchedule.tsx`
- [Prescription workflow](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/DoctorPatientHistory.tsx): `src/components/DoctorPatientHistory.tsx`
- [Admin dashboard](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/AdminDashboard.tsx): `src/components/AdminDashboard.tsx`
- [Appointment oversight](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/AppointmentManager.tsx): `src/components/AppointmentManager.tsx`
- [AI chat](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/components/AIAssistant.tsx): `src/components/AIAssistant.tsx`
- [API client](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/lib/api.ts): `src/lib/api.ts`

### API and workflows

- [Express server](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/server.js): `src/backend/server.js`
- [Authentication](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/auth.js): `src/backend/routes/auth.js`
- [Appointment routes](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/appointments.js): `src/backend/routes/appointments.js`
- [Patient routes](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/patients.js): `src/backend/routes/patients.js`
- [Doctor routes](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/doctors.js): `src/backend/routes/doctors.js`
- [Medical record routes](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/medical-records.js): `src/backend/routes/medical-records.js`
- [Analytics routes](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/stats.js): `src/backend/routes/stats.js`
- [User routes](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/users.js): `src/backend/routes/users.js`
- [AI routes](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/routes/ai.js): `src/backend/routes/ai.js`

### Records and services

- [PostgreSQL](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/db.js): `src/backend/db.js`
- [AI context service](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/ai-service.js): `src/backend/ai-service.js`
- [Email service](https://github.com/tinashe2023/shalom-medical-center/blob/main/src/backend/email-service.js): `src/backend/email-service.js`

### External services

- **SMTP email**
- **LMStudio**

### Other components

- **Patient**
- **Doctor**
- **Administrator**

## Connections

- Patient → Role-based app: uses
- Doctor → Role-based app: uses
- Administrator → Role-based app: uses
- Role-based app → Patient dashboard: routes by role
- Role-based app → Doctor dashboard: routes by role
- Role-based app → Admin dashboard: routes by role
- Patient dashboard → Appointment booking: offers booking
- Patient dashboard → Patient history: shows records
- Doctor dashboard → Doctor schedule: manages availability
- Doctor dashboard → Prescription workflow: manages care
- Admin dashboard → Appointment oversight: manages appointments
- Appointment booking → API client: requests appointments
- Appointment oversight → API client: deletes appointments
- Patient history → API client: requests records
- Doctor schedule → API client: requests schedules
- Prescription workflow → API client: submits prescriptions
- AI chat → API client: sends questions
- API client → Express server: sends API requests
- Express server → Authentication: dispatches auth
- Express server → Appointment routes: dispatches appointments
- Express server → Patient routes: dispatches patients
- Express server → Doctor routes: dispatches doctors
- Express server → Medical record routes: dispatches records
- Express server → Analytics routes: dispatches analytics
- Express server → User routes: dispatches users
- Express server → AI routes: dispatches AI
- Authentication → PostgreSQL: reads and writes
- Appointment routes → PostgreSQL: reads and writes
- Patient routes → PostgreSQL: reads and writes
- Doctor routes → PostgreSQL: reads and writes
- Medical record routes → PostgreSQL: reads and writes
- Analytics routes → PostgreSQL: queries statistics
- User routes → PostgreSQL: reads and writes
- AI routes → AI context service: invokes assistant
- AI context service → PostgreSQL: queries context
- AI context service → LMStudio: sends prompts
- Email service → SMTP email: sends notifications
- Authentication → Email service: sends account mail
- Appointment routes → Email service: sends appointment mail
- Medical record routes → Email service: sends prescriptions
