# dieu-merci-ndenga/fieldsync architecture

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

- Interactive diagram: https://gitdiagram.com/dieu-merci-ndenga/fieldsync
- Repository: https://github.com/dieu-merci-ndenga/fieldsync

## Overview

FieldSync is an offline-first inspection and photo-reporting product. A technician edits inspections and checklists in the mobile app; the SyncEngine records local changes and queued photos, then pushes, uploads, and pulls when connectivity permits. The API validates and merges operations, records history and idempotency state, and serves photo uploads. The README documents search, filters, restore, conflict resolution, and browser support; unsampled implementation details are represented at subsystem level, with only documented relationships shown where source excerpts do not establish calls.

Main entry points: [`mobile/App.tsx`](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/App.tsx) (App shell), [`mobile/src/ui/InspectionDetail.tsx`](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/ui/InspectionDetail.tsx) (Inspection detail), [`mobile/src/api.ts`](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/api.ts) (API client), [`backend/src/app.module.ts`](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/app.module.ts) (API composition)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile experience"]
  node_app["App shell<br/>[App.tsx]"]
  node_inspection_list["Inspection list<br/>[InspectionList.tsx]"]
  node_inspection_detail["Inspection detail"]
  node_photo_viewer["Photo viewer<br/>[PhotoViewer.tsx]"]
  node_ui_components["UI components<br/>[components.tsx]"]
  node_theme["Theme<br/>[theme.ts]"]
end

subgraph group_local["Offline data and sync"]
  node_engine["Sync engine<br/>[engine.ts]"]
  node_sqlite[("Local store<br/>[sqliteStore.ts]")]
  node_web_store[("Browser store<br/>[sqliteStore.web.ts]")]
  node_api_client["API client<br/>[api.ts]"]
  node_photo_storage["Photo storage<br/>[photoStorage.ts]"]
  node_upload_adapter["Upload adapter<br/>[upload.ts]"]
  node_settings["Settings adapter<br/>[settings.ts]"]
end

subgraph group_server["API and reconciliation"]
  node_sync_controller["Sync routes<br/>[sync.controller.ts]"]
  node_validation["Operation validation<br/>[validation.ts]"]
  node_sync_service["Sync service<br/>[sync.service.ts]"]
  node_merge["Three-way merge<br/>[merge.ts]"]
  node_photo_controller["Photo routes"]
  node_auth["Auth guard<br/>[auth.guard.ts]"]
  node_app_module["API composition<br/>[app.module.ts]"]
end

subgraph group_persistence["Server persistence"]
  node_entities["Data entities<br/>[entities.ts]"]
  node_postgres[("PostgreSQL")]
  node_photo_files[("Photo files")]
end

node_technician(("Technician"))

node_technician -->|"uses"| node_app
node_app -->|"creates"| node_engine
node_app -->|"opens"| node_sqlite
node_app -->|"configures"| node_api_client
node_app -->|"loads"| node_settings
node_app -->|"renders"| node_inspection_list
node_app -->|"renders"| node_inspection_detail
node_app -->|"uses"| node_ui_components
node_inspection_detail -->|"edits through"| node_engine
node_inspection_detail -->|"persists photos"| node_photo_storage
node_inspection_detail -->|"shows"| node_photo_viewer
node_inspection_detail -->|"requests history"| node_api_client
node_inspection_list -->|"uses"| node_ui_components
node_inspection_detail -->|"uses"| node_ui_components
node_ui_components -->|"reads"| node_theme
node_inspection_list -->|"reads"| node_theme
node_inspection_detail -->|"reads"| node_theme
node_engine -->|"persists operations"| node_sqlite
node_engine -->|"syncs through"| node_api_client
node_api_client -->|"uploads with"| node_upload_adapter
node_api_client -->|"pushes and pulls"| node_sync_controller
node_api_client -->|"sends photo requests"| node_photo_controller
node_sync_controller -->|"validates operations"| node_validation
node_sync_controller -->|"dispatches"| node_sync_service
node_sync_service -->|"merges patches"| node_merge
node_sync_service -->|"reads and writes"| node_entities
node_photo_controller -->|"stores photo metadata"| node_entities
node_photo_controller -->|"reads and writes"| node_photo_files
node_app_module -->|"registers"| node_sync_controller
node_app_module -->|"registers"| node_photo_controller
node_app_module -->|"provides"| node_sync_service
node_app_module -->|"installs guard"| node_auth
node_app_module -->|"configures"| node_entities
node_entities -.->|"persisted in"| node_postgres
node_engine -.->|"uses in browser"| node_web_store

