How hcm-nigeria-go-deep/health-campaign-field-worker-app works
1. This repository is a Flutter monorepo for the DIGIT Health Campaign Management field worker app. It contains one host application under apps/health_campaign_field_worker_app and many reusable feature packages under packages/, wired together with Melos and code generation.
2. The host app is primarily an orchestration shell. It bootstraps Flutter/Firebase, configures routing, localization, background services, notifications, network state, and then composes feature modules into a single runtime experience.
3. The codebase is built around feature packages rather than one large app. Each package is self-contained and usually follows the same internal structure: blocs for state, pages for screens, router for nested navigation, data for repositories, models for entities, widgets for reusable UI, and utils for feature-specific constants/helpers.
4. The main feature packages map to business capabilities: registration and delivery, attendance, inventory, complaints, referral reconciliation, survey forms, scan/QR support, dashboarding, closed household handling, and post-transit/post-delivery flows. The README’s role-based access model reflects this modular design: different roles surface different packages and workflows.
5. Shared domain and persistence infrastructure lives in foundational packages like digit_data_model, sync_service, digit_scanner, digit_dss, digit_showcase, and digit_firebase_services. These provide the common entity model, sync engine, scanner UI/logic, dashboard rendering, guided UI overlays, and Firebase-related utilities used by the feature packages and app.
6. Data access follows a repository pattern split into local and remote sides. Local repositories persist offline state and query models; remote repositories encapsulate server APIs. The data_model/digit_data_model layer provides common entity/search model abstractions, while package-specific repositories adapt those abstractions to each module’s domain.
7. Offline-first is the central data-flow boundary. User actions go to the feature UI and bloc, then into local repositories, which write to SQLite and/or ISAR-backed stores and create operation-log entries. Those op-log entries are later consumed by sync logic to reconcile local and remote state.
8. Sync is bidirectional and handled by a dedicated sync subsystem. The sync_service package and app-level sync registry/mapper code coordinate sync-down and sync-up across registered repositories, using the op-log to group pending operations and push or fetch changes in batches. This is the key boundary between “device truth” and “server truth.”
9. The app also has a configuration/data-downsync path for MDMS, localization, role access, project setup, and boundary/project-specific records. The README and tree show dedicated repositories for auth, localization, bandwidth checks, project downsync, and MDMS-driven configuration, which means many screens are populated from server-side configuration rather than hardcoded UI.
10. Navigation is modular and generated. The host app’s root router integrates package routers, while each package has its own router and generated route map. This keeps feature flows isolated but still composable into a single app shell.
11. Cross-cutting UI infrastructure includes localization delegates, shared headers, progress indicators, no-result/error screens, showcase/help overlays, and network manager wrappers. These are used across packages to keep a consistent UX while allowing each feature package to remain independent.
12. Native platform code is minimal but important: Android and iOS folders contain standard Flutter runners plus platform hooks such as location service support and Firebase config. That indicates the app relies on native capabilities mainly for device integration, not for business logic.
13. Build and developer tooling are a visible part of the architecture. Generated Dart artifacts (freezed, dart_mappable, router code, and schema code) are produced through build_runner; custom scripts under tools/ generate package imports, APK builds, localization conversions, and cleanup; GitHub Actions automate build and quality workflows.
14. For an architecture diagram, the most important diagram boundaries are: host app shell, feature packages, shared platform packages, local offline stores, remote backend services, and the sync/op-log pipeline connecting local and remote data. The data flow is predominantly UI → bloc → repository → local store/op-log → sync engine → remote API, with sync-down feeding configuration and master data back into local stores.
Main entry points: app.dart App Shell · data_model.dart Data Model · survey_form.dart Survey Forms · sync_registry.dart Sync Registry
Components 24
Host App
Flutter shell for the field worker runtime
- App Shell · Bootstraps the app, wiring services, state, and feature composition
apps/health_campaign_field_worker_app/lib/app.dart - Main Entry · Starts the runtime and selects the main driver
apps/health_campaign_field_worker_app/lib/main.dart - Root Router · Composes package routers into the host navigation tree
apps/health_campaign_field_worker_app/lib/router/app_router.dart - Sync Registry · Registers repositories and maps sync-up/sync-down flows
apps/health_campaign_field_worker_app/lib/data/sync_registry.dart - Sync Mapper · Bridges app repositories to the sync service contract
apps/health_campaign_field_worker_app/lib/data/sync_service_mapper.dart - Op-log Repo · App-level operation log repository used by offline-first writes
apps/health_campaign_field_worker_app/lib/data/repositories/oplog.dart - Downsync Repo · Pulls app configuration, roles, localization, and master data
apps/health_campaign_field_worker_app/lib/data/repositories/remote/downsync.dart - Local Config · Persists configuration and localization state locally
apps/health_campaign_field_worker_app/lib/data/local_store/downsync/downsync.dart
Feature Packages
Business workflows composed into the app
- Registration & Delivery · Household registration, beneficiary delivery, referrals, and side effects
packages/registration_delivery/lib/registration_delivery.dart - Attendance · Register management and attendance marking workflow
packages/attendance_management/lib/attendance_management.dart - Inventory · Stock recording, reconciliation, and reports
packages/inventory_management/lib/inventory_management.dart - Complaints · Complaint registration and inbox management
packages/complaints/lib/complaints.dart - Referral Recon · Facility referral reconciliation and search workflow
packages/referral_reconciliation/lib/referral_reconciliation.dart - Survey Forms · Dynamic service and form capture flow
packages/survey_form/lib/survey_form.dart - Transit Post · Post-transit and post-delivery vaccination flow
packages/transit_post/lib/transit_post.dart - Closed Household · Closed-household handling and acknowledgement flow
packages/closed_household/lib/closed_household.dart
Shared Foundation
Reusable domain, sync, scanner, dashboard, and Firebase support
- Data Model · Common entities, repositories, and SQL/no-sql persistence abstractions
packages/digit_data_model/lib/data_model.dart - Sync Service · Bidirectional sync-up and sync-down orchestration
packages/sync_service/lib/sync_service_lib.dart - Scanner · QR/barcode scanner UI and detection logic
packages/digit_scanner/lib/digit_scanner.dart - Dashboard UI · Dashboard rendering and analytics views
packages/digit_dss/lib/digit_dss.dart - Showcase · Guided overlays and in-app help surfaces
packages/digit_showcase/lib/digit_showcase.dart - Firebase Utils · Firebase helpers and crash tooling used by the host app
packages/digit_firebase_services/lib/digit_firebase_services.dart - Forms Engine · JSON schema-based form rendering and builders
packages/forms_engine/lib/forms_engine.dart
Build Tooling
Generation and automation used across the monorepo
- Tools & Build · Melos, code generation, scripts, and CI automation
tools/run_build_runner.sh
Connections 31
- Main Entry → App Shell: starts · Entrypoint hands off to the application shell
- App Shell → Root Router: navigates · Shell composes the root navigation graph
- App Shell → Sync Registry: orchestrates · Shell wires the sync boundary into runtime state
- Sync Registry → Sync Mapper: maps · Registry delegates repository-to-sync mapping
- Sync Mapper → Sync Service: uses · App-level mapping targets the shared sync engine
- Op-log Repo → Sync Registry: feeds · Operation log entries become sync work items
- Downsync Repo → Local Config: persists · Configuration fetches are stored locally for offline use
- Downsync Repo → Data Model: uses · Downsync payloads are normalized through shared entities
- Registration & Delivery → Data Model: uses · Feature repositories share common domain and storage abstractions
- Attendance → Data Model: uses · Attendance data is modeled through shared persistence primitives
- Inventory → Data Model: uses · Inventory records rely on the common data model layer
- Complaints → Data Model: uses · Complaint flows adapt the shared entity/repository layer
- Referral Recon → Data Model: uses · Referral data is built on the shared domain model
- Survey Forms → Forms Engine: renders · Survey package uses the dynamic form renderer
- Survey Forms → Data Model: uses · Form-driven records persist through shared model abstractions
- Transit Post → Data Model: uses · Transit/post-delivery records use the shared storage model
- Closed Household → Data Model: uses · Closed-household state is backed by shared domain entities
- App Shell → Registration & Delivery: composes · Host app includes the core campaign workflows
- App Shell → Attendance: composes · Host app includes the attendance module
- App Shell → Inventory: composes · Host app includes the inventory module
- App Shell → Complaints: composes · Host app includes the complaints module
- App Shell → Referral Recon: composes · Host app includes referral reconciliation
- App Shell → Survey Forms: composes · Host app includes survey form workflows
- App Shell → Transit Post: composes · Host app includes post-transit workflows
- App Shell → Closed Household: composes · Host app includes closed-household workflows
- App Shell → Scanner: integrates · Shell exposes scanner capability to features
- App Shell → Dashboard UI: integrates · Shell surfaces dashboards and reports
- App Shell → Showcase: integrates · Shell enables guided overlays and help UI
- App Shell → Firebase Utils: integrates · Shell uses Firebase-related utilities and hooks
- App Shell → Tools & Build: built by · Architecture is supported by code generation and CI tooling
- Sync Service → Data Model: syncs · Sync engine operates over the shared offline data layer