# phoenix-0701/bkmed architecture

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

- Interactive diagram: https://gitdiagram.com/phoenix-0701/bkmed
- Repository: https://github.com/phoenix-0701/bkmed

## Overview

MedFlow combines a patient/doctor/admin healthcare portal with a NestJS API and a separate medical NLP/chat AI package. The principal workflow is account access, finding doctors and availability, booking and managing appointments, and recording consultation notes; administration and patient/doctor profile management are additional branches. The AI package includes a train/evaluate pipeline and backend chat services. The README provides no usable architecture detail, and several listed modules were not sampled, so uncertain integrations are shown only as unverified links or omitted.

Main entry points: [`medflow-server/src/prisma/prisma.service.ts`](https://github.com/phoenix-0701/bkmed/blob/main/medflow-server/src/prisma/prisma.service.ts) (Application database), [`medflow-client/app/patient/booking/page.tsx`](https://github.com/phoenix-0701/bkmed/blob/main/medflow-client/app/patient/booking/page.tsx) (Doctor search and booking), [`medflow-server/src/appointments/appointments.service.ts`](https://github.com/phoenix-0701/bkmed/blob/main/medflow-server/src/appointments/appointments.service.ts) (Appointments and notes), [`medflow-client/app/doctor/ConsultationModal.tsx`](https://github.com/phoenix-0701/bkmed/blob/main/medflow-client/app/doctor/ConsultationModal.tsx) (Consultation workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web portal"]
  node_client_auth["Login and registration<br/>[RegisterForm.tsx]"]
  node_client_booking["Doctor search and booking<br/>[page.tsx]"]
  node_client_patient["Patient dashboard and history<br/>[page.tsx]"]
  node_client_doctor["Doctor schedule<br/>[page.tsx]"]
  node_client_consult["Consultation workflow"]
  node_client_admin["Admin dashboard<br/>[page.tsx]"]
end

subgraph group_api["Healthcare API"]
  node_auth["Authentication<br/>[auth.service.ts]"]
  node_users["Profiles and doctors<br/>[users.service.ts]"]
  node_availability["Schedules and leave"]
  node_appointments["Appointments and notes"]
  node_admin_api["Admin operations<br/>[admin.service.ts]"]
  node_database[("Application database<br/>[prisma.service.ts]")]
end

subgraph group_ai["Medical AI"]
  node_ai_entry["Training and evaluation entry<br/>[main.py]"]
  node_trainer["Model trainer<br/>[trainer.py]"]
  node_data["Dataset loading<br/>[data_loader.py]"]
  node_model["ViMQ extraction model<br/>[model.py]"]
end

subgraph group_ai_backend["AI services"]
  node_ai_api["HTTP AI service<br/>[fastapi_app.py]"]
  node_ai_grpc["gRPC chat service<br/>[grpc_server.py]"]
  node_ai_prompts["Chat prompts and helpers<br/>[prompt.py]"]
  node_ai_vimq["ViMQ integration"]
end

node_patient(("Patient"))
node_doctor(("Doctor"))
node_admin(("Administrator"))
node_cloudinary["Cloudinary"]

node_patient -->|"registers or logs in"| node_client_auth
node_patient -.->|"searches and books"| node_client_booking
node_patient -.->|"views account"| node_client_patient
node_doctor -->|"manages schedule"| node_client_doctor
node_doctor -.->|"conducts consultation"| node_client_consult
node_admin -.->|"manages portal"| node_client_admin
node_client_auth -.->|"sends credentials"| node_auth
node_client_booking -.->|"requests doctor listings"| node_users
node_client_booking -.->|"requests open slots"| node_availability
node_client_booking -.->|"submits booking"| node_appointments
node_client_doctor -.->|"fetches schedule"| node_appointments
node_client_consult -.->|"updates consultation"| node_appointments
node_client_admin -.->|"requests administration"| node_admin_api
node_auth -->|"reads and writes users"| node_database
node_users -->|"reads and writes profiles"| node_database
node_availability -->|"reads and writes schedules"| node_database
node_appointments -->|"reads and writes appointments"| node_database
node_admin_api -->|"reads and writes admin data"| node_database
node_ai_entry -->|"creates and runs"| node_trainer
node_trainer -->|"loads datasets"| node_data
node_trainer -->|"uses model utilities"| node_model
node_client_consult -.->|"may request AI assistance"| node_ai_api
node_ai_grpc -.->|"uses chat prompts"| node_ai_prompts
node_ai_api -.->|"may delegate inference"| node_ai_vimq
node_users -->|"uploads avatars"| node_cloudinary

click node_client_auth "https://github.com/phoenix-0701/bkmed/blob/main/medflow-client/app/register/RegisterForm.tsx"
click node_client_booking "https://github.com/phoenix-0701/bkmed/blob/main/medflow-client/app/patient/booking/page.tsx"
click node_client_patient "https://github.com/phoenix-0701/bkmed/blob/main/medflow-client/app/patient/page.tsx"
click node_client_doctor "https://github.com/phoenix-0701/bkmed/blob/main/medflow-client/app/doctor/page.tsx"
click node_client_consult "https://github.com/phoenix-0701/bkmed/blob/main/medflow-client/app/doctor/ConsultationModal.tsx"
click node_client_admin "https://github.com/phoenix-0701/bkmed/blob/main/medflow-client/app/admin/page.tsx"
click node_auth "https://github.com/phoenix-0701/bkmed/blob/main/medflow-server/src/auth/auth.service.ts"
click node_users "https://github.com/phoenix-0701/bkmed/blob/main/medflow-server/src/users/users.service.ts"
click node_availability "https://github.com/phoenix-0701/bkmed/blob/main/medflow-server/src/availabilities/availabilities.service.ts"
click node_appointments "https://github.com/phoenix-0701/bkmed/blob/main/medflow-server/src/appointments/appointments.service.ts"
click node_admin_api "https://github.com/phoenix-0701/bkmed/blob/main/medflow-server/src/admin/admin.service.ts"
click node_database "https://github.com/phoenix-0701/bkmed/blob/main/medflow-server/src/prisma/prisma.service.ts"
click node_ai_entry "https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/src/main.py"
click node_trainer "https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/src/trainer.py"
click node_data "https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/src/data_loader.py"
click node_model "https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/src/model/model.py"
click node_ai_api "https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/backend/fastapi_app.py"
click node_ai_grpc "https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/backend/grpc_server.py"
click node_ai_prompts "https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/backend/prompt.py"
click node_ai_vimq "https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/backend/vimq_integration.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_client_auth,node_client_booking,node_client_patient,node_client_doctor,node_client_consult,node_client_admin toneBlue
class node_auth,node_users,node_availability,node_appointments,node_admin_api,node_database toneAmber
class node_ai_entry,node_trainer,node_data,node_model toneMint
class node_ai_api,node_ai_grpc,node_ai_prompts,node_ai_vimq toneRose
class node_patient,node_doctor,node_admin,node_cloudinary toneIndigo
```

## Components

### Web portal

- [Login and registration](https://github.com/phoenix-0701/bkmed/blob/main/medflow-client/app/register/RegisterForm.tsx): `medflow-client/app/register/RegisterForm.tsx`
- [Doctor search and booking](https://github.com/phoenix-0701/bkmed/blob/main/medflow-client/app/patient/booking/page.tsx): `medflow-client/app/patient/booking/page.tsx`
- [Patient dashboard and history](https://github.com/phoenix-0701/bkmed/blob/main/medflow-client/app/patient/page.tsx): `medflow-client/app/patient/page.tsx`
- [Doctor schedule](https://github.com/phoenix-0701/bkmed/blob/main/medflow-client/app/doctor/page.tsx): `medflow-client/app/doctor/page.tsx`
- [Consultation workflow](https://github.com/phoenix-0701/bkmed/blob/main/medflow-client/app/doctor/ConsultationModal.tsx): `medflow-client/app/doctor/ConsultationModal.tsx`
- [Admin dashboard](https://github.com/phoenix-0701/bkmed/blob/main/medflow-client/app/admin/page.tsx): `medflow-client/app/admin/page.tsx`

### Healthcare API

- [Authentication](https://github.com/phoenix-0701/bkmed/blob/main/medflow-server/src/auth/auth.service.ts): `medflow-server/src/auth/auth.service.ts`
- [Profiles and doctors](https://github.com/phoenix-0701/bkmed/blob/main/medflow-server/src/users/users.service.ts): `medflow-server/src/users/users.service.ts`
- [Schedules and leave](https://github.com/phoenix-0701/bkmed/blob/main/medflow-server/src/availabilities/availabilities.service.ts): `medflow-server/src/availabilities/availabilities.service.ts`
- [Appointments and notes](https://github.com/phoenix-0701/bkmed/blob/main/medflow-server/src/appointments/appointments.service.ts): `medflow-server/src/appointments/appointments.service.ts`
- [Admin operations](https://github.com/phoenix-0701/bkmed/blob/main/medflow-server/src/admin/admin.service.ts): `medflow-server/src/admin/admin.service.ts`
- [Application database](https://github.com/phoenix-0701/bkmed/blob/main/medflow-server/src/prisma/prisma.service.ts): `medflow-server/src/prisma/prisma.service.ts`

### Medical AI

- [Training and evaluation entry](https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/src/main.py): `medflow-ai/src/main.py`
- [Model trainer](https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/src/trainer.py): `medflow-ai/src/trainer.py`
- [Dataset loading](https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/src/data_loader.py): `medflow-ai/src/data_loader.py`
- [ViMQ extraction model](https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/src/model/model.py): `medflow-ai/src/model/model.py`

### AI services

- [HTTP AI service](https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/backend/fastapi_app.py): `medflow-ai/backend/fastapi_app.py`
- [gRPC chat service](https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/backend/grpc_server.py): `medflow-ai/backend/grpc_server.py`
- [Chat prompts and helpers](https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/backend/prompt.py): `medflow-ai/backend/prompt.py`
- [ViMQ integration](https://github.com/phoenix-0701/bkmed/blob/main/medflow-ai/backend/vimq_integration.py): `medflow-ai/backend/vimq_integration.py`

### Other components

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

## Connections

- Patient → Login and registration: registers or logs in
- Patient → Doctor search and booking: searches and books
- Patient → Patient dashboard and history: views account
- Doctor → Doctor schedule: manages schedule (evidence: `medflow-client/app/doctor/page.tsx`)
- Doctor → Consultation workflow: conducts consultation
- Administrator → Admin dashboard: manages portal
- Login and registration → Authentication: sends credentials
- Doctor search and booking → Profiles and doctors: requests doctor listings
- Doctor search and booking → Schedules and leave: requests open slots
- Doctor search and booking → Appointments and notes: submits booking
- Doctor schedule → Appointments and notes: fetches schedule
- Consultation workflow → Appointments and notes: updates consultation
- Admin dashboard → Admin operations: requests administration
- Authentication → Application database: reads and writes users (evidence: `medflow-server/src/auth/auth.service.ts`)
- Profiles and doctors → Application database: reads and writes profiles (evidence: `medflow-server/src/users/users.service.ts`)
- Schedules and leave → Application database: reads and writes schedules (evidence: `medflow-server/src/availabilities/availabilities.service.ts`)
- Appointments and notes → Application database: reads and writes appointments (evidence: `medflow-server/src/appointments/appointments.service.ts`)
- Admin operations → Application database: reads and writes admin data (evidence: `medflow-server/src/admin/admin.service.ts`)
- Training and evaluation entry → Model trainer: creates and runs (evidence: `medflow-ai/src/main.py`)
- Model trainer → Dataset loading: loads datasets (evidence: `medflow-ai/src/trainer.py`)
- Model trainer → ViMQ extraction model: uses model utilities
- Consultation workflow → HTTP AI service: may request AI assistance
- gRPC chat service → Chat prompts and helpers: uses chat prompts
- HTTP AI service → ViMQ integration: may delegate inference
- Profiles and doctors → Cloudinary: uploads avatars