click node_app "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/App.tsx"
click node_inspection_list "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/ui/InspectionList.tsx"
click node_inspection_detail "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/ui/InspectionDetail.tsx"
click node_photo_viewer "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/ui/PhotoViewer.tsx"
click node_ui_components "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/ui/components.tsx"
click node_theme "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/theme.ts"
click node_engine "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/core/engine.ts"
click node_sqlite "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/db/sqliteStore.ts"
click node_web_store "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/db/sqliteStore.web.ts"
click node_api_client "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/api.ts"
click node_photo_storage "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/platform/photoStorage.ts"
click node_upload_adapter "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/platform/upload.ts"
click node_settings "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/platform/settings.ts"
click node_sync_controller "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/sync/sync.controller.ts"
click node_validation "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/sync/validation.ts"
click node_sync_service "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/sync/sync.service.ts"
click node_merge "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/sync/merge.ts"
click node_photo_controller "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/photos.controller.ts"
click node_auth "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/auth.guard.ts"
click node_entities "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/entities.ts"
click node_app_module "https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/app.module.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_app,node_inspection_list,node_inspection_detail,node_photo_viewer,node_ui_components,node_theme toneBlue
class node_engine,node_sqlite,node_web_store,node_api_client,node_photo_storage,node_upload_adapter,node_settings toneAmber
class node_sync_controller,node_validation,node_sync_service,node_merge,node_photo_controller,node_auth,node_app_module toneMint
class node_entities,node_postgres,node_photo_files toneRose
class node_technician toneIndigo
```

## Components

### Mobile experience

- [App shell](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/App.tsx): `mobile/App.tsx`
- [Inspection list](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/ui/InspectionList.tsx): `mobile/src/ui/InspectionList.tsx`
- [Inspection detail](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/ui/InspectionDetail.tsx): `mobile/src/ui/InspectionDetail.tsx`
- [Photo viewer](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/ui/PhotoViewer.tsx): `mobile/src/ui/PhotoViewer.tsx`
- [UI components](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/ui/components.tsx): `mobile/src/ui/components.tsx`
- [Theme](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/theme.ts): `mobile/src/theme.ts`

### Offline data and sync

- [Sync engine](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/core/engine.ts): `mobile/src/core/engine.ts`
- [Local store](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/db/sqliteStore.ts): `mobile/src/db/sqliteStore.ts`
- [Browser store](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/db/sqliteStore.web.ts): `mobile/src/db/sqliteStore.web.ts`
- [API client](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/api.ts): `mobile/src/api.ts`
- [Photo storage](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/platform/photoStorage.ts): `mobile/src/platform/photoStorage.ts`
- [Upload adapter](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/platform/upload.ts): `mobile/src/platform/upload.ts`
- [Settings adapter](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/mobile/src/platform/settings.ts): `mobile/src/platform/settings.ts`

### API and reconciliation

- [Sync routes](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/sync/sync.controller.ts): `backend/src/sync/sync.controller.ts`
- [Operation validation](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/sync/validation.ts): `backend/src/sync/validation.ts`
- [Sync service](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/sync/sync.service.ts): `backend/src/sync/sync.service.ts`
- [Three-way merge](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/sync/merge.ts): `backend/src/sync/merge.ts`
- [Photo routes](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/photos.controller.ts): `backend/src/photos.controller.ts`
- [Auth guard](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/auth.guard.ts): `backend/src/auth.guard.ts`
- [API composition](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/app.module.ts): `backend/src/app.module.ts`

### Server persistence

- [Data entities](https://github.com/dieu-merci-ndenga/fieldsync/blob/main/backend/src/entities.ts): `backend/src/entities.ts`
- **PostgreSQL**
- **Photo files**

### Other components

- **Technician**

## Connections

- Technician → App shell: uses (evidence: `README.md`)
- App shell → Sync engine: creates (evidence: `mobile/App.tsx`)
- App shell → Local store: opens (evidence: `mobile/App.tsx`)
- App shell → API client: configures (evidence: `mobile/App.tsx`)
- App shell → Settings adapter: loads (evidence: `mobile/App.tsx`)
- App shell → Inspection list: renders (evidence: `mobile/App.tsx`)
- App shell → Inspection detail: renders (evidence: `mobile/App.tsx`)
- App shell → UI components: uses (evidence: `mobile/App.tsx`)
- Inspection detail → Sync engine: edits through (evidence: `mobile/src/ui/InspectionDetail.tsx`)
- Inspection detail → Photo storage: persists photos (evidence: `mobile/src/ui/InspectionDetail.tsx`)
- Inspection detail → Photo viewer: shows (evidence: `mobile/src/ui/InspectionDetail.tsx`)
- Inspection detail → API client: requests history (evidence: `mobile/src/ui/InspectionDetail.tsx`)
- Inspection list → UI components: uses (evidence: `mobile/src/ui/InspectionList.tsx`)
- Inspection detail → UI components: uses (evidence: `mobile/src/ui/InspectionDetail.tsx`)
- UI components → Theme: reads (evidence: `mobile/src/ui/components.tsx`)
- Inspection list → Theme: reads (evidence: `mobile/src/ui/InspectionList.tsx`)
- Inspection detail → Theme: reads (evidence: `mobile/src/ui/InspectionDetail.tsx`)
- Sync engine → Local store: persists operations (evidence: `README.md`)
- Sync engine → API client: syncs through (evidence: `README.md`)
- API client → Upload adapter: uploads with (evidence: `mobile/src/api.ts`)
- API client → Sync routes: pushes and pulls (evidence: `README.md`)
- API client → Photo routes: sends photo requests (evidence: `README.md`)
- Sync routes → Operation validation: validates operations (evidence: `backend/src/sync/sync.controller.ts`)
- Sync routes → Sync service: dispatches (evidence: `backend/src/sync/sync.controller.ts`)
- Sync service → Three-way merge: merges patches (evidence: `backend/src/sync/sync.service.ts`)
- Sync service → Data entities: reads and writes (evidence: `backend/src/sync/sync.service.ts`)
- Photo routes → Data entities: stores photo metadata (evidence: `backend/src/photos.controller.ts`)
- Photo routes → Photo files: reads and writes (evidence: `backend/src/photos.controller.ts`)
- API composition → Sync routes: registers (evidence: `backend/src/app.module.ts`)
- API composition → Photo routes: registers (evidence: `backend/src/app.module.ts`)
- API composition → Sync service: provides (evidence: `backend/src/app.module.ts`)
- API composition → Auth guard: installs guard (evidence: `backend/src/app.module.ts`)
- API composition → Data entities: configures (evidence: `backend/src/app.module.ts`)
- Data entities → PostgreSQL: persisted in (evidence: `README.md`)
- Sync engine → Browser store: uses in browser (evidence: `README.md`)
