# turtle8789/bayareacivicshield architecture

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

- Interactive diagram: https://gitdiagram.com/turtle8789/bayareacivicshield
- Repository: https://github.com/turtle8789/bayareacivicshield

## Overview

CivicShield Pro is an Expo mobile app for rights education, translation, document analysis, encounter records, and support resources. The main user workflow is to choose a feature, use its guidance or tools, and organize sensitive information locally, with document images optionally sent to a supporting API and AI provider. The graph preserves the README’s major feature branches. OCR implementation details and several mobile internals were not sampled, so those links are documented at the product level rather than asserted as source-level calls.

Main entry points: [`artifacts/api-server/src/app.ts`](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/api-server/src/app.ts) (Express API), [`artifacts/api-server/src/routes`](https://github.com/turtle8789/bayareacivicshield/tree/main/artifacts/api-server/src/routes) (Document OCR route), [`artifacts/mobile/app/(tabs)/docs.tsx`](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/(tabs)/docs.tsx) (Document analyzer), [`artifacts/mobile/app/log-list.tsx`](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/log-list.tsx) (Encounter records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile experience"]
  node_rights["Rights guidance<br/>[index.tsx]"]
  node_translation["Translation tools<br/>[translate.tsx]"]
  node_document["Document analyzer<br/>[docs.tsx]"]
  node_localization["Language and accessibility<br/>[settings.tsx]"]
end

subgraph group_records["Privacy and records"]
  node_appstate["App state<br/>[AppContext.tsx]"]
  node_encounter["Encounter records<br/>[log-list.tsx]"]
  node_security["App lock<br/>[security.tsx]"]
  node_encryption["Backup encryption<br/>[encryption.ts]"]
  node_backup["Automatic backups<br/>[backupSchedule.ts]"]
end

subgraph group_support["Support and community"]
  node_resources["Resource center<br/>[resources.tsx]"]
  node_legaldata["Curated resources<br/>[legal-resources.ts]"]
  node_resourcehub["Resource hub<br/>[resource-hub.tsx]"]
  node_community["Community forum<br/>[community.tsx]"]
  node_forumdata["Local forum data<br/>[forum-data.ts]"]
end

subgraph group_api["Supporting API"]
  node_api["Express API<br/>[app.ts]"]
  node_ocr["Document OCR route"]
  node_health["Health endpoint<br/>[health.ts]"]
  node_logger["Request logging<br/>[logger.ts]"]
end

node_user(("App user"))
node_ai{{"OpenAI provider"}}

node_user -->|"explores rights"| node_rights
node_user -->|"uses translation"| node_translation
node_user -->|"submits document"| node_document
node_user -->|"records encounter"| node_encounter
node_user -->|"finds support"| node_resources
node_user -->|"browses forum"| node_community
node_user -->|"sets preferences"| node_localization
node_encounter -.->|"uses local state"| node_appstate
node_security -.->|"protects backups"| node_encryption
node_backup -.->|"encrypts data"| node_encryption
node_community -->|"stores locally"| node_forumdata
node_resources -.->|"browses resources"| node_legaldata
node_user -->|"opens hub"| node_resourcehub
node_document -.->|"sends image"| node_ocr
node_ocr -.->|"requests analysis"| node_ai
node_api -.->|"routes requests"| node_ocr
node_api -->|"mounts routes"| node_health
node_api -->|"configures logging"| node_logger

click node_rights "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/(tabs)/index.tsx"
click node_translation "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/(tabs)/translate.tsx"
click node_document "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/(tabs)/docs.tsx"
click node_localization "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/settings.tsx"
click node_appstate "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/context/AppContext.tsx"
click node_encounter "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/log-list.tsx"
click node_security "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/security.tsx"
click node_encryption "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/utils/encryption.ts"
click node_backup "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/utils/backupSchedule.ts"
click node_resources "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/(tabs)/resources.tsx"
click node_legaldata "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/constants/legal-resources.ts"
click node_resourcehub "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/resource-hub.tsx"
click node_community "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/(tabs)/community.tsx"
click node_forumdata "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/constants/forum-data.ts"
click node_api "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/api-server/src/app.ts"
click node_ocr "https://github.com/turtle8789/bayareacivicshield/tree/main/artifacts/api-server/src/routes"
click node_health "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/api-server/src/routes/health.ts"
click node_logger "https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/api-server/src/lib/logger.ts"

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_rights,node_translation,node_document,node_localization,node_user toneBlue
class node_appstate,node_encounter,node_security,node_encryption,node_backup toneAmber
class node_resources,node_legaldata,node_resourcehub,node_community,node_forumdata toneMint
class node_api,node_ocr,node_health,node_logger toneRose
class node_ai toneIndigo
```

## Components

### Mobile experience

- [Rights guidance](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/(tabs)/index.tsx): `artifacts/mobile/app/(tabs)/index.tsx`
- [Translation tools](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/(tabs)/translate.tsx): `artifacts/mobile/app/(tabs)/translate.tsx`
- [Document analyzer](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/(tabs)/docs.tsx): `artifacts/mobile/app/(tabs)/docs.tsx`
- [Language and accessibility](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/settings.tsx): `artifacts/mobile/app/settings.tsx`

### Privacy and records

- [App state](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/context/AppContext.tsx): `artifacts/mobile/context/AppContext.tsx`
- [Encounter records](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/log-list.tsx): `artifacts/mobile/app/log-list.tsx`
- [App lock](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/security.tsx): `artifacts/mobile/app/security.tsx`
- [Backup encryption](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/utils/encryption.ts): `artifacts/mobile/utils/encryption.ts`
- [Automatic backups](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/utils/backupSchedule.ts): `artifacts/mobile/utils/backupSchedule.ts`

### Support and community

- [Resource center](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/(tabs)/resources.tsx): `artifacts/mobile/app/(tabs)/resources.tsx`
- [Curated resources](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/constants/legal-resources.ts): `artifacts/mobile/constants/legal-resources.ts`
- [Resource hub](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/resource-hub.tsx): `artifacts/mobile/app/resource-hub.tsx`
- [Community forum](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/app/(tabs)/community.tsx): `artifacts/mobile/app/(tabs)/community.tsx`
- [Local forum data](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/mobile/constants/forum-data.ts): `artifacts/mobile/constants/forum-data.ts`

### Supporting API

- [Express API](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/api-server/src/app.ts): `artifacts/api-server/src/app.ts`
- [Document OCR route](https://github.com/turtle8789/bayareacivicshield/tree/main/artifacts/api-server/src/routes): `artifacts/api-server/src/routes`
- [Health endpoint](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/api-server/src/routes/health.ts): `artifacts/api-server/src/routes/health.ts`
- [Request logging](https://github.com/turtle8789/bayareacivicshield/blob/main/artifacts/api-server/src/lib/logger.ts): `artifacts/api-server/src/lib/logger.ts`

### Other components

- **App user**
- **OpenAI provider**

## Connections

- App user → Rights guidance: explores rights (evidence: `README.md`)
- App user → Translation tools: uses translation (evidence: `README.md`)
- App user → Document analyzer: submits document (evidence: `README.md`)
- App user → Encounter records: records encounter (evidence: `README.md`)
- App user → Resource center: finds support (evidence: `README.md`)
- App user → Community forum: browses forum (evidence: `README.md`)
- App user → Language and accessibility: sets preferences (evidence: `README.md`)
- Encounter records → App state: uses local state (evidence: `README.md`)
- App lock → Backup encryption: protects backups (evidence: `README.md`)
- Automatic backups → Backup encryption: encrypts data (evidence: `README.md`)
- Community forum → Local forum data: stores locally (evidence: `README.md`)
- Resource center → Curated resources: browses resources (evidence: `README.md`)
- App user → Resource hub: opens hub (evidence: `README.md`)
- Document analyzer → Document OCR route: sends image (evidence: `README.md`)
- Document OCR route → OpenAI provider: requests analysis (evidence: `README.md`)
- Express API → Document OCR route: routes requests (evidence: `README.md`)
- Express API → Health endpoint: mounts routes
- Express API → Request logging: configures logging (evidence: `artifacts/api-server/src/app.ts`)
