# vickyapril02/girder-redcap-mimic-sync architecture

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

- Interactive diagram: https://gitdiagram.com/vickyapril02/girder-redcap-mimic-sync
- Repository: https://github.com/vickyapril02/girder-redcap-mimic-sync

## Overview

This POC accepts patient metadata and files through a REDCap-style interface, organizes them by center, patient, visit, and document type, and uploads them to Girder. Its mimic workflow can save files locally for later synchronization; a separate schema-creation utility provisions the matching Girder folders. SQLite holds the hierarchy, file records, sync state, and folder IDs. The excerpts show the principal calls, but not every route implementation or the full HTML behavior, so those links are limited to documented or visible relationships.

Main entry points: [`app.py`](https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/app.py) (FastAPI Routes), [`girder_client.py`](https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/girder_client.py) (Girder Client), [`database.py`](https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/database.py) (Study Catalog), [`scripts/create_girder_schema.py`](https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/scripts/create_girder_schema.py) (Folder Provisioning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Data Capture"]
  node_api["FastAPI Routes<br/>[app.py]"]
  node_mimic["Mimic Interface<br/>[redcap_mimic.html]"]
  node_patient["Patient Model<br/>[models.py]"]
  node_localfiles["Local Uploads<br/>[app.py]"]
end

subgraph group_catalog["Study Catalog"]
  node_catalogdb[("Study Catalog<br/>[database.py]")]
  node_schema["Folder Provisioning"]
end

subgraph group_sync["Girder Sync"]
  node_batchsync["Batch Sync<br/>[extract_sync.py]"]
  node_girderclient["Girder Client<br/>[girder_client.py]"]
end

subgraph group_storage["Persistence"]
end

node_redcap(("REDCap"))
node_browser(("Web User"))
node_girder[("Girder Storage")]

node_browser -->|"uses"| node_mimic
node_browser -->|"uploads"| node_api
node_redcap -->|"webhook posts"| node_api
node_api -->|"serves"| node_mimic
node_api -->|"validates"| node_patient
node_api -->|"reads and writes"| node_catalogdb
node_api -->|"saves uploads"| node_localfiles
node_api -->|"uploads directly"| node_girderclient
node_schema -->|"reads structure; stores IDs"| node_catalogdb
node_schema -->|"creates folders"| node_girderclient
node_batchsync -->|"reads files; marks synced"| node_catalogdb
node_batchsync -->|"validates and uploads"| node_girderclient
node_girderclient -->|"calls API"| node_girder

click node_api "https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/app.py"
click node_mimic "https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/redcap_mimic.html"
click node_patient "https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/models.py"
click node_localfiles "https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/app.py"
click node_catalogdb "https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/database.py"
click node_schema "https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/scripts/create_girder_schema.py"
click node_batchsync "https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/sync/extract_sync.py"
click node_girderclient "https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/girder_client.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_api,node_mimic,node_patient,node_localfiles,node_browser toneBlue
class node_catalogdb,node_schema,node_girder toneAmber
class node_batchsync,node_girderclient toneMint
class node_redcap toneIndigo
```

## Components

### Data Capture

- [FastAPI Routes](https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/app.py): `app.py`
- [Mimic Interface](https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/redcap_mimic.html): `redcap_mimic.html`
- [Patient Model](https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/models.py): `models.py`
- [Local Uploads](https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/app.py): `app.py`

### Study Catalog

- [Study Catalog](https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/database.py): `database.py`
- [Folder Provisioning](https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/scripts/create_girder_schema.py): `scripts/create_girder_schema.py`

### Girder Sync

- [Batch Sync](https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/sync/extract_sync.py): `sync/extract_sync.py`
- [Girder Client](https://github.com/vickyapril02/girder-redcap-mimic-sync/blob/main/girder_client.py): `girder_client.py`

### Other components

- **REDCap**
- **Web User**
- **Girder Storage**

## Connections

- Web User → Mimic Interface: uses (evidence: `README.md`)
- Web User → FastAPI Routes: uploads (evidence: `README.md`)
- REDCap → FastAPI Routes: webhook posts (evidence: `app.py`)
- FastAPI Routes → Mimic Interface: serves (evidence: `app.py`)
- FastAPI Routes → Patient Model: validates (evidence: `app.py`)
- FastAPI Routes → Study Catalog: reads and writes (evidence: `app.py`)
- FastAPI Routes → Local Uploads: saves uploads (evidence: `README.md`)
- FastAPI Routes → Girder Client: uploads directly (evidence: `app.py`)
- Folder Provisioning → Study Catalog: reads structure; stores IDs (evidence: `scripts/create_girder_schema.py`)
- Folder Provisioning → Girder Client: creates folders (evidence: `scripts/create_girder_schema.py`)
- Batch Sync → Study Catalog: reads files; marks synced (evidence: `sync/extract_sync.py`)
- Batch Sync → Girder Client: validates and uploads (evidence: `sync/extract_sync.py`)
- Girder Client → Girder Storage: calls API (evidence: `girder_client.py`)
