# taarunkarthik/privacy-shield architecture

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

- Interactive diagram: https://gitdiagram.com/taarunkarthik/privacy-shield
- Repository: https://github.com/taarunkarthik/privacy-shield

## Overview

PrivacyShield is a PostgreSQL privacy platform: users register a target database, discover its schema, scan bounded samples for sensitive-data candidates, review advisory classifications, create and approve versioned masking policies, then explicitly deploy protected views. The control plane stores metadata and sanitized evidence; the target database retains source data. The README documents the end-to-end stages and audit guarantees, while sampled source confirms API registration, inline job dispatch, and policy orchestration. Several feature implementations were not sampled, so their documented stages are shown without speculative internal call links.

Main entry points: [`backend/app/services/policies/service.py`](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/services/policies/service.py) (Policy lifecycle), [`backend/app/services/classification`](https://github.com/taarunkarthik/privacy-shield/tree/dev/privacyshield/backend/app/services/classification) (PII recommendations), [`backend/app/services/scanning`](https://github.com/taarunkarthik/privacy-shield/tree/dev/privacyshield/backend/app/services/scanning) (Sample scanning), [`backend/app/workers/inline.py`](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/workers/inline.py) (Inline job runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["User workspace"]
  node_frontend["Web workspace<br/>[App.tsx]"]
  node_api_client["API client<br/>[client.ts]"]
end

subgraph group_api["API and identity"]
  node_api_entry["HTTP application<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_api_routes["Product endpoints"]
end

subgraph group_discovery["Discovery and analysis"]
  node_connections["Database connections<br/>[connections.py]"]
  node_catalog["Schema discovery<br/>[catalog.py]"]
  node_scanning["Sample scanning"]
  node_classification["PII recommendations"]
  node_settings["Detection settings<br/>[service.py]"]
end

subgraph group_governance["Policy governance"]
  node_policy_service["Policy lifecycle<br/>[service.py]"]
  node_policy_compiler["View compiler<br/>[compiler.py]"]
  node_deployment["View deployment<br/>[execution.py]"]
end

subgraph group_runtime["Jobs and audit"]
  node_job_runner["Inline job runner<br/>[inline.py]"]
  node_audit_events["Audit events<br/>[audit.py]"]
  node_audit_chain["Hash-chain audit<br/>[audit_chain.py]"]
end

node_operator(("Workspace user"))
node_control_db[("Control plane")]
node_target_db[("Target PostgreSQL")]
node_local_ai{{"Local AI model"}}

node_operator -->|"uses"| node_frontend
node_frontend -.->|"requests"| node_api_client
node_api_client -.->|"calls API"| node_api_entry
node_api_entry -->|"registers"| node_auth
node_api_entry -->|"registers"| node_api_routes
node_operator -->|"registers"| node_connections
node_connections -->|"stores credentials"| node_target_db
node_connections -->|"discovers"| node_catalog
node_catalog -->|"reads catalog"| node_target_db
node_catalog -->|"stores snapshot"| node_control_db
node_operator -->|"starts scan"| node_scanning
node_scanning -->|"samples read-only"| node_target_db
node_scanning -->|"stores results"| node_control_db
node_operator -->|"requests advice"| node_classification
node_classification -->|"requests recommendation"| node_local_ai
node_classification -->|"stores recommendation"| node_control_db
node_settings -->|"stores patterns"| node_control_db
node_job_runner -->|"runs scan"| node_scanning
node_job_runner -->|"runs classification"| node_classification
node_operator -->|"creates and submits"| node_policy_service
node_classification -->|"informs policy"| node_policy_service
node_policy_service -->|"stores policy"| node_control_db
node_operator -->|"approves version"| node_policy_service
node_policy_service -->|"builds plan"| node_policy_compiler
node_policy_service -->|"queues deployment"| node_deployment
node_job_runner -->|"runs deployment"| node_deployment
node_deployment -->|"creates secure view"| node_target_db
node_operator -->|"queries view"| node_target_db
node_policy_service -->|"records actions"| node_audit_events
node_audit_events -->|"chains events"| node_audit_chain
node_audit_chain -->|"persists chain"| node_control_db

click node_frontend "https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/frontend/src/App.tsx"
click node_api_client "https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/frontend/src/api/client.ts"
click node_api_entry "https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/main.py"
click node_auth "https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/api/auth.py"
click node_api_routes "https://github.com/taarunkarthik/privacy-shield/tree/dev/privacyshield/backend/app/api"
click node_connections "https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/api/connections.py"
click node_catalog "https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/services/discovery/catalog.py"
click node_scanning "https://github.com/taarunkarthik/privacy-shield/tree/dev/privacyshield/backend/app/services/scanning"
click node_classification "https://github.com/taarunkarthik/privacy-shield/tree/dev/privacyshield/backend/app/services/classification"
click node_policy_service "https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/services/policies/service.py"
click node_policy_compiler "https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/services/policies/compiler.py"
click node_deployment "https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/services/policies/execution.py"
click node_settings "https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/services/settings/service.py"
click node_job_runner "https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/workers/inline.py"
click node_audit_events "https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/core/audit.py"
click node_audit_chain "https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/services/audit_chain.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_frontend,node_api_client,node_operator toneBlue
class node_api_entry,node_auth,node_api_routes,node_control_db,node_target_db toneAmber
class node_connections,node_catalog,node_scanning,node_classification,node_settings toneMint
class node_policy_service,node_policy_compiler,node_deployment toneRose
class node_job_runner,node_audit_events,node_audit_chain,node_local_ai toneIndigo
```

## Components

### User workspace

- [Web workspace](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/frontend/src/api/client.ts): `frontend/src/api/client.ts`

### API and identity

- [HTTP application](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/api/auth.py): `backend/app/api/auth.py`
- [Product endpoints](https://github.com/taarunkarthik/privacy-shield/tree/dev/privacyshield/backend/app/api): `backend/app/api`

### Discovery and analysis

- [Database connections](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/api/connections.py): `backend/app/api/connections.py`
- [Schema discovery](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/services/discovery/catalog.py): `backend/app/services/discovery/catalog.py`
- [Sample scanning](https://github.com/taarunkarthik/privacy-shield/tree/dev/privacyshield/backend/app/services/scanning): `backend/app/services/scanning`
- [PII recommendations](https://github.com/taarunkarthik/privacy-shield/tree/dev/privacyshield/backend/app/services/classification): `backend/app/services/classification`
- [Detection settings](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/services/settings/service.py): `backend/app/services/settings/service.py`

### Policy governance

- [Policy lifecycle](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/services/policies/service.py): `backend/app/services/policies/service.py`
- [View compiler](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/services/policies/compiler.py): `backend/app/services/policies/compiler.py`
- [View deployment](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/services/policies/execution.py): `backend/app/services/policies/execution.py`

### Jobs and audit

- [Inline job runner](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/workers/inline.py): `backend/app/workers/inline.py`
- [Audit events](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/core/audit.py): `backend/app/core/audit.py`
- [Hash-chain audit](https://github.com/taarunkarthik/privacy-shield/blob/dev/privacyshield/backend/app/services/audit_chain.py): `backend/app/services/audit_chain.py`

### Other components

- **Workspace user**
- **Control plane**
- **Target PostgreSQL**
- **Local AI model**

## Connections

- Workspace user → Web workspace: uses (evidence: `frontend/src/App.tsx`)
- Web workspace → API client: requests
- API client → HTTP application: calls API
- HTTP application → Authentication: registers (evidence: `backend/app/main.py`)
- HTTP application → Product endpoints: registers (evidence: `backend/app/main.py`)
- Workspace user → Database connections: registers (evidence: `README.md`)
- Database connections → Target PostgreSQL: stores credentials (evidence: `README.md`)
- Database connections → Schema discovery: discovers (evidence: `README.md`)
- Schema discovery → Target PostgreSQL: reads catalog (evidence: `README.md`)
- Schema discovery → Control plane: stores snapshot (evidence: `README.md`)
- Workspace user → Sample scanning: starts scan (evidence: `README.md`)
- Sample scanning → Target PostgreSQL: samples read-only (evidence: `README.md`)
- Sample scanning → Control plane: stores results (evidence: `README.md`)
- Workspace user → PII recommendations: requests advice (evidence: `README.md`)
- PII recommendations → Local AI model: requests recommendation (evidence: `README.md`)
- PII recommendations → Control plane: stores recommendation (evidence: `README.md`)
- Detection settings → Control plane: stores patterns (evidence: `backend/app/services/settings/service.py`)
- Inline job runner → Sample scanning: runs scan (evidence: `backend/app/workers/inline.py`)
- Inline job runner → PII recommendations: runs classification (evidence: `backend/app/workers/inline.py`)
- Workspace user → Policy lifecycle: creates and submits (evidence: `README.md`)
- PII recommendations → Policy lifecycle: informs policy (evidence: `README.md`)
- Policy lifecycle → Control plane: stores policy (evidence: `README.md`)
- Workspace user → Policy lifecycle: approves version (evidence: `README.md`)
- Policy lifecycle → View compiler: builds plan (evidence: `backend/app/services/policies/service.py`)
- Policy lifecycle → View deployment: queues deployment (evidence: `backend/app/services/policies/service.py`)
- Inline job runner → View deployment: runs deployment (evidence: `backend/app/workers/inline.py`)
- View deployment → Target PostgreSQL: creates secure view (evidence: `README.md`)
- Workspace user → Target PostgreSQL: queries view (evidence: `README.md`)
- Policy lifecycle → Audit events: records actions (evidence: `backend/app/services/policies/service.py`)
- Audit events → Hash-chain audit: chains events (evidence: `README.md`)
- Hash-chain audit → Control plane: persists chain (evidence: `README.md`)
