# ricardxdev/medappoint-cgo architecture

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

- Interactive diagram: https://gitdiagram.com/ricardxdev/medappoint-cgo
- Repository: https://github.com/ricardxdev/medappoint-cgo

## Overview

This is a terminal patient-management application: users navigate a Bubble Tea menu to search, create, update, delete, schedule appointments, or browse patient lists and demographic filters. The views call a shared Go patient service, which bridges through cgo to C patient/index operations and file persistence. README capabilities include disability, appointment-date, gender, age, and specialty reporting. The sampled excerpts establish the search and list wiring and service/storage boundary; CRUD view wiring beyond search/list is represented only where paths and product scope support it.

Main entry points: [`main.go`](https://github.com/ricardxdev/medappoint-cgo/blob/main/main.go) (Menu entry), [`src/models/patient.go`](https://github.com/ricardxdev/medappoint-cgo/blob/main/src/models/patient.go) (Patient operations), [`global/patients.go`](https://github.com/ricardxdev/medappoint-cgo/blob/main/global/patients.go) (Service bootstrap), [`src/views/listMenu_view.go`](https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/listMenu_view.go) (List selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Terminal interface"]
  node_app["Menu entry<br/>[main.go]"]
  node_search["Patient search<br/>[search_view.go]"]
  node_add["Patient add form<br/>[add_view.go]"]
  node_update["Patient update form<br/>[update_view.go]"]
  node_delete["Patient removal<br/>[delete_view.go]"]
  node_lists["List selection<br/>[listMenu_view.go]"]
  node_table["Patient tables<br/>[table_view.go]"]
  node_form["Input validation<br/>[help_patient.go]"]
end

subgraph group_service["Patient service"]
  node_global["Service bootstrap<br/>[patients.go]"]
  node_patient_service["Patient operations<br/>[patient.go]"]
  node_metrics["Patient reports<br/>[metrics.go]"]
end

subgraph group_native["C patient engine"]
  node_c_patient["Patient and index logic<br/>[patient.c]"]
  node_c_metrics["Report calculations<br/>[patient_metrics.c]"]
end

subgraph group_persistence["Local persistence"]
  node_patient_file[("Patient records<br/>[patients.bin]")]
  node_index_file[("Patient index<br/>[index.dat]")]
end

node_user(("Terminal user"))

node_user -->|"chooses actions"| node_app
node_app -->|"opens search"| node_search
node_app -->|"opens form"| node_add
node_app -->|"opens form"| node_update
node_app -->|"opens removal"| node_delete
node_app -->|"opens lists"| node_lists
node_add -->|"validates fields"| node_form
node_update -->|"validates fields"| node_form
node_search -->|"gets patient"| node_global
node_add -->|"adds patient"| node_global
node_update -->|"updates patient"| node_global
node_delete -->|"deletes patient"| node_global
node_lists -->|"requests records"| node_global
node_lists -->|"requests filters"| node_patient_service
node_lists -->|"shows results"| node_table
node_global -->|"loads records"| node_patient_service
node_patient_service -->|"calls via cgo"| node_c_patient
node_metrics -->|"calls via cgo"| node_c_metrics
node_patient_service -->|"reads and writes"| node_patient_file
node_patient_service -->|"reads and writes"| node_index_file
node_c_patient -->|"persists records"| node_patient_file
node_c_patient -->|"persists index"| node_index_file
node_metrics -->|"reads patient state"| node_patient_service

click node_app "https://github.com/ricardxdev/medappoint-cgo/blob/main/main.go"
click node_search "https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/search_view.go"
click node_add "https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/add_view.go"
click node_update "https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/update_view.go"
click node_delete "https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/delete_view.go"
click node_lists "https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/listMenu_view.go"
click node_table "https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/table_view.go"
click node_form "https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/help_patient.go"
click node_global "https://github.com/ricardxdev/medappoint-cgo/blob/main/global/patients.go"
click node_patient_service "https://github.com/ricardxdev/medappoint-cgo/blob/main/src/models/patient.go"
click node_metrics "https://github.com/ricardxdev/medappoint-cgo/blob/main/src/models/metrics.go"
click node_c_patient "https://github.com/ricardxdev/medappoint-cgo/blob/main/csrc/patient.c"
click node_c_metrics "https://github.com/ricardxdev/medappoint-cgo/blob/main/csrc/patient_metrics.c"
click node_patient_file "https://github.com/ricardxdev/medappoint-cgo/blob/main/data/patients.bin"
click node_index_file "https://github.com/ricardxdev/medappoint-cgo/blob/main/data/index.dat"

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_search,node_add,node_update,node_delete,node_lists,node_table,node_form,node_user toneBlue
class node_global,node_patient_service,node_metrics toneAmber
class node_c_patient,node_c_metrics toneMint
class node_patient_file,node_index_file toneRose
```

## Components

### Terminal interface

- [Menu entry](https://github.com/ricardxdev/medappoint-cgo/blob/main/main.go): `main.go`
- [Patient search](https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/search_view.go): `src/views/search_view.go`
- [Patient add form](https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/add_view.go): `src/views/add_view.go`
- [Patient update form](https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/update_view.go): `src/views/update_view.go`
- [Patient removal](https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/delete_view.go): `src/views/delete_view.go`
- [List selection](https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/listMenu_view.go): `src/views/listMenu_view.go`
- [Patient tables](https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/table_view.go): `src/views/table_view.go`
- [Input validation](https://github.com/ricardxdev/medappoint-cgo/blob/main/src/views/help_patient.go): `src/views/help_patient.go`

### Patient service

- [Service bootstrap](https://github.com/ricardxdev/medappoint-cgo/blob/main/global/patients.go): `global/patients.go`
- [Patient operations](https://github.com/ricardxdev/medappoint-cgo/blob/main/src/models/patient.go): `src/models/patient.go`
- [Patient reports](https://github.com/ricardxdev/medappoint-cgo/blob/main/src/models/metrics.go): `src/models/metrics.go`

### C patient engine

- [Patient and index logic](https://github.com/ricardxdev/medappoint-cgo/blob/main/csrc/patient.c): `csrc/patient.c`
- [Report calculations](https://github.com/ricardxdev/medappoint-cgo/blob/main/csrc/patient_metrics.c): `csrc/patient_metrics.c`

### Local persistence

- [Patient records](https://github.com/ricardxdev/medappoint-cgo/blob/main/data/patients.bin): `data/patients.bin`
- [Patient index](https://github.com/ricardxdev/medappoint-cgo/blob/main/data/index.dat): `data/index.dat`

### Other components

- **Terminal user**

## Connections

- Terminal user → Menu entry: chooses actions
- Menu entry → Patient search: opens search
- Menu entry → Patient add form: opens form
- Menu entry → Patient update form: opens form
- Menu entry → Patient removal: opens removal
- Menu entry → List selection: opens lists
- Patient add form → Input validation: validates fields
- Patient update form → Input validation: validates fields
- Patient search → Service bootstrap: gets patient
- Patient add form → Service bootstrap: adds patient
- Patient update form → Service bootstrap: updates patient
- Patient removal → Service bootstrap: deletes patient
- List selection → Service bootstrap: requests records
- List selection → Patient operations: requests filters
- List selection → Patient tables: shows results
- Service bootstrap → Patient operations: loads records
- Patient operations → Patient and index logic: calls via cgo
- Patient reports → Report calculations: calls via cgo
- Patient operations → Patient records: reads and writes
- Patient operations → Patient index: reads and writes
- Patient and index logic → Patient records: persists records
- Patient and index logic → Patient index: persists index
- Patient reports → Patient operations: reads patient state
