Data Storage
This document explains what is stored in MySQL and what is stored in Cloudflare R2.
MySQL Database
The MySQL database stores structured records needed by the application.
Main data stored in MySQL:
- users and user roles
- refresh tokens and login/session metadata
- patients and patient demographic details
- patient assignment records
- assignment approval requests
- visits and appointment status
- live clinic queue entries
- dental chart entries
- custom dental chart entries
- dental chart version metadata and chart snapshots
- patient history records
- clinical notes, diagnosis entries, and treatment plans
- payment records
- inventory items and stock transactions
- patient material usage records
- student cases, case progress logs, and case tasks
- audit logs
- system settings
Cloudflare R2
Cloudflare R2 stores uploaded file content.
Examples:
- uploaded patient images
- uploaded patient PDFs
- uploaded document files
The database stores metadata for each uploaded document, including:
- file name
- file type
- size
- patient ID
- uploader ID
- storage provider
- bucket name
- object key
- deleted/restored state
The actual file bytes are stored in R2.
Dental Chart PDFs
Dental chart PDF files are generated by the backend when downloaded. The backend uses the chart data stored in MySQL and renders the PDF using Playwright/Chromium.
Because of this:
- dental chart source data is in MySQL
- generated PDF output is produced by the backend
- the backend should run with Docker in production so Playwright/Chromium works correctly
Why R2 Is Used for Uploaded Documents
Render service disks are not ideal for long-term uploaded clinical documents unless a paid persistent disk is attached and managed carefully. Cloudflare R2 is more suitable because uploaded files stay outside the backend container and are not lost when the backend redeploys.
Backup Responsibility
Production maintainers should confirm:
- Aiven MySQL backups are enabled and restorable.
- Cloudflare R2 bucket access is owned by the institution.
- Render environment variables are documented securely.
- GitHub source code is stored in an institution-owned fork or organization repository.