# abhinavpwn/offlinesurveyapp architecture

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

- Interactive diagram: https://gitdiagram.com/abhinavpwn/offlinesurveyapp
- Repository: https://github.com/abhinavpwn/offlinesurveyapp

## Overview

This is an offline-first Android survey app for NGO field workers. Its apparent workflow is household listing and local household/member data entry, followed by survey completion and synchronization with a remote API; authentication gates access. The available excerpts confirm authentication persistence, API access, and local SQLite repositories, but do not expose the screen-to-use-case wiring or survey submission path. The README is minimal, so some product capabilities are represented by their source modules without inferred call edges.

Main entry points: [`src/services/api/BaseApiClient.ts`](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/services/api/BaseApiClient.ts) (API client), [`src/auth/service/AuthService.ts`](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/auth/service/AuthService.ts) (Authentication), [`src/auth/storage/authStorage.ts`](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/auth/storage/authStorage.ts) (Secure session storage), [`app/_layout.tsx`](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/app/_layout.tsx) (App startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and startup"]
  node_root["App startup<br/>[_layout.tsx]"]
  node_auth["Authentication<br/>[AuthService.ts]"]
  node_authprovider["Auth context<br/>[AuthProvider.tsx]"]
  node_authgate["Access gate<br/>[AuthGate.tsx]"]
  node_authstorage["Secure session storage<br/>[authStorage.ts]"]
  node_session["Session model<br/>[AuthSession.ts]"]
end

subgraph group_households["Household management"]
  node_householdui["Household screens"]
  node_dashboard["Household dashboard"]
  node_householdcases["Household operations"]
end

subgraph group_entry["Member and survey entry"]
  node_memberform["Member form"]
  node_review["Form review<br/>[ReviewStep.tsx]"]
  node_survey["Survey workflow"]
  node_surveycase["Start survey"]
end

subgraph group_sync["Synchronization"]
  node_syncui["Sync control<br/>[useGlobalSync.ts]"]
  node_globalsync["Global sync"]
  node_member_sync["Member sync"]
  node_household_sync["Household sync"]
end

subgraph group_data["Persistence and services"]
  node_householdapi["Household API"]
  node_db[("SQLite database<br/>[index.ts]")]
  node_householdrepo["Household repository"]
  node_memberrepo["Member repository"]
  node_addressrepo["Address lookup"]
  node_baseapi["API client<br/>[BaseApiClient.ts]"]
  node_memberapi["Member API"]
  node_logger["Application logging<br/>[AppLogger.ts]"]
end

node_worker(("Field worker"))
node_server{{"Remote service"}}

node_root -->|"provides context"| node_authprovider
node_root -->|"renders gate"| node_authgate
node_root -->|"initializes database"| node_db
node_authprovider -.->|"uses service"| node_auth
node_auth -->|"loads and saves"| node_authstorage
node_auth -->|"uses model"| node_session
node_auth -->|"persists session"| node_authstorage
node_review -->|"loads addresses"| node_addressrepo
node_householdrepo -->|"reads and writes"| node_db
node_memberrepo -->|"reads and writes"| node_db
node_memberrepo -->|"maps server members"| node_server
node_householdapi -->|"sends requests"| node_baseapi
node_householdapi -->|"fetches listings"| node_server
node_baseapi -->|"loads credentials"| node_authstorage
node_baseapi -->|"makes HTTP calls"| node_server
node_baseapi -->|"logs requests"| node_logger
node_syncui -->|"loads identity"| node_authstorage
node_syncui -->|"executes sync"| node_globalsync
node_memberapi -->|"uses client"| node_baseapi
node_worker -.->|"uses app"| node_householdui
node_worker -.->|"enters member data"| node_memberform
node_worker -.->|"completes survey"| node_survey

click node_root "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/app/_layout.tsx"
click node_auth "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/auth/service/AuthService.ts"
click node_authprovider "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/auth/context/AuthProvider.tsx"
click node_authgate "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/auth/router/AuthGate.tsx"
click node_authstorage "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/auth/storage/authStorage.ts"
click node_session "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/auth/model/AuthSession.ts"
click node_householdui "https://github.com/abhinavpwn/offlinesurveyapp/tree/main/app/(app)/households"
click node_dashboard "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/screens/HouseholdDashboardScreen.tsx"
click node_householdcases "https://github.com/abhinavpwn/offlinesurveyapp/tree/main/src/usecases/household"
click node_householdapi "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/services/HouseholdApiService.ts"
click node_memberform "https://github.com/abhinavpwn/offlinesurveyapp/tree/main/src/features/member-form"
click node_review "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/features/member-form/components/steps/ReviewStep.tsx"
click node_survey "https://github.com/abhinavpwn/offlinesurveyapp/tree/main/src/features/survey"
click node_surveycase "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/usecases/StartClientSurveyUseCase.ts"
click node_syncui "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/hooks/useGlobalSync.ts"
click node_globalsync "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/usecases/sync/GlobalSyncUseCase.ts"
click node_member_sync "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/usecases/members/SyncMemberUseCase.ts"
click node_household_sync "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/usecases/household/SyncHouseholdUseCase.ts"
click node_db "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/db/index.ts"
click node_householdrepo "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/repositories/SQLiteHouseholdLocalRepository.ts"
click node_memberrepo "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/repositories/SQLiteHouseholdMemberLocalRepository.ts"
click node_addressrepo "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/repositories/addressRepository.ts"
click node_baseapi "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/services/api/BaseApiClient.ts"
click node_memberapi "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/services/MemberApiService.ts"
click node_logger "https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/utils/AppLogger.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_root,node_auth,node_authprovider,node_authgate,node_authstorage,node_session toneBlue
class node_householdui,node_dashboard,node_householdcases toneAmber
class node_memberform,node_review,node_survey,node_surveycase toneMint
class node_syncui,node_globalsync,node_member_sync,node_household_sync,node_worker toneRose
class node_householdapi,node_db,node_householdrepo,node_memberrepo,node_addressrepo,node_baseapi,node_memberapi,node_logger,node_server toneIndigo
```

## Components

### Access and startup

- [App startup](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/app/_layout.tsx): `app/_layout.tsx`
- [Authentication](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/auth/service/AuthService.ts): `src/auth/service/AuthService.ts`
- [Auth context](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/auth/context/AuthProvider.tsx): `src/auth/context/AuthProvider.tsx`
- [Access gate](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/auth/router/AuthGate.tsx): `src/auth/router/AuthGate.tsx`
- [Secure session storage](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/auth/storage/authStorage.ts): `src/auth/storage/authStorage.ts`
- [Session model](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/auth/model/AuthSession.ts): `src/auth/model/AuthSession.ts`

### Household management

- [Household screens](https://github.com/abhinavpwn/offlinesurveyapp/tree/main/app/(app)/households): `app/(app)/households`
- [Household dashboard](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/screens/HouseholdDashboardScreen.tsx): `src/screens/HouseholdDashboardScreen.tsx`
- [Household operations](https://github.com/abhinavpwn/offlinesurveyapp/tree/main/src/usecases/household): `src/usecases/household`

### Member and survey entry

- [Member form](https://github.com/abhinavpwn/offlinesurveyapp/tree/main/src/features/member-form): `src/features/member-form`
- [Form review](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/features/member-form/components/steps/ReviewStep.tsx): `src/features/member-form/components/steps/ReviewStep.tsx`
- [Survey workflow](https://github.com/abhinavpwn/offlinesurveyapp/tree/main/src/features/survey): `src/features/survey`
- [Start survey](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/usecases/StartClientSurveyUseCase.ts): `src/usecases/StartClientSurveyUseCase.ts`

### Synchronization

- [Sync control](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/hooks/useGlobalSync.ts): `src/hooks/useGlobalSync.ts`
- [Global sync](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/usecases/sync/GlobalSyncUseCase.ts): `src/usecases/sync/GlobalSyncUseCase.ts`
- [Member sync](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/usecases/members/SyncMemberUseCase.ts): `src/usecases/members/SyncMemberUseCase.ts`
- [Household sync](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/usecases/household/SyncHouseholdUseCase.ts): `src/usecases/household/SyncHouseholdUseCase.ts`

### Persistence and services

- [Household API](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/services/HouseholdApiService.ts): `src/services/HouseholdApiService.ts`
- [SQLite database](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/db/index.ts): `src/db/index.ts`
- [Household repository](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/repositories/SQLiteHouseholdLocalRepository.ts): `src/repositories/SQLiteHouseholdLocalRepository.ts`
- [Member repository](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/repositories/SQLiteHouseholdMemberLocalRepository.ts): `src/repositories/SQLiteHouseholdMemberLocalRepository.ts`
- [Address lookup](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/repositories/addressRepository.ts): `src/repositories/addressRepository.ts`
- [API client](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/services/api/BaseApiClient.ts): `src/services/api/BaseApiClient.ts`
- [Member API](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/services/MemberApiService.ts): `src/services/MemberApiService.ts`
- [Application logging](https://github.com/abhinavpwn/offlinesurveyapp/blob/main/src/utils/AppLogger.ts): `src/utils/AppLogger.ts`

### Other components

- **Field worker**
- **Remote service**

## Connections

- App startup → Auth context: provides context (evidence: `app/_layout.tsx`)
- App startup → Access gate: renders gate (evidence: `app/_layout.tsx`)
- App startup → SQLite database: initializes database (evidence: `app/_layout.tsx`)
- Auth context → Authentication: uses service
- Authentication → Secure session storage: loads and saves (evidence: `src/auth/service/AuthService.ts`)
- Authentication → Session model: uses model (evidence: `src/auth/service/AuthService.ts`)
- Authentication → Secure session storage: persists session (evidence: `src/auth/storage/authStorage.ts`)
- Form review → Address lookup: loads addresses (evidence: `src/features/member-form/components/steps/ReviewStep.tsx`)
- Household repository → SQLite database: reads and writes (evidence: `src/repositories/SQLiteHouseholdLocalRepository.ts`)
- Member repository → SQLite database: reads and writes (evidence: `src/repositories/SQLiteHouseholdMemberLocalRepository.ts`)
- Member repository → Remote service: maps server members (evidence: `src/repositories/SQLiteHouseholdMemberLocalRepository.ts`)
- Household API → API client: sends requests (evidence: `src/services/HouseholdApiService.ts`)
- Household API → Remote service: fetches listings (evidence: `src/services/HouseholdApiService.ts`)
- API client → Secure session storage: loads credentials (evidence: `src/services/api/BaseApiClient.ts`)
- API client → Remote service: makes HTTP calls (evidence: `src/services/api/BaseApiClient.ts`)
- API client → Application logging: logs requests (evidence: `src/services/api/BaseApiClient.ts`)
- Sync control → Secure session storage: loads identity (evidence: `src/hooks/useGlobalSync.ts`)
- Sync control → Global sync: executes sync (evidence: `src/hooks/useGlobalSync.ts`)
- Member API → API client: uses client (evidence: `src/services/MemberApiService.ts`)
- Field worker → Household screens: uses app
- Field worker → Member form: enters member data
- Field worker → Survey workflow: completes survey
