# asherdoestechs/docuguard architecture

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

- Interactive diagram: https://gitdiagram.com/asherdoestechs/docuguard
- Repository: https://github.com/asherdoestechs/docuguard

## Overview

DocuGuard is an offline-first mobile document lifecycle manager with an Express backend and a separate admin client. The main user flow is to authenticate, add and organize documents, view their status, and receive expiry reminders; local data can synchronize with cloud services. The README also describes search, profiles, dashboard summaries, and document security. Edges reflect excerpted calls or explicit documentation; unsampled route and admin wiring is not asserted.

Main entry points: [`app/(tabs)/index.tsx`](https://github.com/asherdoestechs/docuguard/blob/main/app/(tabs)/index.tsx) (Mobile Client), [`DocuGuard-Server/controllers/documentController.js`](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/controllers/documentController.js) (Document Management), [`services/syncService.ts`](https://github.com/asherdoestechs/docuguard/blob/main/services/syncService.ts) (Sync Service), [`DocuGuard-Server/controllers/authController.js`](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/controllers/authController.js) (User Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile App"]
  node_mobile_app["Mobile Client<br/>[index.tsx]"]
end

subgraph group_backend["API Backend"]
  node_auth["User Authentication<br/>[authController.js]"]
  node_auth_routes["Auth Routes<br/>[auth.js]"]
  node_document_api["Document Management"]
  node_profile_api["User Profile"]
  node_logic["Lifecycle Logic<br/>[logicEngine.js]"]
  node_api_server["REST API<br/>[app.js]"]
  node_expiry_jobs["Expiry Monitoring"]
  node_reminders["Reminders"]
  node_search["Document Search"]
  node_backup["Backup Service<br/>[backupService.js]"]
  node_audit["Audit Logging<br/>[auditService.js]"]
  node_server_errors["Error Codes<br/>[errorCodes.js]"]
end

subgraph group_sync["Offline Sync"]
  node_local_store[("Local Documents<br/>[localDatabase.ts]")]
  node_sync_client["Sync Service<br/>[syncService.ts]"]
  node_sync_policy["Sync Policy<br/>[syncPolicy.js]"]
  node_server_revision["Revision Rules<br/>[serverRevision.js]"]
  node_validation["Shared Validation<br/>[schemas.ts]"]
end

subgraph group_platform["Data Platform"]
  node_database[("PostgreSQL<br/>[db.js]")]
  node_cloud_storage["Document Storage<br/>[storageService.js]"]
  node_supabase["Supabase Storage<br/>[supabase.js]"]
  node_data_sync["Server Sync<br/>[dataSyncService.js]"]
  node_realtime["Realtime Updates<br/>[realtimeService.js]"]
  node_crypto["Data Encryption<br/>[cryptoService.js]"]
end

subgraph group_admin["Admin Console"]
  node_admin_client["Admin Client<br/>[dashboard.tsx]"]
end

node_user(("Document User"))

node_user -->|"uses"| node_mobile_app
node_mobile_app -->|"loads dashboard data"| node_local_store
node_mobile_app -->|"uses REST API"| node_api_server
node_api_server -->|"mounts routes"| node_auth_routes
node_auth_routes -->|"routes to"| node_auth
node_auth -->|"queries"| node_database
node_auth -->|"validates with"| node_validation
node_auth -->|"reports codes"| node_server_errors
node_document_api -->|"reads and writes"| node_database
node_document_api -->|"uses"| node_cloud_storage
node_document_api -->|"syncs changes"| node_data_sync
node_document_api -->|"validates with"| node_validation
node_cloud_storage -->|"stores objects"| node_supabase
node_data_sync -->|"queries"| node_database
node_data_sync -->|"publishes updates"| node_realtime
node_data_sync -->|"uses"| node_crypto
node_sync_client -->|"reads and updates"| node_local_store
node_sync_client -->|"sends sync requests"| node_api_server
node_sync_client -->|"applies rules"| node_sync_policy
node_sync_client -->|"resolves revisions"| node_server_revision
node_user -.->|"administers"| node_admin_client
node_mobile_app -.->|"monitors expiry"| node_expiry_jobs
node_mobile_app -.->|"manages reminders"| node_reminders
node_mobile_app -.->|"searches documents"| node_search
node_mobile_app -.->|"manages profile"| node_profile_api
node_mobile_app -.->|"backs up data"| node_backup
node_mobile_app -.->|"records activity"| node_audit

click node_mobile_app "https://github.com/asherdoestechs/docuguard/blob/main/app/(tabs)/index.tsx"
click node_auth "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/controllers/authController.js"
click node_auth_routes "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/routes/auth.js"
click node_document_api "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/controllers/documentController.js"
click node_profile_api "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/controllers/profileController.js"
click node_logic "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/services/logicEngine.js"
click node_api_server "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/app.js"
click node_local_store "https://github.com/asherdoestechs/docuguard/blob/main/services/localDatabase.ts"
click node_sync_client "https://github.com/asherdoestechs/docuguard/blob/main/services/syncService.ts"
click node_sync_policy "https://github.com/asherdoestechs/docuguard/blob/main/shared/sync/syncPolicy.js"
click node_server_revision "https://github.com/asherdoestechs/docuguard/blob/main/shared/sync/serverRevision.js"
click node_validation "https://github.com/asherdoestechs/docuguard/blob/main/shared/validation/schemas.ts"
click node_database "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/config/db.js"
click node_cloud_storage "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/services/storageService.js"
click node_supabase "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/config/supabase.js"
click node_data_sync "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/services/dataSyncService.js"
click node_realtime "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/services/realtimeService.js"
click node_crypto "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/services/cryptoService.js"
click node_admin_client "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Admin/src/app/dashboard.tsx"
click node_expiry_jobs "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/jobs/expirationChecker.js"
click node_reminders "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/controllers/reminderController.js"
click node_search "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/controllers/searchController.js"
click node_backup "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/services/backupService.js"
click node_audit "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/services/auditService.js"
click node_server_errors "https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/utils/errorCodes.js"

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_mobile_app,node_user toneBlue
class node_auth,node_auth_routes,node_document_api,node_profile_api,node_logic,node_api_server,node_expiry_jobs,node_reminders,node_search,node_backup,node_audit,node_server_errors toneAmber
class node_local_store,node_sync_client,node_sync_policy,node_server_revision,node_validation toneMint
class node_database,node_cloud_storage,node_supabase,node_data_sync,node_realtime,node_crypto toneRose
class node_admin_client toneIndigo
```

## Components

### Mobile App

- [Mobile Client](https://github.com/asherdoestechs/docuguard/blob/main/app/(tabs)/index.tsx): `app/(tabs)/index.tsx`

### API Backend

- [User Authentication](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/controllers/authController.js): `DocuGuard-Server/controllers/authController.js`
- [Auth Routes](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/routes/auth.js): `DocuGuard-Server/routes/auth.js`
- [Document Management](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/controllers/documentController.js): `DocuGuard-Server/controllers/documentController.js`
- [User Profile](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/controllers/profileController.js): `DocuGuard-Server/controllers/profileController.js`
- [Lifecycle Logic](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/services/logicEngine.js): `DocuGuard-Server/services/logicEngine.js`
- [REST API](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/app.js): `DocuGuard-Server/app.js`
- [Expiry Monitoring](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/jobs/expirationChecker.js): `DocuGuard-Server/jobs/expirationChecker.js`
- [Reminders](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/controllers/reminderController.js): `DocuGuard-Server/controllers/reminderController.js`
- [Document Search](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/controllers/searchController.js): `DocuGuard-Server/controllers/searchController.js`
- [Backup Service](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/services/backupService.js): `DocuGuard-Server/services/backupService.js`
- [Audit Logging](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/services/auditService.js): `DocuGuard-Server/services/auditService.js`
- [Error Codes](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/utils/errorCodes.js): `DocuGuard-Server/utils/errorCodes.js`

### Offline Sync

- [Local Documents](https://github.com/asherdoestechs/docuguard/blob/main/services/localDatabase.ts): `services/localDatabase.ts`
- [Sync Service](https://github.com/asherdoestechs/docuguard/blob/main/services/syncService.ts): `services/syncService.ts`
- [Sync Policy](https://github.com/asherdoestechs/docuguard/blob/main/shared/sync/syncPolicy.js): `shared/sync/syncPolicy.js`
- [Revision Rules](https://github.com/asherdoestechs/docuguard/blob/main/shared/sync/serverRevision.js): `shared/sync/serverRevision.js`
- [Shared Validation](https://github.com/asherdoestechs/docuguard/blob/main/shared/validation/schemas.ts): `shared/validation/schemas.ts`

### Data Platform

- [PostgreSQL](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/config/db.js): `DocuGuard-Server/config/db.js`
- [Document Storage](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/services/storageService.js): `DocuGuard-Server/services/storageService.js`
- [Supabase Storage](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/config/supabase.js): `DocuGuard-Server/config/supabase.js`
- [Server Sync](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/services/dataSyncService.js): `DocuGuard-Server/services/dataSyncService.js`
- [Realtime Updates](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/services/realtimeService.js): `DocuGuard-Server/services/realtimeService.js`
- [Data Encryption](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Server/services/cryptoService.js): `DocuGuard-Server/services/cryptoService.js`

### Admin Console

- [Admin Client](https://github.com/asherdoestechs/docuguard/blob/main/DocuGuard-Admin/src/app/dashboard.tsx): `DocuGuard-Admin/src/app/dashboard.tsx`

### Other components

- **Document User**

## Connections

- Document User → Mobile Client: uses (evidence: `README.md`)
- Mobile Client → Local Documents: loads dashboard data (evidence: `app/(tabs)/index.tsx`)
- Mobile Client → REST API: uses REST API (evidence: `README.md`)
- REST API → Auth Routes: mounts routes (evidence: `DocuGuard-Server/app.js`)
- Auth Routes → User Authentication: routes to (evidence: `DocuGuard-Server/routes/auth.js`)
- User Authentication → PostgreSQL: queries (evidence: `DocuGuard-Server/controllers/authController.js`)
- User Authentication → Shared Validation: validates with (evidence: `DocuGuard-Server/controllers/authController.js`)
- User Authentication → Error Codes: reports codes (evidence: `DocuGuard-Server/controllers/authController.js`)
- Document Management → PostgreSQL: reads and writes (evidence: `DocuGuard-Server/controllers/documentController.js`)
- Document Management → Document Storage: uses (evidence: `DocuGuard-Server/controllers/documentController.js`)
- Document Management → Server Sync: syncs changes (evidence: `DocuGuard-Server/controllers/documentController.js`)
- Document Management → Shared Validation: validates with (evidence: `DocuGuard-Server/controllers/documentController.js`)
- Document Storage → Supabase Storage: stores objects (evidence: `DocuGuard-Server/services/storageService.js`)
- Server Sync → PostgreSQL: queries (evidence: `DocuGuard-Server/services/dataSyncService.js`)
- Server Sync → Realtime Updates: publishes updates (evidence: `DocuGuard-Server/services/dataSyncService.js`)
- Server Sync → Data Encryption: uses (evidence: `DocuGuard-Server/services/dataSyncService.js`)
- Sync Service → Local Documents: reads and updates (evidence: `services/syncService.ts`)
- Sync Service → REST API: sends sync requests (evidence: `services/syncService.ts`)
- Sync Service → Sync Policy: applies rules (evidence: `services/syncService.ts`)
- Sync Service → Revision Rules: resolves revisions
- Document User → Admin Client: administers
- Mobile Client → Expiry Monitoring: monitors expiry
- Mobile Client → Reminders: manages reminders
- Mobile Client → Document Search: searches documents
- Mobile Client → User Profile: manages profile
- Mobile Client → Backup Service: backs up data
- Mobile Client → Audit Logging: records activity
