# beto0077/ccps-emr-mern-prototype architecture

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

- Interactive diagram: https://gitdiagram.com/beto0077/ccps-emr-mern-prototype
- Repository: https://github.com/beto0077/ccps-emr-mern-prototype

## Overview

This is a patient-record and social-services case-management application: staff use a routed web client to manage patient profiles, loans, clinical and social-work assessments, attachments, internal references, and user accounts. The server exposes corresponding REST routes; controllers perform SQL operations through a MySQL connection pool. The excerpts establish client routing, selected form/context and context/API relationships, server route registration, and examples of controller persistence. Other domain branches are represented from the route and file indexes; client-to-server HTTP links are unverified.

Main entry points: [`server/index.js`](https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/server/index.js) (HTTP API), [`client/src/App.js`](https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/client/src/App.js) (Page router), [`server/controllers`](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/server/controllers) (Domain controllers), [`client/src/components/Patient`](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/Patient) (Patient profiles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_router["Page router<br/>[App.js]"]
  node_userui["User accounts"]
end

subgraph group_records["Patient records"]
  node_patientui["Patient profiles"]
  node_patientstate["Patient state<br/>[PatientContext.js]"]
  node_patientapi["Patient API client<br/>[patient.api.js]"]
  node_referenceui["Internal references"]
  node_attachmentui["Attachments"]
end

subgraph group_assessments["Assessments"]
  node_ptui["Physical therapy"]
  node_psychui["Psychology records"]
  node_socialui["Social work records"]
end

subgraph group_service["Support services"]
  node_loansui["Equipment loans"]
end

subgraph group_server["API and persistence"]
  node_httpapi["HTTP API<br/>[index.js]"]
  node_patientroutes["Patient routes<br/>[patient.routes.js]"]
  node_loanroutes["Loan routes"]
  node_ptroutes["Therapy routes"]
  node_psychroutes["Psychology routes"]
  node_socialroutes["Social work routes"]
  node_referenceroutes["Reference routes"]
  node_attachmentroutes["Attachment routes"]
  node_userroutes["User routes<br/>[user.routes.js]"]
  node_controllers["Domain controllers"]
  node_mysql[("MySQL pool<br/>[database.js]")]
end

node_staff(("Staff user"))

node_staff -->|"uses"| node_router
node_router -->|"routes to"| node_patientui
node_router -->|"routes to"| node_loansui
node_router -->|"routes to"| node_ptui
node_router -->|"routes to"| node_psychui
node_router -->|"routes to"| node_socialui
node_router -->|"routes to"| node_referenceui
node_router -->|"routes to"| node_userui
node_patientui -->|"uses"| node_patientstate
node_patientstate -->|"calls"| node_patientapi
node_patientui -->|"uses"| node_patientstate
node_httpapi -->|"mounts"| node_patientroutes
node_httpapi -->|"mounts"| node_loanroutes
node_httpapi -->|"mounts"| node_ptroutes
node_httpapi -->|"mounts"| node_psychroutes
node_httpapi -->|"mounts"| node_socialroutes
node_httpapi -->|"mounts"| node_referenceroutes
node_httpapi -->|"mounts"| node_attachmentroutes
node_httpapi -->|"mounts"| node_userroutes
node_patientroutes -->|"dispatches"| node_controllers
node_loanroutes -->|"dispatches"| node_controllers
node_ptroutes -->|"dispatches"| node_controllers
node_psychroutes -->|"dispatches"| node_controllers
node_socialroutes -->|"dispatches"| node_controllers
node_referenceroutes -->|"dispatches"| node_controllers
node_attachmentroutes -->|"dispatches"| node_controllers
node_userroutes -->|"dispatches"| node_controllers
node_controllers -->|"queries"| node_mysql
node_patientapi -.->|"HTTP requests"| node_httpapi
node_loansui -.->|"HTTP requests"| node_httpapi
node_ptui -.->|"HTTP requests"| node_httpapi
node_psychui -.->|"HTTP requests"| node_httpapi
node_socialui -.->|"HTTP requests"| node_httpapi
node_referenceui -.->|"HTTP requests"| node_httpapi
node_attachmentui -.->|"HTTP requests"| node_httpapi
node_userui -.->|"HTTP requests"| node_httpapi

click node_router "https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/client/src/App.js"
click node_patientui "https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/Patient"
click node_patientstate "https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/client/src/context/PatientContext.js"
click node_patientapi "https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/client/src/api/patient.api.js"
click node_loansui "https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/Loans"
click node_ptui "https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/PhysicalTherapyInfo"
click node_psychui "https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/PsychologyInfo"
click node_socialui "https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/SocialWorkInfo"
click node_referenceui "https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/InternalReference"
click node_attachmentui "https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/Attachment"
click node_userui "https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/User"
click node_httpapi "https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/server/index.js"
click node_patientroutes "https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/server/routes/Patient/patient.routes.js"
click node_loanroutes "https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/server/routes/LoanInfo"
click node_ptroutes "https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/server/routes/PhysicalTherapyInfo"
click node_psychroutes "https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/server/routes/PsychologyInfo"
click node_socialroutes "https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/server/routes/SocialWorkInfo"
click node_referenceroutes "https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/server/routes/InternalReferencesInfo/internalReference.routes.js"
click node_attachmentroutes "https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/server/routes/Attachment/attachment.routes.js"
click node_userroutes "https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/server/routes/User/user.routes.js"
click node_controllers "https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/server/controllers"
click node_mysql "https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/server/utils/database.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_router,node_userui,node_staff toneBlue
class node_patientui,node_patientstate,node_patientapi,node_referenceui,node_attachmentui toneAmber
class node_ptui,node_psychui,node_socialui toneMint
class node_loansui toneRose
class node_httpapi,node_patientroutes,node_loanroutes,node_ptroutes,node_psychroutes,node_socialroutes,node_referenceroutes,node_attachmentroutes,node_userroutes,node_controllers,node_mysql toneIndigo
```

## Components

### Web client

- [Page router](https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/client/src/App.js): `client/src/App.js`
- [User accounts](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/User): `client/src/components/User`

### Patient records

- [Patient profiles](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/Patient): `client/src/components/Patient`
- [Patient state](https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/client/src/context/PatientContext.js): `client/src/context/PatientContext.js`
- [Patient API client](https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/client/src/api/patient.api.js): `client/src/api/patient.api.js`
- [Internal references](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/InternalReference): `client/src/components/InternalReference`
- [Attachments](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/Attachment): `client/src/components/Attachment`

### Assessments

- [Physical therapy](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/PhysicalTherapyInfo): `client/src/components/PhysicalTherapyInfo`
- [Psychology records](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/PsychologyInfo): `client/src/components/PsychologyInfo`
- [Social work records](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/SocialWorkInfo): `client/src/components/SocialWorkInfo`

### Support services

- [Equipment loans](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/client/src/components/Loans): `client/src/components/Loans`

### API and persistence

- [HTTP API](https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/server/index.js): `server/index.js`
- [Patient routes](https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/server/routes/Patient/patient.routes.js): `server/routes/Patient/patient.routes.js`
- [Loan routes](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/server/routes/LoanInfo): `server/routes/LoanInfo`
- [Therapy routes](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/server/routes/PhysicalTherapyInfo): `server/routes/PhysicalTherapyInfo`
- [Psychology routes](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/server/routes/PsychologyInfo): `server/routes/PsychologyInfo`
- [Social work routes](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/server/routes/SocialWorkInfo): `server/routes/SocialWorkInfo`
- [Reference routes](https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/server/routes/InternalReferencesInfo/internalReference.routes.js): `server/routes/InternalReferencesInfo/internalReference.routes.js`
- [Attachment routes](https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/server/routes/Attachment/attachment.routes.js): `server/routes/Attachment/attachment.routes.js`
- [User routes](https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/server/routes/User/user.routes.js): `server/routes/User/user.routes.js`
- [Domain controllers](https://github.com/beto0077/ccps-emr-mern-prototype/tree/main/server/controllers): `server/controllers`
- [MySQL pool](https://github.com/beto0077/ccps-emr-mern-prototype/blob/main/server/utils/database.js): `server/utils/database.js`

### Other components

- **Staff user**

## Connections

- Staff user → Page router: uses (evidence: `client/src/App.js`)
- Page router → Patient profiles: routes to (evidence: `client/src/App.js`)
- Page router → Equipment loans: routes to (evidence: `client/src/App.js`)
- Page router → Physical therapy: routes to (evidence: `client/src/App.js`)
- Page router → Psychology records: routes to (evidence: `client/src/App.js`)
- Page router → Social work records: routes to (evidence: `client/src/App.js`)
- Page router → Internal references: routes to (evidence: `client/src/App.js`)
- Page router → User accounts: routes to (evidence: `client/src/App.js`)
- Patient profiles → Patient state: uses (evidence: `client/src/components/Patient/PatientSearch.js`)
- Patient state → Patient API client: calls (evidence: `client/src/context/PatientContext.js`)
- Patient profiles → Patient state: uses (evidence: `client/src/components/Patient/PatientSearch.js`)
- HTTP API → Patient routes: mounts (evidence: `server/index.js`)
- HTTP API → Loan routes: mounts (evidence: `server/index.js`)
- HTTP API → Therapy routes: mounts (evidence: `server/index.js`)
- HTTP API → Psychology routes: mounts (evidence: `server/index.js`)
- HTTP API → Social work routes: mounts (evidence: `server/index.js`)
- HTTP API → Reference routes: mounts (evidence: `server/index.js`)
- HTTP API → Attachment routes: mounts (evidence: `server/index.js`)
- HTTP API → User routes: mounts (evidence: `server/index.js`)
- Patient routes → Domain controllers: dispatches (evidence: `server/routes/Patient/patient.routes.js`)
- Loan routes → Domain controllers: dispatches (evidence: `server/routes/LoanInfo/equipmentLoan.routes.js`)
- Therapy routes → Domain controllers: dispatches (evidence: `server/routes/PhysicalTherapyInfo/physicalTherapyInfo.routes.js`)
- Psychology routes → Domain controllers: dispatches (evidence: `server/routes/PsychologyInfo/psychologyInfo.routes.js`)
- Social work routes → Domain controllers: dispatches (evidence: `server/routes/SocialWorkInfo/socialWorkInfo3.routes.js`)
- Reference routes → Domain controllers: dispatches (evidence: `server/routes/InternalReferencesInfo/internalReference.routes.js`)
- Attachment routes → Domain controllers: dispatches (evidence: `server/routes/Attachment/attachment.routes.js`)
- User routes → Domain controllers: dispatches (evidence: `server/routes/User/user.routes.js`)
- Domain controllers → MySQL pool: queries (evidence: `server/controllers/psychologyInfo.controller.js`)
- Patient API client → HTTP API: HTTP requests
- Equipment loans → HTTP API: HTTP requests
- Physical therapy → HTTP API: HTTP requests
- Psychology records → HTTP API: HTTP requests
- Social work records → HTTP API: HTTP requests
- Internal references → HTTP API: HTTP requests
- Attachments → HTTP API: HTTP requests
- User accounts → HTTP API: HTTP requests
