# ahsan-ra2a/medshield-privacyguard architecture

> Architecture diagram of the GitHub repository ahsan-ra2a/medshield-privacyguard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahsan-ra2a/medshield-privacyguard
- Repository: https://github.com/ahsan-ra2a/medshield-privacyguard

## Overview

MedShield is a local Streamlit workspace for demonstrating hospital-record privacy controls with fictional patient data. Users sign in, receive role-specific workspace access, and perform permitted tasks such as searching masked records, registering or correcting records, reviewing consent and retention, auditing activity, viewing analytics, or exporting data. The UI delegates protected operations to Store, which authorizes sessions and works transactionally with SQLite. The README documents the major capabilities; unsampled implementation details are represented at subsystem level rather than inferred as finer-grained calls.

Main entry points: [`core.py`](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py) (Trusted Store service), [`app.py`](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/app.py) (Role-aware Streamlit workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_ui["Role-aware Streamlit workspace<br/>[app.py]"]
end

subgraph group_privacy["Privacy operations"]
  node_login["Authentication and sessions<br/>[core.py]"]
  node_authorization["Role authorization<br/>[core.py]"]
  node_registry["Patient registry<br/>[core.py]"]
  node_privacy_controls["Masking and encryption<br/>[core.py]"]
  node_consent["Consent register<br/>[core.py]"]
  node_corrections["Record corrections<br/>[core.py]"]
end

subgraph group_governance["Governance and assurance"]
  node_retention["Retention management<br/>[core.py]"]
  node_audit["Audit chain and review<br/>[core.py]"]
  node_analytics["Activity analytics<br/>[app.py]"]
  node_exports["CSV and snapshot export<br/>[core.py]"]
  node_recovery["Backup and recovery<br/>[core.py]"]
end

subgraph group_storage["Local persistence"]
  node_store["Trusted Store service<br/>[core.py]"]
  node_sqlite[("Application database")]
  node_keyfile["Local encryption key"]
end

node_users(("Hospital workspace users"))

node_users -->|"use workspace"| node_ui
node_ui -->|"sign in"| node_login
node_ui -->|"call protected operations"| node_store
node_login -->|"establish session"| node_authorization
node_store -->|"authorize requests"| node_authorization
node_store -->|"transactional reads and writes"| node_sqlite
node_store -->|"encrypt and decrypt records"| node_keyfile
node_store -->|"serve registry operations"| node_registry
node_store -->|"protect patient fields"| node_privacy_controls
node_store -->|"record consent choices"| node_consent
node_store -->|"apply authorized corrections"| node_corrections
node_store -->|"manage expiry and deletion"| node_retention
node_store -->|"record and verify activity"| node_audit
node_ui -->|"display activity counts"| node_analytics
node_ui -->|"request exports"| node_exports
node_ui -->|"present recovery workflow"| node_recovery
node_analytics -->|"read event counts"| node_store
node_exports -->|"read export data"| node_sqlite
node_recovery -->|"restore database snapshot"| node_sqlite
node_recovery -->|"restore matching key"| node_keyfile

click node_ui "https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/app.py"
click node_login "https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py"
click node_authorization "https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py"
click node_registry "https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py"
click node_privacy_controls "https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py"
click node_consent "https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py"
click node_corrections "https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py"
click node_retention "https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py"
click node_audit "https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py"
click node_analytics "https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/app.py"
click node_exports "https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py"
click node_recovery "https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py"
click node_store "https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.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_ui,node_users toneBlue
class node_login,node_authorization,node_registry,node_privacy_controls,node_consent,node_corrections toneAmber
class node_retention,node_audit,node_analytics,node_exports,node_recovery toneMint
class node_store,node_sqlite,node_keyfile toneRose
```

## Components

### User experience

- [Role-aware Streamlit workspace](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/app.py): `app.py`

### Privacy operations

- [Authentication and sessions](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py): `core.py`
- [Role authorization](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py): `core.py`
- [Patient registry](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py): `core.py`
- [Masking and encryption](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py): `core.py`
- [Consent register](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py): `core.py`
- [Record corrections](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py): `core.py`

### Governance and assurance

- [Retention management](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py): `core.py`
- [Audit chain and review](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py): `core.py`
- [Activity analytics](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/app.py): `app.py`
- [CSV and snapshot export](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py): `core.py`
- [Backup and recovery](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py): `core.py`

### Local persistence

- [Trusted Store service](https://github.com/ahsan-ra2a/medshield-privacyguard/blob/main/core.py): `core.py`
- **Application database**
- **Local encryption key**

### Other components

- **Hospital workspace users**

## Connections

- Hospital workspace users → Role-aware Streamlit workspace: use workspace (evidence: `README.md`)
- Role-aware Streamlit workspace → Authentication and sessions: sign in (evidence: `README.md`)
- Role-aware Streamlit workspace → Trusted Store service: call protected operations (evidence: `README.md`)
- Authentication and sessions → Role authorization: establish session (evidence: `README.md`)
- Trusted Store service → Role authorization: authorize requests (evidence: `README.md`)
- Trusted Store service → Application database: transactional reads and writes (evidence: `README.md`)
- Trusted Store service → Local encryption key: encrypt and decrypt records (evidence: `README.md`)
- Trusted Store service → Patient registry: serve registry operations (evidence: `README.md`)
- Trusted Store service → Masking and encryption: protect patient fields (evidence: `README.md`)
- Trusted Store service → Consent register: record consent choices (evidence: `README.md`)
- Trusted Store service → Record corrections: apply authorized corrections (evidence: `README.md`)
- Trusted Store service → Retention management: manage expiry and deletion (evidence: `README.md`)
- Trusted Store service → Audit chain and review: record and verify activity (evidence: `README.md`)
- Role-aware Streamlit workspace → Activity analytics: display activity counts (evidence: `README.md`)
- Role-aware Streamlit workspace → CSV and snapshot export: request exports (evidence: `app.py`)
- Role-aware Streamlit workspace → Backup and recovery: present recovery workflow (evidence: `README.md`)
- Activity analytics → Trusted Store service: read event counts (evidence: `README.md`)
- CSV and snapshot export → Application database: read export data (evidence: `README.md`)
- Backup and recovery → Application database: restore database snapshot (evidence: `README.md`)
- Backup and recovery → Local encryption key: restore matching key (evidence: `README.md`)
